Set Availability Ping Timeout with add_device.php

Addons for Cacti and discussion about those addons

Moderators: Developers, Moderators

Post Reply
ptaylor874
Posts: 45
Joined: Fri Jan 04, 2008 11:45 am

Set Availability Ping Timeout with add_device.php

Post by ptaylor874 »

While setting up my new, faster Cacti machine, I set the availability reports to continue for the old machine while also being sent from the new machine. Oddly, I found that the reported availability of my devices is slightly less available with new, faster server. But, it only seemed to be the case for devices that I had deleted and re-added automatically with a script I wrote (which utilizes add_device.php).

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;
That code was added between the case statements for "--ping_retries" and "--max_oids".

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";
I placed that between the echo lines for '--ping_port' and '--ping_retries';
noname
Cacti Guru User
Posts: 1566
Joined: Thu Aug 05, 2010 2:04 am
Location: Japan

Re: Set Availability Ping Timeout with add_device.php

Post by noname »

Wow! You kindly fulfilled my request..:D
- http://bugs.cacti.net/view.php?id=2112

Thanks!
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Re: Set Availability Ping Timeout with add_device.php

Post by gandalf »

Comments from that "bug" report:
You may use that patch which is quite fine.
But we have a development stop on 087 branch. So it is quite unlikely, that it will make it into code of 087 branch.

The required functionality and more is already part of current SVN/main branch cli scripts.
R.
realdreams
Posts: 12
Joined: Sun Mar 17, 2013 12:19 am

Re: Set Availability Ping Timeout with add_device.php

Post by realdreams »

Any update on this? These parameters are missing in web - devices- action - change availability options as well.

I just edited default for ping_timeout in /site/include/global_settings.php
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests