mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00: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:
@@ -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'])) {
|
||||
|
@@ -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)) {
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
|
@@ -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'].")";}
|
||||
|
11
syslog.php
11
syslog.php
@@ -1,27 +1,16 @@
|
||||
#!/usr/bin/php
|
||||
<?php
|
||||
|
||||
# ini_set('display_errors', 0);
|
||||
# ini_set('display_startup_errors', 0);
|
||||
# ini_set('log_errors', 0);
|
||||
# ini_set('error_reporting', E_ALL);
|
||||
|
||||
|
||||
include("config.php");
|
||||
include("includes/syslog.php");
|
||||
|
||||
$i="1";
|
||||
|
||||
#mysql_query("DELETE FROM `syslog` WHERE `datetime` < DATE_SUB(NOW(), INTERVAL ".$config['syslog_age'].")");
|
||||
|
||||
$s=fopen('php://stdin','r');
|
||||
while($line=fgets($s)){
|
||||
`echo "$line" >> /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++;
|
||||
}
|
||||
|
Reference in New Issue
Block a user