~ubuntu-branches/ubuntu/saucy/munin/saucy

« back to all changes in this revision

Viewing changes to plugins/node.d/processes.in

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2012-06-11 12:54:28 UTC
  • mfrom: (8.1.30 sid)
  • Revision ID: package-import@ubuntu.com-20120611125428-k8z25s77rp755vxe
Tags: 2.0.0-1ubuntu1
* Resync with Debian unstable.
* d/munin-node.upstart,munin.upstart: Add upstart configurations.

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
 
6
6
=head1 NAME
7
7
 
8
 
processes - Plugin to monitor processes on Linux FreeBSD, OpenBSD, NetBSD,
9
 
Solaris and OSX.
 
8
processes - Plugin to monitor processes and process states.
10
9
 
11
10
=head1 ABOUT
12
11
 
67
66
[ $ps ]      || ps="ps"
68
67
 
69
68
# Find operating system
70
 
[ $OPERSYS ] || OPERSYS=`uname` || exit 1
 
69
[ $OPERSYS ] || OPERSYS=`uname | cut -f 1 -d _` || exit 1
71
70
 
72
71
if [ "$1" = "autoconf" ]; then
 
72
        case "$OPERSYS" in
 
73
        Linux|SunOS|FreeBSD|OpenBSD|NetBSD|Darwin|CYGWIN)
 
74
        $ps >/dev/null 2>/dev/null
 
75
        if [ $? -ne 0 ]
 
76
        then
 
77
            echo "no (ps=$ps failed)"
 
78
            exit 0
 
79
        fi
 
80
        echo | $awk '{ print "Hei" }' >/dev/null 2>/dev/null
 
81
        if [ $? -ne 0 ]
 
82
        then
 
83
            echo "no (awk=$awk failed)"
 
84
            exit 0
 
85
        fi
73
86
        echo yes
74
87
        exit 0
 
88
        ;;
 
89
        *)
 
90
        echo "no (unknown OS)"
 
91
        exit 0
 
92
        ;;
 
93
        esac
75
94
fi
76
95
 
77
96
. $MUNIN_LIBDIR/plugins/plugin.sh
196
215
        echo "sleeping.info The number of processes that are sleeping for less than about 20 seconds."
197
216
        print_warning sleeping
198
217
        print_critical sleeping
199
 
    else
 
218
    elif [ "$OPERSYS" = "Linux" ] || [ "$OPERSYS" = "SunOS" ]; then
200
219
        echo "sleeping.label sleeping"
201
220
        echo "sleeping.draw AREA"
202
221
        echo "sleeping.colour $SLEEPING"
215
234
        print_critical uninterruptible
216
235
    fi
217
236
 
218
 
    # Common flags
219
 
    echo "zombie.label zombie"
220
 
    echo "zombie.draw STACK"
221
 
    echo "zombie.colour $ZOMBIE"
222
 
    echo "zombie.info The number of defunct ("zombie") processes (process terminated and parent not waiting)."
223
 
    print_warning zombie
224
 
    print_critical zombie
225
 
 
226
 
    echo "stopped.label stopped"
227
 
    echo "stopped.draw STACK"
228
 
    echo "stopped.colour $STOPPED"
229
 
    echo "stopped.info The number of stopped or traced processes."
230
 
    print_warning stopped
231
 
    print_critical stopped
232
 
 
233
 
    echo "runnable.label runnable"
234
 
    echo "runnable.draw STACK"
235
 
    echo "runnable.colour $RUNNABLE"
236
 
    echo "runnable.info The number of runnable processes (on the run queue)."
237
 
    print_warning runnable
238
 
    print_critical runnable
 
237
    # Common (non-cygwin) flags
 
238
    if [ "$OPERSYS" != "CYGWIN" ]; then
 
239
        echo "zombie.label zombie"
 
240
        echo "zombie.draw STACK"
 
241
        echo "zombie.colour $ZOMBIE"
 
242
        echo "zombie.info The number of defunct ("zombie") processes (process terminated and parent not waiting)."
 
243
        print_warning zombie
 
244
        print_critical zombie
 
245
 
 
246
        echo "stopped.label stopped"
 
247
        echo "stopped.draw STACK"
 
248
        echo "stopped.colour $STOPPED"
 
249
        echo "stopped.info The number of stopped or traced processes."
 
250
        print_warning stopped
 
251
        print_critical stopped
 
252
 
 
253
        echo "runnable.label runnable"
 
254
        echo "runnable.draw STACK"
 
255
        echo "runnable.colour $RUNNABLE"
 
256
        echo "runnable.info The number of runnable processes (on the run queue)."
 
257
        print_warning runnable
 
258
        print_critical runnable
 
259
    fi
239
260
 
240
261
    if [ "$OPERSYS" != "SunOS" ]; then
241
262
        # Not using 'graph_total' due to backwards compability. SunOS uses 'total'.
331
352
print "stopped.value "          0+stat["T"];
332
353
print "zombie.value "           0+stat["Z"];
333
354
}'
 
355
 
 
356
elif [ "$OPERSYS" = "CYGWIN" ]; then
 
357
    # First line is header. Remove it. Also remove WINPID duplicates.
 
358
    $ps -aW | sed '1d' | cut -c 30-36 | sort -u | $awk '
 
359
{ processes++; }
 
360
END {
 
361
print "processes.value "        0+processes;
 
362
}'
 
363
 
334
364
fi