Révision e70093d3
| ID | e70093d387e7e05cb6151dd8af6c424ea80337c8 |
remove processes plugin already in main munin distribution
| plugins/processes/processes | ||
|---|---|---|
| 1 |
#!/bin/sh |
|
| 2 |
# |
|
| 3 |
# Copyright (C) 2006 Lars Strand |
|
| 4 |
# |
|
| 5 |
# Munin-plugin to monitor processes on Linux |
|
| 6 |
# FreeBSD, OpenBSD, NetBSD, Solaris and OSX. |
|
| 7 |
# |
|
| 8 |
# Require munin-server version 1.2.5 or 1.3.3 (or higher). |
|
| 9 |
# |
|
| 10 |
# This plugin is backwards compatible with the old processes-plugins |
|
| 11 |
# found on SunOS, Linux and *BSD (i.e. the history is preserved). |
|
| 12 |
# |
|
| 13 |
# All fields have colours associated with them which reflect the type |
|
| 14 |
# of process (sleeping/idle = blue, running = green, |
|
| 15 |
# stopped/zombie/dead = red, etc.) |
|
| 16 |
# |
|
| 17 |
# |
|
| 18 |
# This program is free software; you can redistribute it and/or |
|
| 19 |
# modify it under the terms of the GNU General Public License |
|
| 20 |
# as published by the Free Software Foundation; version 2 dated June, |
|
| 21 |
# 1991. |
|
| 22 |
# |
|
| 23 |
# This program is distributed in the hope that it will be useful, |
|
| 24 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 25 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 26 |
# GNU General Public License for more details. |
|
| 27 |
# |
|
| 28 |
# You should have received a copy of the GNU General Public License |
|
| 29 |
# along with this program; if not, write to the Free Software |
|
| 30 |
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
| 31 |
# |
|
| 32 |
# |
|
| 33 |
# Parameters understood: |
|
| 34 |
# |
|
| 35 |
# config (required) |
|
| 36 |
# autoconf (optional - used by munin-config) |
|
| 37 |
# |
|
| 38 |
# $Log$ |
|
| 39 |
# |
|
| 40 |
# |
|
| 41 |
# |
|
| 42 |
# Magick markers (optional - used by munin-config and som installation |
|
| 43 |
# scripts): |
|
| 44 |
# |
|
| 45 |
#%# family=auto |
|
| 46 |
#%# capabilities=autoconf |
|
| 47 |
|
|
| 48 |
# Search for program in $PATH unless predefined. |
|
| 49 |
[ $awk ] || awk="awk" |
|
| 50 |
[ $ps ] || ps="ps" |
|
| 51 |
|
|
| 52 |
# Find operating system |
|
| 53 |
[ $OPERSYS ] || OPERSYS=`uname` || exit 1 |
|
| 54 |
|
|
| 55 |
if [ "$1" = "autoconf" ]; then |
|
| 56 |
echo yes |
|
| 57 |
exit 0 |
|
| 58 |
fi |
|
| 59 |
|
|
| 60 |
# Define colours |
|
| 61 |
RUNNABLE='22ff22' # Green |
|
| 62 |
SLEEPING='0022ff' # Blue |
|
| 63 |
STOPPED='cc0000' # Darker red |
|
| 64 |
ZOMBIE='990000' # Darkest red |
|
| 65 |
UNINTERRUPTIBLE='ffa500' # Orange |
|
| 66 |
IDLE='4169e1' # Royal blue |
|
| 67 |
PAGING='00aaaa' # Darker turquoise |
|
| 68 |
INTERRUPT='ff00ff' # Fuchsia |
|
| 69 |
LOCK='ff3333' # Lighter red |
|
| 70 |
RUNNING='00ff7f' # Spring green |
|
| 71 |
DEAD='ff0000' # Red |
|
| 72 |
SUSPENDED='ff1493' # Deep pink |
|
| 73 |
TOTAL='c0c0c0' # Silver |
|
| 74 |
|
|
| 75 |
# Taken from ps(1) |
|
| 76 |
# R - Linux, SunOS, FreeBSD, OpenBSD, NetBSD, OSX (runable) |
|
| 77 |
# S - Linux, SunOS, FreeBSD*, OpenBSD*, NetBSD*, OSX* (sleeping) |
|
| 78 |
# T - Linux, SunOS, FreeBSD, OpenBSD, NetBSD, OSX (stopped) |
|
| 79 |
# Z - Linux, SunOS, FreeBSD, OpenBSD, NetBSD, OSX (zombie) |
|
| 80 |
# D - Linux, FreeBSD, OpenBSD, NetBSD (uninterruptible) |
|
| 81 |
# I - FreeBSD, OpenBSD, NetBSD, OSX (idle) |
|
| 82 |
# W - Linux*, FreeBSD* (paging/interrupt) |
|
| 83 |
# L - FreeBSD (lock) |
|
| 84 |
# O - SunOS (running) |
|
| 85 |
# X - Linux (dead) |
|
| 86 |
# U - OSX, NetBSD* (uninterruptible/suspended) |
|
| 87 |
# *) Differ meaning |
|
| 88 |
|
|
| 89 |
if [ "$1" = "config" ]; then |
|
| 90 |
echo "graph_title Processes" |
|
| 91 |
echo "graph_info This graph shows the number of processes" |
|
| 92 |
echo "graph_category processes" |
|
| 93 |
echo "graph_args --base 1000 -l 0" |
|
| 94 |
|
|
| 95 |
# OS specific flags |
|
| 96 |
if [ "$OPERSYS" = "Linux" ]; then |
|
| 97 |
echo "graph_order sleeping stopped zombie dead paging uninterruptible runnable processes" |
|
| 98 |
echo "dead.label dead" |
|
| 99 |
echo "dead.draw STACK" |
|
| 100 |
echo "dead.colour $DEAD" |
|
| 101 |
echo "dead.info The number of dead processes." |
|
| 102 |
echo "paging.label paging" |
|
| 103 |
echo "paging.draw STACK" |
|
| 104 |
echo "paging.colour $PAGING" |
|
| 105 |
echo "paging.info The number of paging processes (<2.6 kernels only)." |
|
| 106 |
|
|
| 107 |
elif [ "$OPERSYS" = "SunOS" ]; then |
|
| 108 |
echo "graph_order sleeping stopped zombie runnable running total" |
|
| 109 |
echo "running.label running" |
|
| 110 |
echo "running.draw STACK" |
|
| 111 |
echo "running.colour $RUNNING" |
|
| 112 |
echo "running.info The number of processes that are running on a processor." |
|
| 113 |
# Be backwards compatible. |
|
| 114 |
echo "total.label total" |
|
| 115 |
echo "total.draw LINE1" |
|
| 116 |
echo "total.colour $TOTAL" |
|
| 117 |
echo "total.info The total number of processes." |
|
| 118 |
|
|
| 119 |
elif [ "$OPERSYS" = "FreeBSD" ]; then |
|
| 120 |
echo "graph_order sleeping idle stopped zombie lock uninterruptible interrupt runnable processes" |
|
| 121 |
echo "lock.label lock" |
|
| 122 |
echo "lock.draw STACK" |
|
| 123 |
echo "lock.colour $LOCK" |
|
| 124 |
echo "lock.info The number of processes that are waiting to acquire a lock." |
|
| 125 |
echo "interrupt.label interrupt" |
|
| 126 |
echo "interrupt.draw STACK" |
|
| 127 |
echo "interrupt.colour $INTERRUPT" |
|
| 128 |
echo "interrupt.info The number of idle interrupt threads." |
|
| 129 |
|
|
| 130 |
elif [ "$OPERSYS" = "OpenBSD" ]; then |
|
| 131 |
echo "graph_order sleeping idle stopped zombie uninterruptible runnable processes" |
|
| 132 |
|
|
| 133 |
elif [ "$OPERSYS" = "NetBSD" ]; then |
|
| 134 |
echo "graph_order sleeping idle stopped zombie uninterruptible suspended runnable processes" |
|
| 135 |
echo "suspended.label suspended" |
|
| 136 |
echo "suspended.draw STACK" |
|
| 137 |
echo "suspended.colour $SUSPENDED" |
|
| 138 |
echo "suspended.info The number of processes that are suspended." |
|
| 139 |
|
|
| 140 |
elif [ "$OPERSYS" = "Darwin" ]; then |
|
| 141 |
echo "graph_order sleeping idle stopped zombie uninterruptible running processes" |
|
| 142 |
echo "uninterruptible.label uninterruptible" |
|
| 143 |
echo "uninterruptible.draw STACK" |
|
| 144 |
echo "uninterruptible.colour $UNINTERRUPTIBLE" |
|
| 145 |
echo "uninterruptible.info The number of uninterruptible processes (usually IO)." |
|
| 146 |
fi |
|
| 147 |
|
|
| 148 |
# Common flags for some OS |
|
| 149 |
if [ "$OPERSYS" = "FreeBSD" ] || [ "$OPERSYS" = "OpenBSD" ] || |
|
| 150 |
[ "$OPERSYS" = "NetBSD" ] || [ "$OPERSYS" = "Darwin" ]; then |
|
| 151 |
echo "idle.label idle" |
|
| 152 |
echo "idle.draw STACK" |
|
| 153 |
echo "idle.colour $IDLE" |
|
| 154 |
echo "idle.info The number of processes that are idle (sleeping for longer than about 20 seconds)." |
|
| 155 |
echo "sleeping.label sleeping" |
|
| 156 |
echo "sleeping.draw AREA" |
|
| 157 |
echo "sleeping.colour $SLEEPING" |
|
| 158 |
echo "sleeping.info The number of processes that are sleeping for less than about 20 seconds." |
|
| 159 |
else |
|
| 160 |
echo "sleeping.label sleeping" |
|
| 161 |
echo "sleeping.draw AREA" |
|
| 162 |
echo "sleeping.colour $SLEEPING" |
|
| 163 |
echo "sleeping.info The number of sleeping processes." |
|
| 164 |
fi |
|
| 165 |
|
|
| 166 |
if [ "$OPERSYS" = "Linux" ] || [ "$OPERSYS" = "FreeBSD" ] || |
|
| 167 |
[ "$OPERSYS" = "OpenBSD" ] || [ "$OPERSYS" = "NetBSD" ]; then |
|
| 168 |
echo "uninterruptible.label uninterruptible" |
|
| 169 |
echo "uninterruptible.draw STACK" |
|
| 170 |
echo "uninterruptible.colour $UNINTERRUPTIBLE" |
|
| 171 |
echo "uninterruptible.info The number of uninterruptible processes (usually IO)." |
|
| 172 |
fi |
|
| 173 |
|
|
| 174 |
# Common flags |
|
| 175 |
echo "zombie.label zombie" |
|
| 176 |
echo "zombie.draw STACK" |
|
| 177 |
echo "zombie.colour $ZOMBIE" |
|
| 178 |
echo "zombie.info The number of defunct ("zombie") processes (process terminated and parent not waiting)."
|
|
| 179 |
|
|
| 180 |
echo "stopped.label stopped" |
|
| 181 |
echo "stopped.draw STACK" |
|
| 182 |
echo "stopped.colour $STOPPED" |
|
| 183 |
echo "stopped.info The number of stopped or traced processes." |
|
| 184 |
|
|
| 185 |
echo "runnable.label runnable" |
|
| 186 |
echo "runnable.draw STACK" |
|
| 187 |
echo "runnable.colour $RUNNABLE" |
|
| 188 |
echo "runnable.info The number of runnable processes (on the run queue)." |
|
| 189 |
|
|
| 190 |
if [ "$OPERSYS" != "SunOS" ]; then |
|
| 191 |
# Not using 'graph_total' due to backwards compability. SunOS uses 'total'. |
|
| 192 |
#echo 'graph_total total' |
|
| 193 |
echo "processes.label total" |
|
| 194 |
echo "processes.draw LINE1" |
|
| 195 |
echo "processes.colour $TOTAL" |
|
| 196 |
echo "processes.info The total number of processes." |
|
| 197 |
fi |
|
| 198 |
|
|
| 199 |
exit 0 |
|
| 200 |
fi |
|
| 201 |
|
|
| 202 |
if [ "$OPERSYS" = "Linux" ]; then |
|
| 203 |
$ps --no-header -eo s | $awk ' |
|
| 204 |
{ processes++; stat[$1]++ }
|
|
| 205 |
END {
|
|
| 206 |
print "processes.value " 0+processes; |
|
| 207 |
print "uninterruptible.value " 0+stat["D"]; |
|
| 208 |
print "runnable.value " 0+stat["R"]; |
|
| 209 |
print "sleeping.value " 0+stat["S"]; |
|
| 210 |
print "stopped.value " 0+stat["T"]; |
|
| 211 |
print "paging.value " 0+stat["W"]; |
|
| 212 |
print "dead.value " 0+stat["X"]; |
|
| 213 |
print "zombie.value " 0+stat["Z"]; |
|
| 214 |
}' |
|
| 215 |
|
|
| 216 |
elif [ "$OPERSYS" = "SunOS" ]; then |
|
| 217 |
$ps -e -o s | $awk ' |
|
| 218 |
{ total++; stat[$1]++ }
|
|
| 219 |
END {
|
|
| 220 |
print "total.value " 0+total; |
|
| 221 |
print "running.value " 0+stat["O"]; |
|
| 222 |
print "sleeping.value " 0+stat["S"]; |
|
| 223 |
print "runnable.value " 0+stat["R"]; |
|
| 224 |
print "stopped.value " 0+stat["T"]; |
|
| 225 |
print "zombie.value " 0+stat["Z"]; |
|
| 226 |
}' |
|
| 227 |
elif [ "$OPERSYS" = "FreeBSD" ]; then |
|
| 228 |
$ps -axo state= | sed -e 's/^\(.\).*/\1/' | $awk ' |
|
| 229 |
{ processes++; stat[$1]++ }
|
|
| 230 |
END {
|
|
| 231 |
print "processes.value " 0+processes; |
|
| 232 |
print "uninterruptible.value " 0+stat["D"]; |
|
| 233 |
print "idle.value " 0+stat["I"]; |
|
| 234 |
print "lock.value " 0+stat["G"]; |
|
| 235 |
print "runnable.value " 0+stat["R"]; |
|
| 236 |
print "sleeping.value " 0+stat["S"]; |
|
| 237 |
print "stopped.value " 0+stat["T"]; |
|
| 238 |
print "interrupt.value " 0+stat["W"]; |
|
| 239 |
print "zombie.value " 0+stat["Z"]; |
|
| 240 |
}' |
|
| 241 |
elif [ "$OPERSYS" = "OpenBSD" ]; then |
|
| 242 |
# First line is header. Remove it. |
|
| 243 |
$ps -axo state= | sed '1d' | sed -e 's/^\(.\).*/\1/' | $awk ' |
|
| 244 |
{ processes++; stat[$1]++ }
|
|
| 245 |
END {
|
|
| 246 |
print "processes.value " 0+processes; |
|
| 247 |
print "uninterruptible.value " 0+stat["D"]; |
|
| 248 |
print "idle.value " 0+stat["I"]; |
|
| 249 |
print "runnable.value " 0+stat["R"]; |
|
| 250 |
print "sleeping.value " 0+stat["S"]; |
|
| 251 |
print "stopped.value " 0+stat["T"]; |
|
| 252 |
print "zombie.value " 0+stat["Z"]; |
|
| 253 |
}' |
|
| 254 |
elif [ "$OPERSYS" = "NetBSD" ]; then |
|
| 255 |
# First line is header. Remove it. |
|
| 256 |
$ps -axo state= | sed '1d' | sed -e 's/^\(.\).*/\1/' | $awk ' |
|
| 257 |
{ processes++; stat[$1]++ }
|
|
| 258 |
END {
|
|
| 259 |
print "processes.value " 0+processes; |
|
| 260 |
print "uninterruptible.value " 0+stat["D"]; |
|
| 261 |
print "idle.value " 0+stat["I"]; |
|
| 262 |
print "suspended.value " 0+stat["U"]; |
|
| 263 |
print "runnable.value " 0+stat["R"]; |
|
| 264 |
print "sleeping.value " 0+stat["S"]; |
|
| 265 |
print "stopped.value " 0+stat["T"]; |
|
| 266 |
print "zombie.value " 0+stat["Z"]; |
|
| 267 |
}' |
|
| 268 |
|
|
| 269 |
elif [ "$OPERSYS" = "Darwin" ]; then |
|
| 270 |
# First line is header. Remove it. |
|
| 271 |
$ps -axo state= | sed '1d' | sed -e 's/^\(.\).*/\1/' | $awk ' |
|
| 272 |
{ processes++; stat[$1]++ }
|
|
| 273 |
END {
|
|
| 274 |
print "processes.value " 0+processes; |
|
| 275 |
print "uninterruptible.value " 0+stat["U"]; |
|
| 276 |
print "idle.value " 0+stat["I"]; |
|
| 277 |
print "runnable.value " 0+stat["R"]; |
|
| 278 |
print "sleeping.value " 0+stat["S"]; |
|
| 279 |
print "stopped.value " 0+stat["T"]; |
|
| 280 |
print "zombie.value " 0+stat["Z"]; |
|
| 281 |
}' |
|
| 282 |
fi |
|
Formats disponibles : Unified diff