From 0ec980c1cdac03f82420c77219d412de62f4376f Mon Sep 17 00:00:00 2001 From: laf Date: Mon, 11 Jul 2016 12:33:09 +0100 Subject: [PATCH 1/6] Moved the device type discovery to before it is needed --- includes/discovery/functions.inc.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/includes/discovery/functions.inc.php b/includes/discovery/functions.inc.php index cecd98d428..6b7070a140 100644 --- a/includes/discovery/functions.inc.php +++ b/includes/discovery/functions.inc.php @@ -97,6 +97,13 @@ function discover_device($device, $options = null) { } } + // Set type to a predefined type for the OS if it's not already set + if ($device['type'] == 'unknown' || $device['type'] == '') { + if ($config['os'][$device['os']]['type']) { + $device['type'] = $config['os'][$device['os']]['type']; + } + } + if ($config['os'][$device['os']]['group']) { $device['os_group'] = $config['os'][$device['os']]['group']; echo ' (' . $device['os_group'] . ')'; @@ -134,13 +141,6 @@ function discover_device($device, $options = null) { register_mibs($device, $devicemib, "includes/discovery/functions.inc.php"); } - // Set type to a predefined type for the OS if it's not already set - if ($device['type'] == 'unknown' || $device['type'] == '') { - if ($config['os'][$device['os']]['type']) { - $device['type'] = $config['os'][$device['os']]['type']; - } - } - $device_end = microtime(true); $device_run = ($device_end - $device_start); $device_time = substr($device_run, 0, 5); From ff5b6c9a2b3be0a368056a8ee9a379926a333d3b Mon Sep 17 00:00:00 2001 From: crcro Date: Wed, 20 Jul 2016 02:14:30 +0300 Subject: [PATCH 2/6] app: nfs-v3-stats Rewrite of the original nfs-stats app. Includes more stats, nicer graphs, no more nfsstats bin requirement. --- html/includes/functions.inc.php | 3 + .../graphs/application/nfs-fh.inc.php | 37 +++++ .../graphs/application/nfs-io.inc.php | 34 +++++ .../graphs/application/nfs-net.inc.php | 36 +++++ .../graphs/application/nfs-ra.inc.php | 44 ++++++ .../graphs/application/nfs-rc.inc.php | 35 +++++ .../graphs/application/nfs-rpc.inc.php | 37 +++++ .../graphs/application/nfs-v3-stats.inc.php | 54 +++++++ .../graphs/generic_v3_multiline.inc.php | 121 ++++++++++++++++ html/pages/device/apps/nfs-v3-stats.inc.php | 35 +++++ .../polling/applications/nfs-v3-stats.inc.php | 132 ++++++++++++++++++ scripts/agent-local/nfs-stats.sh | 47 +++++++ 12 files changed, 615 insertions(+) create mode 100644 html/includes/graphs/application/nfs-fh.inc.php create mode 100644 html/includes/graphs/application/nfs-io.inc.php create mode 100644 html/includes/graphs/application/nfs-net.inc.php create mode 100644 html/includes/graphs/application/nfs-ra.inc.php create mode 100644 html/includes/graphs/application/nfs-rc.inc.php create mode 100644 html/includes/graphs/application/nfs-rpc.inc.php create mode 100644 html/includes/graphs/application/nfs-v3-stats.inc.php create mode 100644 html/includes/graphs/generic_v3_multiline.inc.php create mode 100644 html/pages/device/apps/nfs-v3-stats.inc.php create mode 100644 includes/polling/applications/nfs-v3-stats.inc.php create mode 100644 scripts/agent-local/nfs-stats.sh diff --git a/html/includes/functions.inc.php b/html/includes/functions.inc.php index 5993c2acb2..5e8413f7e6 100644 --- a/html/includes/functions.inc.php +++ b/html/includes/functions.inc.php @@ -67,6 +67,9 @@ function nicecase($item) { case 'nfs-stats': return 'NFS Stats'; + case 'nfs-v3-stats': + return 'NFS v3 Stats'; + default: return ucfirst($item); } diff --git a/html/includes/graphs/application/nfs-fh.inc.php b/html/includes/graphs/application/nfs-fh.inc.php new file mode 100644 index 0000000000..76eed56fed --- /dev/null +++ b/html/includes/graphs/application/nfs-fh.inc.php @@ -0,0 +1,37 @@ + array('descr' => 'lookup','colour' => '136421',), + 'fh_anon' => array('descr' => 'anon','colour' => 'B2C945',), + 'fh_ncachedir' => array('descr' => 'ncachedir','colour' => '778D0D',), + 'fh_ncachenondir' => array('descr' => 'ncachenondir','colour' => '536400',), + 'fh_stale' => array('descr' => 'stale','colour' => '832119',), +); + +$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: $rrd_filename"; +} + +require 'includes/graphs/generic_multi_line_exact_numbers.inc.php'; diff --git a/html/includes/graphs/application/nfs-io.inc.php b/html/includes/graphs/application/nfs-io.inc.php new file mode 100644 index 0000000000..e6778d55ce --- /dev/null +++ b/html/includes/graphs/application/nfs-io.inc.php @@ -0,0 +1,34 @@ + array('descr' => 'read','colour' => '2B9220',), + 'io_write' => array('descr' => 'write','colour' => 'B0262D',), +); + +$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: $rrd_filename"; +} + +require 'includes/graphs/generic_multi_line_exact_numbers.inc.php'; diff --git a/html/includes/graphs/application/nfs-net.inc.php b/html/includes/graphs/application/nfs-net.inc.php new file mode 100644 index 0000000000..70b17cad62 --- /dev/null +++ b/html/includes/graphs/application/nfs-net.inc.php @@ -0,0 +1,36 @@ + array('descr' => 'total','colour' => '000000',), + 'net_udp' => array('descr' => 'udp','colour' => 'AA3F39',), + 'net_tcp' => array('descr' => 'tcp','colour' => '2C8437',), + 'net_tcpconn' => array('descr' => 'tcp conn','colour' => '576996',), +); + +$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: $rrd_filename"; +} + +require 'includes/graphs/generic_multi_line_exact_numbers.inc.php'; diff --git a/html/includes/graphs/application/nfs-ra.inc.php b/html/includes/graphs/application/nfs-ra.inc.php new file mode 100644 index 0000000000..a6503e07b6 --- /dev/null +++ b/html/includes/graphs/application/nfs-ra.inc.php @@ -0,0 +1,44 @@ + array('descr' => 'size','colour' => '091B40',), + 'ra_range01' => array('descr' => '0-10','colour' => '8293B3',), + 'ra_range02' => array('descr' => '10-20','colour' => '566B95',), + 'ra_range03' => array('descr' => '20-30','colour' => '1B315D',), + 'ra_range04' => array('descr' => '30-40','colour' => '091B40',), + 'ra_range05' => array('descr' => '40-50','colour' => '296F6A',), + 'ra_range06' => array('descr' => '50-60','colour' => '498984',), + 'ra_range07' => array('descr' => '60-70','colour' => '125651',), + 'ra_range08' => array('descr' => '70-80','colour' => '023B37',), + 'ra_range09' => array('descr' => '80-90','colour' => '14623A',), + 'ra_range10' => array('descr' => '90-100','colour' => '034423',), + 'ra_notfound' => array('descr' => 'not found','colour' => '590315',), +); + +$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: $rrd_filename"; +} + +require 'includes/graphs/generic_multi_line_exact_numbers.inc.php'; diff --git a/html/includes/graphs/application/nfs-rc.inc.php b/html/includes/graphs/application/nfs-rc.inc.php new file mode 100644 index 0000000000..ba0bdcf2f7 --- /dev/null +++ b/html/includes/graphs/application/nfs-rc.inc.php @@ -0,0 +1,35 @@ + array('descr' => 'hits','colour' => '2B9220',), + 'rc_misses' => array('descr' => 'misses','colour' => 'B36326',), + 'rc_nocache' => array('descr' => 'nocache','colour' => 'B0262D',), +); + +$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: $rrd_filename"; +} + +require 'includes/graphs/generic_multi_line_exact_numbers.inc.php'; diff --git a/html/includes/graphs/application/nfs-rpc.inc.php b/html/includes/graphs/application/nfs-rpc.inc.php new file mode 100644 index 0000000000..4b766e70fc --- /dev/null +++ b/html/includes/graphs/application/nfs-rpc.inc.php @@ -0,0 +1,37 @@ + array('descr' => 'calls','colour' => '000000',), + 'rpc_badcalls' => array('descr' => 'bad calls','colour' => '600604',), + 'rpc_badfmt' => array('descr' => 'bad fmt','colour' => '8C201D',), + 'rpc_badauth' => array('descr' => 'bad auth','colour' => 'DF7A77',), + 'rpc_badclnt' => array('descr' => 'bad clnt','colour' => 'FFB3B1',), +); + +$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: $rrd_filename"; +} + +require 'includes/graphs/generic_multi_line_exact_numbers.inc.php'; diff --git a/html/includes/graphs/application/nfs-v3-stats.inc.php b/html/includes/graphs/application/nfs-v3-stats.inc.php new file mode 100644 index 0000000000..5ab9f7a412 --- /dev/null +++ b/html/includes/graphs/application/nfs-v3-stats.inc.php @@ -0,0 +1,54 @@ + array('descr' => 'Null','colour' => '630606',), + 'proc3_getattr' => array('descr' => 'Get attributes','colour' => '50C150',), + 'proc3_setattr' => array('descr' => 'Set attributes','colour' => '4D65A2',), + 'proc3_lookup' => array('descr' => 'Lookup','colour' => '8B64A1',), + 'proc3_access' => array('descr' => 'Access','colour' => 'AAAA39',), + 'proc3_read' => array('descr' => 'Read','colour' => '308A30',), + 'proc3_write' => array('descr' => 'Write','colour' => '457A9A',), + 'proc3_create' => array('descr' => 'Create','colour' => '690D87',), + 'proc3_mkdir' => array('descr' => 'Make dir','colour' => '3A3478',), + 'proc3_mknod' => array('descr' => 'Make nod','colour' => '512E74',), + 'proc3_link' => array('descr' => 'Link','colour' => '072A3F',), + 'proc3_remove' => array('descr' => 'Remove','colour' => 'F16464',), + 'proc3_rmdir' => array('descr' => 'Remove dir','colour' => '57162D',), + 'proc3_rename' => array('descr' => 'Rename','colour' => 'A40B62',), + 'proc3_readlink' => array('descr' => 'Read link','colour' => '557917',), + 'proc3_readdir' => array('descr' => 'Read dir','colour' => 'A3C666',), + 'proc3_symlink' => array('descr' => 'Symlink','colour' => '85C490',), + 'proc3_readdirplus' => array('descr' => 'Read dir plus','colour' => 'F1F164',), + 'proc3_fsstat' => array('descr' => 'FS stat','colour' => 'F1F191',), + 'proc3_fsinfo' => array('descr' => 'FS info','colour' => '6E2770',), + 'proc3_pathconf' => array('descr' => 'Pathconf','colour' => '993555',), + 'proc3_commit' => array('descr' => 'Commit','colour' => '463176',), + ); + +$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: $rrd_filename"; +} + +require 'includes/graphs/generic_multi_line_exact_numbers.inc.php'; diff --git a/html/includes/graphs/generic_v3_multiline.inc.php b/html/includes/graphs/generic_v3_multiline.inc.php new file mode 100644 index 0000000000..92773ba01d --- /dev/null +++ b/html/includes/graphs/generic_v3_multiline.inc.php @@ -0,0 +1,121 @@ + '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"; + if ($addarea === 1) + { + $descr = ":"; + $rrd_options .= ' AREA:'.$g_defname.$i.'#'.$colour.$transparency.":'".$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'; +} + diff --git a/html/pages/device/apps/nfs-v3-stats.inc.php b/html/pages/device/apps/nfs-v3-stats.inc.php new file mode 100644 index 0000000000..853e50cbac --- /dev/null +++ b/html/pages/device/apps/nfs-v3-stats.inc.php @@ -0,0 +1,35 @@ + 'NFS v3 Statistics', + 'nfs-io' => 'IO', + 'nfs-fh' => 'File handler', + 'nfs-rc' => 'Reply cache', + 'nfs-ra' => 'Read ahead cache', + 'nfs-net' => 'Network stats', + 'nfs-rpc' => 'RPC Stats', + +); + +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 '
+
+

'.$text.'

+
+
+
'; + include 'includes/print-graphrow.inc.php'; + echo '
'; + echo '
'; + echo '
'; +} + diff --git a/includes/polling/applications/nfs-v3-stats.inc.php b/includes/polling/applications/nfs-v3-stats.inc.php new file mode 100644 index 0000000000..21cbdd3f72 --- /dev/null +++ b/includes/polling/applications/nfs-v3-stats.inc.php @@ -0,0 +1,132 @@ + $rc_hits, + 'rc_misses' => $rc_misses, + 'rc_nocache' => $rc_nocache, + 'fh_lookup' => $fh_lookup, + 'fh_anon' => $fh_anon, + 'fh_ncachedir' => $fh_ncachedir, + 'fh_ncachenondir' => $fh_ncachenondir, + 'fh_stale' => $fh_stale, + 'io_read' => $io_read, + 'io_write' => $io_write, + 'ra_size' => $ra_size, + 'ra_range01' => $ra_range01, + 'ra_range02' => $ra_range02, + 'ra_range03' => $ra_range03, + 'ra_range04' => $ra_range04, + 'ra_range05' => $ra_range05, + 'ra_range06' => $ra_range06, + 'ra_range07' => $ra_range07, + 'ra_range08' => $ra_range08, + 'ra_range09' => $ra_range09, + 'ra_range10' => $ra_range10, + 'ra_notfound'=> $ra_notfound, + 'net_all' => $net_all, + 'net_udp' => $net_udp, + 'net_tcp' => $net_tcp, + 'net_tcpconn' => $net_tcpconn, + 'rpc_calls' => $rpc_calls, + 'rpc_badcalls' => $rpc_badcalls, + 'rpc_badfmt' => $rpc_badfmt, + 'rpc_badauth' => $rpc_badauth, + 'rpc_badclnt' => $rpc_badclnt, + 'proc3_null' => $proc3_null, + 'proc3_getattr' => $proc3_getattr, + 'proc3_setattr' => $proc3_setattr, + 'proc3_lookup' => $proc3_lookup, + 'proc3_access' => $proc3_access, + 'proc3_readlink' => $proc3_readlink, + 'proc3_read' => $proc3_read, + 'proc3_write' => $proc3_write, + 'proc3_create' => $proc3_create, + 'proc3_mkdir' => $proc3_mkdir, + 'proc3_symlink' => $proc3_symlink, + 'proc3_mknod' => $proc3_mknod, + 'proc3_remove' => $proc3_remove, + 'proc3_rmdir' => $proc3_rmdir, + 'proc3_rename' => $proc3_rename, + 'proc3_link' => $proc3_link, + 'proc3_readdir' => $proc3_readdir, + 'proc3_readdirplus' => $proc3_readdirplus, + 'proc3_fsstat' => $proc3_fsstat, + 'proc3_fsinfo' => $proc3_fsinfo, + 'proc3_pathconf' => $proc3_pathconf, + 'proc3_commit' => $proc3_commit, +); + +rrdtool_update($rrd_filename, $fields); +$tags = array('name' => 'nfs-v3-stats', 'app_id' => $app['app_id']); +influx_update($device,'app',$tags,$fields); diff --git a/scripts/agent-local/nfs-stats.sh b/scripts/agent-local/nfs-stats.sh new file mode 100644 index 0000000000..25bbb6b1ee --- /dev/null +++ b/scripts/agent-local/nfs-stats.sh @@ -0,0 +1,47 @@ +#!/bin/bash +############################################################ +# copy this file somewhere like /opt and chmod +x it # +# edit your snmpd.conf and add the below line and restart: # +# extend nfs-stats /opt/nfs-stats.sh # +############################################################ +CFG_NFSFILE='/proc/net/rpc/nfsd' +BIN_CAT='/usr/bin/cat' +BIN_SED='/usr/bin/sed' +BIN_AWK='/usr/bin/awk' +BIN_TR='/usr/bin/tr' +BIN_PASTE='/usr/bin/paste' +BIN_RM='/usr/bin/rm' +BIN_MV='/usr/bin/mv' +LOG_OLD='/tmp/nfsio_old' +LOG_NEW='/tmp/nfsio_new' +LOG_FIX='/tmp/nfsio_fix' + +#get reply cache (rc - values: hits, misses, nocache) +$BIN_CAT $CFG_NFSFILE | $BIN_SED -n 1p | $BIN_AWK '{print $2,$3,$4}' | $BIN_TR " " "\n" > $LOG_NEW + +#get server file handle (fh - values: lookup, anon, ncachedir, ncachenondir, stale) +$BIN_CAT $CFG_NFSFILE | $BIN_SED -n 2p | $BIN_AWK '{print $2,$3,$4,$5,$6}' | $BIN_TR " " "\n" >> $LOG_NEW + +#get io bytes (io - values: read, write) +$BIN_CAT $CFG_NFSFILE | $BIN_SED -n 3p | $BIN_AWK '{print $2,$3}' | $BIN_TR " " "\n" >> $LOG_NEW + +#get read ahead cache (ra - values: cache_size, 0-10%, 10-20%, 20-30%, 30-40%, 40-50%, 50-60%, 60-70%, 70-80%, 80-90%, 90-100%, not-found) +$BIN_CAT $CFG_NFSFILE | $BIN_SED -n 5p | $BIN_AWK '{print $3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13}' | $BIN_TR " " "\n" >> $LOG_NEW +$BIN_CAT $CFG_NFSFILE | $BIN_SED -n 5p | $BIN_AWK '{print $2}' > $LOG_FIX + +#get server packet stats (net - values: all reads, udp packets, tcp packets, tcp conn) +$BIN_CAT $CFG_NFSFILE | $BIN_SED -n 6p | $BIN_AWK '{print $2,$3,$4,$5}' | $BIN_TR " " "\n" >> $LOG_NEW + +#get server rpc operations (rpc - values: calls, badcalls, badfmt, badauth, badclnt) +$BIN_CAT $CFG_NFSFILE | $BIN_SED -n 7p | $BIN_AWK '{print $2,$3,$4,$5,$6}' | $BIN_TR " " "\n" >> $LOG_NEW + +#get nfs v3 stats (proc3 - values: null, getattr, setattr, lookup, access, readlink, read, write, create, mkdir, symlink, mknod, remove, rmdir, rename, link, readdir, readdirplus, fsstat, fsinfo, pathconf, commit) +$BIN_CAT $CFG_NFSFILE | $BIN_SED -n 8p | $BIN_AWK '{print $3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$20,$21,$22,$23,$24}' | $BIN_TR " " "\n" >> $LOG_NEW + +$BIN_PASTE $LOG_FIX +$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 From 591983ac75879e4bfede1f7cc044b843eed867e8 Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Fri, 22 Jul 2016 00:26:02 -0500 Subject: [PATCH 3/6] Fix incorrect thresholds The initial value was fetched incorrectly --- includes/discovery/sensors/temperatures/ibm-amm.inc.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/discovery/sensors/temperatures/ibm-amm.inc.php b/includes/discovery/sensors/temperatures/ibm-amm.inc.php index af5c020e83..45becf70e7 100644 --- a/includes/discovery/sensors/temperatures/ibm-amm.inc.php +++ b/includes/discovery/sensors/temperatures/ibm-amm.inc.php @@ -12,7 +12,7 @@ if ($device['os'] == 'ibm-amm') { $oid = 'BLADE-MIB::mmTemp.0'; - $mmtemp = snmp_get($device, $oid, '-OsqnU'); + $mmtemp = snmp_get($device, $oid, '-Oqv'); preg_match('/[\d\.]+/', $mmtemp, $temp_response); if (!empty($temp_response[0])) { @@ -29,7 +29,7 @@ if ($device['os'] == 'ibm-amm') { } $oid = 'BLADE-MIB::frontPanelTemp.0'; - $fptemp = snmp_get($device, $oid, '-OsqnU'); + $fptemp = snmp_get($device, $oid, '-Oqv'); preg_match('/[\d\.]+/', $fptemp, $temp_response); if (!empty($temp_response[0])) { From f10d74f3726bccca7e39c0acb60f5d5884df049f Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Fri, 22 Jul 2016 10:09:10 -0500 Subject: [PATCH 4/6] Validate.php timezone failure Move the timezone into the constructor. --- validate.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/validate.php b/validate.php index 9efdb54b59..65ebe89565 100755 --- a/validate.php +++ b/validate.php @@ -76,8 +76,7 @@ $versions = version_info(); echo "Version info:\n"; $cur_sha = $versions['local_sha']; if ($config['update_channel'] == 'master' && $cur_sha != $versions['github']['sha']) { - $commit_date = new DateTime($versions['local_date']); - $commit_date->setTimezone(new DateTimeZone(date_default_timezone_get())); + $commit_date = new DateTime($versions['local_date'], new DateTimeZone(date_default_timezone_get())); print_warn("Your install is out of date: $cur_sha " . $commit_date->format('(r)')); } else { From 8f00f49b79374289e165e798ec6d83a355438bb6 Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Fri, 22 Jul 2016 18:36:10 -0500 Subject: [PATCH 5/6] Group sensors of the same type together, then order by index, oid --- html/pages/device/overview/generic/sensor.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/html/pages/device/overview/generic/sensor.inc.php b/html/pages/device/overview/generic/sensor.inc.php index f086825624..8de67f5c55 100644 --- a/html/pages/device/overview/generic/sensor.inc.php +++ b/html/pages/device/overview/generic/sensor.inc.php @@ -2,7 +2,7 @@ if ($sensor_class == 'state') { - $sensors = dbFetchRows('SELECT * FROM `sensors` LEFT JOIN `sensors_to_state_indexes` ON sensors_to_state_indexes.sensor_id = sensors.sensor_id LEFT JOIN state_indexes ON state_indexes.state_index_id = sensors_to_state_indexes.state_index_id WHERE `sensor_class` = ? AND device_id = ? ORDER BY `poller_type`, `sensor_index`+0, `sensor_oid`', array($sensor_class, $device['device_id'])); + $sensors = dbFetchRows('SELECT * FROM `sensors` LEFT JOIN `sensors_to_state_indexes` ON sensors_to_state_indexes.sensor_id = sensors.sensor_id LEFT JOIN state_indexes ON state_indexes.state_index_id = sensors_to_state_indexes.state_index_id WHERE `sensor_class` = ? AND device_id = ? ORDER BY `sensor_type`, `sensor_index`+0, `sensor_oid`', array($sensor_class, $device['device_id'])); } else { $sensors = dbFetchRows('SELECT * FROM `sensors` WHERE `sensor_class` = ? AND device_id = ? ORDER BY `poller_type`, `sensor_oid`, `sensor_index`', array($sensor_class, $device['device_id'])); From db0e6eca2ff53095819670885e9e3c76b8b6fb19 Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Fri, 22 Jul 2016 18:46:29 -0500 Subject: [PATCH 6/6] Clean up ibm-amm sensors Add power module state Correct state indexes Use numeric oids, but document named oids --- .../sensors/fanspeeds/ibm-amm.inc.php | 30 ++--- .../discovery/sensors/states/ibm-amm.inc.php | 118 ++++++++++++++---- .../sensors/temperatures/ibm-amm.inc.php | 4 +- 3 files changed, 110 insertions(+), 42 deletions(-) diff --git a/includes/discovery/sensors/fanspeeds/ibm-amm.inc.php b/includes/discovery/sensors/fanspeeds/ibm-amm.inc.php index a2bd990c99..b9d6729af3 100644 --- a/includes/discovery/sensors/fanspeeds/ibm-amm.inc.php +++ b/includes/discovery/sensors/fanspeeds/ibm-amm.inc.php @@ -12,26 +12,22 @@ if ($device['os'] == 'ibm-amm') { - $oids = array('blower1speedRPM', 'blower2speedRPM', 'blower3speedRPM', 'blower4speedRPM'); - d_echo($oids."\n"); - if (!empty($oids)) { + $descr_prefix = 'Blower '; + $oids = array( + '.1.3.6.1.4.1.2.3.51.2.2.3.20.0', // BLADE-MIB:blower1speedRPM + '.1.3.6.1.4.1.2.3.51.2.2.3.21.0', // BLADE-MIB:blower2speedRPM + '.1.3.6.1.4.1.2.3.51.2.2.3.22.0', // BLADE-MIB:blower3speedRPM + '.1.3.6.1.4.1.2.3.51.2.2.3.23.0', // BLADE-MIB:blower4speedRPM + ); - echo 'BLADE-MIB '; - foreach ($oids as $index => $data) { - - if (!empty($data)) { - $value = trim(snmp_get($device, $data.'.0', '-Oqv', 'BLADE-MIB'), '"'); - - if (is_numeric($value)) { - $oid = 'BLADE-MIB::' . $data . '.0'; - $descr = $data; - discover_sensor($valid['sensor'], 'fanspeed', $device, $oid, $index, 'snmp', $descr, 1, 1, null, null, null, null, $value); - } - - } + echo 'BLADE-MIB '; + foreach ($oids as $index => $oid) { + $value = trim(snmp_get($device, $oid, '-Oqv'), '"'); + if (is_numeric($value)) { + $descr = $descr_prefix . ($index + 1); + discover_sensor($valid['sensor'], 'fanspeed', $device, $oid, $index, 'snmp', $descr, 1, 1, null, null, null, null, $value); } - } } diff --git a/includes/discovery/sensors/states/ibm-amm.inc.php b/includes/discovery/sensors/states/ibm-amm.inc.php index c9cdb9c57f..bbed4a2a7a 100644 --- a/includes/discovery/sensors/states/ibm-amm.inc.php +++ b/includes/discovery/sensors/states/ibm-amm.inc.php @@ -13,16 +13,25 @@ if ($device['os'] == 'ibm-amm') { $index = 1; + $state_name = 'ibm-amm_BlowerState'; + $state_descr = 'Blower '; $oids = array( - 'blower1State' => '.1.3.6.1.4.1.2.3.51.2.2.3.10.0', - 'blower2State' => '.1.3.6.1.4.1.2.3.51.2.2.3.11.0', - 'blower3State' => '.1.3.6.1.4.1.2.3.51.2.2.3.12.0', - 'blower4State' => '.1.3.6.1.4.1.2.3.51.2.2.3.13.0' + '.1.3.6.1.4.1.2.3.51.2.2.3.10.0', // BLADE-MIB::blower1State.0 + '.1.3.6.1.4.1.2.3.51.2.2.3.11.0', // BLADE-MIB::blower2State.0 + '.1.3.6.1.4.1.2.3.51.2.2.3.12.0', // BLADE-MIB::blower3State.0 + '.1.3.6.1.4.1.2.3.51.2.2.3.13.0', // BLADE-MIB::blower4State.0 ); + /* BLADE-MIB: blower1State + * unknown(0), + * good(1), + * warning(2), + * bad(3) + */ - foreach ($oids as $state_name => $oid) { - + foreach ($oids as $oid) { $state = snmp_get($device, $oid, '-Oqv'); + $descr = $state_descr . $index; + if (!empty($state)) { $state_index_id = create_state_index($state_name); @@ -30,10 +39,10 @@ if ($device['os'] == 'ibm-amm') { if ($state_index_id) { $states = array( - array($state_index_id,'unknown',0,0,3) , - array($state_index_id,'good',1,1,0) , - array($state_index_id,'warning',1,2,1) , - array($state_index_id,'bad',1,3,2) , + array($state_index_id, 'unknown', 0, 0, 3), + array($state_index_id, 'good', 1, 1, 0), + array($state_index_id, 'warning', 1, 2, 1), + array($state_index_id, 'bad', 1, 3, 2), ); foreach($states as $value) { @@ -49,7 +58,7 @@ if ($device['os'] == 'ibm-amm') { }//end if - discover_sensor($valid['sensor'], 'state', $device, $oid, $index, $state_name, $state_name, '1', '1', null, null, null, null, $state, 'snmp', $index); + discover_sensor($valid['sensor'], 'state', $device, $oid, $index, $state_name, $descr, '1', '1', null, null, null, null, $state, 'snmp', $index); //Create Sensor To State Index create_sensor_to_state_index($device, $state_name, $index); $index++; @@ -59,15 +68,25 @@ if ($device['os'] == 'ibm-amm') { }//end foreach $index = 1; + $state_name = 'ibm-amm_BlowerControllerState'; + $state_descr = 'Blower Controller '; $oids = array( - 'blower1ControllerState' => '.1.3.6.1.4.1.2.3.51.2.2.3.30.0', - 'blower2ControllerState' => '.1.3.6.1.4.1.2.3.51.2.2.3.31.0', - 'blower3ControllerState' => '.1.3.6.1.4.1.2.3.51.2.2.3.32.0', - 'blower4ControllerState' => '.1.3.6.1.4.1.2.3.51.2.2.3.33.0'); - - foreach ($oids as $state_name => $oid) { + '.1.3.6.1.4.1.2.3.51.2.2.3.30.0', // BLADE-MIB::blower1ControllerState.0 + '.1.3.6.1.4.1.2.3.51.2.2.3.31.0', // BLADE-MIB::blower2ControllerState.0 + '.1.3.6.1.4.1.2.3.51.2.2.3.32.0', // BLADE-MIB::blower3ControllerState.0 + '.1.3.6.1.4.1.2.3.51.2.2.3.33.0', // BLADE-MIB::blower4ControllerState.0 + ); + /* BLADE-MIB: blower1ControllerState + * operational(0), + * flashing(1), + * notPresent(2), + * communicationError(3), + * unknown(255) + */ + foreach ($oids as $oid) { $state = snmp_get($device, $oid, '-Oqv'); + $descr = $state_descr . $index; if (is_numeric($state) && $state != 2) { @@ -76,11 +95,11 @@ if ($device['os'] == 'ibm-amm') { if ($state_index_id) { $states = array( - array($state_index_id,'operational',0,0,0), - array($state_index_id,'flashing',1,1,1), - array($state_index_id,'notPresent',1,2,2), - array($state_index_id,'communicationError',1,3,2), - array($state_index_id,'unknown',1,4,2), + array($state_index_id, 'operational', 1, 0, 0), + array($state_index_id, 'flashing', 1, 1, 1), + array($state_index_id, 'notPresent', 1, 2, -1), + array($state_index_id, 'communicationError', 1, 3, 2), + array($state_index_id, 'unknown', 0, 255, 3), ); foreach($states as $value) { @@ -96,7 +115,7 @@ if ($device['os'] == 'ibm-amm') { }//end if - discover_sensor($valid['sensor'], 'state', $device, $oid, $index, $state_name, $state_name, '1', '1', null, null, null, null, $state, 'snmp', $index); + discover_sensor($valid['sensor'], 'state', $device, $oid, $index, $state_name, $descr, '1', '1', null, null, null, null, $state, 'snmp', $index); //Create Sensor To State Index create_sensor_to_state_index($device, $state_name, $index); $index++; @@ -105,4 +124,57 @@ if ($device['os'] == 'ibm-amm') { }//end foreach + $index = 1; + $state_name = 'ibm-amm_PowerModuleState'; + $state_descr = 'Power Module '; + $powerModuleStateOid= '.1.3.6.1.4.1.2.3.51.2.2.4.1.1.3'; // BLADE-MIB::powerModuleState + $data = snmpwalk_cache_oid_num($device, $powerModuleStateOid, array()); + + /* BLADE-MIB: powerModuleState + * unknown(0), + * good(1), + * warning(2), + * notAvailable(3), + * critical(4) + */ + foreach ($data as $oid => $array) { + $state = current($array); // get the first (and only) item from the array + $descr = $state_descr . $index; + + if (is_numeric($state) && $state != 3) { + + $state_index_id = create_state_index($state_name); + + if ($state_index_id) { + + $states = array( + array($state_index_id, 'unknown', 0, 0, 3), + array($state_index_id, 'good', 1, 1, 0), + array($state_index_id, 'warning', 1, 2, 1), + array($state_index_id, 'notAvailable', 1, 3, -1), + array($state_index_id, 'critical', 1, 4, 2), + ); + + foreach ($states as $value) { + $insert = array( + 'state_index_id' => $value[0], + 'state_descr' => $value[1], + 'state_draw_graph' => $value[2], + 'state_value' => $value[3], + 'state_generic_value' => $value[4] + ); + dbInsert($insert, 'state_translations'); + }//end foreach + + }//end if + + discover_sensor($valid['sensor'], 'state', $device, $oid, $index, $state_name, $descr, '1', '1', null, null, + null, null, $state, 'snmp', $index); + //Create Sensor To State Index + create_sensor_to_state_index($device, $state_name, $index); + $index++; + + }//end if + }//end foreach + }//end if diff --git a/includes/discovery/sensors/temperatures/ibm-amm.inc.php b/includes/discovery/sensors/temperatures/ibm-amm.inc.php index 45becf70e7..fc27f27f37 100644 --- a/includes/discovery/sensors/temperatures/ibm-amm.inc.php +++ b/includes/discovery/sensors/temperatures/ibm-amm.inc.php @@ -11,7 +11,7 @@ */ if ($device['os'] == 'ibm-amm') { - $oid = 'BLADE-MIB::mmTemp.0'; + $oid = '.1.3.6.1.4.1.2.3.51.2.2.1.1.2.0'; // BLADE-MIB::mmTemp.0 $mmtemp = snmp_get($device, $oid, '-Oqv'); preg_match('/[\d\.]+/', $mmtemp, $temp_response); @@ -28,7 +28,7 @@ if ($device['os'] == 'ibm-amm') { discover_sensor($valid['sensor'], 'temperature', $device, $oid, $oid, 'ibm-amm', $descr, $divisor, '1', null, null, null, null, $current); } - $oid = 'BLADE-MIB::frontPanelTemp.0'; + $oid = '.1.3.6.1.4.1.2.3.51.2.2.1.5.1.0'; // BLADE-MIB::frontPanelTemp.0 $fptemp = snmp_get($device, $oid, '-Oqv'); preg_match('/[\d\.]+/', $fptemp, $temp_response);