I'm new on cacti and I'm new on php. So please have mercy when I'm asking dumb questions...
I have several Enterasys Securestacks to monitor. Interface statistics works great but there is no way to get the cpu-utilization via snmp. So I wrote a little (cmd-)script which connects via telnet to all the securestacks, reads the values for cpu-load and writes them in a text-file. The format of the output-file is:
Code: Select all
<Date/Time as header for debugging purposes>
<ip1> <5sec4ip1> <60sec4ip1> <300sec4ip1>
<ip2> <5sec4ip2> <60sec4ip2> <300sec4ip2>
.
.
.
<ipX> <5sec4ipX> <60sec4ipX> <300sec4ipX>
Code: Select all
172.30.4.130 13 18 21
Code: Select all
<?php
/* script c2cpu_query.php */
$addr = $argv[1];
$filename = "c:/inetpub/wwwroot/cacti/scripts/c2_cpu_liste.txt";
$vorhanden=file_exists($filename);
if($vorhanden) {
$datei=fopen($filename,"r");
if($datei) {
while($data=fgets($datei))
{
$daten = explode(' ',$data);
if($daten[0] == $addr) {
echo "005sec:".$daten[1]." 060sec:".$daten[2]." 300sec:".$daten[3];
}
}
}
fclose($datei);
}
else echo $filename . " not exists!<br>";
?>
Code: Select all
c:/php/php.exe -q c:/inetpub/wwwroot/cacti/scripts/c2cpu_query.php 172.30.4.130
Code: Select all
005sec:13 060sec:18 300sec:21
Now I have defined a data-input method calling this script, data_templates and graph_templates using this. I created a graph for one of my SecureStacks - and get errors in my log:
Code: Select all
03/22/2007 02:25:23 PM - CACTID: Poller[0] Host[93] DS[192] WARNING: Result from SCRIPT not valid. Partial Result: ...
03/22/2007 02:25:23 PM - CACTID: Poller[0] Host[93] ERROR: Empty result [172.30.4.130]: 'c:/php/php.exe -q c:/Inetpub/wwwroot/cacti/scripts/c2cpu_query.php 172.30.4.130'
Regards
Stefan
Sorry for my bad English, it's not my native language...