File: start_process.cmd.in

package info (click to toggle)
nagios-plugin-check-multi 0.26-3.1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 1,156 kB
  • ctags: 37
  • sloc: perl: 2,296; makefile: 415; sh: 239
file content (27 lines) | stat: -rw-r--r-- 827 bytes parent folder | download | duplicates (7)
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
#
# start_proc.cmd
#
# (c) Matthias Flacke, 5.4.2008
# 
# starts process if not already started and checks result
#
# check_multi -f start_process.cmd -s PROC=<process> -s ARGS=<args>
#
# 1. check for process
command [ proc_before ] = check_procs -c 1: -C "$PROC$" -a "$ARGS$"
#
# 2. start process in background
eeval [ start_proc ] = \
	( $STATE_proc_before$ != 0 ) \
		? ( system("$PROC$ $ARGS$ &") != 0 ) \
			? "- failed: $?" \
			: "- done" \
		:  "- not necessary, already running"
#
# 3. check process again (ok, maybe redundant ;-))
command [ proc_after ] = check_procs -c 1: -C "$PROC$" -a "$ARGS$"
#
# 4. state evaluation
state [ OK       ] = proc_before == OK     && proc_after == OK
state [ WARNING  ] = proc_before != OK     && proc_after == OK
state [ CRITICAL ] = start_proc =~/failed/ || proc_after == CRITICAL