- 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>
/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');
}
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.