mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
additions to unix-agent. addition of basic munin-plugin support.
git-svn-id: http://www.observium.org/svn/observer/trunk@3088 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
23
html/includes/graphs/munin/auth.inc.php
Executable file
23
html/includes/graphs/munin/auth.inc.php
Executable file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
if (is_numeric($id))
|
||||
{
|
||||
$mplug = dbFetchRow("SELECT * FROM `munin_plugins` WHERE `mplug_id` = ?", array($id));
|
||||
|
||||
if (is_numeric($mplug['device_id']) && ($config['allow_unauth_graphs'] || device_permitted($mplug['device_id'])))
|
||||
{
|
||||
$device = device_by_id_cache($mplug['device_id']);
|
||||
$title = generate_device_link($device);
|
||||
# if(!empty($mplug['mplug_instance']))
|
||||
# {
|
||||
# $plugfile = $config['rrd_dir']."/".$device['hostname']."/munin/".$mplug['mplug_type']."_".$mplug['mplug_instance'];
|
||||
# $title .= " :: Plugin :: " . $mplug['mplug_type'] . " :: " . $mplug['mplug_title'];
|
||||
# } else {
|
||||
$plugfile = $config['rrd_dir']."/".$device['hostname']."/munin/".$mplug['mplug_type'];
|
||||
$title .= " :: Plugin :: " . $mplug['mplug_type'] . " - " . $mplug['mplug_title'];
|
||||
# }
|
||||
$auth = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
65
html/includes/graphs/munin/graph.inc.php
Normal file
65
html/includes/graphs/munin/graph.inc.php
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
// Attempt to draw a graph out of DSes we've collected from Munin plugins.
|
||||
// Reverse engineering ftw!
|
||||
|
||||
$scale_min = 0;
|
||||
|
||||
include("includes/graphs/common.inc.php");
|
||||
|
||||
if($width > "500")
|
||||
{
|
||||
$descr_len=24;
|
||||
} else {
|
||||
$descr_len=14;
|
||||
$descr_len += round(($width - 230) / 8.2);
|
||||
}
|
||||
|
||||
if($width > "500")
|
||||
{
|
||||
$rrd_options .= " COMMENT:'".substr(str_pad($mplug['mplug_vlabel'], $descr_len),0,$descr_len)." Current Average Maximum\l'";
|
||||
$rrd_options .= " COMMENT:'\l'";
|
||||
} else {
|
||||
$rrd_options .= " COMMENT:'".substr(str_pad($mplug['mplug_vlabel'], $descr_len),0,$descr_len)." Current Average Maximum\l'";
|
||||
}
|
||||
|
||||
|
||||
$c_i = 0;
|
||||
$dbq = dbFetchRows("SELECT * FROM `munin_plugins_ds` WHERE `mplug_id` = ?", array($mplug['mplug_id']));
|
||||
foreach ($dbq as $ds)
|
||||
{
|
||||
$ds_filename = $plugfile."_".$ds['ds_name'].".rrd";
|
||||
$ds_name = $ds['ds_name'];
|
||||
|
||||
$cmd_def .= " DEF:".$ds['ds_name']."=".$ds_filename.":val:AVERAGE";
|
||||
|
||||
if(!empty($ds['ds_cdef']))
|
||||
{
|
||||
$cmd_cdef .= "";
|
||||
$ds_name = $ds['ds_name']."_cdef";
|
||||
}
|
||||
|
||||
if($ds['ds_graph'] == "yes")
|
||||
{
|
||||
if(empty($ds['colour']))
|
||||
{
|
||||
if (!$config['graph_colours']['mixed'][$c_i]) { $c_i = 0; }
|
||||
$colour=$config['graph_colours']['mixed'][$c_i]; $c_i++;
|
||||
} else {
|
||||
$colour = $ds['colour'];
|
||||
}
|
||||
|
||||
$descr = str_replace(":", "\:", substr(str_pad($ds['ds_label'], $descr_len),0,$descr_len));
|
||||
|
||||
$cmd_graph .= ' '.$ds['ds_draw'].':'.$ds_name.'#'.$colour.':"'.$descr.'"';
|
||||
$cmd_graph .= ' GPRINT:'.$ds_name.':LAST:"%6.2lf%s"';
|
||||
$cmd_graph .= ' GPRINT:'.$ds_name.':AVERAGE:"%6.2lf%s"';
|
||||
$cmd_graph .= ' GPRINT:'.$ds_name.':MAX:"%6.2lf%s\\n"';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$rrd_options .= $cmd_def . $cmd_cdef . $cmd_graph;
|
||||
|
||||
?>
|
Reference in New Issue
Block a user