Hi,
First things first:
FreeBSD 4.7
PHP 4.3.8
mysql-4.0.20
ucd-snmp-4.2.5n (ports)
rrdtool-1.0.49
cacti-0.8.6e
I have a somewhat strange issue with the poller script updating a series of rrd files. I have setup various routers and servers using the templates provided and all works swimmingly the problem comes when updating rrd files that are the target of a script.
<?php
get_bonded_sum($argv[1], $argv[2]);
function get_bonded_sum($ip, $snmpcom) {
//declare snmp mibs
$mib=".1.3.6.1.2.1.2.2.1.2";
$inoct="interfaces.ifTable.ifEntry.ifInOctets.";
$outoct="interfaces.ifTable.ifEntry.ifOutOctets.";
//walk the router...
$snmp=@snmpwalk($ip, $snmpcom, $mib);
$c=0;
$sum_in=array();
$sum_out=array();
foreach($snmp as $v) {
//split the snmp output to only return oid for each int
list ($oid, $foo)=split(" ", $v, 2);
$int=preg_split('/ifDescr+./', $oid);
$oid=$int[1];
//extract interfaces from snmp array and clean up
list ($foo, $value)=split("=", $v, 2);
if (preg_match_all('/ATM.*?\s*?subif$/', $value, $foo)) { continue; }
if (preg_match_all('/ATM.*-atm.\s*layer$/', $value, $foo)) { continue; }
if (preg_match_all('/ATM.*-aal5.\s*layer$/', $value, $foo)) { continue; }
if (preg_match_all('/ATM.*-fast/', $value, $foo)) { continue; }
if (preg_match_all('/ATM.*-int/', $value, $foo)) { continue; }
if (preg_match_all('/ATM.*-adsl/', $value, $foo)) { continue; }
if (preg_match_all('/Dialer.*/', $value, $foo)) { continue; }
if (preg_match_all('/Virtual.*/', $value, $foo)) { continue; }
if (preg_match_all('/Token.*/', $value, $foo)) { continue; }
if (preg_match_all('/Null.*/', $value, $foo)) { continue; }
if (preg_match_all('/BRI.*/', $value, $foo)) { continue; }
if (preg_match_all('/Tunnel.*/', $value, $foo)) { continue; }
if (preg_match_all('/Fast.*/', $value, $foo)) { continue; }
//get snmp data for each router
else {
$in=snmpget($ip, $snmpcom, "$inoct"."$oid");
$out=snmpget($ip, $snmpcom, "$outoct"."$oid");
//sort some data so we can choose relevant interfaces
list ($foo, $speedin)=split(":", $in, 2);
list ($foo, $speedout)=split(":", $out, 2);
}
$sum_in[$c]=$speedin;
$sum_out[$c]=$speedout;
$c++;
}
$total_in=0;
foreach($sum_in as $k=>$v) {
$total_in+=$v;
}
$total_out=0;
foreach($sum_out as $k=>$v) {
$total_out+=$v;
}
echo "bonded_in:$total_in ";
echo "bonded_out:$total_out";
}
?>
The script it self is to calculate aggregated data from CPE atm interfaces and simply returns two outputs. If I use rrdtool update to update the rrd files all works fine (this is the exact same syntax as returned by the poller) but if I leave the cron to its own devices I get no data in the rrd files!
# cacti poll
*/5 * * * * /usr/local/bin/php /home/cactiuser/cacti/poller.php > /dev/null 2>&1
I have set up all the relevant data/graph templates and data sources as required and all appears ok - there are no errors generated just no data.
/usr/local/rrdtool-1.0.49/bin/rrdtool create \
/usr/local/src/cacti-0.8.6e/rra/rmd_haydock_get_bonded_sum_70.rrd \
--step 300 \
DS:bonded_out:GAUGE:600:0:U \
DS:bonded_in:GAUGE:600:0:U \
RRA:AVERAGE:0.5:1:600 \
RRA:AVERAGE:0.5:6:700 \
RRA:AVERAGE:0.5:24:775 \
RRA:AVERAGE:0.5:288:797 \
RRA:MAX:0.5:1:600 \
RRA:MAX:0.5:6:700 \
RRA:MAX:0.5:24:775 \
RRA:MAX:0.5:288:797 \
Here is the relevant out put from the poller:
07/01/2005 02:01:30 PM - POLLER: Poller[0] Parsed MULTI output field 'bonded_in:7540539636' [map bonded_in->bonded_in]
07/01/2005 02:01:30 PM - POLLER: Poller[0] Parsed MULTI output field 'bonded_out:3033958913' [map bonded_out->bonded_out]
07/01/2005 02:01:30 PM - POLLER: Poller[0] CACTI2RRD: /usr/local/rrdtool-1.0.49/bin/rrdtool update /usr/local/src/cacti-0.8.6e/rra/rmd_haydock_get_bonded_sum_70.rrd --template bonded_in:bonded_out 1120222884:7540539636:3033958913
The only slight difference when applying the data manually using rrdtool is that I use 'N' rather than seconds since epoch thusly:
/usr/local/rrdtool-1.0.49/bin/rrdtool update /usr/local/src/cacti-0.8.6e/rra/rmd_haydock_get_bonded_sum_70.rrd --template bonded_in:bonded_out N:7540539636:3033958913
As mentioned above using the rrdtool manually works ok? I have ensured all file permissions are ok etc and AFIACS cli php is working fine ~ can anyone offer any ideas???
TIA,
Ed
poller.php not updating rrd files when using scripted data..
Moderators: Developers, Moderators
- TheWitness
- Developer
- Posts: 17007
- Joined: Tue May 14, 2002 5:08 pm
- Location: MI, USA
- Contact:
First note:
Should be "COUNTER" and not "GUAGE".
TheWitness
Should be "COUNTER" and not "GUAGE".
You need to push the entire "DEBUG" output for me to comment more.DS:bonded_out:GAUGE:600:0:U \
DS:bonded_in:GAUGE:600:0:U \
TheWitness
True understanding begins only when we realize how little we truly understand...
Life is an adventure, let yours begin with Cacti!
Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages
For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
Life is an adventure, let yours begin with Cacti!
Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages
For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
I have made this change but still no data - which debug do you need to see?
Data Source: rmd_wembley - Get Bonded Sum
RRD: /usr/local/src/cacti-0.8.6e/rra/rmd_wembley_get_bonded_sum_63.rrd
Action: 1, Script: php -f /home/cactiuser/cacti/scripts/get_bonded_sum.php 195.38.86.247 tr1nadsl
One thing I did notice is the following...
07/01/2005 03:25:07 PM - CMDPHP: Poller[0] Host[14] DS[70] WARNING: Result from CMD not valid. Partial Result:
07/01/2005 03:25:07 PM - CMDPHP: Poller[0] Host[14] DS[70] CMD: php -f /home/cactiuser/cacti/scripts/get_bonded_sum.php 195.38.86.242 tr1nadsl, output: U
07/01/2005 03:25:07 PM - PHPSVR: Poller[0] DEBUG: PHP Script Server Shutdown request received, exiting
What does the PHPSVR error indicate??
Here is this script being called manually - all is well?
php -f /home/cactiuser/cacti/scripts/get_bonded_sum.php 195.38.86.242 tr1nadsl
bonded_in:7555789195 bonded_out:3040482865
Thanks
Ed
Data Source: rmd_wembley - Get Bonded Sum
RRD: /usr/local/src/cacti-0.8.6e/rra/rmd_wembley_get_bonded_sum_63.rrd
Action: 1, Script: php -f /home/cactiuser/cacti/scripts/get_bonded_sum.php 195.38.86.247 tr1nadsl
One thing I did notice is the following...
07/01/2005 03:25:07 PM - CMDPHP: Poller[0] Host[14] DS[70] WARNING: Result from CMD not valid. Partial Result:
07/01/2005 03:25:07 PM - CMDPHP: Poller[0] Host[14] DS[70] CMD: php -f /home/cactiuser/cacti/scripts/get_bonded_sum.php 195.38.86.242 tr1nadsl, output: U
07/01/2005 03:25:07 PM - PHPSVR: Poller[0] DEBUG: PHP Script Server Shutdown request received, exiting
What does the PHPSVR error indicate??
Here is this script being called manually - all is well?
php -f /home/cactiuser/cacti/scripts/get_bonded_sum.php 195.38.86.242 tr1nadsl
bonded_in:7555789195 bonded_out:3040482865
Thanks
Ed
cheers,
Ted
Ted
- TheWitness
- Developer
- Posts: 17007
- Joined: Tue May 14, 2002 5:08 pm
- Location: MI, USA
- Contact:
Change the output line of your script to be as follows and then rerun:
TheWitness
Code: Select all
print "bonded_in:" . $total_in . " bonded_out:" . $total_out . "\n";
True understanding begins only when we realize how little we truly understand...
Life is an adventure, let yours begin with Cacti!
Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages
For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
Life is an adventure, let yours begin with Cacti!
Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages
For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
Who is online
Users browsing this forum: No registered users and 2 guests