'collect = create' patch for collector

"Edmonds, Alan" <[email protected]>
Newsgroups gmane.network.cricket.user
Message-ID <CA82669882D4A14EA98E013430F5A4E3060DEB@tmexbridge.hammersmith.t-motion.co.uk>
First of all, I like cricket because it's not "network device" centric like most of the other 
applications (cacti, mrtg, etc).  I'm focused on applications and it provides a
good framework for monitoring.

My cricket setup monitors network devices (via SNMP), and applications (offline collection). 
I have built a collection of scripts that process log files, etc, and produce files that
are transferred to the cricket server and then update the .rrd files (home grown script).
The targets collected this way have the "collect = false" set in the target so the collector
doesn't try to update.  If this is a good thing or not is another discussion.  

This all mostly works.

One big problem is when I create a new target.  The syntax for the rrd create is very complicated 
and I don't want to mess with it too much.

I create a target definition, etc.  I set the ds-source to "exec:0:echo Nan".  etc.  
When I create the targets file, I specify

    collect = true

compile and run the collector manually or wait for the next cron run.  After the run,
I edit the targets file and change the true to false.

    collect = false

Then run compile.  Now the offline collection scripts run and update the .rrd etc.

This is tedious. 

Here's a "fix"

I patched the collector to support 

    collect = create

collect = create means to create the .rrd file if it doesn't exist and behave the same
way as collect = false.

Then when I create the target file, I can specify collect = create and compile
the config.  Done and dusted.  The next cron run creates the file and the
offline collection updates the .rrd.  

Here's the "patch" in non patch format.  I took a bit of a shortcut
and didn't create a function or case insensitive check, etc.

In collector:

=== begin ===

    if (defined($target->{'collect'}) && isFalse($target->{'collect'})) {
        Debug("Skipping target $tname due to collect=false tag.");
        return;
    }

    $main::gTargetCt++;

    my($datafile) = $target->{'rrd-datafile'};

    if (!defined($datafile)) {
        Warn("Could not find a datafile for $tname.");
        return;
    }

    if (! -f $datafile) {
        return unless newRRD($name, $target);
    }

+    if (defined($target->{'collect'}) && $target->{'collect'} eq "create") {
+        Debug("Skipping target $tname due to collect=create tag.");
+        return;
+    }

    my $agent_restart = 0;

=== end ====

I hope this is useful.  Improvements and suggestions are welcome.

-- 
Alan Edmonds 
+44 1707 315 195 Office 
+44 7950 203 918 Mobile 
Head ESOC Hosted Solutions Stream (Acting)
T-Mobile International 

This e-mail and any attachment are confidential and may be privileged. If you are not the intended recipient, notify the sender immediately, destroy all copies from your system and do not disclose or use the information for any purpose. 
Diese E-Mail inklusive aller Anhänge ist vertraulich und könnte bevorrechtigtem Schutz unterliegen. Wenn Sie nicht der beabsichtigte Adressat sind, informieren Sie bitte den Absender unverzüglich, löschen Sie alle Kopien von Ihrem System und veröffentlichen Sie oder nutzen Sie die Information keinesfalls, gleich zu welchem Zweck. 



Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
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.