This repository has been archived by the owner on Apr 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathcheck_puppet
executable file
·60 lines (55 loc) · 1.88 KB
/
check_puppet
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
#!/bin/sh
# ABOUT
#
# Small script to check if there is a Puppet pid file and if Puppet did an update recently
# Written by Filip Van Tittelboom (filip@ilibris.be)
#
# CONFIG
#
if [ -d "/var/run/puppetlabs" ]; then
PUPPET_RUN_PATH=/var/run/puppetlabs
else
PUPPET_RUN_PATH=/var/run/puppet
fi
if [ -d "/opt/puppetlabs/puppet/cache/state" ]; then
PUPPET_STATE_PATH=/opt/puppetlabs/puppet/cache/state
else
PUPPET_STATE_PATH=/var/lib/puppet/state
fi
PATH_CLIENTPID=$PUPPET_RUN_PATH/agent.pid
PATH_MASTERPID=$PUPPET_RUN_PATH/master.pid
PATH_STATE=$PUPPET_STATE_PATH/state.yaml
WARNING=7200
CRITICAL=10800
if [ ! -e $1 ]; then
if [ $1 = "server" ]; then
PATH_PID=$PATH_MASTERPID
NAME_DAEMON="puppet master"
else
PATH_PID=$PATH_CLIENTPID
NAME_DAEMON="puppet agent"
fi
# maybe not daemonized but run as cron?
grep -q "START=no" /etc/default/puppet
if [ $? -eq 0 ] || [ -f $PATH_PID ]; then
NOW=$(date +%s)
FILEMODIF=$(stat -c %Y $PATH_STATE)
let TESTTIMEW=$FILEMODIF+$WARNING
let TESTTIMEC=$FILEMODIF+$CRITICAL
if [ $NOW -gt $TESTTIMEC ]; then
echo -e "CRITICAL - It has been more than $((($NOW-$FILEMODIF)/60)) min since $NAME_DAEMON did an update\0"
exit 2
elif [ $NOW -gt $TESTTIMEW ]; then
echo -e "WARNING - It has been more than $((($NOW-$FILEMODIF)/60)) min since $NAME_DAEMON did an update\0"
exit 1
else
echo -e "OK - $NAME_DAEMON is running and updating\0"
exit 0
fi
else
echo -e "CRITICAL - $NAME_DAEMON is not running\0"
exit 2
fi
else
echo "Usage: $0 [client|server]"
fi