mirror of
https://github.com/stylersnico/librenms.git
synced 2026-07-12 16:06:25 +02:00
Temperature monitoring system updates and additions
git-svn-id: http://www.observium.org/svn/observer/trunk@102 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
@@ -1,35 +0,0 @@
|
|||||||
#!/usr/bin/php
|
|
||||||
<?
|
|
||||||
include("config.php");
|
|
||||||
include("includes/functions.php");
|
|
||||||
|
|
||||||
$device_query = mysql_query("SELECT * FROM `devices` WHERE `os` = 'IOS' AND `status` = '1'");
|
|
||||||
while ($device = mysql_fetch_array($device_query)) {
|
|
||||||
$id = $device['device_id'];
|
|
||||||
$hostname = $device['hostname'];
|
|
||||||
$community = $device['community'];
|
|
||||||
echo("Detecting IOS temperature sensors for $hostname\n");
|
|
||||||
$oids = `snmpwalk -v2c -Osqn -c $community $hostname .1.3.6.1.4.1.9.9.13.1.3.1.2 | sed s/.1.3.6.1.4.1.9.9.13.1.3.1.2.//g`;
|
|
||||||
$oids = trim($oids);
|
|
||||||
foreach(explode("\n", $oids) as $data) {
|
|
||||||
$data = trim($data);
|
|
||||||
list($oid) = explode(" ", $data);
|
|
||||||
$temp_oid = ".1.3.6.1.4.1.9.9.13.1.3.1.3.$oid";
|
|
||||||
$descr_oid = ".1.3.6.1.4.1.9.9.13.1.3.1.2.$oid";
|
|
||||||
$descr = `snmpget -O qv -v2c -c $community $hostname $descr_oid`;
|
|
||||||
$temp = `snmpget -O qv -v2c -c $community $hostname $temp_oid`;
|
|
||||||
if(!strstr($descr, "No") && !strstr($temp, "No") && $descr != "" ) {
|
|
||||||
$descr = `snmpget -O qv -v2c -c $community $hostname $descr_oid`;
|
|
||||||
$descr = str_replace("\"", "", $descr);
|
|
||||||
$descr = str_replace("temperature", "", $descr);
|
|
||||||
$descr = str_replace("temp", "", $descr);
|
|
||||||
$descr = trim($descr);
|
|
||||||
if(mysql_result(mysql_query("SELECT count(temp_id) FROM `temperature` WHERE temp_oid = '.1.3.6.1.4.1.9.9.13.1.3.1.3.$oid' AND temp_host = '$id'"),0) == '0') {
|
|
||||||
$query = "INSERT INTO temperature (`temp_host`, `temp_oid`, `temp_descr`) values ('$id', '$temp_oid', '$descr')";
|
|
||||||
echo("$query -> $descr : $temp\n");
|
|
||||||
mysql_query($query);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
@@ -59,6 +59,38 @@ while ($device = mysql_fetch_array($device_query)) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$device_query = mysql_query("SELECT * FROM `devices` WHERE `os` = 'IOS' AND `status` = '1'");
|
||||||
|
while ($device = mysql_fetch_array($device_query)) {
|
||||||
|
$id = $device['device_id'];
|
||||||
|
$hostname = $device['hostname'];
|
||||||
|
$community = $device['community'];
|
||||||
|
echo("Detecting IOS temperature sensors for $hostname\n");
|
||||||
|
$oids = `snmpwalk -v2c -Osqn -c $community $hostname .1.3.6.1.4.1.9.9.13.1.3.1.2 | sed s/.1.3.6.1.4.1.9.9.13.1.3.1.2.//g`;
|
||||||
|
$oids = trim($oids);
|
||||||
|
foreach(explode("\n", $oids) as $data) {
|
||||||
|
$data = trim($data);
|
||||||
|
list($oid) = explode(" ", $data);
|
||||||
|
$temp_oid = ".1.3.6.1.4.1.9.9.13.1.3.1.3.$oid";
|
||||||
|
$descr_oid = ".1.3.6.1.4.1.9.9.13.1.3.1.2.$oid";
|
||||||
|
$descr = `snmpget -O qv -v2c -c $community $hostname $descr_oid`;
|
||||||
|
$temp = `snmpget -O qv -v2c -c $community $hostname $temp_oid`;
|
||||||
|
if(!strstr($descr, "No") && !strstr($temp, "No") && $descr != "" ) {
|
||||||
|
$descr = `snmpget -O qv -v2c -c $community $hostname $descr_oid`;
|
||||||
|
$descr = str_replace("\"", "", $descr);
|
||||||
|
$descr = str_replace("temperature", "", $descr);
|
||||||
|
$descr = str_replace("temp", "", $descr);
|
||||||
|
$descr = trim($descr);
|
||||||
|
if(mysql_result(mysql_query("SELECT count(temp_id) FROM `temperature` WHERE temp_oid = '.1.3.6.1.4.1.9.9.13.1.3.1.3.$oid' AND temp_host = '$id'"),0) == '0') {
|
||||||
|
$query = "INSERT INTO temperature (`temp_host`, `temp_oid`, `temp_descr`) values ('$id', '$temp_oid', '$descr')";
|
||||||
|
echo("$query -> $descr : $temp\n");
|
||||||
|
mysql_query($query);
|
||||||
|
}
|
||||||
|
$temp_exists[] = "$id $temp_oid";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$sql = "SELECT * FROM temperature";
|
$sql = "SELECT * FROM temperature";
|
||||||
$query = mysql_query($sql);
|
$query = mysql_query($sql);
|
||||||
|
|
||||||
|
|||||||
+22
-13
@@ -6,8 +6,7 @@ if(!$_GET['section']) {
|
|||||||
$_GET['section'] = "dev-overview";
|
$_GET['section'] = "dev-overview";
|
||||||
}
|
}
|
||||||
$section = $_GET['section'];
|
$section = $_GET['section'];
|
||||||
$sectionx = str_replace("-", "", $section);
|
$select[$section] = "selected";
|
||||||
$select[$sectionx] = "selected";
|
|
||||||
|
|
||||||
|
|
||||||
$device_query = mysql_query("SELECT * FROM `devices` WHERE `device_id` = '" . $_GET['id'] . "'");
|
$device_query = mysql_query("SELECT * FROM `devices` WHERE `device_id` = '" . $_GET['id'] . "'");
|
||||||
@@ -20,7 +19,7 @@ echo("<div class=mainpane>");
|
|||||||
|
|
||||||
echo("
|
echo("
|
||||||
<ul id='maintab' class='shadetabs'>
|
<ul id='maintab' class='shadetabs'>
|
||||||
<li class=$select[devoverview]>
|
<li class=" . $select['dev-overview'] . ">
|
||||||
<a href='?page=device&id=" . $device['device_id'] . "§ion=dev-overview' >
|
<a href='?page=device&id=" . $device['device_id'] . "§ion=dev-overview' >
|
||||||
<img src='images/16/server_lightning.png' align=absmiddle border=0> Overview
|
<img src='images/16/server_lightning.png' align=absmiddle border=0> Overview
|
||||||
</a>
|
</a>
|
||||||
@@ -28,7 +27,7 @@ echo("
|
|||||||
|
|
||||||
if(@mysql_result(mysql_query("select count(vlan_id) from vlans WHERE device_id = '" . $device['device_id'] . "'"), 0) > '0') {
|
if(@mysql_result(mysql_query("select count(vlan_id) from vlans WHERE device_id = '" . $device['device_id'] . "'"), 0) > '0') {
|
||||||
echo("
|
echo("
|
||||||
<li class=$select[devvlans]>
|
<li class=" . $select['dev-vlans'] . ">
|
||||||
<a href='?page=device&id=" . $device['device_id'] . "§ion=dev-vlans' >
|
<a href='?page=device&id=" . $device['device_id'] . "§ion=dev-vlans' >
|
||||||
<img src='images/16/vlans.png' align=absmiddle border=0> VLANs
|
<img src='images/16/vlans.png' align=absmiddle border=0> VLANs
|
||||||
</a>
|
</a>
|
||||||
@@ -37,44 +36,54 @@ if(@mysql_result(mysql_query("select count(vlan_id) from vlans WHERE device_id =
|
|||||||
|
|
||||||
if(@mysql_result(mysql_query("select count(interface_id) from interfaces WHERE device_id = '" . $device['device_id'] . "'"), 0) > '0') {
|
if(@mysql_result(mysql_query("select count(interface_id) from interfaces WHERE device_id = '" . $device['device_id'] . "'"), 0) > '0') {
|
||||||
echo("
|
echo("
|
||||||
<li class=$select[devifs]>
|
<li class=" . $select['dev-ifs'] . ">
|
||||||
<a href='?page=device&id=" . $device['device_id'] . "§ion=dev-ifs' >
|
<a href='?page=device&id=" . $device['device_id'] . "§ion=dev-ifs' >
|
||||||
<img src='images/16/server_link.png' align=absmiddle border=0> Port Details
|
<img src='images/16/server_link.png' align=absmiddle border=0> Port Details
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li class=$select[devifgraphs]>
|
<li class=" . $select['dev-ifgraphs'] . ">
|
||||||
<a href='?page=device&id=" . $device['device_id'] . "§ion=dev-ifgraphs'>
|
<a href='?page=device&id=" . $device['device_id'] . "§ion=dev-ifgraphs'>
|
||||||
<img src='images/16/chart_curve_link.png' align=absmiddle border=0> Port Graphs
|
<img src='images/16/chart_curve_link.png' align=absmiddle border=0> Port Graphs
|
||||||
</a>
|
</a>
|
||||||
</li>");
|
</li>");
|
||||||
}
|
}
|
||||||
|
|
||||||
echo("<li class=$select[devgraphs]>
|
echo("<li class=" . $select['dev-graphs'] . ">
|
||||||
<a href='?page=device&id=" . $device['device_id'] . "§ion=dev-graphs'>
|
<a href='?page=device&id=" . $device['device_id'] . "§ion=dev-graphs'>
|
||||||
<img src='images/16/server_chart.png' align=absmiddle border=0> Host Graphs
|
<img src='images/16/server_chart.png' align=absmiddle border=0> Host Graphs
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
");
|
");
|
||||||
|
|
||||||
|
if(mysql_result(mysql_query("select count(temp_id) from temperature WHERE temp_host = '" . $device['device_id'] . "'"), 0) > '0') {
|
||||||
|
echo("
|
||||||
|
<li class=" . $select['dev-temp'] . ">
|
||||||
|
<a href='?page=device&id=" . $device['device_id'] . "§ion=dev-temp'>
|
||||||
|
<img src='images/16/weather_sun.png' align=absmiddle border=0> Temps
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
");
|
||||||
|
}
|
||||||
|
|
||||||
if(mysql_result(mysql_query("select count(service_id) from services WHERE service_host = '" . $device['device_id'] . "'"), 0) > '0') {
|
if(mysql_result(mysql_query("select count(service_id) from services WHERE service_host = '" . $device['device_id'] . "'"), 0) > '0') {
|
||||||
echo("
|
echo("
|
||||||
<li class=$select[devsrv]>
|
<li class=" . $select['dev-srv'] . ">
|
||||||
<a href='?page=device&id=" . $device['device_id'] . "§ion=dev-srv'>
|
<a href='?page=device&id=" . $device['device_id'] . "§ion=dev-srv'>
|
||||||
<img src='images/16/server_cog.png' align=absmiddle border=0> Service Details
|
<img src='images/16/server_cog.png' align=absmiddle border=0> Services
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
");
|
");
|
||||||
}
|
}
|
||||||
|
|
||||||
echo("
|
echo("
|
||||||
<li class=$select[devevents]>
|
<li class=" . $select['dev-events'] . ">
|
||||||
<a href='?page=device&id=" . $device['device_id'] . "§ion=dev-events'>
|
<a href='?page=device&id=" . $device['device_id'] . "§ion=dev-events'>
|
||||||
<img src='images/16/report_magnify.png' align=absmiddle border=0> Eventlog
|
<img src='images/16/report_magnify.png' align=absmiddle border=0> Eventlog
|
||||||
</a>
|
</a>
|
||||||
</li>");
|
</li>");
|
||||||
|
|
||||||
echo("
|
echo("
|
||||||
<li class=$select[devsyslog]>
|
<li class=" . $select['dev-syslog'] . ">
|
||||||
<a href='?page=device&id=" . $device['device_id'] . "§ion=dev-syslog'>
|
<a href='?page=device&id=" . $device['device_id'] . "§ion=dev-syslog'>
|
||||||
<img src='images/16/printer.png' align=absmiddle border=0> Syslog
|
<img src='images/16/printer.png' align=absmiddle border=0> Syslog
|
||||||
</a>
|
</a>
|
||||||
@@ -83,9 +92,9 @@ echo("
|
|||||||
|
|
||||||
if($_SESSION[userlevel] > "5") {
|
if($_SESSION[userlevel] > "5") {
|
||||||
echo("
|
echo("
|
||||||
<li class=$select[devedit]>
|
<li class=" . $select['dev-edit'] . ">
|
||||||
<a href='?page=device&id=" . $device['device_id'] . "§ion=dev-edit'>
|
<a href='?page=device&id=" . $device['device_id'] . "§ion=dev-edit'>
|
||||||
<img src='images/16/server_edit.png' align=absmiddle border=0> Edit Device
|
<img src='images/16/server_edit.png' align=absmiddle border=0> Settings
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
");
|
");
|
||||||
|
|||||||
@@ -28,7 +28,8 @@ function temp_graph ($temp, $graph, $from, $to, $width, $height, $title, $vertic
|
|||||||
|
|
||||||
|
|
||||||
$optsa[] = "DEF:temp" . $temperature[temp_id] . "=$temprrd:temp:AVERAGE";
|
$optsa[] = "DEF:temp" . $temperature[temp_id] . "=$temprrd:temp:AVERAGE";
|
||||||
$optsa[] = "LINE1:temp" . $temperature[temp_id] . "#" . $colour . ":" . $temperature[temp_descr_fixed];
|
$optsa[] = "AREA:temp" . $temperature[temp_id] . "#ffcccc:" . $temperature[temp_descr_fixed];
|
||||||
|
$optsa[] = "LINE1.5:temp" . $temperature[temp_id] . "#" . $colour . ":" . $temperature[temp_descr_fixed];
|
||||||
$optsa[] = "GPRINT:temp" . $temperature[temp_id] . ":LAST:%3.0lf°C";
|
$optsa[] = "GPRINT:temp" . $temperature[temp_id] . ":LAST:%3.0lf°C";
|
||||||
$optsa[] = "GPRINT:temp" . $temperature[temp_id] . ":MAX:%3.0lf°C\l";
|
$optsa[] = "GPRINT:temp" . $temperature[temp_id] . ":MAX:%3.0lf°C\l";
|
||||||
$iter++;
|
$iter++;
|
||||||
|
|||||||
Reference in New Issue
Block a user