Discovery Plugin - Patch for hostnames and availability

Discussions on developing plugins for the Cacti Plugin Architecture

Moderators: Developers, Moderators

Post Reply
Vertigo
Posts: 16
Joined: Thu Jul 07, 2005 5:14 pm
Location: Melb, Australia
Contact:

Discovery Plugin - Patch for hostnames and availability

Post by Vertigo »

Hi All,

Another modification I thought I'd share I just made to the Discovery plugin, this one uses the hostname in place of the IP if it can resolve it, and also uses the actual availability method configured, I found it was setting it to Ping and SNMP.

Code: Select all

--- /plugins/discovery/findhosts.php	Thu Dec 22 08:27:32 2011
+++ /plugins/discovery/findhosts.php	Wed Jul 18 15:48:20 2012
@@ -357,6 +357,7 @@
 						$dnsname = discover_get_dns_from_ip($host, $dns, 300);
 						if ($dnsname != $host && $dnsname != 'timed_out') {
 							$device['dnsname'] = $dnsname;
+							$device['hostname'] = $dnsname;
 						}
 						$device['dnsname_short'] = preg_split('/[\.]+/', strtolower($dnsname), -1, PREG_SPLIT_NO_EMPTY);
 					}else{
@@ -438,6 +439,7 @@
 						$dnsname = discover_get_dns_from_ip($host, $dns, 300);
 						if ($dnsname != $host && $dnsname != 'timed_out') {
 							$device['dnsname'] = $dnsname;
+							$device['hostname'] = $dnsname;
 						}
 						$device['dnsname_short'] = preg_split('/[\.]+/', strtolower($dnsname), -1, PREG_SPLIT_NO_EMPTY);
 					}else{
@@ -493,7 +495,7 @@
 	$snmp_timeout         = read_config_option('snmp_timeout');
 	$disable              = false;
 	$tree                 = $device['tree'];
-	$availability_method  = read_config_option("ping_method");
+	$availability_method  = read_config_option("availability_method");
 	$ping_method          = read_config_option("ping_method");
 	$ping_port            = read_config_option("ping_port");
 	$ping_timeout         = read_config_option("ping_timeout");
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Re: Discovery Plugin - Patch for hostnames and availability

Post by gandalf »

Thx, added
R.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest