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
|
@ -1,105 +0,0 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Plugin to monitor CPU usage, for a selected set of users
|
||||
#
|
||||
# Usage: Place in /etc/munin/node.d/ (or link it there using ln -s)
|
||||
# Add this to your /etc/munin/plugin-conf.d/munin-node:
|
||||
# [cpubyuser]
|
||||
# env.USERS root yann
|
||||
#
|
||||
# If env.USERS is set to ALL, count all logged in users.
|
||||
#
|
||||
# root and yann being a list of the users to monitor.
|
||||
# You need to also make sure that awk is installed
|
||||
#
|
||||
# 2008-12-08 v 1.3.1 Hanisch Elián:
|
||||
# - support for dots in user names.
|
||||
# - fix labels
|
||||
#
|
||||
# 2008-12-01 v 1.3 Hanisch Elián:
|
||||
# - fixes, refactoring and code cleanup
|
||||
# - Users that use cpu but aren't in the USERS env var
|
||||
# are plotted as "others", set others.graph to 'no' if
|
||||
# you don't want this.
|
||||
#
|
||||
# 2008-03-20 v 1.2 fireball: fixed minor screwup, works now ^^
|
||||
#
|
||||
# 2008-01-09 v 1.1 fireball: fixed "-" in usernames, those get replaced by "_" now.
|
||||
# set usernames in config accordingly (that is with _)
|
||||
#
|
||||
#
|
||||
# Parameters understood:
|
||||
#
|
||||
# config (required)
|
||||
# autoconf (optional - used by munin-config)
|
||||
#
|
||||
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf
|
||||
|
||||
. "$MUNIN_LIBDIR/plugins/plugin.sh"
|
||||
|
||||
OTHER_FIELD="others"
|
||||
[ "$USERS" = "ALL" ] && USERS=$(w --no-header | awk '{ print $1 }' | sort | uniq)
|
||||
|
||||
|
||||
if [ "$1" = "autoconf" ]; then
|
||||
if [ -n "$USERS" ]; then
|
||||
echo "yes"
|
||||
else
|
||||
echo "no (USERS setting is missing)"
|
||||
fi
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
echo "graph_args --base 1000 -r --lower-limit 0"
|
||||
echo "graph_title CPU usage, by user"
|
||||
echo "graph_category system"
|
||||
echo "graph_info This graph shows CPU usage, for monitored users."
|
||||
echo "graph_vlabel %"
|
||||
echo "graph_scale no"
|
||||
echo "graph_period second"
|
||||
user_fields="$(for user in $USERS; do clean_fieldname "$user" | tr '\n' ' '; done)"
|
||||
echo "graph_order $user_fields $OTHER_FIELD"
|
||||
for user in $USERS "$OTHER_FIELD"; do
|
||||
user_field="$(clean_fieldname "$user")"
|
||||
echo "${user_field}.label $user"
|
||||
echo "${user_field}.info CPU used by user $user"
|
||||
echo "${user_field}.type GAUGE"
|
||||
echo "${user_field}.draw AREASTACK"
|
||||
done
|
||||
exit
|
||||
fi
|
||||
|
||||
top -b -n 1 | sed '1,/^ *PID /d' | \
|
||||
awk -v USERS="$USERS" '
|
||||
# Store the CPU usage of each process - the mapping to the
|
||||
# user happens later. We cannot use the second column
|
||||
# (username) directly, since it may be abbreviated (ending
|
||||
# with "+").
|
||||
{ CPU_PER_PID[$1]=$9 }
|
||||
END {
|
||||
split(USERS, user_array)
|
||||
for (user_index in user_array) {
|
||||
user = user_array[user_index]
|
||||
# retrieve all process IDs belonging to the user
|
||||
"ps -u "user" -o pid --no-headers 2>/dev/null | tr \"\n\" \" \"" | getline pids
|
||||
user_cpu = 0
|
||||
split(pids, pid_array)
|
||||
# summarize the cpu usage of this usage
|
||||
for (pid_index in pid_array) {
|
||||
pid = pid_array[pid_index]
|
||||
user_cpu += CPU_PER_PID[pid]
|
||||
delete CPU_PER_PID[pid]
|
||||
}
|
||||
print user, user_cpu
|
||||
}
|
||||
# add all remaining cpu usages into "others"
|
||||
others_sum = 0
|
||||
for (other_usage in CPU_PER_PID) others_sum+=CPU_PER_PID[other_usage]
|
||||
print "'"$OTHER_FIELD"'", others_sum;
|
||||
}' | while read -r user count; do
|
||||
# apply fieldname cleanup
|
||||
echo "$(clean_fieldname "$user").value $count"
|
||||
done
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
=head1 NAME
|
||||
|
||||
irq - Plugin to monitor inerrupts.
|
||||
irq - Plugin to monitor interrupts.
|
||||
|
||||
=head1 APPLICABLE SYSTEMS
|
||||
|
||||
|
|
|
@ -1,137 +0,0 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Plugin to monitor the load average on a system.
|
||||
#
|
||||
# Usage: Link or copy into /etc/munin/node.d/
|
||||
#
|
||||
# $Log$
|
||||
# Revision 1.5 2004/05/20 19:02:37 jimmyo
|
||||
# Set categories on a bunch of plugins
|
||||
#
|
||||
# Revision 1.4 2004/05/20 13:57:12 jimmyo
|
||||
# Set categories to some of the plugins.
|
||||
#
|
||||
# Revision 1.3 2004/05/16 12:41:04 jimmyo
|
||||
# Changed load plot from lastminute to last 5 minutes.
|
||||
#
|
||||
# Revision 1.2 2004/05/16 12:34:26 jimmyo
|
||||
# Added "info"-fields to linux/cpu and linux/load plugins, to demonstrate how it works.
|
||||
#
|
||||
# Revision 1.1 2004/01/02 18:50:01 jimmyo
|
||||
# Renamed occurrences of lrrd -> munin
|
||||
#
|
||||
# Revision 1.1.1.1 2004/01/02 15:18:07 jimmyo
|
||||
# Import of LRRD CVS tree after renaming to Munin
|
||||
#
|
||||
# Revision 1.4 2003/11/15 11:10:28 jimmyo
|
||||
# Various fixes
|
||||
#
|
||||
# Revision 1.3 2003/11/07 17:43:16 jimmyo
|
||||
# Cleanups and log entries
|
||||
#
|
||||
#
|
||||
#
|
||||
# Magic markers (optional - only used by munin-config and some
|
||||
# installation scripts):
|
||||
#
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf
|
||||
|
||||
|
||||
|
||||
# If run with the "autoconf"-parameter, give our opinion on whether we
|
||||
# should be run on this system or not. This is optinal, and only used by
|
||||
# munin-config. In the case of this plugin, we should most probably
|
||||
# always be included.
|
||||
|
||||
if [ "$1" = "autoconf" ]; then
|
||||
echo yes
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# If run with the "config"-parameter, give out information on how the
|
||||
# graphs should look.
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
# The host name this plugin is for. (Can be overridden to have
|
||||
# one machine answer for several)
|
||||
|
||||
# The title of the graph
|
||||
echo 'graph_title Load average'
|
||||
# Arguments to "rrdtool graph". In this case, tell it that the
|
||||
# lower limit of the graph is '0', and that 1k=1000 (not 1024)
|
||||
echo 'graph_args --base 1000 -l 0'
|
||||
# The Y-axis label
|
||||
echo 'graph_vlabel load'
|
||||
# We want Cur/Min/Avg/Max unscaled (i.e. 0.42 load instead of
|
||||
# 420 milliload)
|
||||
echo 'graph_scale no'
|
||||
# Graph category. Defaults to 'other'
|
||||
echo 'graph_category system'
|
||||
# The fields. "label" is used in the legend. "label" is the only
|
||||
# required subfield.
|
||||
echo 'load1.label load 1 min avg'
|
||||
echo 'load1.draw AREA'
|
||||
echo 'load5.label load 5 min avg'
|
||||
echo 'load5.draw AREA'
|
||||
echo 'load15.label load 15 min avg'
|
||||
echo 'load15.draw AREA'
|
||||
# These 6 are optional. They are only used if you have
|
||||
# configured your munin to tell a Nagios-server about any
|
||||
# problems
|
||||
echo 'load1.warning 10'
|
||||
echo 'load1.critical 120'
|
||||
echo 'load5.warning 10'
|
||||
echo 'load5.critical 120'
|
||||
echo 'load15.warning 10'
|
||||
echo 'load15.critical 120'
|
||||
# This one is purely to add an explanation to the web page. The first
|
||||
# one is for the graph itself, while the second one is for the field
|
||||
# "load".
|
||||
echo 'graph_info The load average of the machine describes how many processes are in the run-queue (scheduled to run "immediately").'
|
||||
echo 'load1.info Average load for 1 minute avg.'
|
||||
echo 'load5.info Average load for 5 minutes avg.'
|
||||
echo 'load15.info Average load for 15 minutes avg.'
|
||||
|
||||
# Last, if run with the "config"-parameter, quit here (don't
|
||||
# display any data)
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# If not run with any parameters at all (or only unknown ones), do the
|
||||
# real work - i.e. display the data. Almost always this will be
|
||||
# "value" subfield for every data field.
|
||||
|
||||
echo -n "load1.value "
|
||||
cut -f1 -d' ' < /proc/loadavg
|
||||
|
||||
echo -n "load5.value "
|
||||
cut -f2 -d' ' < /proc/loadavg
|
||||
|
||||
echo -n "load15.value "
|
||||
cut -f3 -d' ' < /proc/loadavg
|
||||
|
||||
# How could this plugin have been written in its simplest form?
|
||||
# Something like this:
|
||||
#
|
||||
# ---------------------
|
||||
# #!/bin/sh
|
||||
|
||||
#
|
||||
# if [ "$1" = "config" ]; then
|
||||
|
||||
# echo "graph_title Load average"
|
||||
# echo 'graph_args --base 1000 -l 0'
|
||||
# echo 'graph_vlabel load'
|
||||
# echo "load.label load"
|
||||
# exit 0
|
||||
# fi
|
||||
# echo -n "load.value "
|
||||
# cut -f1 -d' ' < /proc/loadavg
|
||||
# ---------------------
|
||||
#
|
||||
# Except for the Nagios-warnings (which most people don't have any need
|
||||
# for) and things used by installation scripts and munin-config (which
|
||||
# you don't need if you don't plan on submitting your plugin to the
|
||||
# pacakge), and the scaling (no milliload numbers) the two versions will
|
||||
# work identically.
|
|
@ -80,7 +80,7 @@ if (@ARGV and $ARGV[0] eq "config")
|
|||
graph_title Page faults by Process
|
||||
graph_args --base 1000
|
||||
graph_vlabel major page faults
|
||||
graph_category system
|
||||
graph_category processes
|
||||
graph_info Shows number of major page faults caused by each process name
|
||||
END
|
||||
|
||||
|
|
|
@ -1,165 +0,0 @@
|
|||
#!/usr/bin/perl
|
||||
# Munin plugin for monitoring swapspace usage
|
||||
#
|
||||
# FIELDS:
|
||||
# Swap Alloc swap allocated (used)
|
||||
# Swap Unalloc swap reserved but not allocated
|
||||
# Swap Avail swap available for reservation
|
||||
#
|
||||
# Core logic developed by Brendan Gregg.
|
||||
# REFERENCE: http://www.brendangregg.com/k9toolkit.html - the swap diagram.
|
||||
#
|
||||
# COPYRIGHT: Copyright (c) 2004 Brendan Gregg.
|
||||
#
|
||||
# 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; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# (http://www.gnu.org/copyleft/gpl.html)
|
||||
|
||||
# Perldoc
|
||||
|
||||
=pod
|
||||
|
||||
=head1 NAME
|
||||
|
||||
swapspace_info - Plugin to monitor Swapspace usage
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Christian Braum, chrisi_braum@web.de
|
||||
|
||||
Core logic developed by Brendan Gregg. See K9Toolkit:
|
||||
http://www.brendangregg.com/K9Toolkit/swapinfo
|
||||
|
||||
=head1 LICENSE
|
||||
|
||||
GPL 2.
|
||||
|
||||
=cut
|
||||
|
||||
# Main
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
if ( defined $ARGV[0] )
|
||||
{
|
||||
if ( $ARGV[0] eq "config" )
|
||||
{
|
||||
&config();
|
||||
}
|
||||
else
|
||||
{
|
||||
&output();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
&output();
|
||||
}
|
||||
|
||||
sub value
|
||||
{
|
||||
my %h_swapvalue;
|
||||
eval 'use Sun::Solaris::Kstat; 1;'
|
||||
or die 'Please install Sun::Solaris::Kstat';
|
||||
my $Kstat = Sun::Solaris::Kstat->new();
|
||||
|
||||
# --- Fetch Hardware info ---
|
||||
### pagesize
|
||||
$ENV{PATH} = "/usr/bin";
|
||||
chomp(my $PAGESIZE = `pagesize`);
|
||||
my $PAGETOMB = $PAGESIZE / (1024 * 1024);
|
||||
my $PAGETOBYTE = $PAGESIZE;
|
||||
my $BLOCKTOP = 512 / $PAGESIZE;
|
||||
my %VMnow;
|
||||
my %VMold;
|
||||
my %VMinfo;
|
||||
|
||||
# --- Fetch VM info ---
|
||||
foreach my $count (0..12)
|
||||
{
|
||||
#
|
||||
# The values are counters that increment each second, here we
|
||||
# check them several times and look for the value changing.
|
||||
# (reading them once then again a second later was not reliable).
|
||||
#
|
||||
foreach my $var ("swap_avail","swap_alloc","swap_free")
|
||||
{
|
||||
$VMnow{$var} = $Kstat->{unix}->{0}->{vminfo}->{$var};
|
||||
unless ($count)
|
||||
{
|
||||
$VMold{$var} = $VMnow{$var};
|
||||
next;
|
||||
}
|
||||
if (($VMnow{$var} != $VMold{$var}) && (! $VMinfo{$var}))
|
||||
{
|
||||
$VMinfo{$var} = $VMnow{$var} - $VMold{$var};
|
||||
}
|
||||
}
|
||||
select(undef, undef, undef, 0.1);
|
||||
$Kstat->update();
|
||||
}
|
||||
|
||||
# --- Calculations ---
|
||||
|
||||
### Swap
|
||||
my $swap_free = $VMinfo{swap_free};
|
||||
my $swap_avail = $VMinfo{swap_avail};
|
||||
my $swap_alloc = $VMinfo{swap_alloc};
|
||||
my $swap_unalloc = $swap_free - $swap_avail;
|
||||
|
||||
my $swap_unalloc_B = sprintf( "%d ", $swap_unalloc * $PAGETOBYTE );
|
||||
my $swap_avail_B = sprintf( "%d ", $swap_avail * $PAGETOBYTE );
|
||||
my $swap_alloc_B = sprintf( "%d ", $swap_alloc * $PAGETOBYTE );
|
||||
my $swap_free_B = sprintf( "%d ", $swap_free * $PAGETOBYTE );
|
||||
|
||||
$h_swapvalue{"Alloc.value"} = "$swap_alloc_B";
|
||||
$h_swapvalue{"Unalloc.value"} = "$swap_unalloc_B";
|
||||
$h_swapvalue{"Avail.value"} = "$swap_avail_B";
|
||||
|
||||
return %h_swapvalue;
|
||||
}
|
||||
|
||||
sub output
|
||||
{
|
||||
my %h_swapvalues=value();
|
||||
print "Alloc.value " . $h_swapvalues{"Alloc.value"} . " \n";
|
||||
print "Unalloc.value " . $h_swapvalues{"Unalloc.value"} . " \n";
|
||||
print "Avail.value " . $h_swapvalues{"Avail.value"} . "\n";
|
||||
}
|
||||
|
||||
sub config
|
||||
{
|
||||
print "graph_args --base 1024 -l 0 \n";
|
||||
print "graph_vlabel Bytes\n";
|
||||
print "graph_title Swapspace usage\n";
|
||||
print "graph_category system\n";
|
||||
print "graph_info This graph shows what the machine uses Swapspace for.\n";
|
||||
print "graph_order ";
|
||||
|
||||
print "Alloc ",
|
||||
"Unalloc ",
|
||||
"Avail ",
|
||||
"\n";
|
||||
|
||||
print "Alloc.label Alloc \n";
|
||||
print "Alloc.draw \n";
|
||||
print "Alloc.info Swap used.\n";
|
||||
print "Unalloc.label Unalloc \n";
|
||||
print "Unalloc.draw \n";
|
||||
print "Unalloc.info Swap reserved but not allocated.\n";
|
||||
print "Avail.label Avail \n";
|
||||
print "Avail.draw \n";
|
||||
print "Avail.info Swap available.\n";
|
||||
}
|
|
@ -90,7 +90,7 @@ if (@ARGV and $ARGV[1] == "config")
|
|||
{
|
||||
print <<END;
|
||||
graph_title $fieldname by Process
|
||||
graph_category system
|
||||
graph_category processes
|
||||
graph_info Shows total of $fieldname (reported by ps) for each process name
|
||||
graph_vlabel $fieldname (from ps)
|
||||
END
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue