2
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2018-11-08 00:59:34 +01:00

Lots of small cleanups

This commit is contained in:
Diver 2017-01-26 18:13:12 +03:00
parent 5868867e4b
commit 72bdea8bb1
2 changed files with 26 additions and 22 deletions

View file

@ -145,6 +145,10 @@ export LANG=C
. "$MUNIN_LIBDIR/plugins/plugin.sh" . "$MUNIN_LIBDIR/plugins/plugin.sh"
cs_addr=""
username=""
blockpw=""
TARGET=$(echo "${0##*/}" | cut -d _ -f 6) TARGET=$(echo "${0##*/}" | cut -d _ -f 6)
# "All Storage Processors we have" # "All Storage Processors we have"
@ -160,9 +164,9 @@ else
NAVICLI="/nas/sbin/navicli" NAVICLI="/nas/sbin/navicli"
fi fi
# Prints "10" on stdout if found Primary Online control station. "11" - for Secondary Online control station.
ssh_check_cmd() { ssh_check_cmd() {
ssh -q $username@$1 "/nasmcd/sbin/getreason | grep -w slot_\`/nasmcd/sbin/t2slot\` | cut -d- -f1" ssh -q "$username@$1" '/nasmcd/sbin/getreason | grep -w "slot_$(/nasmcd/sbin/t2slot)" | cut -d- -f1'
} }
@ -204,8 +208,8 @@ check_conf_and_set_vars () {
fi fi
local probe_sp local probe_sp
for probe_sp in $SPALL; do for probe_sp in $SPALL; do
if $SSH $NAVICLI -h $probe_sp >/dev/null 2>&1; then if $SSH $NAVICLI -h "$probe_sp" >/dev/null 2>&1; then
StorageProcessor=$probe_sp StorageProcessor="$probe_sp"
break break
fi fi
done done
@ -240,8 +244,7 @@ run_navicli() {
} }
# Get Lun List # Get Lun List
LUNLIST=$(run_navicli lun -list -drivetype | sed -ne 's/^Name:\ *//p') LUNLIST=$(run_navicli lun -list -drivetype | sed -ne 's/^Name:\ *//p' | sort)
echo "${TARGET}"
echo "host_name ${TARGET}" echo "host_name ${TARGET}"
echo echo

View file

@ -134,8 +134,12 @@ export LANG=C
. "$MUNIN_LIBDIR/plugins/plugin.sh" . "$MUNIN_LIBDIR/plugins/plugin.sh"
nas_server_ok=""
cs_addr=""
username=""
# Prints "10" on stdout if found Primary Online control station. "11" - for Secondary Online control station.
ssh_check_cmd() { ssh_check_cmd() {
ssh -q $username@$1 "/nasmcd/sbin/getreason | grep -w slot_\`/nasmcd/sbin/t2slot\` | cut -d- -f1" ssh -q "$username@$1" '/nasmcd/sbin/getreason | grep -w "slot_$(/nasmcd/sbin/t2slot)" | cut -d- -f1'
} }
check_conf () { check_conf () {
@ -183,8 +187,7 @@ fi
STATSTYPE=$(echo "${0##*/}" | cut -d _ -f 1-5) STATSTYPE=$(echo "${0##*/}" | cut -d _ -f 1-5)
if [ "$STATSTYPE" = "emc_vnx_file_nfs_stats" ]; then STATSTYPE=NFS; if [ "$STATSTYPE" = "emc_vnx_file_nfs_stats" ]; then STATSTYPE=NFS;
elif [ "$STATSTYPE" = "emc_vnx_file_basicdm_stats" ]; then STATSTYPE=BASICDM; elif [ "$STATSTYPE" = "emc_vnx_file_basicdm_stats" ]; then STATSTYPE=BASICDM;
else echo "Do not know what to do. Name the plugin as 'emc_vnx_file_nfs_stats_<HOSTNAME>' or 'emc_vnx_file_basicdm_stats_<HOSTNAME>'"; exit 1; fi else echo "Do not know what to do. Name the plugin as 'emc_vnx_file_nfs_stats_<HOSTNAME>' or 'emc_vnx_file_basicdm_stats_<HOSTNAME>'" >&2; exit 1; fi
# echo $STATSTYPE
TARGET=$(echo "${0##*/}" | cut -d _ -f 6) TARGET=$(echo "${0##*/}" | cut -d _ -f 6)
: ${nas_servers:="server_2 server_3"} : ${nas_servers:="server_2 server_3"}
@ -192,18 +195,17 @@ TARGET=$(echo "${0##*/}" | cut -d _ -f 6)
check_conf 1>&2 || exit 1 check_conf 1>&2 || exit 1
run_remote () { run_remote () {
ssh -q "$username@$PRIMARY_CS" ". /home/""$username""/.bash_profile; $*" ssh -q "$username@$PRIMARY_CS" ". /home/$username/.bash_profile; $*"
} }
echo "host_name ${TARGET}" echo "host_name ${TARGET}"
if [ "$1" = "config" ] ; then if [ "$1" = "config" ] ; then
for server in $nas_servers; do for server in $nas_servers; do
run_remote nas_server -i $server | grep -q 'type *= nas' run_remote nas_server -i "$server" | grep -q 'type *= nas' || continue
if [ "$?" != 0 ] ; then continue; fi
nas_server_ok=TRUE nas_server_ok=TRUE
if [ $STATSTYPE = "BASICDM" ] ; then if [ "$STATSTYPE" = "BASICDM" ] ; then
cat <<-EOF cat <<-EOF
multigraph emc_vnx_cpu_percent multigraph emc_vnx_cpu_percent
graph_title EMC VNX 5300 Datamover CPU Util % graph_title EMC VNX 5300 Datamover CPU Util %
@ -272,7 +274,7 @@ if [ "$1" = "config" ] ; then
${server}_used.label Used Entries ${server}_used.label Used Entries
EOF EOF
fi fi
if [ $STATSTYPE = "NFS" ] ; then if [ "$STATSTYPE" = "NFS" ] ; then
#nfs.v3.op data #nfs.v3.op data
# [nasadmin@mnemonic0 ~]$ server_stats server_2 -info nfs.v3.op # [nasadmin@mnemonic0 ~]$ server_stats server_2 -info nfs.v3.op
# server_2 : # server_2 :
@ -426,17 +428,16 @@ if [ "$1" = "config" ] ; then
done done
fi fi
done done
if [ -z $nas_server_ok ]; then if [ -z "$nas_server_ok" ]; then
echo "No active data movers!" 1>&2 echo "No active data movers!" 1>&2
fi fi
exit 0 exit 0
fi fi
for server in $nas_servers; do for server in $nas_servers; do
run_remote nas_server -i $server | grep -q 'type *= nas' run_remote nas_server -i $server | grep -q 'type *= nas' || continue
if [ "$?" != 0 ] ; then continue; fi
nas_server_ok=TRUE nas_server_ok=TRUE
if [ $STATSTYPE = "BASICDM" ] ; then if [ "$STATSTYPE" = "BASICDM" ] ; then
#basicdm data #basicdm data
# [nasadmin@mnemonic0 ~]$ server_stats server_2 -count 1 -terminationsummary no # [nasadmin@mnemonic0 ~]$ server_stats server_2 -count 1 -terminationsummary no
# server_2 CPU Network Network dVol dVol # server_2 CPU Network Network dVol dVol
@ -489,7 +490,7 @@ for server in $nas_servers; do
fi fi
if [ $STATSTYPE = "NFS" ] ; then if [ "$STATSTYPE" = "NFS" ] ; then
#nfs.v3.op data #nfs.v3.op data
# [nasadmin@mnemonic0 ~]$ server_stats server_2 -monitor nfs.v3.op -count 1 -terminationsummary no # [nasadmin@mnemonic0 ~]$ server_stats server_2 -monitor nfs.v3.op -count 1 -terminationsummary no
# server_2 NFS Op NFS NFS Op NFS NFS Op % # server_2 NFS Op NFS NFS Op NFS NFS Op %
@ -625,7 +626,7 @@ for server in $nas_servers; do
done done
fi fi
done done
if [ -z $nas_server_ok ]; then if [ -z "$nas_server_ok" ]; then
echo "No active data movers!" 1>&2 echo "No active data movers!" 1>&2
fi fi
exit 0 exit 0