Skip to content

Commit 65dea3a

Browse files
committed
Get process age metric
1 parent 9384353 commit 65dea3a

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

process_mon.sh

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,17 @@
4646
# return new AlarmStatus(CRITICAL, 'Process not running.');
4747
# }
4848
#
49+
# if (metric['process_age'] > 86400) {
50+
# return new AlarmStatus(WARNING, 'Process has been running for over 24 hours.');
51+
# }
52+
#
4953
# return new AlarmStatus(OK, 'Process running normally.');
5054

5155
function help {
5256

5357
cat <<HELP
5458
55-
SYNOPSIS: ./process_mon.sh [process]...
59+
SYNOPSIS: ./process_mon.sh [process]...
5660
USAGE EXAMPLE: ./process_mon.sh lsync
5761
5862
HELP
@@ -64,4 +68,12 @@ if [ -z "$1" ]; then
6468
fi
6569

6670
process_check=`ps ax | grep -v grep | grep -v process_mon | grep -c "$1"`
71+
if (( $process_check > 0 )); then
72+
process_age=`ps -o etimes= -p "$process_check"`
73+
process_age=${process_age## }
74+
fi
75+
6776
echo "metric process_mon int $process_check"
77+
echo "metric process_age int ${process_age:-0}"
78+
79+
exit 0

0 commit comments

Comments
 (0)