mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-24 18:07:20 +00:00
- have some dirs
This commit is contained in:
parent
0b089ea777
commit
08346aac58
687 changed files with 0 additions and 0 deletions
29
plugins/processes/cpuload_
Executable file
29
plugins/processes/cpuload_
Executable file
|
@ -0,0 +1,29 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Munin-plugin to monitor the CPU usage for one or more given process name(s)
|
||||
#
|
||||
# Use the environment variable "process" to define more than one process
|
||||
# name if required. Process names must be separated by comma, no whitespace.
|
||||
#
|
||||
# [cpuload_postfix]
|
||||
# env.process master,qmgmr,proxymap,pickup
|
||||
#
|
||||
# GNU GPL, Bjørn Ruberg
|
||||
|
||||
# Find process names from env variables for the given plugin
|
||||
# If not, extract from filename.
|
||||
|
||||
test -n "$process" || process=`echo $0 | cut -d _ -f 2`
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
echo "graph_title CPU load for $process"
|
||||
echo 'graph_category processes'
|
||||
echo "graph_info This graph shows the CPU load for $process, as reported by 'ps'"
|
||||
echo 'cpuload.label CPU load'
|
||||
echo "cpuload.info CPU load of $process"
|
||||
echo "cpuload.type GAUGE"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo -n "cpuload.value "
|
||||
ps -C $process -o pcpu,comm --no-header | awk '{ sum += $1 } END { print sum }'
|
73
plugins/processes/cpuutil
Executable file
73
plugins/processes/cpuutil
Executable file
|
@ -0,0 +1,73 @@
|
|||
#!/sbin/sh
|
||||
|
||||
# See /usr/include/sys/dk.h !
|
||||
PATH=/usr/bin:/usr/sbin:/sbin
|
||||
|
||||
if [ "$1" = "autoconf" ]; then
|
||||
echo yes
|
||||
exit 0
|
||||
fi
|
||||
|
||||
#ADBINPUT="./vmunix ."
|
||||
ADBINPUT="/stand/vmunix /dev/kmem"
|
||||
|
||||
NMPINFO=$( /bin/echo "nmpinfo/D" | \
|
||||
/bin/adb -o $ADBINPUT 2>/dev/null | \
|
||||
/bin/sed '/^nmpinfo: *[0-9]/!d;s/^[^:]*://' )
|
||||
|
||||
echo_func () {
|
||||
echo ${1}.label $2
|
||||
echo ${1}.draw $3
|
||||
echo ${1}.type DERIVE
|
||||
echo ${1}.min 0
|
||||
echo ${1}.cdef ${1},$NMPINFO,/
|
||||
}
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
echo 'graph_title CPU usage graph based on kernel counters'
|
||||
echo 'graph_order sys user wio idle'
|
||||
# graphmax=$(( $NMPINFO * 100 ))
|
||||
graphmax=100
|
||||
echo "graph_args -r -l 0 --upper-limit $graphmax"
|
||||
echo 'graph_vlabel %'
|
||||
echo 'graph_category processes'
|
||||
echo 'graph_scale no'
|
||||
echo 'graph_info This graph shows how CPU time is spent.'
|
||||
|
||||
echo_func sys system AREA
|
||||
echo "sys.info CPU time spent in running the kernel code"
|
||||
|
||||
echo_func user user STACK
|
||||
echo 'user.info CPU time spent by tunning application code'
|
||||
|
||||
echo_func wio iowait STACK
|
||||
echo 'wio.info CPU idle time in waiting IO (disk)'
|
||||
|
||||
echo_func idle idle STACK
|
||||
echo 'idle.info Idle CPU time'
|
||||
|
||||
exit 0
|
||||
fi
|
||||
|
||||
CPU=0
|
||||
MAXCPU=$(( $NMPINFO * 72 ))
|
||||
ADBCMD="0d200\$w"
|
||||
|
||||
while [ $CPU -lt $MAXCPU ]; do
|
||||
ADBCMD="${ADBCMD}\nmcp_time+0d${CPU}/18D"
|
||||
CPU=$(( $CPU + 72 ))
|
||||
done
|
||||
|
||||
/bin/echo "${ADBCMD}\n\$q" | /bin/adb -o $ADBINPUT 2>/dev/null | \
|
||||
/bin/sed '/^mcp_time.*:.*[0-9]/!d;s/^[^:]*://' | /bin/awk \
|
||||
'{ \
|
||||
uh += $1 ; nh += $3 ; sh += $5 ; ih += $7 ; wh += $9 ; \
|
||||
ul += $2 ; nl += $4 ; sl += $6 ; il += $8 ; wl += $10 ; \
|
||||
} END { \
|
||||
GIGA = 4294967296 ; \
|
||||
printf( "sys.value %0.f\n", sh * GIGA + sl ) ; \
|
||||
printf( "user.value %0.f\n", ( uh + nh ) * GIGA + ul + nl ) ; \
|
||||
printf( "wio.value %0.f\n", wh * GIGA + wl ) ; \
|
||||
printf( "idle.value %0.f\n", ih * GIGA + il ) ; \
|
||||
}'
|
||||
|
72
plugins/processes/multicpu
Executable file
72
plugins/processes/multicpu
Executable file
|
@ -0,0 +1,72 @@
|
|||
#!/usr/bin/php
|
||||
<?
|
||||
/*
|
||||
multicpu monitors the cpu usage of multiple processes.
|
||||
you can configure the list of processes via munin's configuration
|
||||
|
||||
[multicpu]
|
||||
env.ps_filter apache2 mysqld
|
||||
|
||||
I have very little knowlege about munin plugins, it just 'works fine for me'.
|
||||
Please feel free to improve :)
|
||||
|
||||
0.1 initial release - Florian Fida
|
||||
*/
|
||||
|
||||
// make sure that paht to ps is valid for your system
|
||||
$ps_cmd = '/bin/ps -eo "%C,%a"';
|
||||
|
||||
// list of processes to monitor, can also be set by env.ps_filter in munin config
|
||||
$ps_filter = array(
|
||||
'apache2', 'mysqld', 'exim', 'php', 'perl', 'ruby', 'bftpd'
|
||||
);
|
||||
|
||||
|
||||
$cmdl = implode(' ', $argv);
|
||||
$config = stripos($cmdl, 'config') !== false;
|
||||
|
||||
if(!empty($_ENV['ps_filter'])){
|
||||
$ps_filter = explode(' ', $_ENV['ps_filter']);
|
||||
}
|
||||
|
||||
if($config){
|
||||
$out = "multigraph multicpu_pcpu\n";
|
||||
$out .= "graph_title CPU usage per process\n";
|
||||
$out .= "graph_vlabel CPU usage [%]\n";
|
||||
$out .= "graph_category processes\n";
|
||||
foreach($ps_filter as $process) $out .= "$process.label $process\n";
|
||||
|
||||
$out .= "multigraph multicpu_cnt\n";
|
||||
$out .= "graph_title Instances per process\n";
|
||||
$out .= "graph_vlabel count\n";
|
||||
$out .= "graph_category processes\n";
|
||||
foreach($ps_filter as $process) $out .= "$process.label $process\n";
|
||||
|
||||
echo $out."\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
$ps_txt = shell_exec($ps_cmd);
|
||||
$ps_a = explode("\n", $ps_txt);
|
||||
|
||||
$result = array();
|
||||
$result_cnt = array();
|
||||
foreach($ps_filter as $process){
|
||||
if(!isset($result[$process])) $result[$process] = 0;
|
||||
if(!isset($result_cnt[$process])) $result_cnt[$process] = 0;
|
||||
foreach($ps_a as $line){
|
||||
$line_a = explode(',', $line, 2);
|
||||
if(count($line_a) == 2){
|
||||
if(stripos($line_a[1], $process) !== false){
|
||||
$result[$process] += floatval($line_a[0]);
|
||||
++$result_cnt[$process];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo "multigraph multicpu_pcpu\n";
|
||||
foreach($result as $process => $value) echo "$process.value $value\n";
|
||||
echo "multigraph multicpu_cnt\n";
|
||||
foreach($result_cnt as $process => $value) echo "$process.value $value\n";
|
||||
|
102
plugins/processes/multimemory
Executable file
102
plugins/processes/multimemory
Executable file
|
@ -0,0 +1,102 @@
|
|||
#!/bin/sh
|
||||
# -*- sh -*-
|
||||
|
||||
: <<=cut
|
||||
|
||||
=head1 NAME
|
||||
|
||||
multimemory - Munin plugin to monitor memory usage of processes. Which processes
|
||||
are configured in client-conf.d
|
||||
|
||||
=head1 APPLICABLE SYSTEMS
|
||||
|
||||
Any system with a compatible ps command.
|
||||
|
||||
=head1 CONFIGURATION
|
||||
|
||||
There is no default configuration. This is an example:
|
||||
|
||||
[multimemory]
|
||||
env.os freebsd
|
||||
env.names apache2 mysqld php-cgi
|
||||
|
||||
Set env.os to freebsd if you are running this script on a machine which doesnt have
|
||||
GNU sed installed (FreeBSD / OpenBSD / Solaris ...), else set it to linux.
|
||||
|
||||
The names are used to grep with directly, after cleaning. So, this plugin
|
||||
only supports very basic pattern matching. To fix: see multips
|
||||
|
||||
=head1 INTERPRETATION
|
||||
|
||||
This plugin adds up the RSS of all processes matching the
|
||||
regex given as the process name, as reported by ps.
|
||||
|
||||
=head1 MAGIC MARKERS
|
||||
|
||||
#%# family=manual
|
||||
#%# capabilities=autoconf
|
||||
|
||||
=head1 VERSION
|
||||
0.3 light improvement in FreeBSD part of ps parsing
|
||||
0.2 second release, it should now work on machines without GNU sed
|
||||
0.1 first release, based on:
|
||||
multimemory.in 1590 2008-04-17 18:21:31Z matthias
|
||||
As distributed in Debian.
|
||||
|
||||
=head1 BUGS
|
||||
|
||||
None known
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Originally: matthias?
|
||||
Modified by: github.com/dominics github.com/yhager
|
||||
Thanks to: wix
|
||||
|
||||
=head1 LICENSE
|
||||
|
||||
GPLv2
|
||||
|
||||
=cut
|
||||
|
||||
if [ -z "$MUNIN_LIBDIR" ]; then
|
||||
MUNIN_LIBDIR="`dirname $(dirname "$0")`"
|
||||
fi
|
||||
|
||||
. $MUNIN_LIBDIR/plugins/plugin.sh
|
||||
|
||||
if [ "$1" = "autoconf" ]; then
|
||||
echo yes
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ -z "$names" -o -z "$os" ]; then
|
||||
echo "Configuration required"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
echo graph_title Total memory usage
|
||||
echo 'graph_category processes'
|
||||
echo 'graph_args --base 1024 --vertical-label memory -l 0'
|
||||
for name in $names; do
|
||||
fieldname=$(clean_fieldname $name)
|
||||
REGEX='\<'"$name"'\>'
|
||||
|
||||
echo "$fieldname.label $name"
|
||||
echo "$fieldname.draw LINE2"
|
||||
echo "$fieldname.info Processes matching this regular expression: /$REGEX/"
|
||||
done
|
||||
exit 0
|
||||
fi
|
||||
|
||||
for name in $names; do
|
||||
fieldname=$(clean_fieldname $name)
|
||||
printf "$fieldname.value "
|
||||
|
||||
if [ "$os" = "freebsd" ]; then
|
||||
ps awxo rss,command | grep -w $name | grep -v grep | /usr/bin/awk '{ total += $1 } END { print total * 1024 }'
|
||||
else
|
||||
ps auxww | grep -w $name | grep -v grep | sed -re 's/[ ]{1,}/ /g' | /usr/bin/cut -d ' ' -f 6 | /usr/bin/awk '{ total = total + $1 } END { print total * 1024 }'
|
||||
fi
|
||||
done
|
61
plugins/processes/multips
Executable file
61
plugins/processes/multips
Executable file
|
@ -0,0 +1,61 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Script to monitor number of processes. Programs are configured
|
||||
# in /etc/munin/plugin-conf.d/munin-node
|
||||
#
|
||||
# Parameters:
|
||||
#
|
||||
# config (required)
|
||||
# autoconf (optional - used by lrrd-config)
|
||||
#
|
||||
# Configuration example
|
||||
#
|
||||
# [multips]
|
||||
# env.multipsnames pop3d imapd sslwrap
|
||||
# env.regex_imapd ^[0-9]* imapd:
|
||||
# env.regex_pop3d ^[0-9]* pop3d:
|
||||
#
|
||||
# $Log$
|
||||
# Revision 1.1 2004/01/29 19:42:45 jimmyo
|
||||
# Added a new plugin generic/multips to count several procs in one graph. (SF#885579)
|
||||
#
|
||||
#
|
||||
# Magic markers (optional):
|
||||
#%# family=manual
|
||||
#%# capabilities=autoconf
|
||||
|
||||
if [ "$1" = "autoconf" ]; then
|
||||
if [ -z "$multipsnames" ]; then
|
||||
echo "Configuration required $multipsnames"
|
||||
else
|
||||
echo yes
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
|
||||
echo graph_title Number of selected processes
|
||||
echo 'graph_category processes'
|
||||
echo 'graph_args --base 1000 --vertical-label processes -l 0'
|
||||
for name in $multipsnames; do
|
||||
echo "$name.label $name"
|
||||
echo "$name.draw LINE2"
|
||||
done
|
||||
exit 0
|
||||
fi
|
||||
|
||||
for name in $multipsnames; do
|
||||
printf "$name.value "
|
||||
|
||||
eval REGEX='"${regex_'$name'-\<'$name'\>}"'
|
||||
PGREP=`which pgrep`
|
||||
if [ -n "$PGREP" ]; then
|
||||
$PGREP -f -l "$name" | grep "$REGEX" | wc -l
|
||||
elif [ -x /usr/ucb/ps ]; then
|
||||
# Solaris without pgrep. How old is that?
|
||||
/usr/ucb/ps auxwww | grep "$REGEX" | grep -v grep | wc -l
|
||||
else
|
||||
ps auxwww | grep "$REGEX" | grep -v grep | wc -l
|
||||
fi
|
||||
done
|
45
plugins/processes/multipsu
Executable file
45
plugins/processes/multipsu
Executable file
|
@ -0,0 +1,45 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Script to monitor number of processes by user. Programs are configured
|
||||
# in /etc/munin/plugin-conf.d/munin-node
|
||||
#
|
||||
# Parameters:
|
||||
#
|
||||
# config (required)
|
||||
# autoconf (optional - used by lrrd-config)
|
||||
#
|
||||
# Configuration example
|
||||
#
|
||||
# [multipsu]
|
||||
# env.multipsunames root exim ftp
|
||||
#
|
||||
#
|
||||
# Magic markers (optional):
|
||||
#%# family=manual
|
||||
#%# capabilities=autoconf
|
||||
|
||||
if [ "$1" = "autoconf" ]; then
|
||||
if [ -z "$multipsunames" ]; then
|
||||
echo "Configuration required $multipsunames"
|
||||
else
|
||||
echo yes
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
|
||||
echo graph_title Number of selected processes
|
||||
echo 'graph_category processes'
|
||||
echo 'graph_args --base 1000 --vertical-label processes -l 0'
|
||||
for name in $multipsunames; do
|
||||
echo "$name.label $name"
|
||||
echo "$name.draw LINE2"
|
||||
done
|
||||
exit 0
|
||||
fi
|
||||
|
||||
for name in $multipsunames; do
|
||||
printf "$name.value "
|
||||
(pgrep -u "$name"; pgrep -U "$name") | sort -u | wc -l
|
||||
done
|
40
plugins/processes/proc_mem
Executable file
40
plugins/processes/proc_mem
Executable file
|
@ -0,0 +1,40 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# (c) 2010, Rodrigo Sieiro <rsieiro@gmail.com>
|
||||
# Based on the 'du_multidirs' plugin, written by Christian Kujau <lists@nerdbynature.de>
|
||||
#
|
||||
# Configure it by using the processes env var, i.e.:
|
||||
#
|
||||
# [proc_mem]
|
||||
# env.processes munin-node apache2
|
||||
#
|
||||
|
||||
. $MUNIN_LIBDIR/plugins/plugin.sh
|
||||
|
||||
if [ "$1" = "autoconf" ]; then
|
||||
echo yes
|
||||
exit 0
|
||||
fi
|
||||
|
||||
processes=${processes:="munin-node"}
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
echo 'graph_title Memory usage by process'
|
||||
echo 'graph_args --base 1024 -l 0'
|
||||
echo 'graph_vlabel Bytes'
|
||||
echo 'graph_category processes'
|
||||
echo 'graph_info This graph shows the memory usage of several processes'
|
||||
|
||||
for proc in $processes; do
|
||||
echo "$proc.label $proc"
|
||||
done
|
||||
|
||||
# echo "$u".warning 0
|
||||
# echo "$u".critical 0
|
||||
|
||||
exit 0
|
||||
fi
|
||||
|
||||
for proc in $processes; do
|
||||
echo "$proc.value " `ps u -C $proc | awk 'BEGIN { sum = 0 } NR > 1 { sum += $6 }; END { print sum * 1024 }'`
|
||||
done
|
78
plugins/processes/process_count
Executable file
78
plugins/processes/process_count
Executable file
|
@ -0,0 +1,78 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Plugin to monitor CPU usage, for a selected set of processes. Tested on Linux.
|
||||
#
|
||||
# Author: Stefan Osterlitz
|
||||
# Based on work of Erik Cederstrand
|
||||
#
|
||||
# Usage: Place in /usr/local/etc/munin/plugins/ (or link it there using ln -s)
|
||||
# Add this to your /ur/local/etc/munin/plugin-conf.d/plugins.conf:
|
||||
|
||||
# [process_*]
|
||||
# env.procs httpd java
|
||||
#
|
||||
# httpd and java being a list of the processes to monitor. You may use regex expressions for grep, but watch their conversion to field names.
|
||||
# ps options may vary.
|
||||
|
||||
#
|
||||
# Parameters understood:
|
||||
#
|
||||
# config (required)
|
||||
# autoconf (optional - used by munin-config)
|
||||
#
|
||||
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf
|
||||
|
||||
|
||||
|
||||
if [ "$1" = "autoconf" ] ; then
|
||||
if [ -n "$procs" ] ; then
|
||||
echo "yes"
|
||||
else
|
||||
echo "\$procs not defined."
|
||||
fi
|
||||
exit
|
||||
fi
|
||||
|
||||
for proc in $procs; do
|
||||
cproc=${proc//[^A-Za-z0-9_]/_}
|
||||
cprocs+=" $cproc"
|
||||
done;
|
||||
|
||||
if [ "$1" = "config" ] ; then
|
||||
echo "graph_args --base 1000 -r --lower-limit 0";
|
||||
echo "graph_title Process count";
|
||||
echo "graph_category processes";
|
||||
echo "graph_info This graph shows process count, for monitored processes.";
|
||||
echo 'graph_vlabel number of processes'
|
||||
echo 'graph_scale no'
|
||||
echo 'graph_period second'
|
||||
echo "graph_order $cprocs"
|
||||
|
||||
for proc in $procs; do
|
||||
cproc=${proc//[^A-Za-z0-9_]/_}
|
||||
echo "${cproc}.label $proc"
|
||||
echo "${cproc}.info CPU used by process $proc"
|
||||
done ;
|
||||
|
||||
exit
|
||||
fi
|
||||
|
||||
for proc in $procs ; do {
|
||||
cproc=${proc//[^A-Za-z0-9_]/_}
|
||||
ps axo '%mem,comm,command' | grep -v grep | grep "$proc" | LC_ALL=us_US awk '
|
||||
BEGIN {
|
||||
SUM=0
|
||||
}
|
||||
{
|
||||
SUM+=1
|
||||
COMM=$2
|
||||
}
|
||||
END {
|
||||
print "'${cproc}'.value "SUM
|
||||
}
|
||||
'
|
||||
}
|
||||
|
||||
done;
|
78
plugins/processes/process_cpushare
Executable file
78
plugins/processes/process_cpushare
Executable file
|
@ -0,0 +1,78 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Plugin to monitor CPU share, for a selected set of processes. Tested on Linux.
|
||||
#
|
||||
# Author: Stefan Osterlitz
|
||||
# Based on work of Erik Cederstrand
|
||||
#
|
||||
# Usage: Place in /usr/local/etc/munin/plugins/ (or link it there using ln -s)
|
||||
# Add this to your /ur/local/etc/munin/plugin-conf.d/plugins.conf:
|
||||
|
||||
# [process_*]
|
||||
# env.procs httpd java
|
||||
#
|
||||
# httpd and java being a list of the processes to monitor. You may use regex expressions for grep, but watch their conversion to field names.
|
||||
# ps options may vary.
|
||||
|
||||
#
|
||||
# Parameters understood:
|
||||
#
|
||||
# config (required)
|
||||
# autoconf (optional - used by munin-config)
|
||||
#
|
||||
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf
|
||||
|
||||
|
||||
|
||||
if [ "$1" = "autoconf" ] ; then
|
||||
if [ -n "$procs" ] ; then
|
||||
echo "yes"
|
||||
else
|
||||
echo "\$procs not defined."
|
||||
fi
|
||||
exit
|
||||
fi
|
||||
|
||||
for proc in $procs; do
|
||||
cproc=${proc//[^A-Za-z0-9_]/_}
|
||||
cprocs+=" $cproc"
|
||||
done;
|
||||
|
||||
if [ "$1" = "config" ] ; then
|
||||
echo "graph_args --base 1000 -r --lower-limit 0";
|
||||
echo "graph_title CPU usage, by process";
|
||||
echo "graph_category processes";
|
||||
echo "graph_info This graph shows CPU usage, for monitored processes.";
|
||||
echo 'graph_vlabel %'
|
||||
echo 'graph_scale no'
|
||||
echo 'graph_period second'
|
||||
echo "graph_order $cprocs"
|
||||
|
||||
for proc in $procs; do
|
||||
cproc=${proc//[^A-Za-z0-9_]/_}
|
||||
echo "${cproc}.label $proc"
|
||||
echo "${cproc}.info CPU used by process $proc"
|
||||
done ;
|
||||
|
||||
exit
|
||||
fi
|
||||
|
||||
|
||||
|
||||
for proc in $procs ; do {
|
||||
cproc=${proc//[^A-Za-z0-9_]/_}
|
||||
ps axo 'pcpu,comm,command' | grep -v grep | grep "$proc" | LC_ALL=us_US awk '
|
||||
BEGIN {
|
||||
SUM=0
|
||||
}
|
||||
{
|
||||
SUM+=$1
|
||||
}
|
||||
END {
|
||||
print "'${cproc}'.value "SUM
|
||||
}
|
||||
'
|
||||
}
|
||||
done;
|
282
plugins/processes/processes
Executable file
282
plugins/processes/processes
Executable file
|
@ -0,0 +1,282 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Copyright (C) 2006 Lars Strand
|
||||
#
|
||||
# Munin-plugin to monitor processes on Linux
|
||||
# FreeBSD, OpenBSD, NetBSD, Solaris and OSX.
|
||||
#
|
||||
# Require 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.)
|
||||
#
|
||||
#
|
||||
# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
#
|
||||
# Parameters understood:
|
||||
#
|
||||
# config (required)
|
||||
# autoconf (optional - used by munin-config)
|
||||
#
|
||||
# $Log$
|
||||
#
|
||||
#
|
||||
#
|
||||
# Magick markers (optional - used by munin-config and som installation
|
||||
# scripts):
|
||||
#
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf
|
||||
|
||||
# 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
|
||||
|
||||
# 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"
|
||||
|
||||
# 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."
|
||||
echo "paging.label paging"
|
||||
echo "paging.draw STACK"
|
||||
echo "paging.colour $PAGING"
|
||||
echo "paging.info The number of paging processes (<2.6 kernels only)."
|
||||
|
||||
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."
|
||||
# Be backwards compatible.
|
||||
echo "total.label total"
|
||||
echo "total.draw LINE1"
|
||||
echo "total.colour $TOTAL"
|
||||
echo "total.info The total number of processes."
|
||||
|
||||
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."
|
||||
echo "interrupt.label interrupt"
|
||||
echo "interrupt.draw STACK"
|
||||
echo "interrupt.colour $INTERRUPT"
|
||||
echo "interrupt.info The number of idle interrupt threads."
|
||||
|
||||
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."
|
||||
|
||||
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)."
|
||||
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)."
|
||||
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."
|
||||
else
|
||||
echo "sleeping.label sleeping"
|
||||
echo "sleeping.draw AREA"
|
||||
echo "sleeping.colour $SLEEPING"
|
||||
echo "sleeping.info The number of sleeping processes."
|
||||
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)."
|
||||
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)."
|
||||
|
||||
echo "stopped.label stopped"
|
||||
echo "stopped.draw STACK"
|
||||
echo "stopped.colour $STOPPED"
|
||||
echo "stopped.info The number of stopped or traced processes."
|
||||
|
||||
echo "runnable.label runnable"
|
||||
echo "runnable.draw STACK"
|
||||
echo "runnable.colour $RUNNABLE"
|
||||
echo "runnable.info The number of runnable processes (on the run queue)."
|
||||
|
||||
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."
|
||||
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
|
36
plugins/processes/vserver_procs
Executable file
36
plugins/processes/vserver_procs
Executable file
|
@ -0,0 +1,36 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Written by Bernd Zeimetz <bernd@bzed.de>, Wed, 26 Sep 2007 03:04:34 +0200
|
||||
# This script is public domain, do with it what ever you want.
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf
|
||||
|
||||
[ "$1" = "autoconf" ] && echo yes && exit 0
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
|
||||
echo 'graph_title Vserver Process Overview'
|
||||
echo 'graph_args --base 1000 -l 0 '
|
||||
echo 'graph_vlabel number of processes'
|
||||
echo 'graph_category processes'
|
||||
echo 'graph_info This graph shows the number of processes in each vserver context.'
|
||||
|
||||
for vserver in `vserver-stat | sed 1d | awk '{print $8}'`; do
|
||||
echo "${vserver}.label ${vserver}"
|
||||
echo "${vserver}.draw LINE2"
|
||||
echo "${vserver}.info Processes in the vserver context ${vserver}."
|
||||
done
|
||||
exit 0
|
||||
fi
|
||||
|
||||
vserver-stat | sed 1d | awk '{print $8" "$2}' | while read vserver procs; do
|
||||
echo "${vserver}.value ${procs}"
|
||||
done
|
||||
exit 0
|
Loading…
Add table
Add a link
Reference in a new issue