File: processes.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 (90 lines) | stat: -rwxr-xr-x 2,176 bytes parent folder | download | duplicates (3)
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
81
82
83
84
85
86
87
88
89
90
#!@@PERL@@
#
# Plugin to monitor the number of processes on the machine. Using
# "ps | wc -l".
#
#   DESCRIPTION
#   ===========
#      This will report back the number of processes currently running
#      on a server.  By defualt it will report back the total number of
#      processes running (global).  Optionally you can edit the script
#      and add items to look for to the "lookFor" array.  These should
#      be simple things that can be grep'd for.
#      
#   RESCTRICTIONS
#   =============
#      None known.  /usr/bin/ps should be executable by everyone by default.
#
# Optionally you can add items to the lookFor array, and those items will
# be graphed as well.  This can be useful for watching how many processes
# of a particular type are running.
#
# $Log$
# 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
#
#
#
# Parameters:
#
# 	config   (required)
# 	autoconf (optional - used by munin-config)
#
# Magick markers (optional - used by munin-config and some installation
# scripts):
#%# family=contrib
#%# capabilities=autoconf

use strict;


my(@lookFor) = ("root");

if($ARGV[0] && $ARGV[0] eq "autoconf")
  {
    if(-e "/usr/bin/ps" && -X "/usr/bin/ps")
      {
        print "yes\n";
        exit 0;
      }
    else
      {
        print "no\n";
        exit 1;
      }
  }

my($item);  
if($ARGV[0] && $ARGV[0] eq "config")
  {
    print "graph_title Number of Processes\n";
    print "graph_args --base 1000 -l 0 \n";
    print "graph_vlabel number of processes\n";
    print "global.label global\n";
    print "global.draw LINE2\n";
    
    foreach $item (@lookFor)
      {
        print "$item.label $item\n";
        print "$item.draw LINE2\n";
      }
  }
 
my($procNum); 
foreach $item (@lookFor)
  {
    $procNum = `/usr/bin/ps -ef|grep $item|grep -v grep |wc -l`;
    chomp($procNum);
    
    print "$item.value $procNum\n";
  }
  
$procNum = `/usr/bin/ps -ef|grep -v grep|wc -l`;
chomp($procNum);
print "global.value $procNum\n";