File: multips.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 (61 lines) | stat: -rw-r--r-- 1,283 bytes parent folder | download
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
#!/bin/sh
#
# Script to monitor number of processes. Programs are configured
# in client-conf.d
#
# Parameters:
#
# 	config   (required)
# 	autoconf (optional - used by lrrd-config)
#
# Configuration example
#
# [multips]
# env.names pop3d imapd sslwrap
# env.regex_imapd ^[0-9]* imapd:
# env.regex_pop3d ^[0-9]* pop3d:
# 
# $Log$
# Revision 1.1  2004/01/29 19:42:45  jimmyo
# Added a new plugin generic/multips to count several procs in one graph. (SF#885579)
#
#
# Magic markers (optional):
#%# family=manual
#%# capabilities=autoconf

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

if [ -z "$names" ]; then
  echo "Configuration required"
  exit 1
fi

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

	echo graph_title Number of selected processes
	echo 'graph_args --base 1000 --vertical-label processes -l 0'
	for name in $names; do
		echo "$name.label $name"
		echo "$name.draw LINE2"
	done
	exit 0
fi

for name in $names; do
	printf "$name.value "

	eval REGEX='"${regex_'$name'-\<'$name'\>}"'
	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
done