} else { $rows = dbFetchRows("SELECT * FROM `printersupplies` where `device_id` = ?", array($device['device_id'])); } foreach ($rows as $supply) { // If colour was supplied by the device, pass it to the function, otherwise pass the description // and have the function try and figure it out from there. if ($supply['supply_colour'] != '') { $colour = toner_to_colour($supply['supply_colour'], $perc); } else { $colour = toner_to_colour($supply['supply_descr'], $perc); } // If no colour found by the toner to colour function, get one from the configured palette. if (!$colour['found']) { if (!$config['graph_colours'][$colours][$iter]) { $iter = 0; } $colour['left'] = $config['graph_colours'][$colours][$iter]; } $hostname = get_device_by_device_id($supply['device_id']); $descr = rrdtool_escape($supply['supply_descr'], 16); $rrd_filename = get_rrd_path($device, "toner-" . $supply['supply_index'] . ".rrd"); $supply_id = $supply['supply_id']; $rrd_options .= " DEF:level{$supply_id}={$rrd_filename}:level:AVERAGE"; $rrd_options .= " LINE2:level{$supply_id}#" . $colour['left'] . ":'" . $descr . "'"; $rrd_options .= " GPRINT:level{$supply_id}:LAST:'%5.0lf%%'"; $rrd_options .= " GPRINT:level{$supply_id}:MIN:'%5.0lf%%'"; $rrd_options .= " GPRINT:level{$supply_id}:MAX:%5.0lf%%\\l"; $iter++; $colour['left'] = NULL; } // EOF
<?php /** * Observium * * This file is part of Observium. * * @package observium * @subpackage graphs * @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2016 Observium Limited * */ include_once $config['html_dir'] . "/includes/graphs/common.inc.php"; $rrd_options .= " -l 0 -E "; $iter = "1"; $rrd_options .= " COMMENT:'Imaging Drum level Cur Min Max\\n'"; $drums = array('Cyan' => 'c', 'Magenta' => 'm', 'Yellow' => 'y', 'Black' => 'k'); foreach ($drums as $drum => $letter) { $descr = rrdtool_escape("{$drum} Drum", 16); $colour = toner_to_colour($descr); $hostname = get_device_by_device_id($device['device_id']); $rrd_filename = get_rrd_path($device, "drum-{$letter}.rrd"); $rrd_options .= " DEF:drum{$iter}={$rrd_filename}:drum:AVERAGE"; $rrd_options .= " LINE2:drum{$iter}#" . $colour['left'] . ":'" . $descr . "'"; $rrd_options .= " GPRINT:drum{$iter}:LAST:'%5.0lf%%'"; $rrd_options .= " GPRINT:drum{$iter}:MIN:'%5.0lf%%'"; $rrd_options .= " GPRINT:drum{$iter}:MAX:%5.0lf%%\\l"; $iter++; } // EOF
function unixfsgraph($id, $graph, $from, $to, $width, $height, $title, $vertical) { global $config, $installdir; $options = "--alt-autoscale-max -E --start {$from} --end {$to} --width {$width} --height {$height} -b 1024 -l 0"; if ($width <= "300") { $options .= " --font LEGEND:7:" . $config['mono_font'] . " --font AXIS:6:" . $config['mono_font'] . " --font-render-mode normal "; } $hostname = get_device_by_device_id($device); $iter = "1"; $sql = mysql_query("SELECT * FROM storage where storage_id = '{$id}'"); $options .= "COMMENT:\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ Size\\ \\ \\ \\ \\ \\ Used\\ \\ \\ \\ %age\\l"; while ($fs = mysql_fetch_array($sql)) { $hostname = get_device_by_device_id($fs['device_id']); if ($iter == "1") { $colour = "CC0000"; } elseif ($iter == "2") { $colour = "008C00"; } elseif ($iter == "3") { $colour = "4096EE"; } elseif ($iter == "4") { $colour = "73880A"; } elseif ($iter == "5") { $colour = "D01F3C"; } elseif ($iter == "6") { $colour = "36393D"; } elseif ($iter == "7") { $colour = "FF0084"; $iter = "0"; } $descr = str_pad($fs[storage_descr], 14); $descr = substr($descr, 0, 14); $text = str_replace("/", "_", $fs['storage_descr']); $rrd = $config['rrd_dir'] . "/{$hostname}/storage-{$text}.rrd"; $options .= " DEF:{$fs['storage_id']}={$rrd}:used:AVERAGE"; $options .= " DEF:{$fs['storage_id']}s={$rrd}:size:AVERAGE"; $options .= " DEF:{$fs['storage_id']}p={$rrd}:perc:AVERAGE"; $options .= " LINE1.25:{$fs['storage_id']}p#" . $colour . ":'{$descr}'"; $options .= " GPRINT:{$fs['storage_id']}s:LAST:%6.2lf%SB"; $options .= " GPRINT:{$fs['storage_id']}:LAST:%6.2lf%SB"; $options .= " GPRINT:{$fs['storage_id']}p:LAST:%5.2lf%%\\\\l"; $iter++; } shell_exec($config['rrdtool'] . " graph {$graph} {$options}"); return $graph; }
* Observium * * This file is part of Observium. * * @package observium * @subpackage graphs * @copyright (C) 2006-2014 Adam Armstrong * */ $scale_min = "0"; $scale_max = "100"; include $config['html_dir'] . "/includes/graphs/common.inc.php"; $rrd_options .= " -b 1024"; $iter = "1"; $rrd_options .= " COMMENT:' Size Free % Used\\n'"; $hostname = get_device_by_device_id($storage['device_id']); $colour = "CC0000"; $colour_area = "ffaaaa"; $descr = rrdtool_escape($storage['storage_descr'], 12); $percentage = round($storage['storage_perc'], 0); $background = get_percentage_colours($percentage); $rrd_options .= " DEF:used={$rrd_filename}:used:AVERAGE"; $rrd_options .= " DEF:free={$rrd_filename}:free:AVERAGE"; $rrd_options .= " CDEF:size=used,free,+"; $rrd_options .= " CDEF:perc=used,size,/,100,*"; $rrd_options .= " AREA:perc#" . $background['right'] . ":"; $rrd_options .= " LINE1.25:perc#" . $background['left'] . ":'{$descr}'"; $rrd_options .= " GPRINT:size:LAST:%6.2lf%sB"; $rrd_options .= " GPRINT:free:LAST:%6.2lf%sB"; $rrd_options .= " GPRINT:perc:LAST:%5.2lf%%\\\\n"; if ($_GET['trend']) {
case "3": $colour['left'] = "4096EE"; break; case "4": $colour['left'] = "73880A"; break; case "5": $colour['left'] = "D01F3C"; break; case "6": $colour['left'] = "36393D"; break; case "7": default: $colour['left'] = "FF0000"; unset($iter); break; } } $hostname = get_device_by_device_id($toner['device_id']); $descr = rrdtool_escape($toner['toner_descr'], 16); $rrd_filename = get_rrd_path($device, "toner-" . $toner['toner_index'] . ".rrd"); $toner_id = $toner['toner_id']; $rrd_options .= " DEF:toner{$toner_id}={$rrd_filename}:toner:AVERAGE"; $rrd_options .= " LINE2:toner{$toner_id}#" . $colour['left'] . ":'" . $descr . "'"; $rrd_options .= " GPRINT:toner{$toner_id}:LAST:'%5.0lf%%'"; $rrd_options .= " GPRINT:toner{$toner_id}:MIN:'%5.0lf%%'"; $rrd_options .= " GPRINT:toner{$toner_id}:MAX:%5.0lf%%\\\\l"; $iter++; } // EOF