Passing Device Variables to Server Scripts

Templates, scripts for templates, scripts and requests for templates.

Moderators: Developers, Moderators

Post Reply
JSpecMugen
Posts: 8
Joined: Tue Oct 04, 2005 1:53 pm

Passing Device Variables to Server Scripts

Post by JSpecMugen »

I'm trying to create a passive service checking application/solution for Cacti, and here's the basic layout/jist of what i'm trying to accomplish.

- Monitored device sits behind a firewall.
- An application is sitting on device creating an xml document that looks like so:

Code: Select all

<?xml version="1.0" ?> 
<spot pcpid="DMC1000-001-100405-0001" mon_ver="1.01">
  <poll_stamp>100405-092035</poll_stamp> 
  <model_num>DMC1000</model_num> 
  <cpu_load>86</cpu_load> 
  <cpu_temp>320</cpu_temp> 
  <mem_usage>48</mem_usage> 
  <display model="PPM42M5S">
    <screen_pwr>1</screen_pwr> 
    <screen_mode>1</screen_mode> 
  </display>
  <net_in_out>1</net_in_out> 
  <update_log>-1</update_log> 
  <guard_stat>1</guard_stat> 
  <ie_stat>1</ie_stat> 
</spot>
Once this file is generated, I use TFTP to submit it to a directory like this:

/usr/local/cacti/passive

with the whole file string looking like:

/usr/local/cacti/passive/DMC1000-001-100405-0001.xml

Then on the server side, I have the following piece of code that i've designed out: (Note it's not complete nor does it reflect the final piece of code)

Code: Select all

#!/usr/bin/perl -w

# CPU Load XML Reader v1.0

use strict;
use XML::Twig;

# Define where XML status files are located
#

my $drop_path = '/usr/local/cacti/passive/';

# Open that XML status file for parsing
#

my $file = $drop_path . $ARGV[0] . '.xml';
my $twig = XML::Twig->new();

$twig->parsefile($file);

my $root = $twig->root;

foreach my $spot ($root->children('spot')){
print 'CPULoad:' . $spot->first_child_text('cpu_load');
}
With all that said, what i'm trying to accomplish is having Cacti provide the $ARGV variable with the DMC1000-001-100405-0001 of the filename for the XML document. I would like to use the Hostname field in the device configuration due to the fact that I won't be using that field because the monitored device is behind a firewall.

If anyone can help shed some light on how I can pass off that variable it would be most appreciated.

Also as I continue this application I will submit it back to the community, so if there are any other parties interested in providing some feedback, code or even criticism it would be much appreciated.

Thanks!

Jordan W.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest