mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
@@ -64,6 +64,9 @@ function nicecase($item) {
|
||||
case 'bind':
|
||||
return 'BIND';
|
||||
|
||||
case 'nfs-stats':
|
||||
return 'NFS Stats';
|
||||
|
||||
default:
|
||||
return ucfirst($item);
|
||||
}
|
||||
|
90
html/includes/graphs/application/nfs-stats.inc.php
Normal file
90
html/includes/graphs/application/nfs-stats.inc.php
Normal file
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
require 'includes/graphs/common.inc.php';
|
||||
$scale_min = 0;
|
||||
$colours = 'mixed';
|
||||
$unit_text = 'Operations';
|
||||
$unitlen = 10;
|
||||
$bigdescrlen = 15;
|
||||
$smalldescrlen = 15;
|
||||
$dostack = 0;
|
||||
$printtotal = 0;
|
||||
$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/app-nfsstats-'.$app['app_id'].'.rrd';
|
||||
$array = array(
|
||||
'total' => array(
|
||||
'descr' => 'Total',
|
||||
'colour' => '000000',
|
||||
),
|
||||
'null' => array(
|
||||
'descr' => 'NULL',
|
||||
'colour' => '630606',
|
||||
),
|
||||
'getattr' => array(
|
||||
'descr' => 'Get attributes',
|
||||
'colour' => '50C150',
|
||||
),
|
||||
'setattr' => array(
|
||||
'descr' => 'Set attributes',
|
||||
'colour' => '4D65A2',
|
||||
),
|
||||
'lookup' => array(
|
||||
'descr' => 'Lookup',
|
||||
'colour' => '8B64A1',
|
||||
),
|
||||
'access' => array(
|
||||
'descr' => 'Access',
|
||||
'colour' => 'AAAA39',
|
||||
),
|
||||
'read' => array(
|
||||
'descr' => 'Read',
|
||||
'colour' => '',
|
||||
),
|
||||
'write' => array(
|
||||
'descr' => 'Write',
|
||||
'colour' => '457A9A',
|
||||
),
|
||||
'create' => array(
|
||||
'descr' => 'Create',
|
||||
'colour' => '690D87',
|
||||
),
|
||||
'mkdir' => array(
|
||||
'descr' => 'Make dir',
|
||||
'colour' => '072A3F',
|
||||
),
|
||||
'remove' => array(
|
||||
'descr' => 'Remove',
|
||||
'colour' => 'F16464',
|
||||
),
|
||||
'rmdir' => array(
|
||||
'descr' => 'Remove dir',
|
||||
'colour' => '57162D',
|
||||
),
|
||||
'rename' => array(
|
||||
'descr' => 'Rename',
|
||||
'colour' => 'A40B62',
|
||||
),
|
||||
'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';
|
116
html/includes/graphs/generic_multi_line_exact_numbers.inc.php
Normal file
116
html/includes/graphs/generic_multi_line_exact_numbers.inc.php
Normal file
@@ -0,0 +1,116 @@
|
||||
<?php
|
||||
require 'includes/graphs/common.inc.php';
|
||||
|
||||
if ($width > '500') {
|
||||
$descr_len = $bigdescrlen;
|
||||
} else {
|
||||
$descr_len = $smalldescrlen;
|
||||
}
|
||||
|
||||
if ($printtotal === 1) {
|
||||
$descr_len += '2';
|
||||
$unitlen += '2';
|
||||
}
|
||||
|
||||
$unit_text = str_pad(truncate($unit_text, $unitlen), $unitlen);
|
||||
|
||||
if ($width > '500') {
|
||||
$rrd_options .= " COMMENT:'".substr(str_pad($unit_text, ($descr_len + 10)), 0, ($descr_len + 10))."Now Min Max Avg\l'";
|
||||
if($printtotal === 1) {
|
||||
$rrd_options .= " COMMENT:'Total '";
|
||||
}
|
||||
$rrd_options .= " COMMENT:'\l'";
|
||||
} else {
|
||||
$rrd_options .= " COMMENT:'".substr(str_pad($unit_text, ($descr_len + 10)), 0, ($descr_len + 10))."Now Min Max Avg\l'";
|
||||
}
|
||||
|
||||
foreach ($rrd_list as $rrd) {
|
||||
if ($rrd['colour']) {
|
||||
$colour = $rrd['colour'];
|
||||
}
|
||||
else {
|
||||
if (!$config['graph_colours'][$colours][$colour_iter]) {
|
||||
$colour_iter = 0;
|
||||
}
|
||||
|
||||
$colour = $config['graph_colours'][$colours][$colour_iter];
|
||||
$colour_iter++;
|
||||
}
|
||||
|
||||
$ds = $rrd['ds'];
|
||||
$filename = $rrd['filename'];
|
||||
|
||||
$descr = rrdtool_escape($rrd['descr'], $descr_len);
|
||||
$id = 'ds'.$i;
|
||||
|
||||
$rrd_options .= ' DEF:'.$rrd['ds'].$i.'='.$rrd['filename'].':'.$rrd['ds'].':AVERAGE ';
|
||||
|
||||
if ($simple_rrd) {
|
||||
$rrd_options .= ' CDEF:'.$rrd['ds'].$i.'min='.$rrd['ds'].$i.' ';
|
||||
$rrd_options .= ' CDEF:'.$rrd['ds'].$i.'max='.$rrd['ds'].$i.' ';
|
||||
}
|
||||
else {
|
||||
$rrd_options .= ' DEF:'.$rrd['ds'].$i.'min='.$rrd['filename'].':'.$rrd['ds'].':MIN ';
|
||||
$rrd_options .= ' DEF:'.$rrd['ds'].$i.'max='.$rrd['filename'].':'.$rrd['ds'].':MAX ';
|
||||
}
|
||||
|
||||
if ($_GET['previous']) {
|
||||
$rrd_options .= ' DEF:'.$i.'X='.$rrd['filename'].':'.$rrd['ds'].':AVERAGE:start='.$prev_from.':end='.$from;
|
||||
$rrd_options .= ' SHIFT:'.$i."X:$period";
|
||||
$thingX .= $seperatorX.$i.'X,UN,0,'.$i.'X,IF';
|
||||
$plusesX .= $plusX;
|
||||
$seperatorX = ',';
|
||||
$plusX = ',+';
|
||||
}
|
||||
|
||||
if ($printtotal === 1) {
|
||||
$rrd_options .= ' VDEF:tot'.$rrd['ds'].$i.'='.$rrd['ds'].$i.',TOTAL';
|
||||
}
|
||||
|
||||
$g_defname = $rrd['ds'];
|
||||
if (is_numeric($multiplier)) {
|
||||
$g_defname = $rrd['ds'].'_cdef';
|
||||
$rrd_options .= ' CDEF:'.$g_defname.$i.'='.$rrd['ds'].$i.','.$multiplier.',*';
|
||||
$rrd_options .= ' CDEF:'.$g_defname.$i.'min='.$rrd['ds'].$i.'min,'.$multiplier.',*';
|
||||
$rrd_options .= ' CDEF:'.$g_defname.$i.'max='.$rrd['ds'].$i.'max,'.$multiplier.',*';
|
||||
} else if (is_numeric($divider)) {
|
||||
$g_defname = $rrd['ds'].'_cdef';
|
||||
$rrd_options .= ' CDEF:'.$g_defname.$i.'='.$rrd['ds'].$i.','.$divider.',/';
|
||||
$rrd_options .= ' CDEF:'.$g_defname.$i.'min='.$rrd['ds'].$i.'min,'.$divider.',/';
|
||||
$rrd_options .= ' CDEF:'.$g_defname.$i.'max='.$rrd['ds'].$i.'max,'.$divider.',/';
|
||||
}
|
||||
|
||||
if (isset($text_orig) && $text_orig) {
|
||||
$t_defname = $rrd['ds'];
|
||||
} else {
|
||||
$t_defname = $g_defname;
|
||||
}
|
||||
|
||||
if ($i && ($dostack === 1)) {
|
||||
$stack = ':STACK';
|
||||
}
|
||||
|
||||
$rrd_options .= ' LINE2:'.$g_defname.$i.'#'.$colour.":'".$descr."'$stack";
|
||||
$rrd_options .= ' GPRINT:'.$t_defname.$i.':LAST:%8.0lf%s GPRINT:'.$t_defname.$i.'min:MIN:%8.0lf%s';
|
||||
$rrd_options .= ' GPRINT:'.$t_defname.$i.'max:MAX:%8.0lf%s GPRINT:'.$t_defname.$i.":AVERAGE:'%8.0lf%s\\n'";
|
||||
|
||||
if ($printtotal === 1) {
|
||||
$rrd_options .= ' GPRINT:tot'.$rrd['ds'].$i.":%6.2lf%s'".rrdtool_escape($total_units)."'";
|
||||
}
|
||||
|
||||
$rrd_options .= " COMMENT:'\\n'";
|
||||
}//end foreach
|
||||
|
||||
if ($_GET['previous'] == 'yes') {
|
||||
if (is_numeric($multiplier)) {
|
||||
$rrd_options .= ' CDEF:X='.$thingX.$plusesX.','.$multiplier.',*';
|
||||
}
|
||||
else if (is_numeric($divider)) {
|
||||
$rrd_options .= ' CDEF:X='.$thingX.$plusesX.','.$divider.',/';
|
||||
}
|
||||
else {
|
||||
$rrd_options .= ' CDEF:X='.$thingX.$plusesX;
|
||||
}
|
||||
$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);
|
28
scripts/agent-local/nfsstats.sh
Executable file
28
scripts/agent-local/nfsstats.sh
Executable file
@@ -0,0 +1,28 @@
|
||||
#!/bin/bash
|
||||
#############################################################
|
||||
# - put this file on the nfs server somewhere like /opt/ #
|
||||
# - edit your snmpd.conf and add line #
|
||||
# extend nfsstat /opt/nfsstats.sh #
|
||||
# - restart snmpd #
|
||||
# - make sure that you have all the binaries required below #
|
||||
#############################################################
|
||||
|
||||
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