mirror of
https://github.com/stylersnico/librenms.git
synced 2026-07-30 16:14:21 +02:00
clear $array at the start of each device. ignore fake cpus from net-snmpd. syslog additions.
git-svn-id: http://www.observium.org/svn/observer/trunk@886 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
@@ -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`)
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
+2
-10
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user