-
Notifications
You must be signed in to change notification settings - Fork 11
/
ckall.sh
107 lines (88 loc) · 1.68 KB
/
ckall.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
#
# (c) 2000 by Antonio Dell'elce
#
# Notice the ESC variable must be set to ^[ i.e. char n. 27!
#
# This script is supposed to work with a Bourne shell variant
# that supports Functions and 'typeset -f'.
#
# ckall_default and ckall_log use AIX commands (errpt)
# ckall itself will work on any unix with the above requirements.
#
#
# Only configuration parameter will be CKHOSTS variable
# It will point to a file containg a list of hosts (our "cluster")
# on which ckall will execute it's "verifications"
#
export CKHOSTS=${CKHOSTS:-$HOME/.ckhosts}
#
# Standard args for a functions
#
# function_name Options Hostname
#
ckall_default ()
{
uptime
return 0
}
#
# Following
#
ckall_log ()
{
[ $(errpt | wc -l | xargs echo) -eq 0 ] && echo "Error log is empty" &&
return 1
typeset LEDT=$(errpt | head -2 | tail -1 | awk '{print $2}'| cut -c1-4)
typeset MONTH=$(echo $LEDT | cut -c1-2)
typeset DAY=$(echo $LEDT | cut -c3-4)
echo "Last error on $MONTH / $DAY (Month/Day)"
}
ckall_testlog ()
{
echo Errpt size : $(errpt | wc -l )
}
#
# - core function - should work any platform -
#
ckall ()
{
typeset PAUSE_FLAG=0
typeset DEFAULT_FUNC=ckall_null
typeset ESC=""
typeset RED="$ESC[31m"
typeset RESET="$ESC[0m"
[ -z "$1" ] &&
{
ACTION=ckall_default
} ||
{
ACTION=ckall_$1
}
case $1 in
-p)
PAUSE_FLAG=1;
shift
;;
*)
esac
[ ! -f "$CKHOSTS" ] &&
{
echo "Missing hosts file"
return
}
for IN in $(cat $CKHOSTS)
do
echo ====== ${RED}$IN${RESET} ======
(cat << EOF
$(typeset -f $ACTION );
$ACTION
EOF
) | rsh $IN ksh
[ "$PAUSE_FLAG" = 1 ] &&
{
echo
printf "%s" Type return to continue.;read
echo
}
done
}