-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


Ewald Jenisch wrote:
> On Mon, Mar 30, 2009 at 01:08:13PM +0200, Peter Haag wrote:
>> Apart from that, you could have deleted all the data by simply setting the 
>> max data size to 1.
>> This would have deleted all your data cleanly.
> 
> Hi,
> 
> Thanks for the hint - it definitely deletes the data. 
> 
> However the images belonging to the old data are still there; I assume
> that's because they are in
> /usr/local/var/nfsen/profiles-stat/live/...png.

well - this does not really help, as the graphs are a result from the *.rrd 
DBs. You would need to re-initialise the rrd
DBs. You may use the appended script, to rebuild the graphs from existing data. 
If you first remove cleanly the files,
the graphs are empty after Rebuilding. Just note: Fix the "use lib" path at the 
beginning of the script.

        - Peter

> 
> Can I safely delete them in order to also start over with the
> graphics?
> 
> (Just want to get rid of all the old data - both the data itself but
> also in the output displayed).
> 
> -ewald

- --
_______ SWITCH - The Swiss Education and Research Network ______
Peter Haag,  Security Engineer,  Member of SWITCH CERT
PGP fingerprint: D9 31 D5 83 03 95 68 BA  FB 84 CA 94 AB FC 5D D7
SWITCH, Werdstrasse 2, P.O. Box,  CH-8021   Zurich, Switzerland
E-mail: peter.h...@switch.ch Web: http://www.switch.ch/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Darwin)

iQCVAwUBSdC4qv5AbZRALNr/AQKWhAQAhuF0vXq/EBDNc7ozVAQsENZmTABvsmD7
zCipgKpv3l/sE08/ozWvaRBKgGK5aOFwXGIadUFesZZ3fxt8FnG9GJjLzKtF4prr
StDi/ztbMjJn9JcBabds0J5Pn4XbM7a2xuCWqNylUiNelIDVpfQ9Mi2UhpGjL9cy
DRJMQpRJj+E=
=mqT5
-----END PGP SIGNATURE-----
#
#  Copyright (c) 2009, Peter Haag
#  All rights  eserved.
#
#  Redistribution and use in source and binary forms, with or without
#  modification, are permitted provided that the following conditions are met:
#
#   * Redistributions of source code must retain the above copyright notice,
#         this list of conditions and the following disclaimer.
#   * Redistributions in binary form must reproduce the above copyright notice,
#         this list of conditions and the following disclaimer in the 
documentation
#         and/or other materials provided with the distribution.
#   * The names of its contributors may not be used to endorse or promote 
#     products derived from this software without
#         specific prior written permission.
#
#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
#  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
#  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
#  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
#  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
#  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
#  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
#  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
#  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
#  POSSIBILITY OF SUCH DAMAGE.
#
#  $Author: phaag $
#
#  $LastChangedRevision: $

use strict;

##################################
#
# Modify this path to reflect your installation:
use lib "/data/nfsen-1.3/libexec";
#
##################################

use NfConf;
use NfProfile;
use NfSenRRD;


sub RebuildProfile {
        my $profile             = shift;
        my $profilegroup        = shift;
        my $profileinfo         = shift;

        my $profilepath = NfProfile::ProfilePath($profile, $profilegroup);

        print "Reset Graphs of profile ...\n";
        my $tstart = $$profileinfo{'tstart'};
        my $tend   = $$profileinfo{'tend'};

        foreach my $db ( NfProfile::ProfileChannels($profileinfo) ) {
                NfSenRRD::SetupRRD("$NfConf::PROFILESTATDIR/$profilepath", $db, 
$tstart - 300, 1);
        }
        if ( $Log::ERROR ) {
                die "Error setup RRD DBs: $Log::ERROR\n";
        }

        foreach my $channel ( NfProfile::ProfileChannels($profileinfo) ) {
                print "Rebuild Channel $channel ..";
                for ( my $t = $tstart; $t < $tend; $t += 300 ) {
                        my $t_iso       = NfSen::UNIX2ISO($t);
                        my $subdirs = NfSen::SubdirHierarchy($t);
                        my ($statinfo, $exit_code, $err ) = 
NfProfile::ReadStatInfo($profileinfo, $channel, $subdirs, $t_iso, undef);
                        if ( $exit_code != 0 ) {
                                warn $err;
                                next;
                        }

                        my @_values = ();
                        foreach my $ds ( @NfSenRRD::RRD_DS ) {
                        if ( !defined $$statinfo{$ds} || $$statinfo{$ds} == - 1 
) {
                                push @_values, 0;
                        } else {
                                push @_values, $$statinfo{$ds};
                        }
                        }
                        $err = 
NfSenRRD::UpdateDB("$NfConf::PROFILESTATDIR/$profilepath", $channel, $t,
                        join(':',@NfSenRRD::RRD_DS) , join(':', @_values));
                        if ( $Log::ERROR ) {
                                die "ERROR Update RRD time: '$t_iso', db: 
'$channel', profile: '$profile' : $Log::ERROR";
                        }
                }
                print "\n";
        }
        NfSenRRD::UpdateGraphs($profile, $profilegroup, $tend - 300, 1);

} # End of RebuildProfile


if ( !NfConf::LoadConfig() ) {
    die "ERR $Log::ERROR\n";
}

my %opts;
$opts{'profile'} = $ARGV[0];
my ( $profile, $profilegroup );
my $ret = NfProfile::ProfileDecode(\%opts, \$profile, \$profilegroup);
if ( $ret ne 'ok' ) {
        print "ERR $ret\n";
        exit;
} 

if ( !NfProfile::ProfileExists($profile, $profilegroup) ) {
        print "No such profile: $opts{'profile'}\n";
        exit;
}

print "Rebuild Graphs from $opts{'profile'}: \n";

my %profileinfo = NfProfile::ReadProfile($profile, $profilegroup);
if ( $profileinfo{'status'} eq 'empty' ) {
        print "Can not load profile: $opts{'profile'}\n";
        exit;
}

RebuildProfile($profile, $profilegroup,\%profileinfo);


1;

Attachment: RebuildGraphs.pl.sig
Description: video/flv

------------------------------------------------------------------------------
_______________________________________________
Nfsen-discuss mailing list
Nfsen-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nfsen-discuss

Reply via email to