mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-25 02:18:08 +00:00
Cleaning code
This commit is contained in:
parent
a8e1084bb8
commit
e889ffd037
2 changed files with 91 additions and 54 deletions
|
@ -93,35 +93,51 @@ 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"'
|
||||
|
||||
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 ('username' environment variable)!"
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ -z "$cs_addr" ]; then
|
||||
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 "$(ssh_check $CS)" ]]; then
|
||||
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
|
||||
echo "yes"
|
||||
exit 0
|
||||
check_conf_ans=$(check_conf)
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "yes"
|
||||
else
|
||||
echo "no ($check_conf_ans)"
|
||||
fi
|
||||
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;
|
||||
check_conf
|
||||
if [[ $? -eq 1 ]]; then
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
SSH="ssh -q $username@$PRIMARY_CS "
|
||||
|
@ -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"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue