-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfilesystems.sh
executable file
·142 lines (120 loc) · 2.84 KB
/
filesystems.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#!/bin/sh
# FILE: "check_fs.sh"
# DESCRIPTION: Check VNX filesystems
# REQUIRES:
# AUTHOR: Toni Comerma
# DATE: mar-2013
# $Id:$
#
PROGNAME=`readlink -f $0`
PROGPATH=`echo $PROGNAME | sed -e 's,[\\/][^\\/][^\\/]*$,,'`
export NAS_DB=/nas
print_usage() {
echo "Usage:"
echo " $PROGNAME -v <virt> -f <phys> -s <server> "
echo " $PROGNAME -h "
}
print_help() {
print_revision $PROGNAME $REVISION
echo ""
print_usage
echo "checks interface status"
echo ""
echo "Options:"
echo " -v virtual interface to check, both fsn or trunk. Multiple -v allowed o comma separated list"
echo " -p physical interface to check, both fsn or trunk. Multiple -p allowed o comma separated list"
echo " -s server to query (server_2 or server_3 or ALL)"
echo ""
exit $STATE_UNKNOWN
}
STATE_OK=0
STATE_WARNING=1
STATE_CRITICAL=2
STATE_UNKNOWN=3
WARNING=0
CRITICAL=0
TEXT=""
W=75
C=90
# Proces de parametres
while getopts "f:w:c:h" Option
do
case $Option in
f ) F="$OPTARG $F";;
w ) W=$OPTARG;;
c ) C=$OPTARG;;
h ) print_help;;
* ) echo "unimplemented option";;
esac
done
# Ajustar parametres
F=${F//,/ }
F=`echo $F | sed -e 's/^ *//g' -e 's/ *$//g'`
# Checking Control Station Status (primary/standby)
MCDHOME=/nasmcd
RC_CS_IS_STANDBY=11
RC_CS_IS_PRIMARY=10
slot=`$MCDHOME/sbin/t2slot`
peer=$(( $slot == 0 ? 1 : 0 ))
ret=`$MCDHOME/sbin/getreason | grep -w slot_$slot`
rc=`echo $ret | cut -d- -f1`
status=`echo $ret | cut -d- -f2`
if [ $rc -eq $RC_CS_IS_STANDBY ]
then
echo "OK: Standby Control Station - Not Monitoring"
exit $STATE_OK
else
if [ $rc -ne $RC_CS_IS_PRIMARY ]
then
echo "CRITICAL: Unknown Control Station Status (not primary, not standby) take a look"
exit $STATE_CRITICAL
fi
fi
# Check filesystems
for i in $F
do
# Exists?
/nas/bin/nas_fs -info $i | grep Error > /dev/null
if [ $? -eq 0 ]
then
TEXT="$i:Doesn't Exists $TEXT"
CRITICAL=1
else
# Active?
/nas/bin/nas_fs -info $i | grep in_use | grep -i true > /dev/null
if [ $? -eq 1 ]
then
TEXT="$i:INACTIVE $TEXT"
CRITICAL=1
else
# Usage
s=`/nas/bin/nas_fs -info $i -size| grep '^size'`
pct=`echo $s | cut -f 2 -d "(" | cut -f 1 -d "%"`
if [ $pct -ge $C ]
then
TEXT="$i:$pct%(CRIT) $TEXT"
CRITICAL=1
else
if [ $pct -ge $W ]
then
TEXT="$i:$pct%(WARN) $TEXT"
WARNING=1
else
TEXT="$i:$pct% $TEXT"
fi
fi
fi
fi
done
if [ $CRITICAL -eq 1 ]
then
echo "CRITICAL: $TEXT"
exit $STATE_CRITICAL
fi
if [ $WARNING -eq 1 ]
then
echo "WARNING: $TEXT"
exit $STATE_WARNING
fi
echo "OK: $TEXT"
exit $STATE_OK