root / plugins / load / load_extended @ 17f78427
Historique | Voir | Annoter | Télécharger (3,96 ko)
| 1 |
#!/bin/sh |
|---|---|
| 2 |
# |
| 3 |
# Plugin to monitor the load average on a system. |
| 4 |
# |
| 5 |
# Usage: Link or copy into /etc/munin/node.d/ |
| 6 |
# |
| 7 |
# $Log$ |
| 8 |
# Revision 1.5 2004/05/20 19:02:37 jimmyo |
| 9 |
# Set categories on a bunch of plugins |
| 10 |
# |
| 11 |
# Revision 1.4 2004/05/20 13:57:12 jimmyo |
| 12 |
# Set categories to some of the plugins. |
| 13 |
# |
| 14 |
# Revision 1.3 2004/05/16 12:41:04 jimmyo |
| 15 |
# Changed load plot from lastminute to last 5 minutes. |
| 16 |
# |
| 17 |
# Revision 1.2 2004/05/16 12:34:26 jimmyo |
| 18 |
# Added "info"-fields to linux/cpu and linux/load plugins, to demonstrate how it works. |
| 19 |
# |
| 20 |
# Revision 1.1 2004/01/02 18:50:01 jimmyo |
| 21 |
# Renamed occurrences of lrrd -> munin |
| 22 |
# |
| 23 |
# Revision 1.1.1.1 2004/01/02 15:18:07 jimmyo |
| 24 |
# Import of LRRD CVS tree after renaming to Munin |
| 25 |
# |
| 26 |
# Revision 1.4 2003/11/15 11:10:28 jimmyo |
| 27 |
# Various fixes |
| 28 |
# |
| 29 |
# Revision 1.3 2003/11/07 17:43:16 jimmyo |
| 30 |
# Cleanups and log entries |
| 31 |
# |
| 32 |
# |
| 33 |
# |
| 34 |
# Magic markers (optional - only used by munin-config and some |
| 35 |
# installation scripts): |
| 36 |
# |
| 37 |
#%# family=auto |
| 38 |
#%# capabilities=autoconf |
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
# If run with the "autoconf"-parameter, give our opinion on whether we |
| 43 |
# should be run on this system or not. This is optinal, and only used by |
| 44 |
# munin-config. In the case of this plugin, we should most probably |
| 45 |
# always be included. |
| 46 |
|
| 47 |
if [ "$1" = "autoconf" ]; then |
| 48 |
echo yes |
| 49 |
exit 0 |
| 50 |
fi |
| 51 |
|
| 52 |
# If run with the "config"-parameter, give out information on how the |
| 53 |
# graphs should look. |
| 54 |
|
| 55 |
if [ "$1" = "config" ]; then |
| 56 |
# The host name this plugin is for. (Can be overridden to have |
| 57 |
# one machine answer for several) |
| 58 |
|
| 59 |
# The title of the graph |
| 60 |
echo 'graph_title Load average' |
| 61 |
# Arguments to "rrdtool graph". In this case, tell it that the |
| 62 |
# lower limit of the graph is '0', and that 1k=1000 (not 1024) |
| 63 |
echo 'graph_args --base 1000 -l 0' |
| 64 |
# The Y-axis label |
| 65 |
echo 'graph_vlabel load' |
| 66 |
# We want Cur/Min/Avg/Max unscaled (i.e. 0.42 load instead of |
| 67 |
# 420 milliload) |
| 68 |
echo 'graph_scale no' |
| 69 |
# Graph category. Defaults to 'other' |
| 70 |
echo 'graph_category system' |
| 71 |
# The fields. "label" is used in the legend. "label" is the only |
| 72 |
# required subfield. |
| 73 |
echo 'load1.label load 1 min avg' |
| 74 |
echo 'load1.draw AREA' |
| 75 |
echo 'load5.label load 5 min avg' |
| 76 |
echo 'load5.draw AREA' |
| 77 |
echo 'load15.label load 15 min avg' |
| 78 |
echo 'load15.draw AREA' |
| 79 |
# These 6 are optional. They are only used if you have |
| 80 |
# configured your munin to tell a Nagios-server about any |
| 81 |
# problems |
| 82 |
echo 'load1.warning 10' |
| 83 |
echo 'load1.critical 120' |
| 84 |
echo 'load5.warning 10' |
| 85 |
echo 'load5.critical 120' |
| 86 |
echo 'load15.warning 10' |
| 87 |
echo 'load15.critical 120' |
| 88 |
# This one is purely to add an explanation to the web page. The first |
| 89 |
# one is for the graph itself, while the second one is for the field |
| 90 |
# "load". |
| 91 |
echo 'graph_info The load average of the machine describes how many processes are in the run-queue (scheduled to run "immediately").' |
| 92 |
echo 'load1.info Average load for 1 minute avg.' |
| 93 |
echo 'load5.info Average load for 5 minutes avg.' |
| 94 |
echo 'load15.info Average load for 15 minutes avg.' |
| 95 |
|
| 96 |
# Last, if run with the "config"-parameter, quit here (don't |
| 97 |
# display any data) |
| 98 |
exit 0 |
| 99 |
fi |
| 100 |
|
| 101 |
# If not run with any parameters at all (or only unknown ones), do the |
| 102 |
# real work - i.e. display the data. Almost always this will be |
| 103 |
# "value" subfield for every data field. |
| 104 |
|
| 105 |
echo -n "load1.value " |
| 106 |
cut -f1 -d' ' < /proc/loadavg |
| 107 |
|
| 108 |
echo -n "load5.value " |
| 109 |
cut -f2 -d' ' < /proc/loadavg |
| 110 |
|
| 111 |
echo -n "load15.value " |
| 112 |
cut -f3 -d' ' < /proc/loadavg |
| 113 |
|
| 114 |
# How could this plugin have been written in its simplest form? |
| 115 |
# Something like this: |
| 116 |
# |
| 117 |
# --------------------- |
| 118 |
# #!/bin/sh |
| 119 |
|
| 120 |
# |
| 121 |
# if [ "$1" = "config" ]; then |
| 122 |
|
| 123 |
# echo "graph_title Load average" |
| 124 |
# echo 'graph_args --base 1000 -l 0' |
| 125 |
# echo 'graph_vlabel load' |
| 126 |
# echo "load.label load" |
| 127 |
# exit 0 |
| 128 |
# fi |
| 129 |
# echo -n "load.value " |
| 130 |
# cut -f1 -d' ' < /proc/loadavg |
| 131 |
# --------------------- |
| 132 |
# |
| 133 |
# Except for the Nagios-warnings (which most people don't have any need |
| 134 |
# for) and things used by installation scripts and munin-config (which |
| 135 |
# you don't need if you don't plan on submitting your plugin to the |
| 136 |
# pacakge), and the scaling (no milliload numbers) the two versions will |
| 137 |
# work identically. |
