File: ps_.in

package info (click to toggle)
munin 1.2.3-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 1,940 kB
  • ctags: 98
  • sloc: sh: 4,215; makefile: 452; perl: 135
file content (80 lines) | stat: -rwxr-xr-x 1,905 bytes parent folder | download | duplicates (2)
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/bin/sh
#
# Wildcard-script to monitor number of processes. To monitor a
# program, link ps_<program> to this file. E.g.
#
#    ln -s /usr/share/munin/node/plugins-auto/ps_ /etc/munin/node.d/ps_exim
#
# ...will monitor number of exim-processes.
#
# Parameters:
#
# 	config   (required)
# 	autoconf (optional - used by munin-config)
# 	suggest  (optional - used by munin-config)
#
# Configuration variables
#
#   regex - regex to use for filtering pgrep/ps output
#
# $Log$
# Revision 1.4  2004/05/20 13:57:12  jimmyo
# Set categories to some of the plugins.
#
# Revision 1.3  2004/01/29 19:39:00  jimmyo
# Generic plugins now use printf instead of echo -n, as this is more portable (SF#885564)
#
# Revision 1.2  2004/01/29 18:43:20  jimmyo
# Changed wildcard plugin ps_ so it can use env.regex in plugin-conf.d/ (SF#882131)
#
# Revision 1.1  2004/01/02 18:50:00  jimmyo
# Renamed occurrances of lrrd -> munin
#
# Revision 1.1.1.1  2004/01/02 15:18:07  jimmyo
# Import of LRRD CVS tree after renaming to Munin
#
# Revision 1.2  2003/11/07 17:43:16  jimmyo
# Cleanups and log entries
#
#
#
# Magic markers (optional):
#%# family=auto
#%# capabilities=autoconf suggest


myname=`basename $0 | sed 's/^ps_//g'`

name="${name-\<$myname\>}"
REGEX="${regex-\<$name\>}"

if [ "$1" = "autoconf" ]; then
	echo yes
	exit 0
fi

if [ "$1" = "suggest" ]; then
	exit 0
fi

if [ "$1" = "config" ]; then

	echo graph_title Number of $myname processes
	echo 'graph_args --base 1000 --vertical-label processes -l 0'
	echo 'graph_category processes'
	echo "count.label $myname"
	echo 'processes.draw LINE2'
	exit 0
fi

printf "count.value "

PGREP=`which pgrep`
if [ -n "$PGREP" ]; then
	$PGREP -f -l "$name" | grep "$REGEX" | wc -l
elif [ -x /usr/ucb/ps ]; then
	# Solaris without pgrep. How old is that?
	/usr/ucb/ps auxwww | grep "$REGEX" | grep -v grep | wc -l
else
	ps auxwww | grep "$REGEX" | grep -v grep | wc -l
fi