mirror of
https://github.com/stylersnico/librenms.git
synced 2026-07-12 16:06:25 +02:00
cleanups, extend ports.port_descr_type length to 255, maybe break billing, remove and add some FIXMEs, poll toner with snmp_get
git-svn-id: http://www.observium.org/svn/observer/trunk@1985 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
@@ -182,4 +182,15 @@ function safename($name)
|
||||
return preg_replace('/[^a-zA-Z0-9,._\-]/', '_', $name);
|
||||
}
|
||||
|
||||
function zeropad($num, $length = 2)
|
||||
{
|
||||
while (strlen($num) < $length)
|
||||
{
|
||||
$num = '0'.$num;
|
||||
}
|
||||
|
||||
return $num;
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
@@ -9,7 +9,8 @@ if ($config['enable_printers'])
|
||||
if ($device['os_group'] == 'printer')
|
||||
{
|
||||
$oids = trim(snmp_walk($device, "SNMPv2-SMI::mib-2.43.12.1.1.2.1 ", "-OsqnU"));
|
||||
if (!$oids) {
|
||||
if (!$oids)
|
||||
{
|
||||
$oids = trim(snmp_walk($device, "SNMPv2-SMI::mib-2.43.11.1.1.2.1 ", "-OsqnU"));
|
||||
}
|
||||
if ($debug) { echo($oids."\n"); }
|
||||
@@ -52,7 +53,8 @@ if ($config['enable_printers'])
|
||||
{
|
||||
$toner_index = $test_toner['toner_index'];
|
||||
$toner_type = $test_toner['toner_type'];
|
||||
if (!$valid_toner[$toner_type][$toner_index]) {
|
||||
if (!$valid_toner[$toner_type][$toner_index])
|
||||
{
|
||||
echo("-");
|
||||
mysql_query("DELETE FROM `toner` WHERE toner_id = '" . $test_toner['toner_id'] . "'");
|
||||
}
|
||||
@@ -60,6 +62,6 @@ if ($config['enable_printers'])
|
||||
}
|
||||
|
||||
unset($valid_toner); echo("\n");
|
||||
|
||||
} # if ($config['enable_printers'])
|
||||
?>
|
||||
|
||||
?>
|
||||
+1
-17
@@ -28,16 +28,6 @@ function mac_clean_to_readable($mac)
|
||||
return($r);
|
||||
}
|
||||
|
||||
function zeropad($num, $length = 2)
|
||||
{
|
||||
while (strlen($num) < $length)
|
||||
{
|
||||
$num = '0'.$num;
|
||||
}
|
||||
|
||||
return $num;
|
||||
}
|
||||
|
||||
function only_alphanumeric($string)
|
||||
{
|
||||
return preg_replace('/[^a-zA-Z0-9]/', '', $string);
|
||||
@@ -197,12 +187,6 @@ function interface_errors($rrd_file, $period = '-1d') // Returns the last in/out
|
||||
return $errors;
|
||||
}
|
||||
|
||||
# FIXME: below function is unused, only commented out in html/pages/device/overview/ports.inc.php - do we still need it?
|
||||
function device_traffic_image($device, $width, $height, $from, $to)
|
||||
{
|
||||
return "<img src='graph.php?device=" . $device . "&type=device_bits&from=" . $from . "&to=" . $to . "&width=" . $width . "&height=" . $height . "&legend=no' />";
|
||||
}
|
||||
|
||||
function getImage($host)
|
||||
{
|
||||
global $config;
|
||||
@@ -679,7 +663,7 @@ function log_event($text, $device = NULL, $type = NULL, $reference = NULL)
|
||||
{
|
||||
global $debug;
|
||||
|
||||
if (!is_array($device)) { $device = device_by_id_cache($device); }
|
||||
if (!is_array($device)) { $device = device_by_id_cache($device); }
|
||||
|
||||
$event_query = "INSERT INTO eventlog (host, reference, type, datetime, message) VALUES (" . ($device['device_id'] ? $device['device_id'] : "NULL");
|
||||
$event_query .= ", '" . ($reference ? $reference : "NULL") . "', '" . ($type ? $type : "NULL") . "', NOW(), '" . mres($text) . "')";
|
||||
|
||||
@@ -9,10 +9,7 @@ if ($config['enable_printers'])
|
||||
{
|
||||
echo("Checking toner " . $toner['toner_descr'] . "... ");
|
||||
|
||||
# FIXME needs snmp_get
|
||||
$toner_cmd = $config['snmpget'] . " -M ".$config['mibdir'] . " -O Uqnv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " " . $toner['toner_oid'] . "|grep -v \"No Such Instance\"";
|
||||
$tonerperc = trim(str_replace("\"", "", shell_exec($toner_cmd)));
|
||||
$tonerperc = $tonerperc / $toner['toner_capacity'] * 100;
|
||||
$tonerperc = snmp_get($device, $toner['toner_oid'], "-OUqnv") / $toner['toner_capacity'] * 100;
|
||||
|
||||
$tonerrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("toner-" . $toner['toner_descr'] . ".rrd");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user