I was having trouble with cacti running on Solaris with net-snmp that I compiled. Most
of the trouble was because I'm also still using MRTG and it was running at the exact
same time as cacti, and just changing the times that cacti starts (so it doesn't fight
with MRTG making queries to the same devices at the same time).
But I also put in some code to do retries on failed SNMP queries. This might be a good
thing to put in as a configurable option (either in Cacti settings or just in the config.php
file). I changed cacti_snmp_get() in include/snmp_functions.php to do this:
[...]
snmp_set_quick_print(0);
$max_tries = 5;
$try = 0;
do {
$snmp_value = snmpget($hostname, $community, $oid);
$try++;
} while ((strlen($snmp_value) == 0) && ($try < $max_tries));
$tstr = strchr($snmp_value, '=');
if (strlen($tstr) > 0) {
$snmp_value = ltrim($tstr, ' =');
}
Note the ltrim statement on the 2nd to last line? I also was having trouble with
version of net-snmp I had compiled and linked PHP with. For some reason, I was
always getting output of the format "MIBOID=value" which was confusing cacti.
I never did figure out why this was happening (something in the way I compiled or
set up net-snmp I guess) and it was easier to just tweak cacti to skip the MIBOID=
part.
Obviously, the code should be re-written a bit so it also handles cases where
the MIBOID= stuff isn't in $snmp_value (the above code assumes it is and trims it).
But I thought I'd include it in case anyone cared.
I had to make the same trimming hack to the cacti_snmp_walk() function too.
'Hope this is helpful!
Brent
SNMP retries and more robust cleanup of replies
Moderators: Developers, Moderators
Who is online
Users browsing this forum: No registered users and 2 guests