Re: One script for many data items

Kenneth Porter <[email protected]>
Newsgroups gmane.network.cacti.user
Message-ID <E04D1CCDA87FEEFC4E41681A@[10.0.0.199]>
--On Friday, September 28, 2012 7:07 PM +0200 Gandalf <[email protected]> 
wrote:

> In this case, I'd like to advise a two step approach.
> Step 1: Poll the data and put them into some intermediate store (e.g. a
> file, a database table)
> Step 2: Poll the data from that store.
> This latter one is the "usual" Data Input Method associated with a graph
> etc. pp. The first step can be put as an initial script being run
> directly from crontab or by some single Cacti data source which needs not
> to be associated with any graph.

Thanks. I've now developed step 1:

#!/usr/bin/env perl

# collect byte counters from dummy iptables rules in chains with name
# that starts with cacti

use IO::LockedFile;

# read all chains atomically, with byte and packet counters
my @iptables = split(/\n/, `/sbin/iptables-save -c`);

# acquire output file for writing with exclusive lock
my $cacti_iptables_counters
        = new IO::LockedFile(">/tmp/cacti_iptables_counters");

foreach my $line (@iptables) {
        $cacti_iptables_counters->print("$1\t$2\n")
                if $line =~ m/\[(\d+):\d+\] -A cacti-(\S+)/;
}





------------------------------------------------------------------------------
How fast is your code?
3 out of 4 devs don\\\'t know how their code performs in production.
Find out how slow your code is with AppDynamics Lite.
http://ad.doubleclick.net/clk;262219672;13503038;z?
http://info.appdynamics.com/FreeJavaPerformanceDownload.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.