From c5bac776db1a86b62b2016af73b94580c214a535 Mon Sep 17 00:00:00 2001 From: Adam Amstrong Date: Tue, 3 May 2011 20:13:15 +0000 Subject: [PATCH] updates git-svn-id: http://www.observium.org/svn/observer/trunk@2230 61d68cd4-352d-0410-923a-c4978735b2b8 --- html/includes/graphs/device/toner.inc.php | 4 ++-- html/pages/device.inc.php | 4 +++- includes/common.php | 12 ++++++++++++ includes/polling/toner.inc.php | 10 ++++++++-- 4 files changed, 25 insertions(+), 5 deletions(-) diff --git a/html/includes/graphs/device/toner.inc.php b/html/includes/graphs/device/toner.inc.php index 34ba6e116..8e372c1e8 100644 --- a/html/includes/graphs/device/toner.inc.php +++ b/html/includes/graphs/device/toner.inc.php @@ -46,7 +46,7 @@ while ($toner = mysql_fetch_assoc($sql)) $hostname = gethostbyid($toner['device_id']); $descr = substr(str_pad($toner['toner_descr'], 16),0,16); - $rrd_filename = $config['rrd_dir'] . "/".$device['hostname']."/" . safename("toner-" . $toner['toner_descr'] . ".rrd"); + $rrd_filename = $config['rrd_dir'] . "/".$device['hostname']."/" . safename("toner-" . $toner['toner_index'] . ".rrd"); $toner_id = $toner['toner_id']; $rrd_options .= " DEF:toner$toner_id=$rrd_filename:toner:AVERAGE"; @@ -58,4 +58,4 @@ while ($toner = mysql_fetch_assoc($sql)) $iter++; } -?> \ No newline at end of file +?> diff --git a/html/pages/device.inc.php b/html/pages/device.inc.php index 49319036a..77ee12775 100644 --- a/html/pages/device.inc.php +++ b/html/pages/device.inc.php @@ -21,7 +21,9 @@ if (device_permitted($_GET['id']) || $check_device == $_GET['id']) $select[$section] = "selected"; - $device = device_by_id_cache($_GET['id']); + $device = device_by_id_cache($_GET['id']); + $attribs = get_dev_attribs($device['device_id']); + if ($config['os'][$device['os']]['group']) { $device['os_group'] = $config['os'][$device['os']]['group']; } echo(''); diff --git a/includes/common.php b/includes/common.php index 768921461..535ee2edb 100644 --- a/includes/common.php +++ b/includes/common.php @@ -249,6 +249,18 @@ function set_dev_attrib($device, $attrib_type, $attrib_value) return mysql_affected_rows(); } +function get_dev_attribs($device) +{ + $attribs = array(); + $sql = "SELECT attrib_type, attrib_value FROM devices_attribs WHERE `device_id` = '" . mres($device['device_id']) . "'"; + $data = mysql_query($sql); + while($entry = mysql_fetch_array($data)) + { + $attribs[$entry['attrib_type']] = $attribs['attrib_value']; + } + return $attribs; +} + function get_dev_attrib($device, $attrib_type) { $sql = "SELECT attrib_value FROM devices_attribs WHERE `device_id` = '" . mres($device['device_id']) . "' AND `attrib_type` = '$attrib_type'"; diff --git a/includes/polling/toner.inc.php b/includes/polling/toner.inc.php index 8d4926d6c..92010b227 100755 --- a/includes/polling/toner.inc.php +++ b/includes/polling/toner.inc.php @@ -13,7 +13,13 @@ if ($config['enable_printers']) $tonerperc = snmp_get($device, $toner['toner_oid'], "-OUqnv") / $toner['toner_capacity'] * 100; - $tonerrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("toner-" . $toner['toner_descr'] . ".rrd"); + $old_tonerrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("toner-" . $toner['toner_descr'] . ".rrd"); + $tonerrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("toner-" . $toner['toner_index'] . ".rrd"); + + if (!is_file($tonerrrd) && is_file($old_tonerrrd)) + { + rename($old_tonerrrd, $tonerrrd); + } if (!is_file($tonerrrd)) { @@ -41,4 +47,4 @@ if ($config['enable_printers']) } } -?> \ No newline at end of file +?>