mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-21 18:41:03 +00:00
Plugin-Gallery: Get better 2nd level headings
Review of category processes, system, snmp
This commit is contained in:
parent
4b400a7320
commit
e777037d06
27 changed files with 15 additions and 15 deletions
29
plugins/cpu/cpuload_
Executable file
29
plugins/cpu/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/cpu/cpuutil
Executable file
73
plugins/cpu/cpuutil
Executable file
|
@ -0,0 +1,73 @@
|
|||
#!/bin/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/cpu/multicpu
Executable file
72
plugins/cpu/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 knowledge 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";
|
||||
|
78
plugins/cpu/process_count
Executable file
78
plugins/cpu/process_count
Executable file
|
@ -0,0 +1,78 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# 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/cpu/process_cpushare
Executable file
78
plugins/cpu/process_cpushare
Executable file
|
@ -0,0 +1,78 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# 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;
|
Loading…
Add table
Add a link
Reference in a new issue