/usr/share/munin/plugins/processes is in munin-node 1.4.6-3ubuntu3.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 | #!/bin/sh
# -*- sh -*-
: << =cut
=head1 NAME
processes - Plugin to monitor processes on Linux FreeBSD, OpenBSD, NetBSD,
Solaris and OSX.
=head1 ABOUT
This plugin requires munin-server version 1.2.5 or 1.3.3 (or higher).
This plugin is backwards compatible with the old processes-plugins found on
SunOS, Linux and *BSD (i.e. the history is preserved).
All fields have colours associated with them which reflect the type of process
(sleeping/idle = blue, running = green, stopped/zombie/dead = red, etc.)
=head1 CONFIGURATION
No configuration for this plugin.
=head1 AUTHOR
Copyright (C) 2006 Lars Strand
=head1 LICENSE
GNU General Public License, version 2
=begin comment
This file is part of Munin.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; version 2 dated June, 1991.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
Street, Fifth Floor, Boston, MA 02110-1301 USA.
=end comment
=head1 MAGIC MARKERS
=begin comment
These magic markers are used by munin-node-configure when installing
munin-node.
=end comment
#%# family=auto
#%# capabilities=autoconf
=cut
# Search for program in $PATH unless predefined.
[ $awk ] || awk="awk"
[ $ps ] || ps="ps"
# Find operating system
[ $OPERSYS ] || OPERSYS=`uname` || exit 1
if [ "$1" = "autoconf" ]; then
echo yes
exit 0
fi
. $MUNIN_LIBDIR/plugins/plugin.sh
# Define colours
RUNNABLE='22ff22' # Green
SLEEPING='0022ff' # Blue
STOPPED='cc0000' # Darker red
ZOMBIE='990000' # Darkest red
UNINTERRUPTIBLE='ffa500' # Orange
IDLE='4169e1' # Royal blue
PAGING='00aaaa' # Darker turquoise
INTERRUPT='ff00ff' # Fuchsia
LOCK='ff3333' # Lighter red
RUNNING='00ff7f' # Spring green
DEAD='ff0000' # Red
SUSPENDED='ff1493' # Deep pink
TOTAL='c0c0c0' # Silver
# Taken from ps(1)
# R - Linux, SunOS, FreeBSD, OpenBSD, NetBSD, OSX (runable)
# S - Linux, SunOS, FreeBSD*, OpenBSD*, NetBSD*, OSX* (sleeping)
# T - Linux, SunOS, FreeBSD, OpenBSD, NetBSD, OSX (stopped)
# Z - Linux, SunOS, FreeBSD, OpenBSD, NetBSD, OSX (zombie)
# D - Linux, FreeBSD, OpenBSD, NetBSD (uninterruptible)
# I - FreeBSD, OpenBSD, NetBSD, OSX (idle)
# W - Linux*, FreeBSD* (paging/interrupt)
# L - FreeBSD (lock)
# O - SunOS (running)
# X - Linux (dead)
# U - OSX, NetBSD* (uninterruptible/suspended)
# *) Differ meaning
if [ "$1" = "config" ]; then
echo "graph_title Processes"
echo "graph_info This graph shows the number of processes"
echo "graph_category processes"
echo "graph_args --base 1000 -l 0"
echo "graph_vlabel Number of processes"
# OS specific flags
if [ "$OPERSYS" = "Linux" ]; then
echo "graph_order sleeping stopped zombie dead paging uninterruptible runnable processes"
echo "dead.label dead"
echo "dead.draw STACK"
echo "dead.colour $DEAD"
echo "dead.info The number of dead processes."
print_warning dead
print_critical dead
echo "paging.label paging"
echo "paging.draw STACK"
echo "paging.colour $PAGING"
echo "paging.info The number of paging processes (<2.6 kernels only)."
print_warning paging
print_critical paging
elif [ "$OPERSYS" = "SunOS" ]; then
echo "graph_order sleeping stopped zombie runnable running total"
echo "running.label running"
echo "running.draw STACK"
echo "running.colour $RUNNING"
echo "running.info The number of processes that are running on a processor."
print_warning running
print_critical running
# Be backwards compatible.
echo "total.label total"
echo "total.draw LINE1"
echo "total.colour $TOTAL"
echo "total.info The total number of processes."
print_warning total
print_critical total
elif [ "$OPERSYS" = "FreeBSD" ]; then
echo "graph_order sleeping idle stopped zombie lock uninterruptible interrupt runnable processes"
echo "lock.label lock"
echo "lock.draw STACK"
echo "lock.colour $LOCK"
echo "lock.info The number of processes that are waiting to acquire a lock."
print_warning lock
print_critical lock
echo "interrupt.label interrupt"
echo "interrupt.draw STACK"
echo "interrupt.colour $INTERRUPT"
echo "interrupt.info The number of idle interrupt threads."
print_warning interrupt
print_critical interrupt
elif [ "$OPERSYS" = "OpenBSD" ]; then
echo "graph_order sleeping idle stopped zombie uninterruptible runnable processes"
elif [ "$OPERSYS" = "NetBSD" ]; then
echo "graph_order sleeping idle stopped zombie uninterruptible suspended runnable processes"
echo "suspended.label suspended"
echo "suspended.draw STACK"
echo "suspended.colour $SUSPENDED"
echo "suspended.info The number of processes that are suspended."
print_warning suspended
print_critical suspended
elif [ "$OPERSYS" = "Darwin" ]; then
echo "graph_order sleeping idle stopped zombie uninterruptible running processes"
echo "uninterruptible.label uninterruptible"
echo "uninterruptible.draw STACK"
echo "uninterruptible.colour $UNINTERRUPTIBLE"
echo "uninterruptible.info The number of uninterruptible processes (usually IO)."
print_warning uninterruptible
print_critical uninterruptible
fi
# Common flags for some OS
if [ "$OPERSYS" = "FreeBSD" ] || [ "$OPERSYS" = "OpenBSD" ] ||
[ "$OPERSYS" = "NetBSD" ] || [ "$OPERSYS" = "Darwin" ]; then
echo "idle.label idle"
echo "idle.draw STACK"
echo "idle.colour $IDLE"
echo "idle.info The number of processes that are idle (sleeping for longer than about 20 seconds)."
print_warning idle
print_critical idle
echo "sleeping.label sleeping"
echo "sleeping.draw AREA"
echo "sleeping.colour $SLEEPING"
echo "sleeping.info The number of processes that are sleeping for less than about 20 seconds."
print_warning sleeping
print_critical sleeping
else
echo "sleeping.label sleeping"
echo "sleeping.draw AREA"
echo "sleeping.colour $SLEEPING"
echo "sleeping.info The number of sleeping processes."
print_warning sleeping
print_critical sleeping
fi
if [ "$OPERSYS" = "Linux" ] || [ "$OPERSYS" = "FreeBSD" ] ||
[ "$OPERSYS" = "OpenBSD" ] || [ "$OPERSYS" = "NetBSD" ]; then
echo "uninterruptible.label uninterruptible"
echo "uninterruptible.draw STACK"
echo "uninterruptible.colour $UNINTERRUPTIBLE"
echo "uninterruptible.info The number of uninterruptible processes (usually IO)."
print_warning uninterruptible
print_critical uninterruptible
fi
# Common flags
echo "zombie.label zombie"
echo "zombie.draw STACK"
echo "zombie.colour $ZOMBIE"
echo "zombie.info The number of defunct ("zombie") processes (process terminated and parent not waiting)."
print_warning zombie
print_critical zombie
echo "stopped.label stopped"
echo "stopped.draw STACK"
echo "stopped.colour $STOPPED"
echo "stopped.info The number of stopped or traced processes."
print_warning stopped
print_critical stopped
echo "runnable.label runnable"
echo "runnable.draw STACK"
echo "runnable.colour $RUNNABLE"
echo "runnable.info The number of runnable processes (on the run queue)."
print_warning runnable
print_critical runnable
if [ "$OPERSYS" != "SunOS" ]; then
# Not using 'graph_total' due to backwards compability. SunOS uses 'total'.
#echo 'graph_total total'
echo "processes.label total"
echo "processes.draw LINE1"
echo "processes.colour $TOTAL"
echo "processes.info The total number of processes."
print_warning processes
print_critical processes
fi
exit 0
fi
if [ "$OPERSYS" = "Linux" ]; then
$ps --no-header -eo s | $awk '
{ processes++; stat[$1]++ }
END {
print "processes.value " 0+processes;
print "uninterruptible.value " 0+stat["D"];
print "runnable.value " 0+stat["R"];
print "sleeping.value " 0+stat["S"];
print "stopped.value " 0+stat["T"];
print "paging.value " 0+stat["W"];
print "dead.value " 0+stat["X"];
print "zombie.value " 0+stat["Z"];
}'
elif [ "$OPERSYS" = "SunOS" ]; then
$ps -e -o s | $awk '
{ total++; stat[$1]++ }
END {
print "total.value " 0+total;
print "running.value " 0+stat["O"];
print "sleeping.value " 0+stat["S"];
print "runnable.value " 0+stat["R"];
print "stopped.value " 0+stat["T"];
print "zombie.value " 0+stat["Z"];
}'
elif [ "$OPERSYS" = "FreeBSD" ]; then
$ps -axo state= | sed -e 's/^\(.\).*/\1/' | $awk '
{ processes++; stat[$1]++ }
END {
print "processes.value " 0+processes;
print "uninterruptible.value " 0+stat["D"];
print "idle.value " 0+stat["I"];
print "lock.value " 0+stat["G"];
print "runnable.value " 0+stat["R"];
print "sleeping.value " 0+stat["S"];
print "stopped.value " 0+stat["T"];
print "interrupt.value " 0+stat["W"];
print "zombie.value " 0+stat["Z"];
}'
elif [ "$OPERSYS" = "OpenBSD" ]; then
# First line is header. Remove it.
$ps -axo state= | sed '1d' | sed -e 's/^\(.\).*/\1/' | $awk '
{ processes++; stat[$1]++ }
END {
print "processes.value " 0+processes;
print "uninterruptible.value " 0+stat["D"];
print "idle.value " 0+stat["I"];
print "runnable.value " 0+stat["R"];
print "sleeping.value " 0+stat["S"];
print "stopped.value " 0+stat["T"];
print "zombie.value " 0+stat["Z"];
}'
elif [ "$OPERSYS" = "NetBSD" ]; then
# First line is header. Remove it.
$ps -axo state= | sed '1d' | sed -e 's/^\(.\).*/\1/' | $awk '
{ processes++; stat[$1]++ }
END {
print "processes.value " 0+processes;
print "uninterruptible.value " 0+stat["D"];
print "idle.value " 0+stat["I"];
print "suspended.value " 0+stat["U"];
print "runnable.value " 0+stat["R"];
print "sleeping.value " 0+stat["S"];
print "stopped.value " 0+stat["T"];
print "zombie.value " 0+stat["Z"];
}'
elif [ "$OPERSYS" = "Darwin" ]; then
# First line is header. Remove it.
$ps -axo state= | sed '1d' | sed -e 's/^\(.\).*/\1/' | $awk '
{ processes++; stat[$1]++ }
END {
print "processes.value " 0+processes;
print "uninterruptible.value " 0+stat["U"];
print "idle.value " 0+stat["I"];
print "runnable.value " 0+stat["R"];
print "sleeping.value " 0+stat["S"];
print "stopped.value " 0+stat["T"];
print "zombie.value " 0+stat["Z"];
}'
fi
|