mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
device_processor_stacked type for unix devices (where all CPUs share the same domain, not useful on network hardware where different CPUs do different jobs) Also we need inherit properties to $config['os'] from $config['os_group'], where they are not already set in $config['os']. Also updog.
git-svn-id: http://www.observium.org/svn/observer/trunk@2138 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
<?php
|
||||
|
||||
$device = device_by_id_cache($id);
|
||||
$query = mysql_query("SELECT * FROM `processors` where `device_id` = '".$id."'");
|
||||
#$device = device_by_id_cache($id);
|
||||
#$query = mysql_query("SELECT * FROM `processors` where `device_id` = '".$id."'");
|
||||
|
||||
|
||||
|
||||
$i = 0;
|
||||
|
38
html/includes/graphs/device/processor_stack.inc.php
Normal file
38
html/includes/graphs/device/processor_stack.inc.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
#$device = device_by_id_cache($id);
|
||||
#$query = mysql_query("SELECT * FROM `processors` where `device_id` = '".$id."'");
|
||||
|
||||
$i = 0;
|
||||
|
||||
while ($proc = mysql_fetch_assoc($query))
|
||||
{
|
||||
$rrd_filename = $config['rrd_dir'] . "/".$device['hostname']."/" . safename("processor-" . $proc['processor_type'] . "-" . $proc['processor_index'] . ".rrd");
|
||||
|
||||
if (is_file($rrd_filename))
|
||||
{
|
||||
$descr = short_hrDeviceDescr($proc['processor_descr']);
|
||||
|
||||
$rrd_list[$i]['filename'] = $rrd_filename;
|
||||
$rrd_list[$i]['descr'] = $descr;
|
||||
$rrd_list[$i]['rra'] = "usage";
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
$unit_text = "Load %";
|
||||
|
||||
$units = '%';
|
||||
$total_units = '%';
|
||||
$colours ='oranges';
|
||||
|
||||
$scale_min = "0";
|
||||
$scale_max = "100";
|
||||
|
||||
$divider = $i;
|
||||
$text_orig = 1;
|
||||
$nototal = 1;
|
||||
|
||||
include("includes/graphs/generic_multi_simplex_seperated.inc.php");
|
||||
|
||||
?>
|
@@ -2,40 +2,67 @@
|
||||
|
||||
include("includes/graphs/common.inc.php");
|
||||
|
||||
$unit_text = str_pad(truncate($unit_text,10),10);
|
||||
|
||||
$descrlen = "18";
|
||||
$unitlen = "10";
|
||||
if($nototal) { $descrlen += "2"; $unitlen += "2";}
|
||||
$unit_text = str_pad(truncate($unit_text,$unitlen),$unitlen);
|
||||
|
||||
$rrd_options .= " COMMENT:'$unit_text Cur Max'";
|
||||
if (!$nototal) { $rrd_options .= " COMMENT:'Total '"; }
|
||||
$rrd_options .= " COMMENT:'\\n'";
|
||||
|
||||
$iter=0;
|
||||
foreach ($rrd_list as $rrd)
|
||||
$colour_iter=0;
|
||||
foreach ($rrd_list as $i => $rrd)
|
||||
{
|
||||
if (!$config['graph_colours'][$colours][$iter]) { $iter = 0; }
|
||||
$colour = $config['graph_colours'][$colours][$iter];
|
||||
if (!$config['graph_colours'][$colours][$colour_iter]) { $colour_iter = 0; }
|
||||
$colour = $config['graph_colours'][$colours][$colour_iter];
|
||||
$colour_iter++;
|
||||
|
||||
$rrd_options .= " DEF:".$rrd['rra'].$i."=".$rrd['filename'].":".$rrd['rra'].":AVERAGE ";
|
||||
$rrd_options .= " DEF:".$rrd['rra'].$i."max=".$rrd['filename'].":".$rrd['rra'].":MAX ";
|
||||
|
||||
## Suppress totalling?
|
||||
if (!$nototal)
|
||||
{
|
||||
$rrd_options .= " VDEF:tot".$rrd['rra'].$i."=".$rrd['rra'].$i.",TOTAL";
|
||||
}
|
||||
|
||||
## This this not the first entry?
|
||||
if ($i) { $stack="STACK"; }
|
||||
|
||||
# if we've been passed a multiplier we must make a CDEF based on it!
|
||||
$defname = $rrd['rra'];
|
||||
$g_defname = $rrd['rra'];
|
||||
if (is_numeric($multiplier))
|
||||
{
|
||||
$defname = $defname . "_cdef";
|
||||
$rrd_options .= " CDEF:" . $defname . $i . "=" . $rrd['rra'] . $i . "," . $multiplier . ",*";
|
||||
}
|
||||
$rrd_options .= " AREA:" . $defname . $i . "#" . $colour . ":'" . substr(str_pad($rrd['descr'], 18),0,18) . "':$stack";
|
||||
$rrd_options .= " GPRINT:".$rrd['rra'].$i.":LAST:%6.2lf%s$units";
|
||||
$rrd_options .= " GPRINT:".$rrd['rra'].$i."max:MAX:%6.2lf%s$units";
|
||||
$g_defname = $rrd['rra'] . "_cdef";
|
||||
$rrd_options .= " CDEF:" . $g_defname . $i . "=" . $rrd['rra'] . $i . "," . $multiplier . ",*";
|
||||
$rrd_options .= " CDEF:" . $g_defname . $i . "max=" . $rrd['rra'] . $i . "max," . $multiplier . ",*";
|
||||
|
||||
if (!$nototal) { $rrd_options .= " GPRINT:tot".$rrd['rra'].$i.":%6.2lf%s$total_units"; }
|
||||
## If we've been passed a divider (divisor!) we make a CDEF for it.
|
||||
} elseif (is_numeric($divider))
|
||||
{
|
||||
$g_defname = $rrd['rra'] . "_cdef";
|
||||
$rrd_options .= " CDEF:" . $g_defname . $i . "=" . $rrd['rra'] . $i . "," . $divider . ",/";
|
||||
$rrd_options .= " CDEF:" . $g_defname . $i . "max=" . $rrd['rra'] . $i . "max," . $divider . ",/";
|
||||
}
|
||||
|
||||
## Are our text values related to te multiplier/divisor or not?
|
||||
if(isset($text_orig) && $text_orig)
|
||||
{
|
||||
$t_defname = $rrd['rra'];
|
||||
} else {
|
||||
$t_defname = $g_defname;
|
||||
}
|
||||
|
||||
|
||||
$rrd_options .= " AREA:".$g_defname.$i."#".$colour.":'".substr(str_pad($rrd['descr'], $descrlen),0,$descrlen)."':$stack";
|
||||
$rrd_options .= " GPRINT:".$t_defname.$i.":LAST:%6.2lf%s".str_replace("%", "%%", $units)."";
|
||||
$rrd_options .= " GPRINT:".$t_defname.$i."max:MAX:%6.2lf%s".str_replace("%", "%%", $units)."";
|
||||
|
||||
if (!$nototal) { $rrd_options .= " GPRINT:tot".$rrd['rra'].$i.":%6.2lf%s".str_replace("%", "%%", $total_units).""; }
|
||||
|
||||
$rrd_options .= " COMMENT:'\\n'";
|
||||
$i++; $iter++;
|
||||
}
|
||||
|
||||
?>
|
||||
|
@@ -10,12 +10,6 @@ preg_match('/^(?P<type>[A-Za-z0-9]+)_(?P<subtype>.+)/', mres($graph_type), $grap
|
||||
$type = $graphtype['type'];
|
||||
$subtype = $graphtype['subtype'];
|
||||
|
||||
if (isset($config['graph'][$type][$subtype])) { $descr = $config['graph'][$type][$subtype]; } else { $descr = $graph_type; }
|
||||
|
||||
#$descr = mysql_result(mysql_query("SELECT `graph_descr` FROM `graph_types` WHERE `graph_type` = '".$type."' AND `graph_subtype` = '".$subtype."'"),0);
|
||||
|
||||
$descr = $config['graph_types'][$type][$subtype]['descr'];
|
||||
|
||||
if (is_file("includes/graphs/".$type."/auth.inc.php"))
|
||||
{
|
||||
include("includes/graphs/".$type."/auth.inc.php");
|
||||
@@ -27,7 +21,11 @@ if (!$auth)
|
||||
} else {
|
||||
|
||||
# Do we really need to show the type? User does not have to see the type of graph (i.e. sensor_temperature)
|
||||
# if (isset($config['graph'][$type][$subtype])) { $title .= " :: ".$config['graph'][$type][$subtype]; } else { $title .= " :: ".$graph_type; }
|
||||
|
||||
# Yes, i think we doo, else we have graph titles of "router1". It's nice to show the type here. maybe only the pretty
|
||||
# array_type?
|
||||
|
||||
if (isset($config['graph_types'][$type][$subtype]['descr'])) { $title .= " :: ".$config['graph_types'][$type][$subtype]['descr']; } else { $title .= " :: ".$graph_type; }
|
||||
|
||||
$graph_array['height'] = "60";
|
||||
$graph_array['width'] = "150";
|
||||
|
@@ -109,6 +109,7 @@ $warn_colour_b = "#ffcccc";
|
||||
#$config['graph_colours']['blues'] = array("b5d7ff","6eb7ff","0064ff","0082ff","0019d5","0016cb","00007d"); ## Cold Blues
|
||||
|
||||
$config['graph_colours']['mixed'] = array('CC0000','008C00','4096EE','73880A','D01F3C','36393D','FF0084');
|
||||
$config['graph_colours']['oranges'] = array('E43C00','E74B00','EB5B00','EF6A00','F37900','F78800','FB9700','FFA700');
|
||||
$config['graph_colours']['greens'] = array('B6D14B','91B13C','6D912D','48721E','24520F','003300');
|
||||
$config['graph_colours']['pinks'] = array('D0558F','B34773','943A57','792C38','5C1F1E','401F10');
|
||||
$config['graph_colours']['blues'] = array('A0A0E5','8080BD','606096','40406F','202048','000033');
|
||||
|
@@ -18,6 +18,11 @@ $config['os']['default']['over'][0]['text'] = "Processor Usage";
|
||||
$config['os']['default']['over'][1]['graph'] = "device_mempool";
|
||||
$config['os']['default']['over'][1]['text'] = "Memory Usage";
|
||||
|
||||
$os_group = "unix";
|
||||
$config['os_group'][$os_group]['type'] = "server";
|
||||
$config['os_group'][$os_group]['processor_stacked'] = 1;
|
||||
|
||||
|
||||
$os = "generic";
|
||||
$config['os'][$os]['text'] = "Generic Device";
|
||||
|
||||
@@ -697,6 +702,20 @@ $config['os'][$os]['over'][0]['graph'] = "device_current";
|
||||
$config['os'][$os]['over'][0]['text'] = "Current";
|
||||
$config['os'][$os]['icon'] = "tripplite";
|
||||
|
||||
foreach($config['os'] as $this_os => $blah)
|
||||
{
|
||||
$this_os_group = $config['os'][$this_os]['group'];
|
||||
if(isset($config['os'][$this_os]['group']) && isset($config['os_group'][$this_os_group]))
|
||||
{
|
||||
foreach ($config['os_group'][$this_os_group] as $property => $value)
|
||||
{
|
||||
if(!isset($config['os'][$this_os][$property]))
|
||||
{
|
||||
$config['os'][$this_os][$property] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$device_types = array('server', 'network', 'firewall', 'workstation', 'printer', 'power', 'environment');
|
||||
|
||||
|
Reference in New Issue
Block a user