mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Fix some broken things.
git-svn-id: http://www.observium.org/svn/observer/trunk@91 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
@@ -5,7 +5,7 @@ include("includes/functions.php");
|
|||||||
|
|
||||||
# Discover interfaces
|
# Discover interfaces
|
||||||
|
|
||||||
$device_query = mysql_query("SELECT id,hostname,community,snmpver FROM `devices` WHERE `id` LIKE '%" . $argv[1] . "' AND status = '1' AND os != 'Snom' ORDER BY id DESC");
|
$device_query = mysql_query("SELECT device_id,hostname,community,snmpver FROM `devices` WHERE `device_id` LIKE '%" . $argv[1] . "' AND status = '1' AND os != 'Snom' ORDER BY device_id DESC");
|
||||||
while ($device = mysql_fetch_row($device_query)) {
|
while ($device = mysql_fetch_row($device_query)) {
|
||||||
|
|
||||||
$id = $device['0'];
|
$id = $device['0'];
|
||||||
|
@@ -18,7 +18,7 @@ if($bg == $list_colour_a) { $bg = $list_colour_b; } else { $bg=$list_colour_a; }
|
|||||||
" . $entry['datetime'] . "
|
" . $entry['datetime'] . "
|
||||||
</td>");
|
</td>");
|
||||||
if(!$_GET[id] && !$overview) {
|
if(!$_GET[id] && !$overview) {
|
||||||
$dev['id'] = $entry['host'];
|
$dev['device_id'] = $entry['host'];
|
||||||
$dev['hostname'] = $hostname;
|
$dev['hostname'] = $hostname;
|
||||||
echo("<td class=list-bold width=250>
|
echo("<td class=list-bold width=250>
|
||||||
" . generatedevicelink($dev) . "
|
" . generatedevicelink($dev) . "
|
||||||
|
@@ -47,9 +47,12 @@ while($device = mysql_fetch_array($device_query)) {
|
|||||||
$graph_type = "cpu"; include ("includes/print-device-graph.php");
|
$graph_type = "cpu"; include ("includes/print-device-graph.php");
|
||||||
echo("<br />");
|
echo("<br />");
|
||||||
if($device[os] == "m0n0wall" || $device[os] == "pfSense" || $device[os] == "Voswall" || $device[monowall]) {
|
if($device[os] == "m0n0wall" || $device[os] == "pfSense" || $device[os] == "Voswall" || $device[monowall]) {
|
||||||
echo("<div class=graphhead>Device Uptime</div>");
|
echo("<div class=graphhead>IP Statistics</div>");
|
||||||
$graph_type = "uptime"; include ("includes/print-device-graph.php"); break;
|
$graph_type = "ip_graph"; include ("includes/print-device-graph.php");
|
||||||
echo("<br />");
|
echo("<br />");
|
||||||
|
echo("<div class=graphhead>Device Uptime</div>");
|
||||||
|
$graph_type = "uptime"; include ("includes/print-device-graph.php");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if($device['os'] != "NetBSD") {
|
if($device['os'] != "NetBSD") {
|
||||||
echo("<div class=graphhead>Memory Utilisation</div>");
|
echo("<div class=graphhead>Memory Utilisation</div>");
|
||||||
@@ -57,13 +60,13 @@ while($device = mysql_fetch_array($device_query)) {
|
|||||||
echo("<br />");
|
echo("<br />");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(mysql_result(mysql_query("SELECT count(storage_id) FROM storage WHERE host_id = '$device[id]'"),0)) {
|
if(mysql_result(mysql_query("SELECT count(storage_id) FROM storage WHERE host_id = '" . $device['device_id'] . "'"),0)) {
|
||||||
echo("<div class=graphhead>Storage</div>");
|
echo("<div class=graphhead>Storage</div>");
|
||||||
$graph_type = "unixfs"; include ("includes/print-device-graph.php");
|
$graph_type = "unixfs"; include ("includes/print-device-graph.php");
|
||||||
echo("<br />");
|
echo("<br />");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(mysql_result(mysql_query("SELECT count(*) FROM temperature WHERE temp_host = '$device[id]'"),0)) {
|
if(mysql_result(mysql_query("SELECT count(*) FROM temperature WHERE temp_host = '" . $device['device_id'] . "'"),0)) {
|
||||||
echo("<div class=graphhead>Temperatures</div>");
|
echo("<div class=graphhead>Temperatures</div>");
|
||||||
$graph_type = "temp"; include ("includes/print-device-graph.php");
|
$graph_type = "temp"; include ("includes/print-device-graph.php");
|
||||||
echo("<br />");
|
echo("<br />");
|
||||||
|
@@ -393,26 +393,6 @@ function fixIOSHardware($hardware){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateHost ($host, $community, $snmpver)
|
|
||||||
{
|
|
||||||
# $soft = `snmpget -O vq -$snmpver -c $community $host sysDescr.0 | grep IOS | sed s/Cisco\ IOS\ Software\,// | sed s/\"\ //g | sed s/IOS\ \(tm\)\ // | sed s/\,\ RELEASE\ SOFTWARE.*// | sed s/.*\ Software\ // | sed s/\,\ /\|\|/ | sed s/\Version\ // | sed s/,\ EARLY\ DEPLOYMENT\ RELEASE\ SOFTWARE\ .*//`;
|
|
||||||
$sysdescr = `snmpget -O vq -$snmpver -c $community $host sysDescr.0`;
|
|
||||||
$sysdecr = str_replace("\"","", $sysdescr);
|
|
||||||
$location = str_replace("\"","", `snmpget -O vq -v2c -c $community $host sysLocation.0`);
|
|
||||||
list ($features, $version) = explode('||', $soft);
|
|
||||||
$features = str_replace("(","", $features);
|
|
||||||
$features = str_replace(")","", $features);
|
|
||||||
$version = str_replace("\n","", $version);
|
|
||||||
$version = trim($version);
|
|
||||||
$location = trim($location);
|
|
||||||
list ($hardware, $features) = explode("-", $features);
|
|
||||||
$hardware = fixIOSHardware($hardware);
|
|
||||||
$features = fixIOSFeatures($features);
|
|
||||||
$sql = "UPDATE `devices` SET `hardware` = '$hardware', `features` = '$features', `version` = '$version', `sysdesc` = '$sysdescr', `location` = '$location' WHERE `hostname` = '$host'";
|
|
||||||
# echo("$sql \n");
|
|
||||||
# mysql_query($sql);
|
|
||||||
}
|
|
||||||
|
|
||||||
function getHostOS($host, $community, $snmpver) {
|
function getHostOS($host, $community, $snmpver) {
|
||||||
$sysDescr = trim(`snmpget -O qv -$snmpver -c $community $host sysDescr.0`);
|
$sysDescr = trim(`snmpget -O qv -$snmpver -c $community $host sysDescr.0`);
|
||||||
if ($sysDescr == "") {$sysDescr = trim(`snmpget -O qv -$snmpver -c $community $host 1.3.6.1.2.1.7526.2.4`);}
|
if ($sysDescr == "") {$sysDescr = trim(`snmpget -O qv -$snmpver -c $community $host 1.3.6.1.2.1.7526.2.4`);}
|
||||||
|
@@ -2,9 +2,6 @@
|
|||||||
|
|
||||||
$id = $device['device_id'];
|
$id = $device['device_id'];
|
||||||
$hostname = $device['hostname'];
|
$hostname = $device['hostname'];
|
||||||
$hardware = $device['hardware'];
|
|
||||||
$version = $device['version'];
|
|
||||||
$features = $device['features'];
|
|
||||||
|
|
||||||
$loadrrd = "rrd/" . $hostname . "-load.rrd";
|
$loadrrd = "rrd/" . $hostname . "-load.rrd";
|
||||||
$loadgraph = "public_html/graphs/" . $hostname . "-load.png";
|
$loadgraph = "public_html/graphs/" . $hostname . "-load.png";
|
||||||
|
4
ips.php
4
ips.php
@@ -3,11 +3,11 @@
|
|||||||
include("config.php");
|
include("config.php");
|
||||||
include("includes/functions.php");
|
include("includes/functions.php");
|
||||||
|
|
||||||
$sql = "SELECT * FROM devices WHERE id LIKE '%$argv[1]' AND status = '1' AND os != 'Snom' order by id DESC";
|
$sql = "SELECT * FROM devices WHERE device_id LIKE '%$argv[1]' AND status = '1' AND os != 'Snom' order by device_id DESC";
|
||||||
$q = mysql_query($sql);
|
$q = mysql_query($sql);
|
||||||
while ($device = mysql_fetch_array($q)) {
|
while ($device = mysql_fetch_array($q)) {
|
||||||
$hostname = $device['hostname'];
|
$hostname = $device['hostname'];
|
||||||
$hostid = $device['id'];
|
$hostid = $device['device_id'];
|
||||||
$community = $device['community'];
|
$community = $device['community'];
|
||||||
echo("$hostname\n");
|
echo("$hostname\n");
|
||||||
$oids = `snmpbulkwalk -v2c -Osq -c $community $hostname ipAdEntIfIndex | sed s/ipAdEntIfIndex.//g`;
|
$oids = `snmpbulkwalk -v2c -Osq -c $community $hostname ipAdEntIfIndex | sed s/ipAdEntIfIndex.//g`;
|
||||||
|
@@ -30,6 +30,7 @@ while ($device = mysql_fetch_array($device_query)) {
|
|||||||
$snmpdata = `$snmp_cmd`;
|
$snmpdata = `$snmp_cmd`;
|
||||||
$snmpdata = preg_replace("/^.*IOS/","", $snmpdata);
|
$snmpdata = preg_replace("/^.*IOS/","", $snmpdata);
|
||||||
$snmpdata = trim($snmpdata);
|
$snmpdata = trim($snmpdata);
|
||||||
|
$snmpdata = str_replace("\"", "", $snmpdata);
|
||||||
list($sysUptime, $sysLocation, $ciscomodel, $sysDescr) = explode("\n", $snmpdata);
|
list($sysUptime, $sysLocation, $ciscomodel, $sysDescr) = explode("\n", $snmpdata);
|
||||||
$sysUptime = str_replace("(", "", $sysUptime);
|
$sysUptime = str_replace("(", "", $sysUptime);
|
||||||
$sysUptime = str_replace(")", "", $sysUptime);
|
$sysUptime = str_replace(")", "", $sysUptime);
|
||||||
@@ -50,23 +51,23 @@ while ($device = mysql_fetch_array($device_query)) {
|
|||||||
case "Voswall":
|
case "Voswall":
|
||||||
case "NetBSD":
|
case "NetBSD":
|
||||||
case "pfSense":
|
case "pfSense":
|
||||||
if($device['os'] == "FreeBSD") {
|
if ($device['os'] == "FreeBSD") {
|
||||||
$sysDescr = str_replace(" 0 ", " ", $sysDescr);
|
$sysDescr = str_replace(" 0 ", " ", $sysDescr);
|
||||||
list(,,$version) = explode (" ", $sysDescr);
|
list(,,$version) = explode (" ", $sysDescr);
|
||||||
$hardware = "i386";
|
$hardware = "i386";
|
||||||
$features = "GENERIC";
|
$features = "GENERIC";
|
||||||
} elseif($device['os'] == "DragonFly") {
|
} elseif ($device['os'] == "DragonFly") {
|
||||||
list(,,$version,,,$features,,$hardware) = explode (" ", $sysDescr);
|
list(,,$version,,,$features,,$hardware) = explode (" ", $sysDescr);
|
||||||
} elseif($device['os'] == "NetBSD") {
|
} elseif ($device['os'] == "NetBSD") {
|
||||||
list(,,$version,,,$features) = explode (" ", $sysDescr);
|
list(,,$version,,,$features) = explode (" ", $sysDescr);
|
||||||
$features = str_replace("(", "", $features);
|
$features = str_replace("(", "", $features);
|
||||||
$features = str_replace(")", "", $features);
|
$features = str_replace(")", "", $features);
|
||||||
list(,,$hardware) = explode ("$features", $sysDescr);
|
list(,,$hardware) = explode ("$features", $sysDescr);
|
||||||
} elseif($device['os'] == "OpenBSD") {
|
} elseif ($device['os'] == "OpenBSD") {
|
||||||
list(,,$version,$features,$hardware) = explode (" ", $sysDescr);
|
list(,,$version,$features,$hardware) = explode (" ", $sysDescr);
|
||||||
$features = str_replace("(", "", $features);
|
$features = str_replace("(", "", $features);
|
||||||
$features = str_replace(")", "", $features);
|
$features = str_replace(")", "", $features);
|
||||||
} elseif($device['os'] == "m0n0wall" || $device['os'] == "Voswall") {
|
} elseif ($device['os'] == "m0n0wall" || $device['os'] == "Voswall") {
|
||||||
list(,,$version,$hardware,$freebsda, $freebsdb, $arch) = split(" ", $sysDescr);
|
list(,,$version,$hardware,$freebsda, $freebsdb, $arch) = split(" ", $sysDescr);
|
||||||
$features = $freebsda . " " . $freebsdb;
|
$features = $freebsda . " " . $freebsdb;
|
||||||
$hardware = "$hardware ($arch)";
|
$hardware = "$hardware ($arch)";
|
||||||
@@ -143,26 +144,32 @@ while ($device = mysql_fetch_array($device_query)) {
|
|||||||
$status = '0';
|
$status = '0';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unset( $update ) ;
|
||||||
|
|
||||||
if ( $sysDescr && $sysDescr != $device['sysDescr'] ) {
|
if ( $sysDescr && $sysDescr != $device['sysDescr'] ) {
|
||||||
$update = "`sysDescr` = '$sysDescr'";
|
$update .= "`sysDescr` = '$sysDescr'";
|
||||||
$seperator = ", ";
|
$seperator = ", ";
|
||||||
mysql_query("INSERT INTO eventlog (host, interface, datetime, message) VALUES ('" . $device['device_id'] . "', NULL, NOW(), 'sysDescr -> $sysDescr')");
|
mysql_query("INSERT INTO eventlog (host, interface, datetime, message) VALUES ('" . $device['device_id'] . "', NULL, NOW(), 'sysDescr -> $sysDescr')");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $location && $device['location'] != $location ) {
|
if ( $location && $device['location'] != $location ) {
|
||||||
$update = "`location` = '$location'";
|
$update .= "`location` = '$location'";
|
||||||
$seperator = ", ";
|
$seperator = ", ";
|
||||||
mysql_query("INSERT INTO eventlog (host, interface, datetime, message) VALUES ('" . $device['device_id'] . "', NULL, NOW(), 'Location -> $location')");
|
mysql_query("INSERT INTO eventlog (host, interface, datetime, message) VALUES ('" . $device['device_id'] . "', NULL, NOW(), 'Location -> $location')");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $version && $device['version'] != $version ) {
|
if ( $version && $device['version'] != $version ) {
|
||||||
$update .= $seperator . "`version` = '$version'";
|
$update .= $seperator . "`version` = '$version'";
|
||||||
$seperator = ", ";
|
$seperator = ", ";
|
||||||
mysql_query("INSERT INTO eventlog (host, interface, datetime, message) VALUES ('" . $device['device_id'] . "', NULL, NOW(), 'OS Version -> $version')");
|
mysql_query("INSERT INTO eventlog (host, interface, datetime, message) VALUES ('" . $device['device_id'] . "', NULL, NOW(), 'OS Version -> $version')");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $features && $features != $device['features'] ) {
|
if ( $features && $features != $device['features'] ) {
|
||||||
$update .= $seperator . "`features` = '$features'";
|
$update .= $seperator . "`features` = '$features'";
|
||||||
$seperator = ", ";
|
$seperator = ", ";
|
||||||
mysql_query("INSERT INTO eventlog (host, interface, datetime, message) VALUES ('" . $device['device_id'] . "', NULL, NOW(), 'OS Features -> $features')");
|
mysql_query("INSERT INTO eventlog (host, interface, datetime, message) VALUES ('" . $device['device_id'] . "', NULL, NOW(), 'OS Features -> $features')");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $hardware && $hardware != $device['hardware'] ) {
|
if ( $hardware && $hardware != $device['hardware'] ) {
|
||||||
$update .= $seperator . "`hardware` = '$hardware'";
|
$update .= $seperator . "`hardware` = '$hardware'";
|
||||||
$seperator = ", ";
|
$seperator = ", ";
|
||||||
|
@@ -72,12 +72,12 @@ while ($interface = mysql_fetch_array($interface_query)) {
|
|||||||
mysql_query("INSERT INTO eventlog (`host`, `interface`, `datetime`, `message`) VALUES ('" . $interface['device_id'] . "', '" . $interface['interface_id'] . "', NOW(), 'Desc -> $ifAlias')");
|
mysql_query("INSERT INTO eventlog (`host`, `interface`, `datetime`, `message`) VALUES ('" . $interface['device_id'] . "', '" . $interface['interface_id'] . "', NOW(), 'Desc -> $ifAlias')");
|
||||||
}
|
}
|
||||||
if ( $interface['ifOperStatus'] != $ifOperStatus && $ifOperStatus != "" ) {
|
if ( $interface['ifOperStatus'] != $ifOperStatus && $ifOperStatus != "" ) {
|
||||||
$update .= $seperator . "`up` = '$ifOperStatus'";
|
$update .= $seperator . "`ifOperStatus` = '$ifOperStatus'";
|
||||||
$seperator = ", ";
|
$seperator = ", ";
|
||||||
mysql_query("INSERT INTO eventlog (`host`, `interface`, `datetime`, `message`) VALUES ('" . $interface['device_id'] . "', '" . $interface['interface_id'] . "', NOW(), 'Interface went $ifOperStatus')");
|
mysql_query("INSERT INTO eventlog (`host`, `interface`, `datetime`, `message`) VALUES ('" . $interface['device_id'] . "', '" . $interface['interface_id'] . "', NOW(), 'Interface went $ifOperStatus')");
|
||||||
}
|
}
|
||||||
if ( $interface['ifAdminStatus'] != $ifAdminStatus && $ifAdminStatus != "" ) {
|
if ( $interface['ifAdminStatus'] != $ifAdminStatus && $ifAdminStatus != "" ) {
|
||||||
$update .= $seperator . "`up_admin` = '$ifAdminStatus'";
|
$update .= $seperator . "`ifAdminStatus` = '$ifAdminStatus'";
|
||||||
$seperator = ", ";
|
$seperator = ", ";
|
||||||
if($ifAdminStatus == "up") { $admin = "enabled"; } else { $admin = "disabled"; }
|
if($ifAdminStatus == "up") { $admin = "enabled"; } else { $admin = "disabled"; }
|
||||||
mysql_query("INSERT INTO eventlog (`host`, `interface`, `datetime`, `message`) VALUES ('" . $interface['device_id'] . "', '" . $interface['interface_id'] . "', NOW(), 'Interface $admin')");
|
mysql_query("INSERT INTO eventlog (`host`, `interface`, `datetime`, `message`) VALUES ('" . $interface['device_id'] . "', '" . $interface['interface_id'] . "', NOW(), 'Interface $admin')");
|
||||||
|
@@ -16,8 +16,8 @@ while($l = mysql_fetch_array($q)){
|
|||||||
unset($maybehost);
|
unset($maybehost);
|
||||||
unset($perhapshost);
|
unset($perhapshost);
|
||||||
|
|
||||||
$maybehost = @mysql_result(mysql_query("SELECT D.id as id FROM ipaddr AS A, interfaces AS I, devices AS D WHERE A.addr = '$l[host]' AND I.id = A.interface_id AND D.id = I.host"),0);
|
$maybehost = @mysql_result(mysql_query("SELECT D.device_id as device_id FROM ipaddr AS A, interfaces AS I, devices AS D WHERE A.addr = '" . $l['host'] . "' AND I.interface_id = A.interface_id AND D.device_id = I.device_id"),0);
|
||||||
$perhapshost = @mysql_result(mysql_query("SELECT id FROM devices WHERE `hostname` = '$l[host]'"),0);
|
$perhapshost = @mysql_result(mysql_query("SELECT device_id FROM devices WHERE `hostname` = '$l[host]'"),0);
|
||||||
|
|
||||||
if($maybehost) {
|
if($maybehost) {
|
||||||
$host = $maybehost;
|
$host = $maybehost;
|
||||||
@@ -27,7 +27,7 @@ while($l = mysql_fetch_array($q)){
|
|||||||
|
|
||||||
if($host) {
|
if($host) {
|
||||||
|
|
||||||
if(mysql_result(mysql_query("SELECT os FROM `devices` WHERE `id` = '$host'"),0) == "IOS") {
|
if(mysql_result(mysql_query("SELECT os FROM `devices` WHERE `device_id` = '$host'"),0) == "IOS") {
|
||||||
list(,$l[msg]) = split(": %", $l[msg]);
|
list(,$l[msg]) = split(": %", $l[msg]);
|
||||||
$l[msg] = "%" . $l[msg];
|
$l[msg] = "%" . $l[msg];
|
||||||
$l[msg] = preg_replace("/^%(.+):\ /", "\\1||", $l[msg]);
|
$l[msg] = preg_replace("/^%(.+):\ /", "\\1||", $l[msg]);
|
||||||
|
Reference in New Issue
Block a user