Investigating further, it seems that the new version of Cacti has slightly different defaults than the old version, in that the Availability timeout (ping_timeout in the DB) was 400 ms on my new box (500 ms on my old one) and the ping retries (ping_retries in the DB) was 1 on my new box (vs. 2 on my old box). I would not have thought these would be different, as I simply backed up my old servers database and restored it to the new server, but when the DB upgrade process happened, it must have changed these defaults as well.
I updated the database directly to set both of these back to the previous settings (don't want the availability reports to show lower availability than it did previously!)... But, since sometimes devices are added using my script, I altered my tool to also pass --ping_retries via the CLI, so all settings for these devices will be consistent.
In looking through the code for add_device.php, I saw no method to set --ping_timeout, though. The PHP code is so consistent, however, that a variable called "$ping_timeout" was already being used. I only needed to add code to read it from the options passed via the command line.
This code allows you to set the --ping_timeout (used for Availability checking):
Code: Select all
case "--ping_timeout":
if (is_numeric($value) && ($value > 0)) {
$ping_timeout = $value;
}else{
echo "ERROR: Invalid Ping Timeout: ($value)\n\n";
display_help();
exit(1);
}
break;
In addition, I updated the display_help() function, though this isn't required for this to work:
Code: Select all
echo " --ping_timeout 500, the time in ms to wait for a reply to an avail poll\n";