forked from danievanzyl/nagios_check_scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
check_activemq.sh
62 lines (56 loc) · 1.04 KB
/
check_activemq.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
#!/bin/bash
#
# author: danievanzyl (https://github.com/danievanzyl)
# version: 1.0
# license: http://www.apache.org/licenses/LICENSE-2.0.html
# read changelog for most up-to-date changes
##########################
#Global Variables
exit_status=-1
STATUS[0]="OK - "
STATUS[1]="WARNING - "
STATUS[2]="CRITICAL - "
STATUS[3]="UNKNOWN - "
activemq_user=activemq
LOCK=/opt/viamedia/activemq/data/kahadb/lock
#Functions
#
function check_lock {
fuser -s $LOCK &> /dev/null
return $?
}
function check_proc {
local _proc
_proc=$(ps hU ${activemq_user} |awk '{print $1}')
if [ -z "$_proc" ];then
return 1
else
echo $_proc
return 0
fi
}
function main {
#catch output
pid=$(check_proc)
#check return val
if [ "$?" -eq "1" ]; then
msg="No running process found!"
exit_status=2
else
check_lock
#check return val
if [ "$?" -eq "0" ];then
msg="Master running with pid: $pid"
else
msg="Slave idling with pid: $pid"
fi
exit_status=0
fi
echo ${STATUS[$exit_status]} $msg
exit $exit_status
}
#
#EOFunctions
#run main function
#
main