| 
									
										
										
										
											2007-04-03 14:10:23 +00:00
										 |  |  | #!/usr/bin/php
 | 
					
						
							| 
									
										
										
										
											2009-09-07 11:07:59 +00:00
										 |  |  | <?php | 
					
						
							| 
									
										
										
										
											2007-04-03 14:10:23 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | include("config.php"); | 
					
						
							|  |  |  | include("includes/functions.php"); | 
					
						
							| 
									
										
										
										
											2009-10-28 13:49:37 +00:00
										 |  |  | include("includes/functions-poller.inc.php"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | $poller_start = utime(); | 
					
						
							| 
									
										
										
										
											2008-03-22 13:30:33 +00:00
										 |  |  | echo("Observer Poller v".$config['version']."\n\n"); | 
					
						
							| 
									
										
										
										
											2007-11-23 11:37:28 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-10-28 13:49:37 +00:00
										 |  |  | $options = getopt("h:t:i:n:d::a::"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if ($options['h'] == "odd") { | 
					
						
							| 
									
										
										
										
											2009-11-07 02:30:38 +00:00
										 |  |  |   $where = "AND MOD(device_id,2) = 1";  $doing = $options['h']; | 
					
						
							| 
									
										
										
										
											2009-10-28 13:49:37 +00:00
										 |  |  | } elseif ($options['h'] == "even") { | 
					
						
							| 
									
										
										
										
											2009-11-07 02:30:38 +00:00
										 |  |  |   $where = "AND MOD(device_id,2) = 0";  $doing = $options['h']; | 
					
						
							|  |  |  | } elseif ($options['h'] == "all") { | 
					
						
							|  |  |  |   $where = " ";  $doing = "all"; | 
					
						
							| 
									
										
										
										
											2009-10-28 13:49:37 +00:00
										 |  |  | } elseif($options['h']) { | 
					
						
							| 
									
										
										
										
											2009-11-07 02:30:38 +00:00
										 |  |  |   $where = "AND `device_id` = '".$options['h']."'";  $doing = "Host ".$options['h']; | 
					
						
							| 
									
										
										
										
											2009-10-28 13:49:37 +00:00
										 |  |  | } elseif ($options['i'] && isset($options['n'])) { | 
					
						
							| 
									
										
										
										
											2009-11-07 02:30:38 +00:00
										 |  |  |   $where = "AND MOD(device_id,".$options['i'].") = '" . $options['n'] . "'";  $doing = "Proc ".$options['n'] ."/".$options['i']; | 
					
						
							| 
									
										
										
										
											2007-11-23 11:37:28 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-07 02:30:38 +00:00
										 |  |  | if(!$where) { | 
					
						
							|  |  |  |   echo("-h <device id>                Poll single device\n"); | 
					
						
							|  |  |  |   echo("-h odd                        Poll odd numbered devices  (same as -i 2 -n 0)\n"); | 
					
						
							|  |  |  |   echo("-h even                       Poll even numbered devices (same as -i 2 -n 1)\n"); | 
					
						
							|  |  |  |   echo("-h all                        Poll all devices\n\n"); | 
					
						
							|  |  |  |   echo("-i <instances> -n <number>    Poll as instance <number> of <instances>\n"); | 
					
						
							|  |  |  |   echo("                              Instances start at 0. 0-3 for -n 4\n\n"); | 
					
						
							|  |  |  |   echo("-d                            Enable some debugging output\n"); | 
					
						
							|  |  |  |   echo("\n"); | 
					
						
							|  |  |  |   echo("No polling type specified!\n"); | 
					
						
							|  |  |  |   exit; | 
					
						
							|  |  |  |  } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if(isset($options['d'])) { echo("DEBUG!\n"); $debug = 1; } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-11-23 11:37:28 +00:00
										 |  |  | echo("Starting polling run:\n\n"); | 
					
						
							| 
									
										
										
										
											2009-10-28 13:49:37 +00:00
										 |  |  | $i = 0; | 
					
						
							| 
									
										
										
										
											2007-11-23 11:37:28 +00:00
										 |  |  | $device_query = mysql_query("SELECT * FROM `devices` WHERE `ignore` = '0' $where  ORDER BY `device_id` ASC"); | 
					
						
							| 
									
										
										
										
											2007-04-03 14:10:23 +00:00
										 |  |  | while ($device = mysql_fetch_array($device_query)) { | 
					
						
							| 
									
										
										
										
											2007-04-08 14:34:19 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-28 09:48:23 +00:00
										 |  |  |   echo($device['hostname'] . " ".$device['device_id']." ".$device['os']." "); | 
					
						
							|  |  |  |   if($os_groups[$device[os]]) {$device['os_group'] = $os_groups[$device[os]]; echo "(".$device['os_group'].")";} | 
					
						
							|  |  |  |   echo("\n"); | 
					
						
							| 
									
										
										
										
											2007-11-23 11:37:28 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   unset($update); unset($update_query); unset($seperator); unset($version); unset($uptime); unset($features);  | 
					
						
							| 
									
										
										
										
											2009-03-30 11:20:18 +00:00
										 |  |  |   unset($sysLocation); unset($hardware); unset($sysDescr); unset($sysContact); unset($sysName); | 
					
						
							| 
									
										
										
										
											2007-04-09 13:14:03 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-04-08 14:34:19 +00:00
										 |  |  |   $pingable = isPingable($device['hostname']); | 
					
						
							| 
									
										
										
										
											2007-11-23 11:37:28 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-16 15:19:44 +00:00
										 |  |  |   $host_rrd = $config['rrd_dir'] . "/" . $device['hostname']; | 
					
						
							| 
									
										
										
										
											2008-03-12 13:13:50 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   if(!is_dir($host_rrd)) { mkdir($host_rrd); echo("Created directory : $host_rrd\n"); } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-11-23 11:37:28 +00:00
										 |  |  |   if($pingable) { echo("Pings : yes :)\n"); } else { echo("Pings : no :(\n"); } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-04-03 14:10:23 +00:00
										 |  |  |   $snmpable = FALSE; | 
					
						
							| 
									
										
										
										
											2007-04-08 14:34:19 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-04-03 14:10:23 +00:00
										 |  |  |   if($pingable) { | 
					
						
							| 
									
										
										
										
											2009-02-02 16:00:11 +00:00
										 |  |  |     $snmpable = isSNMPable($device['hostname'], $device['community'], $device['snmpver'], $device['port']); | 
					
						
							| 
									
										
										
										
											2008-03-19 18:55:31 +00:00
										 |  |  |     if($snmpable) { echo("SNMP : yes :)\n"); } else { echo("SNMP : no :(\n"); } | 
					
						
							| 
									
										
										
										
											2007-04-03 14:10:23 +00:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2007-04-08 12:23:45 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-03-31 13:08:17 +00:00
										 |  |  |   unset($snmpdata); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-03-19 18:55:31 +00:00
										 |  |  |   if ($snmpable) {  | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-04-08 14:34:19 +00:00
										 |  |  |     $status = '1'; | 
					
						
							| 
									
										
										
										
											2009-11-07 02:30:38 +00:00
										 |  |  |     $snmp_cmd =  $config['snmpget'] . " -m SNMPv2-MIB -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " .  $device['hostname'].":".$device['port']; | 
					
						
							| 
									
										
										
										
											2009-11-28 09:48:23 +00:00
										 |  |  |     $snmp_cmd .= " sysUpTime.0 sysLocation.0 sysContact.0 sysName.0"; | 
					
						
							| 
									
										
										
										
											2008-03-19 18:55:31 +00:00
										 |  |  |     $snmpdata = shell_exec($snmp_cmd); | 
					
						
							| 
									
										
										
										
											2009-09-30 12:27:18 +00:00
										 |  |  |     #$snmpdata = preg_replace("/^.*IOS/","", $snmpdata);
 | 
					
						
							| 
									
										
										
										
											2007-04-03 14:10:23 +00:00
										 |  |  |     $snmpdata = trim($snmpdata); | 
					
						
							| 
									
										
										
										
											2007-04-11 20:57:56 +00:00
										 |  |  |     $snmpdata = str_replace("\"", "", $snmpdata); | 
					
						
							| 
									
										
										
										
											2009-03-02 18:12:09 +00:00
										 |  |  |     list($sysUptime, $sysLocation, $sysContact, $sysName) = explode("\n", $snmpdata); | 
					
						
							| 
									
										
										
										
											2009-04-23 21:13:56 +00:00
										 |  |  |     $sysDescr = trim(shell_exec($config['snmpget'] . " -m SNMPv2-MIB -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " .  $device['hostname'].":".$device['port'] . " sysDescr.0")); | 
					
						
							| 
									
										
										
										
											2007-04-03 14:10:23 +00:00
										 |  |  |     $sysUptime = str_replace("(", "", $sysUptime); | 
					
						
							|  |  |  |     $sysUptime = str_replace(")", "", $sysUptime);  | 
					
						
							| 
									
										
										
										
											2009-11-28 09:48:23 +00:00
										 |  |  |     $sysName = strtolower($sysName); | 
					
						
							| 
									
										
										
										
											2007-04-03 14:10:23 +00:00
										 |  |  |     list($days, $hours, $mins, $secs) = explode(":", $sysUptime); | 
					
						
							|  |  |  |     list($secs, $microsecs) = explode(".", $secs); | 
					
						
							|  |  |  |     $hours = $hours + ($days * 24); | 
					
						
							|  |  |  |     $mins = $mins + ($hours * 60); | 
					
						
							|  |  |  |     $secs = $secs + ($mins * 60); | 
					
						
							| 
									
										
										
										
											2007-04-08 21:27:05 +00:00
										 |  |  |     $uptime = $secs; | 
					
						
							| 
									
										
										
										
											2007-04-03 14:10:23 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-28 09:48:23 +00:00
										 |  |  |     if(is_file($config['install_dir'] . "/includes/polling/device-".$device['os'].".inc.php")) { | 
					
						
							|  |  |  |       /// OS Specific
 | 
					
						
							|  |  |  |       include($config['install_dir'] . "/includes/polling/device-".$device['os'].".inc.php"); | 
					
						
							|  |  |  |     }elseif($device['os_group'] && is_file($config['install_dir'] . "/includes/polling/device-".$device['os_group'].".inc.php")) { | 
					
						
							|  |  |  |       /// OS Group Specific
 | 
					
						
							|  |  |  |       include($config['install_dir'] . "/includes/polling/device-".$device['os_group'].".inc.php"); | 
					
						
							|  |  |  |     }else{ | 
					
						
							|  |  |  |       echo("Generic :("); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-03-31 13:08:17 +00:00
										 |  |  |     $sysLocation = str_replace("\"","", $sysLocation);  | 
					
						
							| 
									
										
										
										
											2007-04-08 12:23:45 +00:00
										 |  |  |    | 
					
						
							| 
									
										
										
										
											2009-11-11 11:43:06 +00:00
										 |  |  |     include("includes/polling/temperatures.inc.php"); | 
					
						
							|  |  |  |     include("includes/polling/device-netstats.inc.php"); | 
					
						
							| 
									
										
										
										
											2009-11-28 09:48:23 +00:00
										 |  |  |     include("includes/polling/ipSystemStats.inc.php"); | 
					
						
							| 
									
										
										
										
											2009-11-11 11:43:06 +00:00
										 |  |  |     include("includes/polling/ports.inc.php"); | 
					
						
							|  |  |  |     include("includes/polling/cisco-mac-accounting.inc.php"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-04-11 20:57:56 +00:00
										 |  |  |   unset( $update ) ; | 
					
						
							| 
									
										
										
										
											2007-11-23 11:37:28 +00:00
										 |  |  |   unset( $seperator) ; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   if ( $sysContact && $sysContact != $device['sysContact'] ) { | 
					
						
							| 
									
										
										
										
											2009-11-28 09:48:23 +00:00
										 |  |  |     $update .= $seperator . "`sysContact` = '".mres($sysContact)."'"; | 
					
						
							| 
									
										
										
										
											2007-11-23 11:37:28 +00:00
										 |  |  |     $seperator = ", "; | 
					
						
							|  |  |  |     mysql_query("INSERT INTO eventlog (host, interface, datetime, message) VALUES ('" . $device['device_id'] . "', NULL, NOW(), 'Contact -> $sysContact')"); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-02 18:12:09 +00:00
										 |  |  |   if ( $sysName && $sysName != $device['sysName'] ) { | 
					
						
							|  |  |  |     $update .= $seperator . "`sysName` = '$sysName'"; | 
					
						
							|  |  |  |     $seperator = ", "; | 
					
						
							|  |  |  |     mysql_query("INSERT INTO eventlog (host, interface, datetime, message) VALUES ('" . $device['device_id'] . "', NULL, NOW(), 'sysName -> $sysName')"); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-04-08 14:34:19 +00:00
										 |  |  |   if ( $sysDescr && $sysDescr != $device['sysDescr'] ) { | 
					
						
							| 
									
										
										
										
											2007-05-20 19:21:35 +00:00
										 |  |  |     $update .= $seperator . "`sysDescr` = '$sysDescr'"; | 
					
						
							| 
									
										
										
										
											2007-04-03 14:10:23 +00:00
										 |  |  |     $seperator = ", "; | 
					
						
							| 
									
										
										
										
											2007-04-08 14:34:19 +00:00
										 |  |  |     mysql_query("INSERT INTO eventlog (host, interface, datetime, message) VALUES ('" . $device['device_id'] . "', NULL, NOW(), 'sysDescr -> $sysDescr')"); | 
					
						
							| 
									
										
										
										
											2007-04-03 14:10:23 +00:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2007-04-11 20:57:56 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-03-31 13:08:17 +00:00
										 |  |  |   if ( $sysLocation && $device['location'] != $sysLocation ) { | 
					
						
							|  |  |  |     $update .= $seperator . "`location` = '$sysLocation'"; | 
					
						
							| 
									
										
										
										
											2007-04-03 14:10:23 +00:00
										 |  |  |     $seperator = ", "; | 
					
						
							| 
									
										
										
										
											2008-03-31 13:08:17 +00:00
										 |  |  |     mysql_query("INSERT INTO eventlog (host, interface, datetime, message) VALUES ('" . $device['device_id'] . "', NULL, NOW(), 'Location -> $sysLocation')"); | 
					
						
							| 
									
										
										
										
											2007-04-03 14:10:23 +00:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2007-04-11 20:57:56 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-04-08 21:27:05 +00:00
										 |  |  |   if ( $version && $device['version'] != $version ) { | 
					
						
							|  |  |  |     $update .= $seperator . "`version` = '$version'"; | 
					
						
							| 
									
										
										
										
											2007-04-03 14:10:23 +00:00
										 |  |  |     $seperator = ", "; | 
					
						
							| 
									
										
										
										
											2007-04-08 21:27:05 +00:00
										 |  |  |     mysql_query("INSERT INTO eventlog (host, interface, datetime, message) VALUES ('" . $device['device_id'] . "', NULL, NOW(), 'OS Version -> $version')"); | 
					
						
							| 
									
										
										
										
											2007-04-03 14:10:23 +00:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2007-04-11 20:57:56 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-04-08 21:27:05 +00:00
										 |  |  |   if ( $features && $features != $device['features'] ) { | 
					
						
							|  |  |  |     $update .= $seperator . "`features` = '$features'"; | 
					
						
							| 
									
										
										
										
											2007-04-03 14:10:23 +00:00
										 |  |  |     $seperator = ", "; | 
					
						
							| 
									
										
										
										
											2007-04-08 21:27:05 +00:00
										 |  |  |     mysql_query("INSERT INTO eventlog (host, interface, datetime, message) VALUES ('" . $device['device_id'] . "', NULL, NOW(), 'OS Features -> $features')"); | 
					
						
							| 
									
										
										
										
											2007-04-03 14:10:23 +00:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2007-04-11 20:57:56 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-04-08 21:27:05 +00:00
										 |  |  |   if ( $hardware && $hardware != $device['hardware'] ) { | 
					
						
							|  |  |  |     $update .= $seperator . "`hardware` = '$hardware'"; | 
					
						
							| 
									
										
										
										
											2007-04-03 14:10:23 +00:00
										 |  |  |     $seperator = ", "; | 
					
						
							| 
									
										
										
										
											2007-04-08 21:27:05 +00:00
										 |  |  |     mysql_query("INSERT INTO eventlog (host, interface, datetime, message) VALUES ('" . $device['device_id'] . "', NULL, NOW(), 'Hardware -> $hardware')"); | 
					
						
							| 
									
										
										
										
											2007-04-03 14:10:23 +00:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2007-04-04 10:08:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-04-08 21:27:05 +00:00
										 |  |  |   if( $device['status'] != $status ) { | 
					
						
							|  |  |  |     $update .= $seperator . "`status` = '$status'"; | 
					
						
							| 
									
										
										
										
											2007-04-03 14:10:23 +00:00
										 |  |  |     $seperator = ", "; | 
					
						
							| 
									
										
										
										
											2007-04-08 21:27:05 +00:00
										 |  |  |     if ($status == '1') { $stat = "Up";  | 
					
						
							| 
									
										
										
										
											2007-04-08 14:34:19 +00:00
										 |  |  |       mysql_query("INSERT INTO alerts (importance, device_id, message) VALUES ('0', '" . $device['device_id'] . "', 'Device is up\n')"); | 
					
						
							| 
									
										
										
										
											2007-04-03 14:10:23 +00:00
										 |  |  |     } else {  | 
					
						
							|  |  |  |       $stat = "Down";  | 
					
						
							| 
									
										
										
										
											2007-04-08 14:34:19 +00:00
										 |  |  |       mysql_query("INSERT INTO alerts (importance, device_id, message) VALUES ('9', '" . $device['device_id'] . "', 'Device is down\n')"); | 
					
						
							| 
									
										
										
										
											2007-04-03 14:10:23 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2007-04-08 14:34:19 +00:00
										 |  |  |     mysql_query("INSERT INTO eventlog (host, interface, datetime, message) VALUES ('" . $device['device_id'] . "', NULL, NOW(), 'Device status changed to $stat')"); | 
					
						
							| 
									
										
										
										
											2007-04-03 14:10:23 +00:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2007-04-04 10:08:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-04-08 21:27:05 +00:00
										 |  |  |   if ($uptime) { | 
					
						
							| 
									
										
										
										
											2007-06-24 14:56:47 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-28 09:48:23 +00:00
										 |  |  |     if( $uptime < $device['uptime'] ) { | 
					
						
							| 
									
										
										
										
											2007-11-23 11:37:28 +00:00
										 |  |  |       if($device['sysContact']) { $email = $device['sysContact']; } else { $email = $config['email_default']; } | 
					
						
							| 
									
										
										
										
											2009-11-28 09:48:23 +00:00
										 |  |  |       mail($email, "Device Rebooted: " . $device['hostname'], "Device Rebooted :" . $device['hostname'] . " at " . date('l dS F Y h:i:s A'), $config['email_headers']); | 
					
						
							| 
									
										
										
										
											2007-06-24 14:56:47 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-16 15:19:44 +00:00
										 |  |  |     $uptimerrd    = $config['rrd_dir'] . "/" . $device['hostname'] . "/uptime.rrd"; | 
					
						
							| 
									
										
										
										
											2008-03-12 13:13:50 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-04-07 19:28:52 +00:00
										 |  |  |     if(!is_file($uptimerrd)) { | 
					
						
							| 
									
										
										
										
											2008-04-14 09:32:54 +00:00
										 |  |  |       $woo = shell_exec($config['rrdtool'] . " create $uptimerrd \
 | 
					
						
							| 
									
										
										
										
											2007-04-07 19:28:52 +00:00
										 |  |  |         DS:uptime:GAUGE:600:0:U \ | 
					
						
							|  |  |  |         RRA:AVERAGE:0.5:1:600 \ | 
					
						
							|  |  |  |         RRA:AVERAGE:0.5:6:700 \ | 
					
						
							|  |  |  |         RRA:AVERAGE:0.5:24:775 \ | 
					
						
							| 
									
										
										
										
											2008-04-14 09:32:54 +00:00
										 |  |  |         RRA:AVERAGE:0.5:288:797");
 | 
					
						
							| 
									
										
										
										
											2007-04-07 19:25:55 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2008-03-09 21:13:27 +00:00
										 |  |  |     rrdtool_update($uptimerrd, "N:$uptime"); | 
					
						
							| 
									
										
										
										
											2007-04-07 19:25:55 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-28 09:48:23 +00:00
										 |  |  |     $update .= $seperator . "`uptime` = '$uptime'"; | 
					
						
							|  |  |  |     $seperator = ", "; | 
					
						
							|  |  |  |   }  | 
					
						
							|  |  |  |   $update .= $seperator . "`last_polled` = NOW()"; | 
					
						
							| 
									
										
										
										
											2007-04-03 14:10:23 +00:00
										 |  |  |   if ($update) { | 
					
						
							|  |  |  |     $update_query  = "UPDATE `devices` SET "; | 
					
						
							|  |  |  |     $update_query .= $update; | 
					
						
							| 
									
										
										
										
											2007-04-08 21:27:05 +00:00
										 |  |  |     $update_query .= " WHERE `device_id` = '" . $device['device_id'] . "'"; | 
					
						
							| 
									
										
										
										
											2009-11-28 09:48:23 +00:00
										 |  |  |     echo("Updating " . $device['hostname'] . " - $update_query \n"); | 
					
						
							| 
									
										
										
										
											2007-04-03 14:10:23 +00:00
										 |  |  |     $update_result = mysql_query($update_query); | 
					
						
							|  |  |  |   } else { | 
					
						
							| 
									
										
										
										
											2007-11-23 11:37:28 +00:00
										 |  |  |     echo("No Changes to " . $device['hostname'] . "\n"); | 
					
						
							| 
									
										
										
										
											2007-04-03 14:10:23 +00:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2009-10-28 13:49:37 +00:00
										 |  |  |   $i++; | 
					
						
							| 
									
										
										
										
											2007-11-23 11:37:28 +00:00
										 |  |  |   echo("\n"); | 
					
						
							| 
									
										
										
										
											2009-11-28 09:48:23 +00:00
										 |  |  |   } else { | 
					
						
							|  |  |  |     $update_query  = "UPDATE `devices` SET "; | 
					
						
							|  |  |  |     $update .= " `status` = '0'"; | 
					
						
							|  |  |  |     $update_query .= " WHERE `device_id` = '" . $device['device_id'] . "'"; | 
					
						
							|  |  |  |     echo("Updating " . $device['hostname'] . "\n"); | 
					
						
							|  |  |  |     $update_result = mysql_query($update_query); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2007-04-03 14:10:23 +00:00
										 |  |  | }    | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-10-28 13:49:37 +00:00
										 |  |  | $poller_end = utime(); $poller_run = $poller_end - $poller_start; $poller_time = substr($poller_run, 0, 5); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | $string = $argv[0] . " $doing " .  date("F j, Y, G:i") . " - $i devices polled in $poller_time secs"; | 
					
						
							|  |  |  | echo("$string\n"); | 
					
						
							| 
									
										
										
										
											2009-11-11 16:02:58 +00:00
										 |  |  | shell_exec("echo '".$string."' >> ".$config['install_dir']."/observer.log"); | 
					
						
							| 
									
										
										
										
											2009-10-28 13:49:37 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-07 02:30:38 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-04-03 14:10:23 +00:00
										 |  |  | ?>
 |