5 PIDFILE
=$OMD_ROOT/tmp
/run
/mkeventd
/pid
6 STATUS_SOCKET
=$OMD_ROOT/tmp
/run
/mkeventd
/status
7 DAEMON
=$OMD_ROOT/bin
/mkeventd
8 STATEFILE
=$OMD_ROOT/var
/mkeventd
/status
9 THE_PID
=$
(cat $PIDFILE 2>/dev
/null
)
13 .
$OMD_ROOT/etc
/omd
/site.conf
14 if [ "$CONFIG_MKEVENTD" != on
] ; then
20 if [ "$CONFIG_MKEVENTD_SYSLOG" = on
] \
21 ||
[ "$CONFIG_MKEVENTD_SYSLOG_TCP" = on
] \
22 ||
[ "$CONFIG_MKEVENTD_SNMPTRAP" = on
]; then
25 if [ "$CONFIG_MKEVENTD_SYSLOG" = on
]; then
26 ADD_TXT
+='syslog-udp,'
27 OPTS
+=' --syslog --syslog-fd 3'
29 if [ "$CONFIG_MKEVENTD_SYSLOG_TCP" = on
]; then
30 ADD_TXT
+='syslog-tcp,'
31 OPTS
+=' --syslog-tcp --syslog-tcp-fd 4'
33 if [ "$CONFIG_MKEVENTD_SNMPTRAP" = on
]; then
35 OPTS
+=' --snmptrap --snmptrap-fd 5'
38 echo -n "Starting mkeventd (builtin: ${ADD_TXT%*,})..."
39 if kill -0 $THE_PID >/dev
/null
2>&1; then
40 echo 'Already running.'
45 ${DAEMON}_open514
$OPTS
47 echo -n 'Starting mkeventd...'
48 if kill -0 $THE_PID >/dev
/null
2>&1; then
49 echo 'Already running.'
57 echo -n 'Stopping mkeventd...'
58 if [ -z "$THE_PID" ] ; then
61 echo -n "killing $THE_PID..."
62 kill $THE_PID 2>/dev
/null
64 # Only wait for pidfile removal when the signal could be sent
66 while [ -e "$PIDFILE" ] ; do
70 if [ $N -gt 20 ] ; then
71 echo "PID file did not vanish."
76 # Remove the stale pidfile to have a clean state after this
83 $0 stop
&& sleep 1 && $0 start
86 echo -n 'Reloading mkeventd...'
87 if [ -z "$THE_PID" ] ; then
91 echo "killing $THE_PID with SIGHUP..."
97 echo -n 'Checking status of mkeventd...'
98 if [ -z "$THE_PID" ] ; then
99 echo "not running (PID file missing)"
101 elif ! kill -0 $THE_PID ; then
102 echo "not running (PID file orphaned)"
110 if [ -n "$THE_PID" ] && kill -0 $THE_PID ; then
111 echo -n "Flushing current state and history..."
112 result
=$
(echo "COMMAND FLUSH" | unixcat
$STATUS_SOCKET)
113 if [ "$result" = "None" ] ; then
117 echo "ERROR: $result"
121 echo -n "Deleting status and history files..."
122 rm -f $OMD_ROOT/var
/mkeventd
/{status
,master_config
,slave_status
,history
/*}
128 echo "Usage: $0 {start|stop|restart|reload|status|flush}"