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

Cleaning code

This commit is contained in:
Diver 2016-12-26 22:08:26 +03:00
parent a8e1084bb8
commit e889ffd037
2 changed files with 91 additions and 54 deletions

View File

@ -93,27 +93,26 @@ export LANG=C
TARGET=$(echo "${0##*/}" | cut -d _ -f 6)
SPALL="SPA SPB"
NAVICLI="/nas/sbin/navicli"
SSH_CHECK='ssh -q $username@$CS "/nasmcd/sbin/getreason | grep -w slot_\`/nasmcd/sbin/t2slot\` | cut -d- -f1"'
if [ "$1" = "autoconf" ]; then
echo "yes"
exit 0
fi
ssh_check() {
ssh -q $username@$1 "/nasmcd/sbin/getreason | grep -w slot_\`/nasmcd/sbin/t2slot\` | cut -d- -f1"
}
check_conf () {
if [ -z "$username" ]; then
echo "No username!"
exit 1
echo "No username ('username' environment variable)!"
return 1
fi
if [ -z "$cs_addr" ]; then
echo "No control station addresses!"
exit 1
echo "No control station addresses ('cs_addr' environment variable)!"
return 1
fi
#Choosing Cotrol Station. Code have to be "10"
for CS in $cs_addr; do
if [[ "10" -eq "$(eval $SSH_CHECK)" ]]; then
# echo "$CS is Primary"
if [[ "10" -eq "$(ssh_check $CS)" ]]; then
PRIMARY_CS=$CS
break
fi
@ -121,6 +120,23 @@ done
if [ -z "$PRIMARY_CS" ]; then
echo "No alive primary Control Station from list \"$cs_addr\"";
return 1
fi
return 0
}
if [ "$1" = "autoconf" ]; then
check_conf_ans=$(check_conf)
if [ $? -eq 0 ]; then
echo "yes"
else
echo "no ($check_conf_ans)"
fi
exit 0
fi
check_conf
if [[ $? -eq 1 ]]; then
exit 1;
fi
@ -137,7 +153,6 @@ fi
NAVICLI="/nas/sbin/navicli -h $SP"
# Get Lun List
#LUNLIST="$($SSH $NAVICLI lun -list -drivetype | grep Name | sed -ne 's/^Name:\ *//p')"
LUNLIST="$($SSH $NAVICLI lun -list -drivetype | sed -ne 's/^Name:\ *//p')"
echo -e "host_name ${TARGET}\n"

View File

@ -17,7 +17,7 @@
=head1 MAGIC MARKERS
#%# family=auto
#%# capabilities=autoconf
#%# capabilities=autoconf suggest
=head1 DESCRIPTION
@ -81,34 +81,24 @@
export LANG=C
STATSTYPE=$(echo "${0##*/}" | cut -d _ -f 1-5)
if [ $STATSTYPE = "emc_vnx_file_nfs_stats" ]; then STATSTYPE=NFS;
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
# echo $STATSTYPE
TARGET=$(echo "${0##*/}" | cut -d _ -f 6)
: ${nas_servers:="server_2 server_3"}
SSH_CHECK='ssh -q $username@$CS "/nasmcd/sbin/getreason | grep -w slot_\`/nasmcd/sbin/t2slot\` | cut -d- -f1"'
if [ "$1" = "autoconf" ]; then
echo "yes"
exit 0
fi
ssh_check() {
ssh -q $username@$1 "/nasmcd/sbin/getreason | grep -w slot_\`/nasmcd/sbin/t2slot\` | cut -d- -f1"
}
check_conf () {
if [ -z "$username" ]; then
echo "No username!"
exit 1
return 1
fi
if [ -z "$cs_addr" ]; then
echo "No control station addresses!"
exit 1
return 1
fi
#Choosing Cotrol Station. Code have to be "10"
for CS in $cs_addr; do
if [[ "10" -eq "$(eval $SSH_CHECK)" ]]; then
if [[ "10" -eq "$(ssh_check $CS)" ]]; then
# echo "$CS is Primary"
PRIMARY_CS=$CS
break
@ -117,6 +107,38 @@ done
if [ -z "$PRIMARY_CS" ]; then
echo "No alive primary Control Station from list \"$cs_addr\"";
return 1
fi
return 0
}
if [ "$1" = "autoconf" ]; then
check_conf_ans=$(check_conf)
if [ $? -eq 0 ]; then
echo "yes"
else
echo "no ($check_conf_ans)"
fi
exit 0
fi
if [ "$1" = "suggest" ]; then
echo "nfs_stats"
echo "basicdm_stats"
exit 0;
fi
STATSTYPE=$(echo "${0##*/}" | cut -d _ -f 1-5)
if [ $STATSTYPE = "emc_vnx_file_nfs_stats" ]; then STATSTYPE=NFS;
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
# echo $STATSTYPE
TARGET=$(echo "${0##*/}" | cut -d _ -f 6)
: ${nas_servers:="server_2 server_3"}
check_conf
if [[ $? -eq 1 ]]; then
exit 1;
fi