diff --git a/discovery.php b/discovery.php index 29525f8ce6..8415160275 100755 --- a/discovery.php +++ b/discovery.php @@ -74,11 +74,7 @@ if(isset($options['d'])) { echo("DEBUG!\n"); $debug = 1; } else { $debug = 0; } $devices_discovered = 0; $device_query = mysql_query("SELECT * FROM `devices` WHERE status = '1' $where ORDER BY device_id DESC"); -while ($device = mysql_fetch_array($device_query)) { - $devices[] = $device; -} - -foreach ($devices as $device) +while ($device = mysql_fetch_array($device_query)) { echo($device['hostname'] . " ".$device['device_id']." ".$device['os']." "); if($device['os'] != strtolower($device['os'])) { diff --git a/includes/discovery/processors-hrdevice.inc.php b/includes/discovery/processors-hrdevice.inc.php index 070862e5c7..2e7018cd26 100755 --- a/includes/discovery/processors-hrdevice.inc.php +++ b/includes/discovery/processors-hrdevice.inc.php @@ -26,7 +26,7 @@ echo("Moved RRD "); } - if(!strstr($descr, "No") && !strstr($usage, "No") && $descr != "" ) + if(!strstr($descr, "No") && !strstr($usage, "No") && $descr != "" && $descr != "An electronic chip that makes the computer work.") { if(mysql_result(mysql_query("SELECT count(processor_id) FROM `processors` WHERE `processor_index` = '$index' AND `device_id` = '".$device['device_id']."' AND `processor_type` = 'hr'"),0) == '0') { $query = "INSERT INTO processors (`hrDeviceIndex`, `device_id`, `processor_descr`, `processor_index`, `processor_oid`, `processor_usage`, `processor_type`) diff --git a/includes/polling/ucd-mib.inc.php b/includes/polling/ucd-mib.inc.php index 243d3f1f8c..5bd3c94c51 100755 --- a/includes/polling/ucd-mib.inc.php +++ b/includes/polling/ucd-mib.inc.php @@ -37,7 +37,7 @@ if (!is_file($cpurrd)) { RRA:MAX:0.5:288:800"); } -rrdtool_update($cpurrd, "N:$cpuUser:$cpuSystem:$cpuNice:$cpuIdle"); +rrdtool_update($cpurrd, "N:".($cpuUser+0).":".($cpuSystem+0).":".($cpuNice+0).":".($cpuIdle+0)); if (!is_file($memrrd)) { diff --git a/includes/syslog.php b/includes/syslog.php index 943f79c812..c6ad15baab 100755 --- a/includes/syslog.php +++ b/includes/syslog.php @@ -10,24 +10,18 @@ function process_syslog ($entry, $update) { } } - $device_id_host = @mysql_result(mysql_query("SELECT device_id FROM devices WHERE `hostname` = '".$entry['host']."'"),0); + $device_id_host = @mysql_result(mysql_query("SELECT device_id FROM devices WHERE `hostname` = '".$entry['host']."' OR `sysName` = '".$entry['host']."'"),0); if($device_id_host) { $entry['device_id'] = $device_id_host; } else { $device_id_ip = @mysql_result(mysql_query("SELECT device_id FROM ipv4_addresses AS A, interfaces AS I WHERE A.ipv4_address = '" . $entry['host']."' AND I.interface_id = A.interface_id"),0); - - #echo("SELECT device_id FROM ipv4_addresses AS A, interfaces AS I WHERE - #A.ipv4_address = '" . $entry['host']."' AND I.interface_id = A.interface_id"); - if($device_id_ip) { $entry['device_id'] = $device_id_ip; } } - print_r($entry); - if($entry['device_id'] && !$delete) { $os = mysql_result(mysql_query("SELECT `os` FROM `devices` WHERE `device_id` = '".$entry['device_id']."'"),0); if($os == "ios" || $os == "iosxe") { @@ -40,7 +34,6 @@ function process_syslog ($entry, $update) { $entry['msg'] = preg_replace("/^.*[0-9]:/", "", $entry['msg']); $entry['msg'] = preg_replace("/^[0-9][0-9]\ [A-Z]{3}:/", "", $entry['msg']); $entry['msg'] = preg_replace("/^(.+?):\ /", "\\1||", $entry['msg']); - #$entry['msg'] = "||" . $entry['msg']; } $entry['msg'] = preg_replace("/^.+\.[0-9]{3}:/", "", $entry['msg']); @@ -67,8 +60,7 @@ function process_syslog ($entry, $update) { $x = "UPDATE `syslog` set `device_id` = '".$entry['device_id']."', `program` = '".$entry['program']."', `msg` = '" . mysql_real_escape_string($entry['msg']) . "', processed = '1' WHERE `seq` = '" . $entry['seq'] . "'"; $x = "INSERT INTO `syslog` (`device_id`,`program`,`facility`,`priority`, `level`, `tag`, `msg`, `timestamp`) "; $x .= "VALUES ('".$entry['device_id']."','".$entry['program']."','".$entry['facility']."','".$entry['priority']."', '".$entry['level']."', '".$entry['tag']."', '".$entry['msg']."','".$entry['timestamp']."')"; - if($update) { mysql_query($x); } - if(mysql_affected_rows() > "0") { shell_exec("echo written $x >> /tmp/syslog"); } else { echo(mysql_error()); } + if($update && $entry['device_id']) { mysql_query($x); } unset ($fix); } diff --git a/poll-device.php b/poll-device.php index 8c80d01de5..c2e2e67ff0 100755 --- a/poll-device.php +++ b/poll-device.php @@ -42,7 +42,7 @@ echo("Starting polling run:\n\n"); $polled_devices = 0; $device_query = mysql_query("SELECT * FROM `devices` WHERE `ignore` = '0' $where ORDER BY `device_id` ASC"); while ($device = mysql_fetch_array($device_query)) { - $status = 0; + $status = 0; unset($array); echo($device['hostname'] . " ".$device['device_id']." ".$device['os']." "); if ($os_groups[$device[os]]) {$device['os_group'] = $os_groups[$device[os]]; echo "(".$device['os_group'].")";} diff --git a/syslog.php b/syslog.php index 2536f98734..91d6cb0692 100755 --- a/syslog.php +++ b/syslog.php @@ -1,27 +1,16 @@ #!/usr/bin/php > /tmp/syslog`; list($entry['host'],$entry['facility'],$entry['priority'], $entry['level'], $entry['tag'], $entry['timestamp'], $entry['msg']) = explode("||", trim($line)); shell_exec('echo "'.$i.'. '.$entry['host'].' -> '.$entry['msg'].'" >> /tmp/syslog'); - process_syslog($entry, 1); - unset($entry); unset($line); $i++; }