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:
parent
a8e1084bb8
commit
e889ffd037
2 changed files with 91 additions and 54 deletions
|
@ -93,34 +93,50 @@ export LANG=C
|
||||||
TARGET=$(echo "${0##*/}" | cut -d _ -f 6)
|
TARGET=$(echo "${0##*/}" | cut -d _ -f 6)
|
||||||
SPALL="SPA SPB"
|
SPALL="SPA SPB"
|
||||||
NAVICLI="/nas/sbin/navicli"
|
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
|
ssh_check() {
|
||||||
echo "yes"
|
ssh -q $username@$1 "/nasmcd/sbin/getreason | grep -w slot_\`/nasmcd/sbin/t2slot\` | cut -d- -f1"
|
||||||
exit 0
|
}
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -z "$username" ]; then
|
|
||||||
echo "No username!"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -z "$cs_addr" ]; then
|
check_conf () {
|
||||||
echo "No control station addresses!"
|
if [ -z "$username" ]; then
|
||||||
exit 1
|
echo "No username ('username' environment variable)!"
|
||||||
fi
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
#Choosing Cotrol Station. Code have to be "10"
|
if [ -z "$cs_addr" ]; then
|
||||||
for CS in $cs_addr; do
|
echo "No control station addresses ('cs_addr' environment variable)!"
|
||||||
if [[ "10" -eq "$(eval $SSH_CHECK)" ]]; then
|
return 1
|
||||||
# echo "$CS is Primary"
|
fi
|
||||||
|
|
||||||
|
#Choosing Cotrol Station. Code have to be "10"
|
||||||
|
for CS in $cs_addr; do
|
||||||
|
if [[ "10" -eq "$(ssh_check $CS)" ]]; then
|
||||||
PRIMARY_CS=$CS
|
PRIMARY_CS=$CS
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ -z "$PRIMARY_CS" ]; then
|
if [ -z "$PRIMARY_CS" ]; then
|
||||||
echo "No alive primary Control Station from list \"$cs_addr\"";
|
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;
|
exit 1;
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -137,7 +153,6 @@ fi
|
||||||
NAVICLI="/nas/sbin/navicli -h $SP"
|
NAVICLI="/nas/sbin/navicli -h $SP"
|
||||||
|
|
||||||
# Get Lun List
|
# 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')"
|
LUNLIST="$($SSH $NAVICLI lun -list -drivetype | sed -ne 's/^Name:\ *//p')"
|
||||||
|
|
||||||
echo -e "host_name ${TARGET}\n"
|
echo -e "host_name ${TARGET}\n"
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
=head1 MAGIC MARKERS
|
=head1 MAGIC MARKERS
|
||||||
|
|
||||||
#%# family=auto
|
#%# family=auto
|
||||||
#%# capabilities=autoconf
|
#%# capabilities=autoconf suggest
|
||||||
|
|
||||||
=head1 DESCRIPTION
|
=head1 DESCRIPTION
|
||||||
|
|
||||||
|
@ -81,6 +81,53 @@
|
||||||
|
|
||||||
export LANG=C
|
export LANG=C
|
||||||
|
|
||||||
|
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!"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$cs_addr" ]; then
|
||||||
|
echo "No control station addresses!"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
#Choosing Cotrol Station. Code have to be "10"
|
||||||
|
for CS in $cs_addr; do
|
||||||
|
if [[ "10" -eq "$(ssh_check $CS)" ]]; then
|
||||||
|
# echo "$CS is Primary"
|
||||||
|
PRIMARY_CS=$CS
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
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)
|
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;
|
||||||
|
@ -89,34 +136,9 @@ else echo "Do not know what to do. Name the plugin as 'emc_vnx_file_nfs_stats_<H
|
||||||
|
|
||||||
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"}
|
||||||
SSH_CHECK='ssh -q $username@$CS "/nasmcd/sbin/getreason | grep -w slot_\`/nasmcd/sbin/t2slot\` | cut -d- -f1"'
|
|
||||||
|
|
||||||
if [ "$1" = "autoconf" ]; then
|
check_conf
|
||||||
echo "yes"
|
if [[ $? -eq 1 ]]; then
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -z "$username" ]; then
|
|
||||||
echo "No username!"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -z "$cs_addr" ]; then
|
|
||||||
echo "No control station addresses!"
|
|
||||||
exit 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"
|
|
||||||
PRIMARY_CS=$CS
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ -z "$PRIMARY_CS" ]; then
|
|
||||||
echo "No alive primary Control Station from list \"$cs_addr\"";
|
|
||||||
exit 1;
|
exit 1;
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue