mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
fix discovery to remove include_dir function. ignore -32768 values returned for sensors. build rrd graphs via pipe.
git-svn-id: http://www.observium.org/svn/observer/trunk@2493 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
@@ -1,5 +1,45 @@
|
||||
<?php
|
||||
|
||||
function rrdtool_graph($rrdfile, $options)
|
||||
{
|
||||
|
||||
global $config;
|
||||
|
||||
if ($config['rrdcached'])
|
||||
{
|
||||
$command = $config['rrdtool'] . " --daemon " . $config['rrdcached'] . " -";
|
||||
} else {
|
||||
$command = $config['rrdtool'] . " -";
|
||||
}
|
||||
|
||||
$descriptorspec = array(
|
||||
0 => array("pipe", "r"), // stdin is a pipe that the child will read from
|
||||
1 => array("pipe", "w"), // stdout is a pipe that the child will write to
|
||||
2 => array("file", "/tmp/error-output.txt", "a") // stderr is a file to write to
|
||||
);
|
||||
|
||||
$cwd = $config['rrd_dir'];
|
||||
$env = array();
|
||||
|
||||
$process = proc_open($command, $descriptorspec, $pipes, $cwd, $env);
|
||||
|
||||
if (is_resource($process)) {
|
||||
// $pipes now looks like this:
|
||||
// 0 => writeable handle connected to child stdin
|
||||
// 1 => readable handle connected to child stdout
|
||||
// Any error output will be appended to /tmp/error-output.txt
|
||||
|
||||
fwrite($pipes[0], "graph $rrdfile $options");
|
||||
fclose($pipes[0]);
|
||||
fclose($pipes[1]);
|
||||
|
||||
// It is important that you close any pipes before calling
|
||||
// proc_close in order to avoid a deadlock
|
||||
$return_value = proc_close($process);
|
||||
# echo "command returned $return_value\n";
|
||||
}
|
||||
}
|
||||
|
||||
function generate_link($text, $vars, $new_vars = array())
|
||||
{
|
||||
return '<a href="'.generate_url($vars, $new_vars).'">'.$text.'</a>';
|
||||
|
@@ -29,7 +29,7 @@ foreach (dbFetchRows("SELECT * FROM `ports` WHERE `device_id` = ?", array($id))
|
||||
}
|
||||
|
||||
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/port-" . safename($port['ifIndex'] . ".rrd");
|
||||
if (is_file($rrd_filename) && $ignore != 1)
|
||||
if ($ignore != 1 && is_file($rrd_filename))
|
||||
{
|
||||
$rrd_filenames[] = $rrd_filename;
|
||||
$rrd_list[$i]['filename'] = $rrd_filename;
|
||||
|
@@ -88,7 +88,8 @@ function graph_error($string)
|
||||
|
||||
#$rrd_options .= " HRULE:0#cc0000";
|
||||
#$rrd_cmd = $config['rrdtool'] . " graph $graphfile $rrd_options" . $rrd_switches;
|
||||
$rrd_cmd = $config['rrdtool'] . " graph $graphfile --title='".$string."' -l 0 -u 100 -E --start -10y --end now --width $width --height $height -c BACK#ff9999cc -c SHADEA#EEEEEE00 -c SHADEB#EEEEEE00 -c FONT#000000 -c CANVAS#FFFFFF00 -c GRID#a5a5a5 -c MGRID#FF9999 -c FRAME#5e5e5e -c ARROW#5e5e5e -R normal --font LEGEND:8:DejaVuSansMono --font AXIS:7:DejaVuSansMono --font-render-mode normal HRULE:0#cc0000" . $rrd_switches;
|
||||
|
||||
echo(rrdtool_graph($graphfile, " --title='".$string."' -l 0 -u 100 -E --start -10y --end now --width $width --height $height -c BACK#ff9999cc -c SHADEA#EEEEEE00 -c SHADEB#EEEEEE00 -c FONT#000000 -c CANVAS#FFFFFF00 -c GRID#a5a5a5 -c MGRID#FF9999 -c FRAME#5e5e5e -c ARROW#5e5e5e -R normal --font LEGEND:8:DejaVuSansMono --font AXIS:7:DejaVuSansMono --font-render-mode normal HRULE:0#cc0000"));
|
||||
|
||||
if ($height > "99") {
|
||||
#$rrd_cmd .= " --only-graph"; }
|
||||
@@ -140,8 +141,7 @@ if ($error_msg) {
|
||||
if ($rrd_options)
|
||||
{
|
||||
if ($config['rrdcached']) { $rrd_switches = " --daemon ".$config['rrdcached'] . " "; }
|
||||
$rrd_cmd = $config['rrdtool'] . " graph $graphfile $rrd_options" . $rrd_switches;
|
||||
$woo = shell_exec($rrd_cmd);
|
||||
rrdtool_graph($graphfile, " $rrd_options");
|
||||
if ($debug) { echo("<pre>".$rrd_cmd."</pre>"); }
|
||||
if (is_file($graphfile) && !$debug)
|
||||
{
|
||||
|
@@ -221,17 +221,21 @@ $config['ignore_mount_removable'] = 1; # Ignore removable disk storage
|
||||
$config['ignore_mount_network'] = 1; # Ignore network mounted storage
|
||||
$config['ignore_mount_optical'] = 1; # Ignore mounted optical discs
|
||||
|
||||
### Per-device interface graph filters
|
||||
|
||||
$config['device_traffic_iftype'][] = '/loopback/';
|
||||
$config['device_traffic_iftype'][] = '/tunnel/';
|
||||
$config['device_traffic_iftype'][] = '/virtual/';
|
||||
$config['device_traffic_iftype'][] = '/mpls/';
|
||||
$config['device_traffic_iftype'][] = '/ieee8023adLag/';
|
||||
$config['device_traffic_iftype'][] = '/l2vlan/';
|
||||
|
||||
$config['device_traffic_descr'][] = '/loopback/';
|
||||
$config['device_traffic_descr'][] = '/vlan/';
|
||||
$config['device_traffic_descr'][] = '/tunnel/';
|
||||
$config['device_traffic_descr'][] = '/:\d+/';
|
||||
$config['device_traffic_descr'][] = '/bond/';
|
||||
|
||||
### IRC Bot configuration
|
||||
|
||||
$config['irc_host'] = "chat.eu.freenode.net";
|
||||
|
@@ -1,7 +1,11 @@
|
||||
<?php
|
||||
echo("Current: ");
|
||||
|
||||
include_dir("includes/discovery/current");
|
||||
### Include all discovery modules
|
||||
|
||||
$include_dir = "includes/discovery/current";
|
||||
include("includes/include-dir.inc.php");
|
||||
|
||||
|
||||
if ($debug) { print_r($valid['sensor']['current']); }
|
||||
|
||||
|
@@ -1,7 +1,5 @@
|
||||
<?php
|
||||
|
||||
|
||||
|
||||
## APC
|
||||
if ($device['os'] == "apc")
|
||||
{
|
||||
|
@@ -1,7 +1,5 @@
|
||||
<?php
|
||||
|
||||
global $valid_sensor;
|
||||
|
||||
// blindly copied from sentry3
|
||||
|
||||
if ($device['os'] == 'raritan')
|
||||
|
@@ -1,7 +1,11 @@
|
||||
<?php
|
||||
|
||||
echo("Fanspeeds : ");
|
||||
include_dir("includes/discovery/fanspeeds");
|
||||
|
||||
### Include all discovery modules
|
||||
|
||||
$include_dir = "includes/discovery/fanspeeds";
|
||||
include("includes/include-dir.inc.php");
|
||||
|
||||
if ($debug) { print_r($valid['sensor']['fanspeed']); }
|
||||
|
||||
|
@@ -2,7 +2,10 @@
|
||||
|
||||
echo("Frequencies: ");
|
||||
|
||||
include_dir("includes/discovery/frequencies");
|
||||
### Include all discovery modules
|
||||
|
||||
$include_dir = "includes/discovery/frequencies";
|
||||
include("includes/include-dir.inc.php");
|
||||
|
||||
if ($debug) { print_r($valid['sensor']['frequency']); }
|
||||
|
||||
|
@@ -2,7 +2,10 @@
|
||||
|
||||
echo("Humidity : ");
|
||||
|
||||
include_dir("includes/discovery/humidity");
|
||||
### Include all discovery modules
|
||||
|
||||
$include_dir = "includes/discovery/humidity";
|
||||
include("includes/include-dir.inc.php");
|
||||
|
||||
if ($debug) { print_r($valid['sensor']['humidity']); }
|
||||
|
||||
|
@@ -2,9 +2,10 @@
|
||||
|
||||
echo("Memory : ");
|
||||
|
||||
global $valid_mempool; ## FIXME PLEASE!
|
||||
### Include all discovery modules
|
||||
|
||||
include_dir("includes/discovery/mempools");
|
||||
$include_dir = "includes/discovery/mempools";
|
||||
include("includes/include-dir.inc.php");
|
||||
|
||||
### Remove memory pools which weren't redetected here
|
||||
|
||||
|
@@ -1,7 +1,5 @@
|
||||
<?php
|
||||
|
||||
global $valid_mempool;
|
||||
|
||||
if ($device['os'] == "aos")
|
||||
{
|
||||
echo("Alcatel-Lucent OS: ");
|
||||
|
@@ -1,7 +1,5 @@
|
||||
<?php
|
||||
|
||||
global $valid_mempool;
|
||||
|
||||
if ($device['os'] == "ios" || $device['os_group'] == "ios")
|
||||
{
|
||||
echo("CISCO-ENHANCED-MEMORY-POOL: ");
|
||||
|
@@ -1,7 +1,5 @@
|
||||
<?php
|
||||
|
||||
global $valid_mempool;
|
||||
|
||||
## Ignore this discovery module if we have already discovered things in CISCO-ENHANCED-MEMPOOL-MIB. Dirty duplication.
|
||||
|
||||
$cemp_count = mysql_result(mysql_query("SELECT COUNT(*) FROM `mempools` WHERE `device_id` = '".$device['device_id']."' AND `mempool_type` = 'cemp'"),0);
|
||||
@@ -21,4 +19,4 @@ if (($device['os'] == "ios" || $device['os_group'] == "ios") && $cemp_count == "
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
@@ -1,7 +1,5 @@
|
||||
<?php
|
||||
|
||||
global $valid_mempool;
|
||||
|
||||
#NETSWITCH-MIB::hpLocalMemSlotIndex.1 = INTEGER: 1
|
||||
#NETSWITCH-MIB::hpLocalMemSlabCnt.1 = Counter32: 3966
|
||||
#NETSWITCH-MIB::hpLocalMemFreeSegCnt.1 = Counter32: 166
|
||||
@@ -41,4 +39,4 @@ if (is_array($array))
|
||||
unset($array);
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
@@ -1,7 +1,5 @@
|
||||
<?php
|
||||
|
||||
global $valid_mempool;
|
||||
|
||||
$storage_array = snmpwalk_cache_oid($device, "hrStorageEntry", NULL, "HOST-RESOURCES-MIB:HOST-RESOURCES-TYPES:NetWare-Host-Ext-MIB");
|
||||
|
||||
if (is_array($storage_array))
|
||||
|
@@ -1,7 +1,5 @@
|
||||
<?php
|
||||
|
||||
global $valid_mempool;
|
||||
|
||||
if ($device['os'] == "ironware" || $device['os_type'] == "ironware")
|
||||
{
|
||||
echo("Ironware Dynamic: ");
|
||||
@@ -13,4 +11,4 @@ if ($device['os'] == "ironware" || $device['os_type'] == "ironware")
|
||||
discover_mempool($valid_mempool, $device, 0, "ironware-dyn", "Dynamic Memory", "1", NULL, NULL);
|
||||
}
|
||||
}
|
||||
?>
|
||||
?>
|
||||
|
@@ -1,7 +1,5 @@
|
||||
<?php
|
||||
|
||||
global $valid_mempool;
|
||||
|
||||
## JUNOS mempools
|
||||
if ($device['os'] == "junos")
|
||||
{
|
||||
@@ -32,4 +30,4 @@ if ($device['os'] == "junos")
|
||||
|
||||
unset ($mempools_array);
|
||||
|
||||
?>
|
||||
?>
|
||||
|
@@ -1,7 +1,5 @@
|
||||
<?php
|
||||
|
||||
global $valid_mempool;
|
||||
|
||||
if ($device['os'] == "screenos")
|
||||
{
|
||||
echo("ScreenOS: ");
|
||||
|
@@ -2,7 +2,10 @@
|
||||
|
||||
echo("Power: ");
|
||||
|
||||
include_dir("includes/discovery/power");
|
||||
### Include all discovery modules
|
||||
|
||||
$include_dir = "includes/discovery/power";
|
||||
include("includes/include-dir.inc.php");
|
||||
|
||||
if ($debug) { print_r($valid['sensor']['power']); }
|
||||
|
||||
|
@@ -2,7 +2,10 @@
|
||||
|
||||
echo("Processors : ");
|
||||
|
||||
include_dir("includes/discovery/processors");
|
||||
### Include all discovery modules
|
||||
|
||||
$include_dir = "includes/discovery/processors";
|
||||
include("includes/include-dir.inc.php");
|
||||
|
||||
## Last-resort discovery here
|
||||
|
||||
|
@@ -2,10 +2,10 @@
|
||||
|
||||
echo("Storage : ");
|
||||
|
||||
global $valid_storage;
|
||||
|
||||
include_dir("includes/discovery/storage");
|
||||
### Include all discovery modules
|
||||
|
||||
$include_dir = "includes/discovery/storage";
|
||||
include("includes/include-dir.inc.php");
|
||||
|
||||
### Remove storage which weren't redetected here
|
||||
|
||||
|
@@ -2,8 +2,6 @@
|
||||
|
||||
$hrstorage_array = snmpwalk_cache_oid($device, "hrStorageEntry", NULL, "HOST-RESOURCES-MIB:HOST-RESOURCES-TYPES:NetWare-Host-Ext-MIB");
|
||||
|
||||
global $valid_storage;
|
||||
|
||||
if (is_array($hrstorage_array))
|
||||
{
|
||||
echo("hrStorage : ");
|
||||
|
@@ -2,7 +2,10 @@
|
||||
|
||||
echo("Temperatures: ");
|
||||
|
||||
include_dir("includes/discovery/temperatures");
|
||||
### Include all discovery modules
|
||||
|
||||
$include_dir = "includes/discovery/temperatures";
|
||||
include("includes/include-dir.inc.php");
|
||||
|
||||
if ($debug) { print_r($valid['sensor']['temperature']); }
|
||||
|
||||
|
@@ -2,7 +2,10 @@
|
||||
|
||||
echo("Voltages: ");
|
||||
|
||||
include_dir("includes/discovery/voltages");
|
||||
### Include all discovery modules
|
||||
|
||||
$include_dir = "includes/discovery/voltages";
|
||||
include("includes/include-dir.inc.php");
|
||||
|
||||
if ($debug) { print_r($valid['sensor']['voltage']); }
|
||||
|
||||
|
@@ -23,6 +23,8 @@ function poll_sensor($device, $class, $unit)
|
||||
$sensor_value = snmp_get($device, $sensor['sensor_oid'], "-OUqnv", "SNMPv2-MIB");
|
||||
}
|
||||
|
||||
if($sensor_value == -32768) { echo("Invalid (-32768) "); $sensor_value = 0; }
|
||||
|
||||
if ($sensor['sensor_divisor']) { $sensor_value = $sensor_value / $sensor['sensor_divisor']; }
|
||||
if ($sensor['sensor_multiplier']) { $sensor_value = $sensor_value * $sensor['sensor_multiplier']; }
|
||||
|
||||
|
@@ -766,6 +766,7 @@ $rewrite_ios_features = array(
|
||||
|
||||
$rewrite_shortif = array (
|
||||
'tengigabitethernet' => 'Te',
|
||||
'tengige' => 'Te',
|
||||
'gigabitethernet' => 'Gi',
|
||||
'fastethernet' => 'Fa',
|
||||
'ethernet' => 'Et',
|
||||
@@ -779,6 +780,7 @@ $rewrite_ios_features = array(
|
||||
'vlan' => 'Vlan',
|
||||
'tunnel' => 'Tunnel',
|
||||
'serviceinstance' => 'SI',
|
||||
'dwdm' => 'DWDM',
|
||||
);
|
||||
|
||||
$rewrite_iftype = array (
|
||||
@@ -841,7 +843,7 @@ function makeshortif($if)
|
||||
$if = fixifName ($if);
|
||||
$if = strtolower($if);
|
||||
$if = array_str_replace($rewrite_shortif, $if);
|
||||
|
||||
$if = ucfirst($if);
|
||||
return $if;
|
||||
}
|
||||
|
||||
|
@@ -21,10 +21,10 @@ function rrdtool_fetch($rrdfile, $rrdupdate)
|
||||
return rrdtool("fetch", $rrdfile, $rrdupdate);
|
||||
}
|
||||
|
||||
function rrdtool_graph($rrdfile, $rrdupdate)
|
||||
{
|
||||
return rrdtool("graph", $rrdfile, $rrdupdate);
|
||||
}
|
||||
#function rrdtool_graph($rrdfile, $rrdupdate)
|
||||
#{
|
||||
# return rrdtool("graph", $rrdfile, $rrdupdate);
|
||||
#}
|
||||
|
||||
function rrdtool_last($rrdfile, $rrdupdate)
|
||||
{
|
||||
@@ -51,4 +51,4 @@ function rrdtool($command, $file, $options)
|
||||
return shell_exec($command);
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
Reference in New Issue
Block a user