mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
added a new application monitoring: nfs server stats
This commit is contained in:
87
html/includes/graphs/application/nfs-stats.inc.php
Normal file
87
html/includes/graphs/application/nfs-stats.inc.php
Normal file
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
require 'includes/graphs/common.inc.php';
|
||||
$scale_min = 0;
|
||||
$colours = 'mixed';
|
||||
$unit_text = 'Operation';
|
||||
$unitlen = 9;
|
||||
$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/app-nfsstats-'.$app['app_id'].'.rrd';
|
||||
$array = array(
|
||||
'total' => array(
|
||||
'descr' => 'Total',
|
||||
'colour' => '570623',
|
||||
),
|
||||
'null' => array(
|
||||
'descr' => 'NULL',
|
||||
'colour' => 'D37F9D',
|
||||
),
|
||||
'getattr' => array(
|
||||
'descr' => 'Get attributes',
|
||||
'colour' => 'F1B264',
|
||||
),
|
||||
'setattr' => array(
|
||||
'descr' => 'Set attributes',
|
||||
'colour' => '634219',
|
||||
),
|
||||
'lookup' => array(
|
||||
'descr' => 'Lookup',
|
||||
'colour' => '60849A',
|
||||
),
|
||||
'access' => array(
|
||||
'descr' => 'Access',
|
||||
'colour' => 'AED983',
|
||||
),
|
||||
'read' => array(
|
||||
'descr' => 'Read',
|
||||
'colour' => '9AD95A',
|
||||
),
|
||||
'write' => array(
|
||||
'descr' => 'Write',
|
||||
'colour' => '457A9A',
|
||||
),
|
||||
'create' => array(
|
||||
'descr' => 'Create',
|
||||
'colour' => '132E3F',
|
||||
),
|
||||
'mkdir' => array(
|
||||
'descr' => 'Make dir',
|
||||
'colour' => '072A3F',
|
||||
),
|
||||
'remove' => array(
|
||||
'descr' => 'Remove',
|
||||
'colour' => '570623',
|
||||
),
|
||||
'rmdir' => array(
|
||||
'descr' => 'Remove dir',
|
||||
'colour' => '57162D',
|
||||
),
|
||||
'rename' => array(
|
||||
'descr' => 'Rename',
|
||||
'colour' => 'AA7739',
|
||||
),
|
||||
'readdirplus' => array(
|
||||
'descr' => 'Read dir plus',
|
||||
'colour' => 'F1F164',
|
||||
),
|
||||
'fsstat' => array(
|
||||
'descr' => 'FS stat',
|
||||
'colour' => 'F1F191',
|
||||
),
|
||||
);
|
||||
|
||||
$i = 0;
|
||||
|
||||
if (is_file($rrd_filename)) {
|
||||
foreach ($array as $ds => $vars) {
|
||||
$rrd_list[$i]['filename'] = $rrd_filename;
|
||||
$rrd_list[$i]['descr'] = $vars['descr'];
|
||||
$rrd_list[$i]['ds'] = $ds;
|
||||
$rrd_list[$i]['colour'] = $vars['colour'];
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
echo "file missing: $file";
|
||||
}
|
||||
|
||||
require 'includes/graphs/generic_multi_line_exact_numbers.inc.php';
|
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
require 'includes/graphs/common.inc.php';
|
||||
|
||||
if ($width > '500') {
|
||||
$descr_len = 24;
|
||||
}
|
||||
else {
|
||||
$descr_len = 12;
|
||||
$descr_len += round(($width - 250) / 8);
|
||||
}
|
||||
|
||||
if ($nototal) {
|
||||
$descr_len += '2';
|
||||
$unitlen += '2';
|
||||
}
|
||||
|
||||
if ($width > '500') {
|
||||
$rrd_options .= " COMMENT:'".substr(str_pad($unit_text, ($descr_len + 5)), 0, ($descr_len + 5))."Now Min Max Avg\l'";
|
||||
if (!$nototal) {
|
||||
$rrd_options .= " COMMENT:'Total '";
|
||||
}
|
||||
|
||||
$rrd_options .= " COMMENT:'\l'";
|
||||
}
|
||||
else {
|
||||
$rrd_options .= " COMMENT:'".substr(str_pad($unit_text, ($descr_len + 5)), 0, ($descr_len + 5))."Now Min Max Avg\l'";
|
||||
}
|
||||
|
||||
$i = 0;
|
||||
$iter = 0;
|
||||
|
||||
foreach ($rrd_list as $rrd) {
|
||||
if (!$config['graph_colours'][$colours][$iter]) {
|
||||
$iter = 0;
|
||||
}
|
||||
|
||||
$colour = $config['graph_colours'][$colours][$iter];
|
||||
if (!empty($rrd['area']) && empty($rrd['areacolour'])) {
|
||||
$rrd['areacolour'] = $colour."20";
|
||||
}
|
||||
|
||||
$ds = $rrd['ds'];
|
||||
$filename = $rrd['filename'];
|
||||
|
||||
$descr = rrdtool_escape($rrd['descr'], $descr_len);
|
||||
|
||||
$id = 'ds'.$i;
|
||||
|
||||
$rrd_options .= ' DEF:'.$id."=$filename:$ds:AVERAGE";
|
||||
if ($simple_rrd) {
|
||||
$rrd_options .= ' CDEF:'.$id.'min='.$id.' ';
|
||||
$rrd_options .= ' CDEF:'.$id.'max='.$id.' ';
|
||||
}
|
||||
else {
|
||||
$rrd_options .= ' DEF:'.$id."min=$filename:$ds:MIN";
|
||||
$rrd_options .= ' DEF:'.$id."max=$filename:$ds:MAX";
|
||||
}
|
||||
|
||||
if ($rrd['invert']) {
|
||||
$rrd_options .= ' CDEF:'.$id.'i='.$id.',-1,*';
|
||||
$rrd_optionsb .= ' LINE1.25:'.$id.'i#'.$colour.":'$descr'";
|
||||
if (!empty($rrd['areacolour'])) {
|
||||
$rrd_optionsb .= ' AREA:'.$id.'i#'.$rrd['areacolour'];
|
||||
}
|
||||
}
|
||||
else {
|
||||
$rrd_optionsb .= ' LINE1.25:'.$id.'#'.$colour.":'$descr'";
|
||||
if (!empty($rrd['areacolour'])) {
|
||||
$rrd_optionsb .= ' AREA:'.$id.'#'.$rrd['areacolour'];
|
||||
}
|
||||
}
|
||||
|
||||
$rrd_optionsb .= ' GPRINT:'.$id.':LAST:%8.0lf%s'.$units.' GPRINT:'.$id.'min:MIN:%8.0lf%s'.$units;
|
||||
$rrd_optionsb .= ' GPRINT:'.$id.'max:MAX:%8.0lf%s'.$units.' GPRINT:'.$id.":AVERAGE:'%8.0lf%s$units\\n'";
|
||||
|
||||
$i++;
|
||||
$iter++;
|
||||
}//end foreach
|
||||
|
||||
$rrd_options .= $rrd_optionsb;
|
||||
$rrd_options .= ' HRULE:0#555555';
|
28
html/pages/device/apps/nfs-stats.inc.php
Normal file
28
html/pages/device/apps/nfs-stats.inc.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
global $config;
|
||||
|
||||
$graphs = array(
|
||||
'nfs-stats' => 'NFS Server - Statistics',
|
||||
);
|
||||
|
||||
foreach ($graphs as $key => $text) {
|
||||
$graph_type = $key;
|
||||
$graph_array['height'] = '100';
|
||||
$graph_array['width'] = '215';
|
||||
$graph_array['to'] = $config['time']['now'];
|
||||
$graph_array['id'] = $app['app_id'];
|
||||
$graph_array['type'] = 'application_'.$key;
|
||||
|
||||
echo '<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">'.$text.'</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div class="row">';
|
||||
include 'includes/print-graphrow.inc.php';
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
}
|
||||
|
55
includes/polling/applications/nfs-stats.inc.php
Normal file
55
includes/polling/applications/nfs-stats.inc.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/app-nfsstats-'.$app['app_id'].'.rrd';
|
||||
$options = '-O qv';
|
||||
$mib = 'NET-SNMP-EXTEND-MIB';
|
||||
$oid = '.1.3.6.1.4.1.8072.1.3.2.4';
|
||||
echo ' nfsstat';
|
||||
|
||||
$nfsstats = snmp_walk($device, $oid, $options, $mib);
|
||||
list($total,$null,$getattr,$setattr,$lookup,$access,$read,$write,$create,$mkdir,$remove,$rmdir,$rename,$readdirplus,$fsstat) = explode("\n",$nfsstats);
|
||||
|
||||
if(!is_file($rrd_filename))
|
||||
{
|
||||
rrdtool_create(
|
||||
$rrd_filename,
|
||||
'--step 300
|
||||
DS:total:GAUGE:600:0:U
|
||||
DS:null:GAUGE:600:0:U
|
||||
DS:getattr:GAUGE:600:0:U
|
||||
DS:setattr:GAUGE:600:0:U
|
||||
DS:lookup:GAUGE:600:0:U
|
||||
DS:access:GAUGE:600:0:U
|
||||
DS:read:GAUGE:600:0:U
|
||||
DS:write:GAUGE:600:0:U
|
||||
DS:create:GAUGE:600:0:U
|
||||
DS:mkdir:GAUGE:600:0:U
|
||||
DS:remove:GAUGE:600:0:U
|
||||
DS:rmdir:GAUGE:600:0:U
|
||||
DS:rename:GAUGE:600:0:U
|
||||
DS:readdirplus:GAUGE:600:0:U
|
||||
DS:fsstat:GAUGE:600:0:U
|
||||
'.$config['rrd_rra']
|
||||
);
|
||||
}
|
||||
|
||||
$fields = array(
|
||||
'total' => $total,
|
||||
'null' => $null,
|
||||
'getattr' => $getattr,
|
||||
'setattr' => $setattr,
|
||||
'lookup' => $lookup,
|
||||
'access' => $access,
|
||||
'read' => $read,
|
||||
'write' => $write,
|
||||
'create' => $create,
|
||||
'mkdir' => $mkdir,
|
||||
'remove' => $remove,
|
||||
'rmdir' => $rmdir,
|
||||
'rename' => $rename,
|
||||
'readdirplus' => $readdirplus,
|
||||
'fsstat' => $fsstat,
|
||||
);
|
||||
|
||||
rrdtool_update($rrd_filename, $fields);
|
||||
$tags = array('name' => 'nfsstats', 'app_id' => $app['app_id']);
|
||||
influx_update($device,'app',$tags,$fields);
|
20
scripts/agent-local/nfsstats.sh
Executable file
20
scripts/agent-local/nfsstats.sh
Executable file
@@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
CFG_NFSVER='3'
|
||||
BIN_NFSSTAT='/usr/sbin/nfsstat'
|
||||
BIN_TR='/usr/bin/tr'
|
||||
BIN_CUT='/usr/bin/cut'
|
||||
BIN_GREP='/usr/bin/grep'
|
||||
BIN_PASTE='/usr/bin/paste'
|
||||
BIN_RM='/usr/bin/rm'
|
||||
BIN_MV='/usr/bin/mv'
|
||||
LOG_OLD='/tmp/nfsstats_old'
|
||||
LOG_NEW='/tmp/nfsstats_new'
|
||||
|
||||
$BIN_NFSSTAT -$CFG_NFSVER -n -l | $BIN_TR -s " " | $BIN_CUT -d ' ' -f 5 | $BIN_GREP -v '^$' > $LOG_NEW 2>&1
|
||||
|
||||
$BIN_PASTE $LOG_NEW $LOG_OLD | while read a b ; do
|
||||
echo $(($a - $b))
|
||||
done
|
||||
|
||||
$BIN_RM $LOG_OLD 2>&1
|
||||
$BIN_MV $LOG_NEW $LOG_OLD 2>&1
|
Reference in New Issue
Block a user