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
117
plugins/system/auth
Executable file
117
plugins/system/auth
Executable file
|
@ -0,0 +1,117 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# A Munin Plugin to show auth stuff
|
||||
# Created by Dominik Schulz <lkml@ds.gauner.org>
|
||||
# http://developer.gauner.org/munin/
|
||||
# Based on a work of "jintxo"
|
||||
#
|
||||
# Parameters understood:
|
||||
#
|
||||
# config (required)
|
||||
# autoconf (optional - used by munin-config)
|
||||
#
|
||||
#
|
||||
# Magic markers (optional - used by munin-config and installation
|
||||
# scripts):
|
||||
#
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf
|
||||
|
||||
|
||||
#############################
|
||||
# Configuration
|
||||
#############################
|
||||
MAXLABEL=20
|
||||
STAT_FILE=/var/lib/munin/plugin-state/plugin-auth.state
|
||||
EXPR_BIN=/usr/bin/expr
|
||||
#############################
|
||||
|
||||
if [ "$1" = "autoconf" ]; then
|
||||
echo yes
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
|
||||
echo 'graph_title Auth Log Parser'
|
||||
echo 'graph_args --base 1000 -l 0'
|
||||
echo 'graph_vlabel Daily Auth Counters'
|
||||
echo 'graph_category system'
|
||||
echo 'illegal_user.label Illegal User'
|
||||
echo 'possible_breakin.label Breakin Attempt'
|
||||
echo 'authentication_failure.label Authentication Fail'
|
||||
echo 'valid_login.label Valid Login'
|
||||
exit 0
|
||||
fi
|
||||
|
||||
#############################
|
||||
# Initialization
|
||||
#############################
|
||||
if [ ! -r $STAT_FILE ]; then
|
||||
echo "ILL=0" > $STAT_FILE
|
||||
echo "POS=0" >> $STAT_FILE
|
||||
echo "AUT=0" >> $STAT_FILE
|
||||
echo "VAL=0" >> $STAT_FILE
|
||||
fi
|
||||
#############################
|
||||
|
||||
#############################
|
||||
# Illegal User
|
||||
#############################
|
||||
echo -en "illegal_user.value "
|
||||
NEW_ILL=$(grep "Illegal user\|no such user" /var/log/auth.log | grep "`date '+%b %d'`" | wc -l)
|
||||
OLD_ILL=$(grep ILL $STAT_FILE | cut -f2 -d '=')
|
||||
ILL=$($EXPR_BIN $NEW_ILL - $OLD_ILL)
|
||||
if [ $ILL -gt 0 ]; then
|
||||
echo "$ILL"
|
||||
else
|
||||
echo "0"
|
||||
fi
|
||||
echo -n
|
||||
#############################
|
||||
# Possible Breakins
|
||||
#############################
|
||||
echo -en "possible_breakin.value "
|
||||
NEW_POS=$(grep -i "breakin attempt" /var/log/auth.log | grep "`date '+%b %d'`" | wc -l)
|
||||
OLD_POS=$(grep POS $STAT_FILE | cut -f2 -d '=')
|
||||
POS=$($EXPR_BIN $NEW_POS - $OLD_POS)
|
||||
if [ $POS -gt 0 ]; then
|
||||
echo "$POS"
|
||||
else
|
||||
echo "0"
|
||||
fi
|
||||
echo -n
|
||||
#############################
|
||||
# Authentication Failures
|
||||
#############################
|
||||
echo -en "authentication_failure.value "
|
||||
NEW_AUT=$(grep "authentication failure" /var/log/auth.log | grep "`date '+%b %d'`" | wc -l)
|
||||
OLD_AUT=$(grep AUT $STAT_FILE | cut -f2 -d '=')
|
||||
AUT=$($EXPR_BIN $NEW_AUT - $OLD_AUT)
|
||||
if [ $AUT -gt 0 ]; then
|
||||
echo "$AUT"
|
||||
else
|
||||
echo "0"
|
||||
fi
|
||||
echo -n
|
||||
#############################
|
||||
# Valid Logins
|
||||
#############################
|
||||
echo -en "valid_login.value "
|
||||
NEW_VAL=$(grep "sshd.*Accepted" /var/log/auth.log | grep "`date '+%b %d'`" | wc -l)
|
||||
OLD_VAL=$(grep VAL $STAT_FILE | cut -f2 -d '=')
|
||||
VAL=$($EXPR_BIN $NEW_VAL - $OLD_VAL)
|
||||
if [ $VAL -gt 0 ]; then
|
||||
echo "$VAL"
|
||||
else
|
||||
echo "0"
|
||||
fi
|
||||
echo -n
|
||||
###
|
||||
# Save the current values
|
||||
###
|
||||
echo "ILL=$NEW_ILL" > $STAT_FILE
|
||||
echo "POS=$NEW_POS" >> $STAT_FILE
|
||||
echo "AUT=$NEW_AUT" >> $STAT_FILE
|
||||
echo "VAL=$NEW_VAL" >> $STAT_FILE
|
||||
|
39
plugins/system/bgpd
Executable file
39
plugins/system/bgpd
Executable file
|
@ -0,0 +1,39 @@
|
|||
#!/bin/sh
|
||||
|
||||
# bgpd.sh
|
||||
#
|
||||
#
|
||||
# Created by spleen.
|
||||
|
||||
if [ "$1" = "autoconf" ]; then
|
||||
echo yes
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
|
||||
echo 'graph_title bgp pfxs'
|
||||
echo 'graph_args -l 0'
|
||||
echo 'graph_vlabel PfxRcvd'
|
||||
echo 'graph_category System'
|
||||
echo 'graph_scale no'
|
||||
echo 'graph_info show ip bgp summary'
|
||||
mfs=0
|
||||
/usr/local/bin/vtysh -c "sh ip bgp su" | /usr/bin/awk '{ if (( $2 == "4" ) || ( $2 == "6")) print $1 }' | while read i; do
|
||||
case $i in
|
||||
*) name=`echo $i | /usr/bin/awk '{ gsub("[^a-zA-Z0-9_]", root_, $1); print $1 }'` ;;
|
||||
esac
|
||||
dn=`echo $i | sed 's/_/ /g'`
|
||||
echo "$name.label $dn"
|
||||
done
|
||||
exit 0
|
||||
fi
|
||||
|
||||
/usr/local/bin/vtysh -c "sh ip bgp su" | /usr/bin/awk '{ if (( $2 == "4" ) || ( $2 == "6")) print $1,$10 }' | while read i; do
|
||||
case $i in
|
||||
*) name=`echo $i | /usr/bin/awk '{ gsub("[^a-zA-Z0-9_]", root_, $1); print $1 }'` ;;
|
||||
esac
|
||||
dn=`echo $i | awk '{print $2}'`
|
||||
echo "$name.value $dn"
|
||||
done
|
||||
|
39
plugins/system/blockhosts
Executable file
39
plugins/system/blockhosts
Executable file
|
@ -0,0 +1,39 @@
|
|||
#!/bin/sh
|
||||
# Plugin to monitor the number of hosts denied by BlockHosts
|
||||
#
|
||||
# $Log$
|
||||
# based on:
|
||||
# denyhosts plugin
|
||||
# Revision 1.0 2009/06/05 16:00:00 tjansson
|
||||
#
|
||||
# Modified by d.becker 2010/02/04
|
||||
#
|
||||
# Parameters:
|
||||
# config (required)
|
||||
# autoconf (optional - used by munin-config)
|
||||
|
||||
LOG=/etc/hosts.allow
|
||||
|
||||
if [ "$1" = "autoconf" ]; then
|
||||
if [ -r "$LOG" ]; then
|
||||
echo yes
|
||||
exit 0
|
||||
else
|
||||
echo no
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
|
||||
echo 'graph_title Hosts denied by BlockHosts'
|
||||
echo 'graph_args -l 0'
|
||||
echo 'graph_vlabel denied hosts '
|
||||
echo 'graph_category system'
|
||||
echo 'HostsDenied.label Hosts denied by BlockHosts'
|
||||
echo 'HostsWatched.label Hosts watched by BlockHosts'
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo HostsDenied.value `egrep -c " : deny" $LOG`
|
||||
echo HostsWatched.value `egrep -c "#bh: ip:" $LOG`
|
146
plugins/system/buddyinfo
Executable file
146
plugins/system/buddyinfo
Executable file
|
@ -0,0 +1,146 @@
|
|||
#! /usr/bin/perl -w
|
||||
|
||||
=head1 NAME
|
||||
|
||||
buddyinfo - Plugin to monitor memory fragmentation on Linux systems.
|
||||
|
||||
=head1 APPLICABLE SYSTEMS
|
||||
|
||||
Linux 2.6
|
||||
|
||||
=head1 CONFIGURATION
|
||||
|
||||
None needed.
|
||||
|
||||
=head1 INTERPRETATION
|
||||
|
||||
Linux manages virtual memory on a page granularity. There are some operations
|
||||
however that require physically contiguous pages to be allocated by the kernel.
|
||||
Such allocations may fail if the memory gets fragmented and even though there
|
||||
are enough pages free, but they are not contiguous.
|
||||
|
||||
This plugin monitors the amount of contiguous areas, called higher order pages.
|
||||
The order means the exponent of two of the size of the area, so order 2 means
|
||||
2^2 = 4 pages.
|
||||
|
||||
=head1 SEE ALSO
|
||||
|
||||
See C<Documentation/filesystems/proc.txt> in the Linux source tree for the
|
||||
description of the buddyinfo file.
|
||||
|
||||
=head1 MAGIC MARKERS
|
||||
|
||||
#%# family=manual
|
||||
#%# capabilities=autoconf
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Gábor Gombás <gombasg@sztaki.hu>
|
||||
|
||||
=head1 LICENSE
|
||||
|
||||
GPLv2 or later
|
||||
|
||||
=cut
|
||||
|
||||
use strict;
|
||||
use Munin::Plugin;
|
||||
use POSIX;
|
||||
use Carp;
|
||||
|
||||
need_multigraph();
|
||||
|
||||
if ($ARGV[0] and $ARGV[0] eq 'autoconf') {
|
||||
if (-f "/proc/buddyinfo") {
|
||||
print "yes\n";
|
||||
}
|
||||
else {
|
||||
print "no (/proc/buddyinfo is missing)\n";
|
||||
}
|
||||
exit 0;
|
||||
}
|
||||
|
||||
# The most common page size is 4k, but it is not universal
|
||||
my $pagesize = POSIX::sysconf(&POSIX::_SC_PAGESIZE) / 1024;
|
||||
|
||||
my $zones = {};
|
||||
|
||||
open(FH, '< /proc/buddyinfo')
|
||||
or croak "Failed to open '/proc/buddyinfo': $!";
|
||||
while (my $line = <FH>) {
|
||||
chomp $line;
|
||||
|
||||
$line =~ m/Node (\d+), zone\s+(\S+)\s+(\S.*)$/;
|
||||
my $name = "Node $1, zone $2";
|
||||
my @cnt = split(/ +/, $3);
|
||||
$zones->{$name} = \@cnt;
|
||||
}
|
||||
close FH;
|
||||
|
||||
my $totals = [];
|
||||
foreach my $zone (keys %$zones) {
|
||||
for my $i (0 .. $#{$zones->{$zone}}) {
|
||||
$totals->[$i] += $zones->{$zone}->[$i]
|
||||
}
|
||||
}
|
||||
|
||||
sub do_config {
|
||||
print "multigraph buddyinfo\n";
|
||||
print "graph_title Memory fragmentation\n";
|
||||
print "graph_args --base 1024 --lower-limit 0\n";
|
||||
print "graph_vlabel pages free\n";
|
||||
print "graph_category system\n";
|
||||
print "graph_info This graph shows the number of free pages of different size\n";
|
||||
print "graph_order " . join(' ', map { "order$_" } (0 .. $#{$totals})) . "\n";
|
||||
for my $i (0 .. $#{$totals}) {
|
||||
print "order$i.label Order $i\n";
|
||||
print "order$i.info Number of order $i (" . ($pagesize * 2 ** $i) . " KiB) pages\n";
|
||||
print "order$i.type GAUGE\n";
|
||||
print "order$i.draw LINE2\n";
|
||||
print "order$i.min 0\n";
|
||||
}
|
||||
for my $zone (sort keys %$zones) {
|
||||
my $zoneid = $zone;
|
||||
$zoneid = clean_fieldname($zone);
|
||||
|
||||
print "multigraph buddyinfo.$zoneid\n";
|
||||
print "graph_title Memory fragmentation in $zone\n";
|
||||
print "graph_args --base 1024 --lower-limit 0\n";
|
||||
print "graph_vlabel pages free\n";
|
||||
print "graph_category system\n";
|
||||
print "graph_info This graph shows the number of free pages in $zone\n";
|
||||
print "graph_order " .
|
||||
join(' ', map { "order$_" } (0 .. $#{$zones->{$zone}})) . "\n";
|
||||
for my $i (0 .. $#{$zones->{$zone}}) {
|
||||
print "order$i.label Order $i\n";
|
||||
print "order$i.info Number of order $i (" .
|
||||
($pagesize * 2 ** $i) . " KiB) pages\n";
|
||||
print "order$i.type GAUGE\n";
|
||||
print "order$i.draw LINE2\n";
|
||||
print "order$i.min 0\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub do_fetch {
|
||||
print "multigraph buddyinfo\n";
|
||||
for my $i (0 .. $#{$totals}) {
|
||||
print "order$i.value " . $totals->[$i] . "\n";
|
||||
}
|
||||
for my $zone (sort keys %$zones) {
|
||||
my $zoneid = $zone;
|
||||
$zoneid =~ tr/ ,/__/;
|
||||
|
||||
print "multigraph buddyinfo.$zoneid\n";
|
||||
for my $i (0 .. $#{$zones->{$zone}}) {
|
||||
print "order$i.value " . $zones->{$zone}->[$i] . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($ARGV[0] and $ARGV[0] eq 'config') {
|
||||
do_config();
|
||||
exit 0;
|
||||
}
|
||||
|
||||
do_fetch();
|
84
plugins/system/cpu-usage-by-process
Executable file
84
plugins/system/cpu-usage-by-process
Executable file
|
@ -0,0 +1,84 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Plugin to monitor CPU usage, for a selected set of processes. Tested on FreeBSD.
|
||||
#
|
||||
# Author: Erik Cederstrand
|
||||
# Based on http://waste.mandragor.org/munin_tutorial/cpubyuser
|
||||
# Thanks to Yann Hamon.
|
||||
#
|
||||
# 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:
|
||||
# [cpubyproc]
|
||||
# env.procs httpd java
|
||||
#
|
||||
# httpd and java being a list of the processes to monitor.
|
||||
|
||||
#
|
||||
# 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
|
||||
|
||||
if [ "$1" = "config" ] ; then
|
||||
echo "graph_args --base 1000 -r --lower-limit 0";
|
||||
echo "graph_title CPU usage, by process";
|
||||
echo "graph_category system";
|
||||
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 $procs"
|
||||
|
||||
FIRSTPROC=1;
|
||||
for proc in $procs; do
|
||||
echo "${proc}.label $proc"
|
||||
echo "${proc}.info CPU used by process $proc"
|
||||
echo "${proc}.type GAUGE"
|
||||
if [ $FIRSTPROC -eq 1 ] ; then
|
||||
echo "${proc}.draw AREA"
|
||||
export FIRSTPROC=0;
|
||||
else
|
||||
echo "${proc}.draw STACK"
|
||||
fi
|
||||
done ;
|
||||
|
||||
exit
|
||||
fi
|
||||
|
||||
|
||||
|
||||
for proc in $procs ; do {
|
||||
|
||||
ps -axo 'pcpu,comm' | grep "$proc" |
|
||||
awk '
|
||||
BEGIN {
|
||||
FS=" "
|
||||
CPU_PROC=0
|
||||
}
|
||||
|
||||
{
|
||||
CPU_PROC+=$0
|
||||
}
|
||||
|
||||
END {
|
||||
print "'$proc'.value "CPU_PROC
|
||||
}'
|
||||
}
|
||||
|
||||
done;
|
135
plugins/system/cpu_by_process
Executable file
135
plugins/system/cpu_by_process
Executable file
|
@ -0,0 +1,135 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Copyright (C) 2006 Holger Levsen
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# Configuration variables
|
||||
# vservers - specify the vservers to include in the graph (default: all)
|
||||
# limits - if true, turn on limit graphing (default: false)
|
||||
#
|
||||
# NOTE: If no configuration variables are set, the defaults will be used
|
||||
|
||||
# Example /etc/munin/plugin-conf.d/munin-node
|
||||
#
|
||||
# The first group monitors the vservers named "vserver1 vserver2
|
||||
# vserver3 vserver4" and looks to see if the resource limit has been
|
||||
# breached, if so it sends a message to nagios via send_nsca, and
|
||||
# sends an email to notify that this has happened.
|
||||
#
|
||||
# The second monitors the vservers "vserver5 vserver6 vserver7" and
|
||||
# has no limit notifications turned on.
|
||||
#
|
||||
# The third monitors all vservers on the system, in one graph, and it has
|
||||
# no limit notifications defined.
|
||||
#
|
||||
# You can use any combination of these to fit your needs.
|
||||
#
|
||||
#
|
||||
# [vsrmem_group1]
|
||||
# user root
|
||||
# env.vservers vserver1 vserver2 vserver3 vserver4
|
||||
# env.limits 1
|
||||
# contacts nagios email
|
||||
# contact.nagios.command /usr/bin/send_nsca -H your.nagios-host.here -c /etc/send_nsca.cfg
|
||||
# contact.email.command mail -s "Munin-notification for ${var:group} :: ${var:host}" your@email.address.here
|
||||
#
|
||||
# [vsrmem_group2]
|
||||
# user root
|
||||
# env.vservers vserver5 vserver6 vserver7
|
||||
# env.limits 0
|
||||
#
|
||||
# [vserver_rmemory]
|
||||
# user root
|
||||
#
|
||||
# Graph Vserver RSS usage and limits
|
||||
#
|
||||
# Changelog
|
||||
# version 0.1 - 2006 April xx - Holger Levsen
|
||||
# - initial author
|
||||
# version 0.2 - 2006 April 24 - Micah Anderson <micah@riseup.net>
|
||||
# - Add dynamic arch page size determination
|
||||
# - Some cleanup and clarification
|
||||
# version 0.3 - 2006 May 3 - Micah Anderson <micah@riseup.net>
|
||||
# - Add ability to group vservers via environment vars
|
||||
# - Fix missing close quotes and standardize indents
|
||||
# - Add limit notification
|
||||
# - Update documentation to include info on groups and limits
|
||||
# version 0.4 - 2006 Jun 22 - Micah Anderson <micah@riseup.net>
|
||||
# - Fix error that results if NodeName is set to include a domain name
|
||||
|
||||
#scriptname=`basename $0`
|
||||
#vsname=`echo $scriptname | perl -ne '/^vserver_proc_VM_(.*)/ and print $1'`
|
||||
|
||||
#if [ "$1" = "suggest" ]; then
|
||||
# ls -1 /etc/vservers
|
||||
# exit 0
|
||||
#elif [ -z "$vsname" ]; then
|
||||
# echo "Must be used with a vserver name; try '$0 suggest'" >&2
|
||||
# exit 2
|
||||
#fi
|
||||
|
||||
#xid=`cat /etc/vservers/$vsname/context`
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
echo "graph_title CPU time by Process"
|
||||
echo 'graph_args --base 1000 -l 0'
|
||||
echo 'graph_vlabel seconds'
|
||||
echo 'graph_category system'
|
||||
echo "graph_info Shows CPU time used by each process name"
|
||||
|
||||
# ps -eo time,comm h | perl -e '
|
||||
ps -eo pid,time,comm | perl -e '
|
||||
$junk = <>;
|
||||
while (<>)
|
||||
{
|
||||
@a = split;
|
||||
$proc = $a[2];
|
||||
$var = $proc;
|
||||
$var =~ s|/.*||;
|
||||
$var =~ s|\.$||;
|
||||
$var =~ tr|a-zA-Z0-9|_|c;
|
||||
$procs{$var} = $proc;
|
||||
}
|
||||
my $stack = 0;
|
||||
sub draw() { return $stack++ ? "STACK" : "AREA" }
|
||||
print map
|
||||
{
|
||||
"$_.label $procs{$_}\n" .
|
||||
"$_.min 0\n" .
|
||||
"$_.type DERIVE\n" .
|
||||
"$_.draw " . draw() . "\n"
|
||||
}
|
||||
sort keys %procs;
|
||||
'
|
||||
exit 0
|
||||
else
|
||||
# ps -eo time,comm h | perl -e '
|
||||
ps -eo pid,time,comm | perl -e '
|
||||
$junk = <>;
|
||||
while (<>)
|
||||
{
|
||||
@a = split;
|
||||
$cpu = $a[1];
|
||||
$var = $a[2];
|
||||
$var =~ s|/.*||;
|
||||
$var =~ s|\.$||;
|
||||
$var =~ tr|a-zA-Z0-9|_|c;
|
||||
@b = split /:/, $cpu;
|
||||
$cpu = (($b[0] * 60) + $b[1]) * 60 + $b[2];
|
||||
$total{$var} += $cpu;
|
||||
}
|
||||
print map {"$_.value $total{$_}\n"} sort keys %total'
|
||||
fi
|
88
plugins/system/cpubyuser
Executable file
88
plugins/system/cpubyuser
Executable file
|
@ -0,0 +1,88 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# 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
|
||||
#
|
||||
# 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
|
||||
|
||||
if [ "$1" = "autoconf" ]; then
|
||||
if [ -n "$USERS" ]; then
|
||||
echo "yes"
|
||||
else
|
||||
echo "\$USERS not defined."
|
||||
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"
|
||||
_USERS=${USERS//[-.]/_}
|
||||
echo "graph_order $_USERS others"
|
||||
FIRSTUSER=1;
|
||||
for USER in $USERS "others"; do
|
||||
_USER=${USER//[-.]/_}
|
||||
echo "${_USER}.label $USER"
|
||||
echo "${_USER}.info CPU used by user $USER"
|
||||
echo "${_USER}.type GAUGE"
|
||||
if [ $FIRSTUSER -eq 1 ]; then
|
||||
echo "${_USER}.draw AREA"
|
||||
FIRSTUSER=0
|
||||
else
|
||||
echo "${_USER}.draw STACK"
|
||||
fi
|
||||
done
|
||||
exit
|
||||
fi
|
||||
|
||||
ps -e -o "%C%U" | \
|
||||
awk -v USERS="$USERS" '
|
||||
{ if ($2 != "USER") CPU_USER[$2]+=$1 }
|
||||
END {
|
||||
others_sum = 0
|
||||
for (user in CPU_USER) {
|
||||
m = match(USERS,user)
|
||||
if (m != 0) {
|
||||
_user=user
|
||||
gsub(/[-.]/,"_", _user);
|
||||
print _user".value", CPU_USER[user]
|
||||
} else
|
||||
others_sum += CPU_USER[user]
|
||||
}
|
||||
print "others.value", others_sum;
|
||||
}'
|
55
plugins/system/cpufreq
Executable file
55
plugins/system/cpufreq
Executable file
|
@ -0,0 +1,55 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Plugin to monitor CPU speed on system that allow to reduce it for power saving
|
||||
#
|
||||
# probably only useful on laptops if you configure it to lower CPU frequency for
|
||||
# less power consumptoin. This plugin works by reading from the /sys file system.
|
||||
#
|
||||
# by dominik dot stadler at gmx.at
|
||||
#
|
||||
# Magic markers (optional - only used by munin-config and some
|
||||
# installation scripts):
|
||||
#
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf
|
||||
|
||||
if [ "$1" = "autoconf" ]; then
|
||||
if [ -r /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq ]; then
|
||||
echo yes
|
||||
exit 0
|
||||
else
|
||||
echo no
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
echo 'graph_title CPU speed'
|
||||
echo 'graph_args --base 1000 -l 0'
|
||||
echo 'graph_vlabel speed'
|
||||
# echo 'graph_scale no'
|
||||
echo 'graph_category system'
|
||||
echo 'graph_info This graph shows the speed of the system fan.'
|
||||
echo 'maxspeed.label maxspeed'
|
||||
echo 'maxspeed.info The maximum speed of the CPU.'
|
||||
echo 'minspeed.label minspeed'
|
||||
echo 'minspeed.info The minimum speed of the CPU.'
|
||||
echo 'cpuspeed.label speed'
|
||||
echo 'cpuspeed.info The current speed of the CPU.'
|
||||
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo -n "maxspeed.value "
|
||||
cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq
|
||||
echo -n "minspeed.value "
|
||||
cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq
|
||||
echo -n "cpuspeed.value "
|
||||
|
||||
# cpuinfo_cur_freq is not readable for user munin, therefore using scaling_cur_freq for now, should
|
||||
# be equal information, see http://wiki.ubuntuusers.de/Prozessortaktung
|
||||
# We could also configure this plugin to require root access, but I like it better this way.
|
||||
#cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq
|
||||
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq
|
||||
|
144
plugins/system/cpufreq-avg
Executable file
144
plugins/system/cpufreq-avg
Executable file
|
@ -0,0 +1,144 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Plugin to measure average CPU frequency for each CPU/core.
|
||||
#
|
||||
# Contributed by Mark Edwards
|
||||
#
|
||||
# Usage: Place in /etc/munin/plugins (or link it there using ln -s)
|
||||
#
|
||||
# Parameters understood:
|
||||
#
|
||||
# config (required)
|
||||
# autoconf (optional - used by munin-config)
|
||||
#
|
||||
# $Log$
|
||||
#
|
||||
# Revision 0.2 2010/01/04 16:37:00 medwards
|
||||
# Minor bugfixes in config section
|
||||
#
|
||||
# Revision 0.1 2010/01/04 16:13:00 medwards
|
||||
# First version
|
||||
#
|
||||
#
|
||||
#
|
||||
# Magic markers - optional - used by installation scripts and
|
||||
# munin-config:
|
||||
#
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf
|
||||
|
||||
if [ "$1" = "autoconf" ]; then
|
||||
if [ -r /sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state ]; then
|
||||
echo yes
|
||||
exit 0
|
||||
else
|
||||
echo no
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
cpu_count=`grep -c "^processor" /proc/cpuinfo`
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
|
||||
echo 'graph_title Average CPU Frequency'
|
||||
up_lim=`cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq`
|
||||
low_lim=`cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq`
|
||||
up_lim=`expr $up_lim \* 1000` # Convert to Hz
|
||||
low_lim=`expr $low_lim \* 1000` # Convert to Hz
|
||||
echo "graph_args -u $up_lim -l $low_lim -r --base 1000"
|
||||
echo 'graph_vlabel Hz'
|
||||
echo 'graph_category system'
|
||||
cpu=0
|
||||
while [ $cpu -lt $cpu_count ]
|
||||
do
|
||||
echo "cpu_$cpu.label CPU $cpu"
|
||||
echo "cpu_$cpu.type GAUGE"
|
||||
echo "cpu_$cpu.info Hz"
|
||||
cpu=`expr $cpu + 1`
|
||||
done
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Run measurements
|
||||
cpu=0
|
||||
while [ $cpu -lt $cpu_count ]
|
||||
do
|
||||
|
||||
time_in_state=`cat /sys/devices/system/cpu/cpu$cpu/cpufreq/stats/time_in_state`
|
||||
|
||||
# Check/create statefile(s)
|
||||
statefile="/var/lib/munin/plugin-state/cpufreq-avg_cpu$cpu.state"
|
||||
if [ ! -r "$statefile" ]
|
||||
then
|
||||
echo "$time_in_state" > $statefile
|
||||
if [ "$?" -ne "0" ]
|
||||
then
|
||||
exit ${1}
|
||||
else
|
||||
cpu=`expr $cpu + 1`
|
||||
continue
|
||||
fi
|
||||
fi
|
||||
state=`cat $statefile`
|
||||
|
||||
# Calculated total time since last state
|
||||
total_time=0
|
||||
total_time=$(
|
||||
echo "$time_in_state" | {
|
||||
i=0
|
||||
while read line
|
||||
do
|
||||
this_freq=`echo $line | awk '{ print $1; }'`
|
||||
this_time=`echo $line | awk '{ print $2; }'`
|
||||
this_time_state=`echo "$state" | grep $this_freq | awk '{ print $2; }'`
|
||||
if [ $this_time -ge $this_time_state ] # Only measure if state is valid
|
||||
then
|
||||
time_diff=`expr $this_time - $this_time_state` # Calculate time since last state
|
||||
total_time=`expr $total_time + $time_diff`
|
||||
fi
|
||||
i=`expr $i + 1`
|
||||
done
|
||||
echo $total_time
|
||||
}
|
||||
)
|
||||
|
||||
# Measure average CPU frequency if total time calculation was successful
|
||||
|
||||
frequency=0
|
||||
frequency=$(
|
||||
echo "$time_in_state" | {
|
||||
i=0
|
||||
while read line
|
||||
do
|
||||
this_freq=`echo $line | awk '{ print $1; }'`
|
||||
this_time=`echo $line | awk '{ print $2; }'`
|
||||
this_time_state=`echo "$state" | grep $this_freq | awk '{ print $2; }'`
|
||||
this_freq=`expr $this_freq \* 1000` # Convert to Hz
|
||||
this_time=`expr $this_time - $this_time_state` # Calculate time since last state
|
||||
if [ $total_time -gt 0 ]
|
||||
then
|
||||
calc=`echo "($this_time / $total_time) * $this_freq" | bc -l`
|
||||
frequency=`echo "$frequency + $calc" | bc -l`
|
||||
fi
|
||||
i=`expr $i + 1`
|
||||
done
|
||||
echo $frequency
|
||||
}
|
||||
)
|
||||
|
||||
# Round result to an integer and return it
|
||||
frequency=`echo "scale=0 ; ($frequency+0.5)/1" | bc -l`
|
||||
if [ $frequency -gt 0 ]
|
||||
then
|
||||
echo "cpu_$cpu.value $frequency"
|
||||
fi
|
||||
|
||||
# Update statefile
|
||||
echo "$time_in_state" > $statefile
|
||||
|
||||
cpu=`expr $cpu + 1`
|
||||
|
||||
done
|
||||
|
||||
exit 0
|
100
plugins/system/cpufreq-info
Executable file
100
plugins/system/cpufreq-info
Executable file
|
@ -0,0 +1,100 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Plugin to measure CPU frequency via cpufreq-info binary.
|
||||
# This makes the plugin run on linux machines only.
|
||||
# However the same goes for using sysfs directly.
|
||||
#
|
||||
# Contributed by Jo Schulze
|
||||
#
|
||||
# Config variables:
|
||||
#
|
||||
#
|
||||
# Requires:
|
||||
# cpufrequtils http://www.kernel.org/pub/linux/utils/kernel/cpufreq/cpufrequtils.html
|
||||
#
|
||||
# @remarks
|
||||
# jo20061130 using cpufreq-info should simplify the whole thing
|
||||
# jo20061202 tested on AMD K8 X2, intel Core 2 Duo
|
||||
#
|
||||
# $Log$
|
||||
#
|
||||
# Magic markers - optional - used by installation scripts and
|
||||
# munin-config:
|
||||
#
|
||||
#%# family=manual
|
||||
#%# capabilities=autoconf
|
||||
|
||||
LC_ALL="C"
|
||||
|
||||
CINFOBIN="/usr/bin/cpufreq-info"
|
||||
|
||||
nCPU=$(grep -c "^processor" /proc/cpuinfo)
|
||||
|
||||
function getFreq ()
|
||||
{
|
||||
i=0
|
||||
while ((i < nCPU)); do
|
||||
affc=`$CINFOBIN -a -c $i`
|
||||
internal=`echo $affc | tr ' ' '_'`
|
||||
cpus=( $affc )
|
||||
n=${#cpus[@]}
|
||||
|
||||
freq=`$CINFOBIN -f -c $i`
|
||||
echo "freq_$internal.value $freq"
|
||||
|
||||
((i += n))
|
||||
done
|
||||
}
|
||||
|
||||
function getAvail ()
|
||||
{
|
||||
i=0
|
||||
while ((i < nCPU)); do
|
||||
affc=`$CINFOBIN -a -c $i`
|
||||
internal=`echo $affc | tr ' ' '_'`
|
||||
label=`echo $affc | tr ' ' ','`
|
||||
cpus=( $affc )
|
||||
n=${#cpus[@]}
|
||||
|
||||
echo "freq_$internal.label CPU $i (Core $label)"
|
||||
echo "freq_$internal.type GAUGE"
|
||||
echo "freq_$internal.info Hz"
|
||||
|
||||
((i += n))
|
||||
done
|
||||
}
|
||||
|
||||
function config ()
|
||||
{
|
||||
cat <<CONFIGTXT
|
||||
graph_title CPU frequency(s)
|
||||
graph_args --base 1000 -l 0
|
||||
graph_vlabel Hz
|
||||
graph_category system
|
||||
graph_info This graph shows the CPU frequency(s).
|
||||
CONFIGTXT
|
||||
getAvail
|
||||
}
|
||||
|
||||
function autoconf ()
|
||||
{
|
||||
if [ -x $CINFOBIN ]; then
|
||||
echo "yes"
|
||||
else
|
||||
echo "no"
|
||||
fi
|
||||
exit 0
|
||||
}
|
||||
|
||||
case $1 in
|
||||
"autoconf")
|
||||
autoconf
|
||||
;;
|
||||
"config")
|
||||
config
|
||||
;;
|
||||
*)
|
||||
getFreq
|
||||
;;
|
||||
esac
|
||||
|
193
plugins/system/cpufreq_
Executable file
193
plugins/system/cpufreq_
Executable file
|
@ -0,0 +1,193 @@
|
|||
#!/usr/bin/perl -w
|
||||
#
|
||||
# munin plugin for monitoring cpu frequency
|
||||
# Since multiple cpus on one graph doesn't really work, this plugin links to a cpu, i.e. cpufreq_cpu0
|
||||
#
|
||||
# written by BenV / JuNe
|
||||
# email: benv-munin@junerules.com
|
||||
#
|
||||
# Version: 0.1
|
||||
#
|
||||
# Requires:
|
||||
# Storable (saving state)
|
||||
#
|
||||
# Parameters:
|
||||
#
|
||||
# config required
|
||||
#
|
||||
# Configurable variables
|
||||
# statedir location where the state file is saved. Defaults to /var/lib/munin/plugin-state.
|
||||
# statefile name that's appended to statedir as filename for saving state. Defaults to "cpufreq_$cpu.state"
|
||||
#
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf suggest
|
||||
|
||||
use strict;
|
||||
|
||||
if ($ARGV[0] and $ARGV[0] eq "autoconf" ) {
|
||||
# Check required perl modules
|
||||
unless (eval "require Storable")
|
||||
{
|
||||
print "No (Missing Storable)\n";
|
||||
exit 1;
|
||||
}
|
||||
# Check for required proc/sys files
|
||||
if (-d "/sys/devices/system/cpu/cpu0/cpufreq")
|
||||
{
|
||||
print "Yes\n";
|
||||
exit 0;
|
||||
}
|
||||
print "No (Couldn't find /sys/devices/system/cpu/cpu0/cpufreq dir)";
|
||||
exit 1;
|
||||
}
|
||||
|
||||
if ($ARGV[0] and $ARGV[0] eq 'suggest' ) {
|
||||
foreach my $d (</sys/devices/system/cpu/cpu[0-9]*/cpufreq/>)
|
||||
{
|
||||
$d =~ /(cpu[0-9]+)/i;
|
||||
print "$1\n";
|
||||
}
|
||||
exit 0;
|
||||
}
|
||||
|
||||
if (eval "require Storable")
|
||||
{
|
||||
Storable->import(qw /lock_store lock_nstore lock_retrieve/);
|
||||
}
|
||||
else
|
||||
{
|
||||
die "Sorry, you don't have Storable. (update your perl!)\n";
|
||||
}
|
||||
|
||||
# Let's see what is requested.
|
||||
my $target;
|
||||
if ($0 =~ /_(cpu\d+)$/i)
|
||||
{
|
||||
$target = $1;
|
||||
}
|
||||
else
|
||||
{
|
||||
die "Error: we need to know what cpu you want, so link this plugin as cpufreq_cpu0 orso.";
|
||||
}
|
||||
|
||||
my $statedir = $ENV{"statedir"} || "/var/lib/munin/plugin-state/";
|
||||
my $statefile = $statedir.($ENV{"statefile"} || "/cpufreq_$target.state");
|
||||
$statefile = glob($statefile); # Make it saner, remove tildes. Not foolproof though ;)
|
||||
|
||||
my $cpufreq;
|
||||
|
||||
eval { $cpufreq = lock_retrieve($statefile); };
|
||||
unless(defined($cpufreq))
|
||||
{
|
||||
print STDERR "Couldn't read state file! (ignore this error on first run)\n";
|
||||
$cpufreq = {};
|
||||
}
|
||||
|
||||
my $cpufreq_now = {};
|
||||
foreach my $d (</sys/devices/system/cpu/$target/cpufreq/stats/>)
|
||||
{
|
||||
unless(open(TIS, "<", "$d"."/time_in_state"))
|
||||
{
|
||||
die "Could not open ${d}/time_in_state: $!\n";
|
||||
}
|
||||
$d =~ /(cpu[0-9]+)/i;
|
||||
my $cpu = $1;
|
||||
while(<TIS>)
|
||||
{
|
||||
if (/^(\d+)\s(\d+)/)
|
||||
{
|
||||
$cpufreq_now->{$cpu}{$1} = $2;
|
||||
$cpufreq_now->{total}{$cpu} = 0 unless(defined($cpufreq_now->{$cpu}));
|
||||
$cpufreq_now->{total}{$cpu} += $2;
|
||||
}
|
||||
}
|
||||
close(TIS);
|
||||
}
|
||||
|
||||
# Let's figure out the percentages.
|
||||
my %freq_p;
|
||||
my $cpu = $target;
|
||||
foreach my $freq (keys %{$cpufreq_now->{$cpu}})
|
||||
{
|
||||
my $new = $cpufreq_now->{$cpu}{$freq};
|
||||
my $old = (defined($cpufreq->{$cpu}{$freq})?$cpufreq->{$cpu}{$freq}:0); # If no old data, we average everything.
|
||||
my $total = $cpufreq_now->{total}{$cpu};
|
||||
$total -= $cpufreq->{total}{$cpu} if (defined($cpufreq->{total}{$cpu}));
|
||||
if (defined($total) && $total > 0)
|
||||
{
|
||||
my $p = ($new - $old) / $total;
|
||||
$freq_p{$cpu}{$freq} = $p * 100.0;
|
||||
$freq_p{avg}{$cpu} += $p * $freq; # Average speed, weighted average
|
||||
}
|
||||
else
|
||||
{
|
||||
$freq_p{$cpu}{$freq} = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if ( $ARGV[0] and $ARGV[0] eq "config" )
|
||||
{
|
||||
print "graph_title Cpu frequency usage of $target\n";
|
||||
print "graph_args --base 1000 -l 0\n";
|
||||
print "graph_vlabel CPU Frequency %\n";
|
||||
print "graph_category System\n";
|
||||
print "graph_info This graph shows information about the cpu frequency scaling of your CPU(s)\n";
|
||||
|
||||
my $count = 0;
|
||||
my ($r,$g,$blue) = (0,255,0);
|
||||
my $range = scalar(keys(%{$freq_p{$cpu}}));
|
||||
my $step = (255+255) / ($range - 1);
|
||||
# In order to let color work, let's go from green to yellow to red -- 00FF00 to FFFF00 to FF0000. 256 and 256 steps.
|
||||
foreach my $freq (sort { $a <=> $b } keys %{$freq_p{$cpu}})
|
||||
{
|
||||
printf "freq_%d.label %s\n", $freq, "$freq KHz";
|
||||
printf "freq_%d.info %s\n", $freq, "Time $cpu spent (percentage) running on $freq KHz";
|
||||
printf "freq_%d.type GAUGE\n", $freq;
|
||||
printf "freq_%d.draw %s\n", $freq, ($count++?"STACK":"AREA");
|
||||
printf "freq_%d.colour %02X%02X%02X\n", $freq, $r,$g,$blue;
|
||||
# Update color
|
||||
my $s = $step;
|
||||
if ($r < 255)
|
||||
{
|
||||
$r += $s;
|
||||
if ($r > 255)
|
||||
{
|
||||
$s = $r - 255;
|
||||
$r = 255;
|
||||
$g -= $s;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$g -= $step;
|
||||
$g = 0 if ($g < 0);
|
||||
}
|
||||
}
|
||||
printf "cpuspeed_avg.label %s\n", "Average speed of cpu $cpu";
|
||||
printf "cpuspeed_avg.info %s\n", "Average speed of cpu $cpu scaled to a percentage";
|
||||
printf "cpuspeed_avg.GAUGE\n";
|
||||
printf "cpuspeed_avg.LINE2\n";
|
||||
printf "cpuspeed_avg.colour 0000FF\n";
|
||||
exit 0;
|
||||
}
|
||||
|
||||
# Print requested garbage.
|
||||
foreach my $freq (sort { $a <=> $b } keys %{$freq_p{$cpu}})
|
||||
{
|
||||
printf "freq_%d.value %s\n", $freq, $freq_p{$cpu}{$freq};
|
||||
}
|
||||
# Average speed should be as a percentage as well. So divide it by the max freq.
|
||||
my $max_freq = (sort { $a <=> $b } keys %{$freq_p{$cpu}})[-1];
|
||||
if (defined($max_freq) && $max_freq > 0)
|
||||
{
|
||||
printf "cpuspeed_avg.value %d\n", $freq_p{avg}{$cpu} / $max_freq * 100;
|
||||
}
|
||||
|
||||
# Save state!
|
||||
eval { lock_nstore($cpufreq_now, $statefile) };
|
||||
if ($@)
|
||||
{
|
||||
print STDERR "[$0] Error writing state file!\n";
|
||||
}
|
||||
|
||||
exit 0;
|
34
plugins/system/cpuspeed
Executable file
34
plugins/system/cpuspeed
Executable file
|
@ -0,0 +1,34 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Munin-plugin to monitor the CPU temperature using mbmon
|
||||
#
|
||||
# Used the plugin-frame from "cpuload" by Bjørn Ruberg, published under the GNU GPL
|
||||
#
|
||||
# Plugin monitors the cpu-frequency for both cores of my AMD 64-X2-3600+. Works fine running Debian
|
||||
# GNU/Linux 4.0 (Etch). I do not know any perl and will not proceed in developing this plugin any further.
|
||||
# If you wish to, feel free to do so yourself. If I am able to, I will help with any problems, contact me
|
||||
# via Mail (x-stars <at> gmx.de) or through the Debian-German-User-Mailing-List.
|
||||
#
|
||||
# Frank-Michael Schulze, 21-09-2007
|
||||
# Licensed under: GNU GPL
|
||||
|
||||
|
||||
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
echo "graph_title CPU speed"
|
||||
echo 'graph_category system'
|
||||
echo "graph_info This graph shows the cpu-speed for each core, as reported by the kernel"
|
||||
echo 'core0.label Core 0 speed in MHz'
|
||||
echo 'core1.label Core 1 speed in MHz'
|
||||
echo "core0.info Core 0 speed in MHz"
|
||||
echo "core1.info Core 1 speed in MHz"
|
||||
echo "core0.type GAUGE"
|
||||
echo "core1.type GAUGE"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo -n "core0.value "
|
||||
cat /proc/cpuinfo | grep MHz | head -n 1 | cut -c 12- | awk '{ sum += $1 } END { print sum }'
|
||||
echo -n "core1.value "
|
||||
cat /proc/cpuinfo | grep MHz | tail -n 1 | cut -c 12- | awk '{ sum += $1 } END { print sum }'
|
45
plugins/system/cpuspeed2
Executable file
45
plugins/system/cpuspeed2
Executable file
|
@ -0,0 +1,45 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Munin-plugin to monitor the cpu speeds of all available cpus
|
||||
#
|
||||
# Armin Haaf, 4-11-2007
|
||||
# Licensed under: GNU GPL
|
||||
|
||||
MAX_CORES=1024
|
||||
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
echo "graph_title CPU speed"
|
||||
echo 'graph_category system'
|
||||
echo "graph_info This graph shows the cpu-speed for each core, as reported by the kernel"
|
||||
|
||||
i=0
|
||||
while [ $i -lt $MAX_CORES ]
|
||||
do
|
||||
MODEL=`cat /proc/cpuinfo | grep -A 6 "processor.*:.*$i" | grep "model name"`
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
break
|
||||
fi
|
||||
MODEL=`echo $MODEL | cut -c 12-`
|
||||
echo "core$i.label Core $i speed in MHz"
|
||||
echo "core$i.info Core $i speed in MHz $MODEL"
|
||||
echo "core$i.type GAUGE"
|
||||
i=$[$i+1]
|
||||
done
|
||||
exit 0
|
||||
fi
|
||||
|
||||
i=0
|
||||
while true
|
||||
do
|
||||
cat /proc/cpuinfo | grep -A 6 "processor.*:.*$i" > /dev/null
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
break
|
||||
fi
|
||||
echo -n "core$i.value "
|
||||
cat /proc/cpuinfo | grep -A 6 "processor.*:.*$i" | grep "cpu MHz" | cut -c 12- | cut -f 1 -d .
|
||||
i=$[$i+1]
|
||||
done
|
||||
|
60
plugins/system/cpuspeed_sane
Executable file
60
plugins/system/cpuspeed_sane
Executable file
|
@ -0,0 +1,60 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Plugin to graph cpu speed on FreeBSD
|
||||
#
|
||||
# Parameters:
|
||||
#
|
||||
# sysctl - Override path to sysctl program
|
||||
#
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf
|
||||
|
||||
sysctl=${sysctl:-/sbin/sysctl}
|
||||
|
||||
if [ "$1" = "autoconf" ]; then
|
||||
if [ -x ${sysctl} ]; then
|
||||
${sysctl} dev.cpu.0.freq 2>/dev/null | grep 'dev' >/dev/null 2>/dev/null
|
||||
if [ "$?" = "0" ]; then
|
||||
echo yes
|
||||
exit 0
|
||||
fi
|
||||
echo "no (dev.cpu.0.freq not found)"
|
||||
exit 1
|
||||
else
|
||||
echo "no (sysctl binary not found)"
|
||||
exit 2
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
|
||||
echo 'graph_title CPU speed'
|
||||
echo 'graph_args --base 1000 -l 0'
|
||||
echo 'graph_vlabel speed in MHz'
|
||||
echo 'graph_category system'
|
||||
echo 'graph_scale no'
|
||||
echo 'graph_info Current CPU speed in MHz. Available levels for the CPU:' `$sysctl -n dev.cpu.0.freq_levels|sed 's!/[0-9]*!!g;s! !, !g'` 'MHz'
|
||||
|
||||
echo cpu0.label cpu0
|
||||
echo cpu0.info `$sysctl -n hw.model` Speed
|
||||
|
||||
exit 0
|
||||
fi
|
||||
|
||||
file=/usr/local/var/munin/plugin-state/cpuspeed
|
||||
|
||||
echo -n "cpu0.value "
|
||||
if find $file -mtime -300s 2>/dev/null|grep -Fq $file ; then
|
||||
head -1 $file
|
||||
else
|
||||
$sysctl -n dev.cpu.0.freq
|
||||
fi
|
||||
|
||||
# Get/cache cpuspeed "later".
|
||||
export sysctl file
|
||||
sh -c '(
|
||||
rand=$(dd if=/dev/urandom bs=1 count=1 2>/dev/null|od -A n -D)
|
||||
rand=$(expr $rand \* 60 / 256 + 25)
|
||||
sleep $rand
|
||||
$sysctl -n dev.cpu.0.freq > $file
|
||||
)&' >/dev/null 2>&1
|
101
plugins/system/dar_cpuusage
Executable file
101
plugins/system/dar_cpuusage
Executable file
|
@ -0,0 +1,101 @@
|
|||
#!/usr/bin/perl -w
|
||||
# -*- perl -*-
|
||||
|
||||
=head1 NAME
|
||||
|
||||
dar_cpuusage - Munin plugin to monitor darwin cpu usage.
|
||||
|
||||
=head1 APPLICABLE SYSTEMS
|
||||
|
||||
Should work on any darwin (Mac OS X) system with the 'top' command.
|
||||
|
||||
=head1 CONFIGURATION
|
||||
|
||||
None needed
|
||||
|
||||
=head1 INTERPRETATION
|
||||
|
||||
The plugin runs the top command and shows the CPU usage for the machine.
|
||||
|
||||
=head1 BUGS
|
||||
|
||||
The stats are a snapshot at the time of the command - a 5 minute average would
|
||||
be better.
|
||||
|
||||
=head1 MAGIC MARKERS
|
||||
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
v.0.0.1
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Copyright (C) 2010.
|
||||
|
||||
Original version by J.T.Sage (at) gmail (dot) com.
|
||||
|
||||
=head1 LICENSE
|
||||
|
||||
GPLv2
|
||||
|
||||
=cut
|
||||
|
||||
use Munin::Plugin;
|
||||
|
||||
if ( defined($ARGV[0])) {
|
||||
if ($ARGV[0] eq 'autoconf') {
|
||||
$uname = `uname`;
|
||||
if ( not ( $uname =~ /Darwin/ ) ) { print "no (not a Darwin System)\n"; }
|
||||
else {
|
||||
if ( not -x "/usr/bin/top" ) { print "no (top not found)\n"; }
|
||||
else {
|
||||
print "yes\n";
|
||||
}
|
||||
}
|
||||
exit 0;
|
||||
}
|
||||
|
||||
if ( $ARGV[0] eq "config" ) {
|
||||
print "graph_title CPU usage\n";
|
||||
print "graph_args --base 1000 -r --lower-limit 0 --upper-limit 100\n";
|
||||
print "graph_vlabel %\n";
|
||||
print "graph_scale no\n";
|
||||
print "graph_category system\n";
|
||||
print "sys.label system\n";
|
||||
print "sys.type GAUGE\n";
|
||||
print "sys.min 0\nsys.draw AREA\n";
|
||||
print "user.label user\n";
|
||||
print "user.type GAUGE\n";
|
||||
print "user.min 0\nuser.draw STACK\n";
|
||||
print "idle.label idle\n";
|
||||
print "idle.type GAUGE\n";
|
||||
print "idle.min 0\nidle.draw STACK\n";
|
||||
exit 0;
|
||||
}
|
||||
}
|
||||
|
||||
@top = `top -l1 -n0 -u`;
|
||||
$quit = 0;
|
||||
for ( $i = 1; ($i < $#top and $quit == 0); $i++ ) {
|
||||
if ( $top[$i] =~ /^CPU/ ) {
|
||||
$usr = $sys = $idl = $top[$i];
|
||||
$usr =~ s/^.+?: (\d+\.\d+)\% user.+$/$1/;
|
||||
chomp($usr);
|
||||
$sys =~ s/^.+?, (\d+\.\d+)\% sys.+$/$1/;
|
||||
chomp($sys);
|
||||
$idl =~ s/^.+?, (\d+\.\d+)\% idle.+$/$1/;
|
||||
chomp($idl);
|
||||
print "sys.value " . $sys . "\n";
|
||||
print "user.value " . $usr . "\n";
|
||||
print "idle.value " . $idl . "\n";
|
||||
$quit = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
# vim:syntax=perl
|
104
plugins/system/dar_memusage
Executable file
104
plugins/system/dar_memusage
Executable file
|
@ -0,0 +1,104 @@
|
|||
#!/usr/bin/perl -w
|
||||
# -*- perl -*-
|
||||
|
||||
=head1 NAME
|
||||
|
||||
dar_mumusage - Munin plugin to monitor darwin physical memory usage.
|
||||
|
||||
=head1 APPLICABLE SYSTEMS
|
||||
|
||||
Should work on any darwin (Mac OS X) system with the 'top' command.
|
||||
|
||||
=head1 CONFIGURATION
|
||||
|
||||
None needed
|
||||
|
||||
=head1 INTERPRETATION
|
||||
|
||||
The plugin runs the top command and shows the physical memory for the machine.
|
||||
|
||||
=head1 BUGS
|
||||
|
||||
The stats are a snapshot at the time of the command - a 5 minute average would
|
||||
be better.
|
||||
|
||||
=head1 MAGIC MARKERS
|
||||
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
v.0.0.1
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Copyright (C) 2010.
|
||||
|
||||
Original version by J.T.Sage (at) gmail (dot) com.
|
||||
|
||||
=head1 LICENSE
|
||||
|
||||
GPLv2
|
||||
|
||||
=cut
|
||||
|
||||
use Munin::Plugin;
|
||||
|
||||
if ( defined($ARGV[0])) {
|
||||
if ($ARGV[0] eq 'autoconf') {
|
||||
$uname = `uname`;
|
||||
if ( not ( $uname =~ /Darwin/ ) ) { print "no (not a Darwin System)\n"; }
|
||||
else {
|
||||
if ( not -x "/usr/bin/top" ) { print "no (top not found)\n"; }
|
||||
else {
|
||||
print "yes\n";
|
||||
}
|
||||
}
|
||||
exit 0;
|
||||
}
|
||||
|
||||
if ( $ARGV[0] eq "config" ) {
|
||||
$maxmemcmd = `hostinfo | grep memory`;
|
||||
$maxmemcmd =~ m/^.+?: (\d+\.\d+) (\w).+$/;
|
||||
$memline = $1;
|
||||
if ( $2 eq "m" ) { $memline = $memline * 1024 * 1024; }
|
||||
if ( $2 eq "g" ) { $memline = $memline * 1024 * 1024 * 1024; }
|
||||
|
||||
print "graph_title Memory usage\n";
|
||||
print "graph_args --base 1024 --lower-limit 0 --upper-limit ".$memline." --rigid\n";
|
||||
print "graph_vlabel Bytes\n";
|
||||
print "graph_scale yes\n";
|
||||
print "graph_category system\n";
|
||||
print "wired.label wired\nwired.type GAUGE\nwired.draw AREA\n";
|
||||
print "active.label active\nactive.type GAUGE\nactive.draw STACK\n";
|
||||
print "inactive.label inactive\ninactive.type GAUGE\ninactive.draw STACK\n";
|
||||
print "free.label free\nfree.type GAUGE\nfree.draw STACK\n";
|
||||
print "used.label used\nused.type GAUGE\nused.draw LINE2\n";
|
||||
exit 0;
|
||||
}
|
||||
}
|
||||
|
||||
@top = `top -l1 -n0 -u`;
|
||||
$quit = 0;
|
||||
for ( $i = 1; ($i < $#top and $quit == 0); $i++ ) {
|
||||
if ( $top[$i] =~ /^PhysMem/ ) {
|
||||
$wired = $active = $inactive = $free = $used = $top[$i];
|
||||
$wired =~ s/^.+?: (\d+)M wired.+$/$1/; chomp $wired; $wired = $wired * 1024 * 1024;
|
||||
$active =~ s/^.+?, (\d+)M active.+$/$1/; chomp $active; $active = $active * 1024 * 1024;
|
||||
$inactive =~ s/^.+?, (\d+)M inactive.+$/$1/; chomp $inactive; $inactive = $inactive * 1024 * 1024;
|
||||
$free =~ s/^.+?, (\d+)([M|K]) free.+$/$1/; chomp $free; $free = $free * 1024 * 1024; if ( $2 eq "K" ) { $free = $free / 1024; }
|
||||
$used =~ s/^.+?, (\d+)M used.+$/$1/; chomp $used; $used = $used * 1024 * 1024;
|
||||
print "wired.value " . $wired . "\n";
|
||||
print "active.value " . $active . "\n";
|
||||
print "inactive.value " . $inactive . "\n";
|
||||
print "free.value " . $free . "\n";
|
||||
print "used.value " . $used . "\n";
|
||||
$quit = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
# vim:syntax=perl
|
97
plugins/system/dar_swap
Executable file
97
plugins/system/dar_swap
Executable file
|
@ -0,0 +1,97 @@
|
|||
#!/usr/bin/perl -w
|
||||
# -*- perl -*-
|
||||
|
||||
=head1 NAME
|
||||
|
||||
dar_swap - Munin plugin to monitor darwin swap in/out.
|
||||
|
||||
=head1 APPLICABLE SYSTEMS
|
||||
|
||||
Should work on any darwin (Mac OS X) system with the 'vm_stat' command.
|
||||
|
||||
=head1 CONFIGURATION
|
||||
|
||||
None needed
|
||||
|
||||
=head1 INTERPRETATION
|
||||
|
||||
The plugin runs the vm_stat command a shows the number of pages swapped
|
||||
in/out per second.
|
||||
|
||||
=head1 BUGS
|
||||
|
||||
None right now.
|
||||
|
||||
=head1 MAGIC MARKERS
|
||||
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
v.0.0.1
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Copyright (C) 2010.
|
||||
|
||||
Original version by J.T.Sage (at) gmail (dot) com.
|
||||
|
||||
=head1 LICENSE
|
||||
|
||||
GPLv2
|
||||
|
||||
=cut
|
||||
|
||||
use Munin::Plugin;
|
||||
|
||||
if ( defined($ARGV[0])) {
|
||||
if ($ARGV[0] eq 'autoconf') {
|
||||
$uname = `uname`;
|
||||
if ( not ( $uname =~ /Darwin/ ) ) { print "no (not a Darwin System)\n"; }
|
||||
else {
|
||||
if ( not -x "/usr/bin/vm_stat" ) { print "no (vm_stat not found)\n"; }
|
||||
else {
|
||||
print "yes\n";
|
||||
}
|
||||
}
|
||||
exit 0;
|
||||
}
|
||||
|
||||
if ( $ARGV[0] eq "config" ) {
|
||||
print "graph_title Swap in/out\n";
|
||||
print "graph_args -l 0 --base 1000\n";
|
||||
print "graph_vlabel pages per \${graph_period} in (-) / out (+)\n";
|
||||
print "graph_category system\n";
|
||||
print "swap_in.label swap\nswap_in.type DERIVE\nswap_in.max 100000\nswap_in.min 0\nswap_in.graph no\n";
|
||||
print "swap_out.label swap\nswap_out.type DERIVE\nswap_out.max 100000\nswap_out.min 0\nswap_out.negative swap_in\n";
|
||||
exit 0;
|
||||
}
|
||||
}
|
||||
|
||||
@vmstat = `vm_stat`;
|
||||
for ( $i = 1; $i < $#vmstat; $i++ ) {
|
||||
$line = $vmstat[$i];
|
||||
$label = $line;
|
||||
$label =~ s/"//g;
|
||||
$label =~ s/(\w+)\:.+$/$1/;
|
||||
$label =~ s/\n//g;
|
||||
$name = $label;
|
||||
$name =~ tr/A-Z/a-z/;
|
||||
$name =~ s/[^A-Za-z0-9_]/_/g;
|
||||
$data = $line;
|
||||
$data =~ s/.+?(\d+)\./$1/;
|
||||
$data =~ s/\n//g;
|
||||
$data = int(($data / 1000) + .5);
|
||||
if ( $name eq "pageins" ) {
|
||||
print "swap_in.value " . $data . "\n";
|
||||
}
|
||||
if ( $name eq "pageouts" ) {
|
||||
print "swap_out.value " . $data . "\n";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
# vim:syntax=perl
|
96
plugins/system/dar_uptime
Executable file
96
plugins/system/dar_uptime
Executable file
|
@ -0,0 +1,96 @@
|
|||
#!/usr/bin/perl
|
||||
# -*- perl -*-
|
||||
|
||||
=head1 NAME
|
||||
|
||||
dar_uptime - Munin plugin to monitor darwin system uptime.
|
||||
|
||||
=head1 APPLICABLE SYSTEMS
|
||||
|
||||
Should work on any darwin (Mac OS X) system with the 'uptime' command.
|
||||
|
||||
=head1 CONFIGURATION
|
||||
|
||||
None needed
|
||||
|
||||
=head1 INTERPRETATION
|
||||
|
||||
The plugin runs the uptime command, and parses the value into days.
|
||||
|
||||
=head1 BUGS
|
||||
|
||||
Limited test data set, probably fails some of the time - very likely
|
||||
on systems with a very low uptime.
|
||||
|
||||
=head1 MAGIC MARKERS
|
||||
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
v.0.0.1
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Copyright (C) 2010.
|
||||
|
||||
Original version by J.T.Sage (at) gmail (dot) com.
|
||||
|
||||
=head1 LICENSE
|
||||
|
||||
GPLv2
|
||||
|
||||
=cut
|
||||
|
||||
use Munin::Plugin;
|
||||
|
||||
if ( defined($ARGV[0])) {
|
||||
if ($ARGV[0] eq 'autoconf') {
|
||||
$uname = `uname`;
|
||||
if ( not ( $uname =~ /Darwin/ ) ) { print "no (not a Darwin System)\n"; }
|
||||
else {
|
||||
if ( not -x "/usr/bin/uptime" ) { print "no (uptime not found)\n"; }
|
||||
else {
|
||||
print "yes\n";
|
||||
}
|
||||
}
|
||||
exit 0;
|
||||
}
|
||||
|
||||
if ( $ARGV[0] eq "config" ) {
|
||||
print "graph_title Uptime\n";
|
||||
print "graph_args --base 1000 -l 0 \n";
|
||||
print "graph_vlabel uptime in days\n";
|
||||
print "graph_category system\n";
|
||||
print "uptime.label uptime\n";
|
||||
print "uptime.draw AREA\n";
|
||||
exit 0;
|
||||
}
|
||||
}
|
||||
|
||||
@uptime = `/usr/bin/uptime`;
|
||||
foreach(@uptime) {
|
||||
$_ =~ m/^.+up (.+?), \d+ us.+$/;
|
||||
$timestr = $1;
|
||||
if ( $timestr =~ m/^(\d+) day.+?$/ ) {
|
||||
$days = $1;
|
||||
} else { $days = 0; }
|
||||
if ( $timestr =~ m/(\d+) h/ ) {
|
||||
$hrs = $1;
|
||||
} else { $hrs = 0; }
|
||||
if ( $timestr =~ m/(\d+)\:(\d+)/ ) {
|
||||
$hours = $1; $min = $2;
|
||||
} else { $hours = 0; $min = 0; }
|
||||
if ( $timestr =~ m/(\d+) m/ ) {
|
||||
$mint = $1;
|
||||
} else {
|
||||
$mint = 0;
|
||||
}
|
||||
$total = ( $days * 24 * 60 * 60 ) + ( ( $hrs + $hours ) * 60 * 60 ) + ( ( $min + $mint ) * 60 );
|
||||
$daysf = $total / ( 24 * 60 * 60 );
|
||||
$daysi = ( int( $daysf * 1000 ) / 1000 );
|
||||
print "uptime.value " . $daysi . "\n";
|
||||
}
|
||||
|
||||
# vim:syntax=perl
|
110
plugins/system/dar_vmstat
Executable file
110
plugins/system/dar_vmstat
Executable file
|
@ -0,0 +1,110 @@
|
|||
#!/usr/bin/perl -w
|
||||
# -*- perl -*-
|
||||
|
||||
=head1 NAME
|
||||
|
||||
dar_vmstat - Munin plugin to monitor darwin virtual memory usage.
|
||||
|
||||
=head1 APPLICABLE SYSTEMS
|
||||
|
||||
Should work on any darwin (Mac OS X) system with the 'vm_stat' command.
|
||||
|
||||
=head1 CONFIGURATION
|
||||
|
||||
None needed
|
||||
|
||||
=head1 INTERPRETATION
|
||||
|
||||
The plugin runs the vm_stat command a shows the results. Consult the
|
||||
vm_stat man page for more information on the output.
|
||||
|
||||
=head1 BUGS
|
||||
|
||||
None right now.
|
||||
|
||||
=head1 MAGIC MARKERS
|
||||
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
v.0.0.1
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Copyright (C) 2010.
|
||||
|
||||
Original version by J.T.Sage (at) gmail (dot) com.
|
||||
|
||||
=head1 LICENSE
|
||||
|
||||
GPLv2
|
||||
|
||||
=cut
|
||||
|
||||
use Munin::Plugin;
|
||||
|
||||
if ( defined($ARGV[0])) {
|
||||
if ($ARGV[0] eq 'autoconf') {
|
||||
$uname = `uname`;
|
||||
if ( not ( $uname =~ /Darwin/ ) ) { print "no (not a Darwin System)\n"; }
|
||||
else {
|
||||
if ( not -x "/usr/bin/vm_stat" ) { print "no (vm_stat not found)\n"; }
|
||||
else {
|
||||
print "yes\n";
|
||||
}
|
||||
}
|
||||
exit 0;
|
||||
}
|
||||
|
||||
if ( $ARGV[0] eq "config" ) {
|
||||
print "graph_title Virtual Memory Statiscs\n";
|
||||
print "graph_args --base 1000 -l 0\n";
|
||||
print "graph_vlabel bytes\n";
|
||||
print "graph_scale yes\n";
|
||||
print "graph_category system\n";
|
||||
@vmstat = `vm_stat`;
|
||||
for ( $i = 1; $i < $#vmstat; $i++ ) {
|
||||
$line = $vmstat[$i];
|
||||
$label = $line;
|
||||
$label =~ s/"//g;
|
||||
$label =~ s/(\w+)\:.+$/$1/;
|
||||
$label =~ s/\n//g;
|
||||
$name = $label;
|
||||
$name =~ tr/A-Z/a-z/;
|
||||
$name =~ s/[^A-Za-z0-9_]/_/g;
|
||||
if ( $name eq "pages_free" || $name eq "pages_active" || $name eq "pages_inactive" || $name eq "pages_speculative" || $name eq "pages_wired_down" ) {
|
||||
$label =~ s/Pages //;
|
||||
print $name, ".label ", $label, "\n";
|
||||
print $name, ".type GAUGE\n";
|
||||
print $name, ".cdef ", $name, ",4096,*\n";
|
||||
}
|
||||
}
|
||||
exit 0;
|
||||
}
|
||||
}
|
||||
|
||||
@vmstat = `vm_stat`;
|
||||
for ( $i = 1; $i < $#vmstat; $i++ ) {
|
||||
$line = $vmstat[$i];
|
||||
$label = $line;
|
||||
$label =~ s/"//g;
|
||||
$label =~ s/(\w+)\:.+$/$1/;
|
||||
$label =~ s/\n//g;
|
||||
$name = $label;
|
||||
$name =~ tr/A-Z/a-z/;
|
||||
$name =~ s/[^A-Za-z0-9_]/_/g;
|
||||
$data = $line;
|
||||
$data =~ s/.+?(\d+)\./$1/;
|
||||
$data =~ s/\n//g;
|
||||
#$data = int(($data / 1000) + .5);
|
||||
if ( $name eq "pages_free" || $name eq "pages_active" || $name eq "pages_inactive" || $name eq "pages_speculative" || $name eq "pages_wired_down" ) {
|
||||
print $name, ".value ", $data, "\n";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
# vim:syntax=perl
|
74
plugins/system/debsecan
Executable file
74
plugins/system/debsecan
Executable file
|
@ -0,0 +1,74 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Plugin to monitor the number of CVE vulnerabilities present on a Debian
|
||||
# system (using debsecan). Might work on other distib, who knows...
|
||||
#
|
||||
# Inspiration of the moment 10/10/2007
|
||||
#
|
||||
# Nicolas BOUTHORS <nbouthors@nbi.fr> http://nbi.fr/
|
||||
#
|
||||
# Licence : Public Domain
|
||||
#
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf
|
||||
|
||||
# Auto enable if we have debsecan only
|
||||
if [ "$1" = "autoconf" ] ; then
|
||||
if [ -x /usr/bin/debsecan ]; then
|
||||
echo yes
|
||||
else
|
||||
echo no
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Fail if we don't have debsecan
|
||||
if [ ! -x /usr/bin/debsecan ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$1" = "config" ] ; then
|
||||
cat <<EOF_
|
||||
graph_title DebSecan : vulnerabilities
|
||||
graph_args -l 0 --base 1000
|
||||
graph_vlabel number of CVE
|
||||
graph_category system
|
||||
graph_period second
|
||||
graph_info This graph show the number of known vulnerabilities present on your system. Use debsecan to see detail.
|
||||
high.label high
|
||||
high.type GAUGE
|
||||
high.max 50000
|
||||
high.min 0
|
||||
high.info The number CVE marked high high priority
|
||||
medium.label medium
|
||||
medium.type GAUGE
|
||||
medium.max 50000
|
||||
medium.min 0
|
||||
medium.info The number CVE marked medium high priority
|
||||
low.label low
|
||||
low.type GAUGE
|
||||
low.max 50000
|
||||
low.min 0
|
||||
low.info The number CVE marked low high priority
|
||||
other.label other
|
||||
other.type GAUGE
|
||||
other.max 50000
|
||||
other.min 0
|
||||
other.info The number CVE with unspecified priority
|
||||
EOF_
|
||||
exit 0
|
||||
fi
|
||||
|
||||
debsecan 2> /dev/null > /tmp/debsecan.munin.$$
|
||||
high=`grep -c '(high urgency)' /tmp/debsecan.munin.$$`
|
||||
medium=`grep -c '(medium urgency)' /tmp/debsecan.munin.$$`
|
||||
low=`grep -c '(low urgency)' /tmp/debsecan.munin.$$`
|
||||
other=`grep -c -v -e '(low urgency)' -e '(medium urgency)' -e '(high urgency)' /tmp/debsecan.munin.$$`
|
||||
cat <<EOF_
|
||||
high.value $high
|
||||
medium.value $medium
|
||||
low.value $low
|
||||
other.value $other
|
||||
EOF_
|
||||
|
||||
rm -f /tmp/debsecan.munin.$$
|
44
plugins/system/hostsdeny
Executable file
44
plugins/system/hostsdeny
Executable file
|
@ -0,0 +1,44 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Plugin to monitor the number of hosts in /etc/hosts.deny
|
||||
# that are deined access to sshd
|
||||
#
|
||||
# Based on denyhosts plugin by tjansson (2009)
|
||||
#
|
||||
# Copyright (C) 2009 Kåre Hartvig Jensen (kaare.hartvig.jensen@gmail.com)
|
||||
#
|
||||
# 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
if [ "$1" = "autoconf" ]; then
|
||||
if [ -r "$LOG" ]; then
|
||||
echo yes
|
||||
exit 0
|
||||
else
|
||||
echo no
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
|
||||
echo 'graph_title Hosts denied sshd access in /etc/hosts.deny'
|
||||
echo 'graph_args --base 1000 -l 0'
|
||||
echo 'graph_vlabel Hosts denied '
|
||||
echo 'graph_category system'
|
||||
echo 'HostsDenied.label Hosts denied'
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo HostsDenied.value `cat /etc/hosts.deny | grep sshd | wc -l`
|
42
plugins/system/ibmfan
Executable file
42
plugins/system/ibmfan
Executable file
|
@ -0,0 +1,42 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Plugin to monitor fan speed on an IBM/Lenovo Laptop
|
||||
#
|
||||
# This plugin reads the current speed of the system fan from
|
||||
# the /proc file system. As it queries specific files provided
|
||||
# by kernel modules for IBM/Lenovo Laptops, it probably only
|
||||
# works for those, but it should be easy to adapt to others
|
||||
# if similar information is available for other types of laptops.
|
||||
#
|
||||
# By dominik dot stadler at gmx dot at
|
||||
#
|
||||
# Magic markers (optional - only used by munin-config and some
|
||||
# installation scripts):
|
||||
#
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf
|
||||
|
||||
if [ "$1" = "autoconf" ]; then
|
||||
if [ -r /proc/acpi/ibm/fan ]; then
|
||||
echo yes
|
||||
exit 0
|
||||
else
|
||||
echo no
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
echo 'graph_title Fan speed'
|
||||
echo 'graph_args --base 1000 -l 0'
|
||||
echo 'graph_vlabel speed'
|
||||
echo 'graph_scale no'
|
||||
echo 'graph_category system'
|
||||
echo 'graph_info This graph shows the speed of the system fan.'
|
||||
echo 'fan.label speed'
|
||||
echo 'fan.info The current speed of the system fan.'
|
||||
exit 0
|
||||
fi
|
||||
|
||||
cat /proc/acpi/ibm/fan | grep "speed:" | awk '{print "fan.value " $2}'
|
79
plugins/system/iostat-cputps-average
Executable file
79
plugins/system/iostat-cputps-average
Executable file
|
@ -0,0 +1,79 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Script to monitor iostat cpu|tps.
|
||||
#
|
||||
# Parameters understood:
|
||||
#
|
||||
# config (required)
|
||||
# autoconf (optional - used by munin-config)
|
||||
|
||||
judge=`basename $0 | sed 's/^iostat_//g'`
|
||||
current=`date +%H":"%M":"%S`;
|
||||
tenMago=`date --date "10 minutes ago" +%H":"%M":"%S`
|
||||
export LANG=en_US.UTF-8
|
||||
|
||||
# autoconf
|
||||
|
||||
if [ "$1" == "autoconf" ]; then
|
||||
if ( sar 1 1 >/dev/null 2>&1 ); then
|
||||
echo yes
|
||||
exit 0
|
||||
else
|
||||
if [ $? -eq 127 ]; then
|
||||
echo "no (could not run \"sar\")"
|
||||
exit 1
|
||||
else
|
||||
echo no
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
ARRAY=( `sar -p -d -s ${tenMago} -e ${current} | grep -v nodev | grep "Average" | awk '{ print $2 , $3 , $10 }'` )
|
||||
|
||||
# config
|
||||
|
||||
if [ "$1" == "config" ]; then
|
||||
if [ "$judge" == cpu_average ]; then
|
||||
echo 'graph_title iostat util'
|
||||
echo 'graph_args --upper-limit 100 -l 0'
|
||||
echo 'graph_vlabel %'
|
||||
echo 'graph_category System'
|
||||
for (( i=0 ; i<${#ARRAY[*]} ; i++ )) ; do
|
||||
echo "_dev_${ARRAY[i]}.label ${ARRAY[i]}"
|
||||
i=`expr $i + 2`
|
||||
done
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$judge" == tps_average ]; then
|
||||
echo 'graph_title iostat tps'
|
||||
echo 'graph_args -l 0'
|
||||
echo 'graph_vlabel tps'
|
||||
echo 'graph_category System'
|
||||
for (( i=0 ; i<${#ARRAY[*]} ; i++ )) ; do
|
||||
echo "_dev_${ARRAY[i]}.label ${ARRAY[i]}"
|
||||
i=`expr $i + 2`
|
||||
done
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
# other
|
||||
|
||||
if [ "$judge" == cpu_average ]; then
|
||||
for (( i=0 ; i<${#ARRAY[*]} ; i++ )) ; do
|
||||
echo -n "_dev_${ARRAY[i]}.value "
|
||||
i=`expr $i + 2`
|
||||
echo "${ARRAY[i]}"
|
||||
done
|
||||
fi
|
||||
|
||||
if [ "$judge" == tps_average ]; then
|
||||
for (( i=0 ; i<${#ARRAY[*]} ; i++ )) ; do
|
||||
echo -n "_dev_${ARRAY[i]}.value "
|
||||
i=`expr $i + 1`
|
||||
echo "${ARRAY[i]}"
|
||||
i=`expr $i + 1`
|
||||
done
|
||||
fi
|
153
plugins/system/ipmi_sdr_
Executable file
153
plugins/system/ipmi_sdr_
Executable file
|
@ -0,0 +1,153 @@
|
|||
#!/usr/bin/perl -w
|
||||
#
|
||||
# IPMI data gathering for munin.
|
||||
#
|
||||
# Author: 2008 Benjamin Pineau <ben.pineau@gmail.com>
|
||||
# This work is hereby released into the Public Domain.
|
||||
# To view a copy of the public domain dedication, visit
|
||||
# http://creativecommons.org/licenses/publicdomain/
|
||||
#
|
||||
# Requirements :
|
||||
#
|
||||
# - ipmitool command line utility (and kernel drivers)
|
||||
# - access rights to /dev/ipmi0 device (ie, root privileges
|
||||
# can be configured in /etc/munin/plugin-conf.d/munin-node)
|
||||
#
|
||||
# Parameters supported:
|
||||
#
|
||||
# config
|
||||
# autoconf
|
||||
#
|
||||
# Setup :
|
||||
#
|
||||
# ipmitool sdr || echo "please load IPMI kernel modules"
|
||||
# cp ipmi_sdr_ /usr/share/munin/plugins/
|
||||
# chmod +x /usr/share/munin/plugins/ipmi_sdr_
|
||||
# ln -s /usr/share/munin/plugins/ipmi_sdr_ /etc/munin/plugins/ipmi_sdr_fan
|
||||
# ln -s /usr/share/munin/plugins/ipmi_sdr_ /etc/munin/plugins/ipmi_sdr_current
|
||||
# ln -s /usr/share/munin/plugins/ipmi_sdr_ /etc/munin/plugins/ipmi_sdr_voltage
|
||||
# ln -s /usr/share/munin/plugins/ipmi_sdr_ /etc/munin/plugins/ipmi_sdr_temperature
|
||||
# echo -e "\n[ipmi_sdr*]\nuser root\ntimeout 15\n" >> /etc/munin/plugin-conf.d/munin-node
|
||||
# /etc/init.d/munin-node restart
|
||||
#
|
||||
# Magic markers
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
$ENV{'LANG'} = 'C';
|
||||
$ENV{'LC_ALL'} = 'C';
|
||||
|
||||
my $ipmidump = $ENV{'ipmidump'} || '/var/lib/munin/plugin-state/ipmi_sdr';
|
||||
my $ipmitool = $ENV{'ipmitool'} || 'ipmitool';
|
||||
my $drefresh = $ENV{'drefresh'} || 86400;
|
||||
|
||||
my %sensors;
|
||||
|
||||
my $desc = {
|
||||
'fan' => {
|
||||
'graph_title' => 'Fans rotations per minute',
|
||||
'graph_vlabel' => 'RPM',
|
||||
'graph_info' => 'Fans rotations per minute',
|
||||
},
|
||||
'voltage' => {
|
||||
'graph_title' => 'Electrical tensions',
|
||||
'graph_vlabel' => 'Volts',
|
||||
'graph_info' => 'Electrical tensions',
|
||||
},
|
||||
'temperature' => {
|
||||
'graph_title' => 'Hardware temperatures',
|
||||
'graph_vlabel' => 'Degrees Celsius',
|
||||
'graph_info' => 'Hardware temperature sensors output',
|
||||
},
|
||||
'current' => {
|
||||
'graph_title' => 'Hardware power consumption',
|
||||
'graph_vlabel' => 'Watts or Amperes',
|
||||
'graph_info' => 'Hardware power consumption',
|
||||
},
|
||||
};
|
||||
|
||||
my $stype = $0 =~ /.*ipmi_sdr_(\w+)$/ ? lc($1) : 'temperature';
|
||||
|
||||
if (!defined($desc->{"$stype"})) {
|
||||
printf STDERR "Unknown sensor type : '$stype'. Aborting.\n";
|
||||
exit 1;
|
||||
}
|
||||
|
||||
sub strip_spaces($) {
|
||||
(my $s = shift) =~ s/^\s*(.*?)\s*\n?$/$1/;
|
||||
return $s;
|
||||
}
|
||||
|
||||
sub normalize_name($) {
|
||||
(my $l = lc(strip_spaces(shift))) =~ tr/\t ./_/;
|
||||
return $l;
|
||||
}
|
||||
|
||||
sub sdrlist_parse(@) {
|
||||
foreach(@_) {
|
||||
next unless /^([^\|]+)\s*\|\s*(\w+)\s*\|[^\|]+\|[^\|]+\|\s*([\d\.]+)\s+/;
|
||||
$sensors{$_}{"name"} = strip_spaces($1);
|
||||
$sensors{$_}{"value"} = strip_spaces($3);
|
||||
$sensors{$_}{"label"} = normalize_name($1) . normalize_name($2);
|
||||
}
|
||||
}
|
||||
|
||||
if (defined $ARGV[0] and $ARGV[0] eq 'autoconf') {
|
||||
`$ipmitool help 2> /dev/null`;
|
||||
if ($?) {
|
||||
print "no ($ipmitool not found)";
|
||||
exit 1;
|
||||
}
|
||||
|
||||
`$ipmitool sdr dump $ipmidump`;
|
||||
if ($?) {
|
||||
printf "no (ipmitool sdr dump returned code %d)\n", $? >> 8;
|
||||
exit 1;
|
||||
}
|
||||
|
||||
`$ipmitool sdr type $stype -S $ipmidump`;
|
||||
if ($?) {
|
||||
print "no (ipmitool didn't found any sensor of type ";
|
||||
printf "'$stype', returned code %d)\n", $? >> 8;
|
||||
exit 1;
|
||||
}
|
||||
|
||||
print "yes\n";
|
||||
exit 0;
|
||||
}
|
||||
|
||||
# "ipmitool dump" dumps speeds up data retreival big time, by avoiding
|
||||
# IPMI sensors autodiscovery. This only caches sensors names/types/ids
|
||||
# (not values/datas), so we can have a very long cache lifetime policy.
|
||||
if (-f $ipmidump) {
|
||||
unlink($ipmidump) if (time - (stat($ipmidump))[9] >= $drefresh);
|
||||
}
|
||||
|
||||
unless (-f $ipmidump) {
|
||||
`$ipmitool sdr dump $ipmidump` || die $!;
|
||||
}
|
||||
|
||||
(my @dt = `$ipmitool sdr type $stype -S $ipmidump`) || die $!;
|
||||
sdrlist_parse(@dt);
|
||||
|
||||
if (defined($ARGV[0]) && $ARGV[0] eq "config") {
|
||||
print "graph_category system\n";
|
||||
print "graph_title " . $desc->{$stype}->{"graph_title"} . "\n";
|
||||
print "graph_vlabel " . $desc->{$stype}->{"graph_vlabel"} . "\n";
|
||||
print "graph_info " . $desc->{$stype}->{"graph_info"} . "\n";
|
||||
|
||||
foreach my $v (values(%sensors)) {
|
||||
print $v->{"label"} . ".label " . $v->{"name"} . "\n";
|
||||
print $v->{"label"} . ".type GAUGE\n";
|
||||
}
|
||||
|
||||
exit 0;
|
||||
}
|
||||
|
||||
foreach my $v (values(%sensors)) {
|
||||
print $v->{"label"} . ".value " . $v->{"value"} . "\n";
|
||||
}
|
||||
|
64
plugins/system/kmemsum
Executable file
64
plugins/system/kmemsum
Executable file
|
@ -0,0 +1,64 @@
|
|||
#!/bin/sh
|
||||
# Kernel Memory usage stats.
|
||||
# Author: alex@trull.org
|
||||
#
|
||||
# Based on the short script at http://wiki.freebsd.org/ZFSTuningGuide (20080820)
|
||||
#
|
||||
# Parameters:
|
||||
#
|
||||
# config (required)
|
||||
# autoconf (optional - only used by munin-config)
|
||||
#
|
||||
# Magic markers (optional - only used by munin-config and some
|
||||
# installation scripts):
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf
|
||||
|
||||
if [ "$1" = "autoconf" ]; then
|
||||
if [ -x /sbin/sysctl ]; then
|
||||
/sbin/sysctl vm.kmem_size_max > /dev/null
|
||||
if [ $? = "0" ]; then
|
||||
echo yes
|
||||
exit 0
|
||||
else
|
||||
echo no
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo no
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
TEXT=`kldstat | tr a-f A-F | awk 'BEGIN {print "ibase=16"}; NR > 1 {print $4}' | bc | awk '{a+=$1}; END {print a}'`
|
||||
DATA=`vmstat -m | sed 's/K//' | awk '{a+=$3}; END {print a*1024}'`
|
||||
TOTAL=`echo $DATA $TEXT | awk '{print $1+$2}'`
|
||||
MAX=`sysctl vm.kmem_size_max | awk '{print $2}'`
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
echo 'graph_args --base 1024 -l 0 --vertical-label Bytes'
|
||||
echo 'graph_title Kernel Memory usage'
|
||||
echo 'graph_category system'
|
||||
echo 'graph_info This graph shows kmem usage.'
|
||||
echo 'graph_order text data'
|
||||
echo 'text.label text'
|
||||
echo 'text.info kmem text'
|
||||
echo 'text.draw AREA'
|
||||
echo 'data.label data'
|
||||
echo 'data.info kmem data'
|
||||
echo 'data.draw STACK'
|
||||
echo 'total.label total'
|
||||
echo 'total.info kmem total'
|
||||
echo 'total.draw LINE'
|
||||
echo 'max.label max'
|
||||
echo 'max.info kmem max'
|
||||
echo 'max.draw LINE2'
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "text.value $TEXT"
|
||||
echo "data.value $DATA"
|
||||
echo "total.value $TOTAL"
|
||||
echo "max.value $MAX"
|
||||
|
||||
|
137
plugins/system/load_extended
Executable file
137
plugins/system/load_extended
Executable file
|
@ -0,0 +1,137 @@
|
|||
#!/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 occurrances 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 wether 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.
|
97
plugins/system/lpar_cpu
Executable file
97
plugins/system/lpar_cpu
Executable file
|
@ -0,0 +1,97 @@
|
|||
#!/usr/bin/perl -w
|
||||
#
|
||||
# Plugin to monitor physical cpu usage in an IBM POWER P5 / OpenPower LPAR
|
||||
#
|
||||
# Usage: Place in /etc/munin/plugins (or make a symlink to it there)
|
||||
#
|
||||
# Parameters understood:
|
||||
#
|
||||
# config
|
||||
# autoconf
|
||||
#
|
||||
# This should be run as root, so drop a file with something like this in
|
||||
# /etc/munin/plugin-conf.d/lpar_cpu:
|
||||
# [lpar_cpu]
|
||||
# user root
|
||||
#
|
||||
# Great thanks to Nigel Griffith of IBM for the magic to get these values
|
||||
#
|
||||
# Author: Ingvar Hagelund <ingvar(at)linpro.no>
|
||||
#
|
||||
# Licence: GNU General Public Licence v2.0,
|
||||
# see http://www.gnu.org/copyleft/gpl.html
|
||||
|
||||
use strict;
|
||||
|
||||
my $stats="/proc/ppc64/lparcfg";
|
||||
my $cpuinfo="/proc/cpuinfo";
|
||||
my $seconds=2;
|
||||
my $counter="";
|
||||
my $after="";
|
||||
my $timebase="";
|
||||
|
||||
sub readstats {
|
||||
my $stats=shift;
|
||||
my $purr;
|
||||
|
||||
open (STATS,"$stats") or die "Unable to read $stats, $!";
|
||||
while (<STATS>) {
|
||||
if ( /^purr\=(\d+)$/ ) { $purr = $1; }
|
||||
}
|
||||
close STATS;
|
||||
return $purr;
|
||||
}
|
||||
|
||||
sub error {
|
||||
print "something horrible happened\n";
|
||||
exit 2;
|
||||
}
|
||||
|
||||
|
||||
################
|
||||
#
|
||||
# Main
|
||||
#
|
||||
#
|
||||
|
||||
if ( defined $ARGV[0] ) {
|
||||
|
||||
if ( $ARGV[0] eq 'autoconf' ) {
|
||||
if ( -e $stats && -e $cpuinfo ) {
|
||||
print "yes\n";
|
||||
exit 0;
|
||||
}
|
||||
else {
|
||||
print "no\n";
|
||||
exit 1;
|
||||
}
|
||||
}
|
||||
elsif ( $ARGV[0] eq 'config' ) {
|
||||
print "graph_title LPAR physical CPU usage\n";
|
||||
print "graph_args --base 1000\n";
|
||||
print "graph_vlabel percent\n";
|
||||
print "graph_category system\n";
|
||||
print "cpu.label cpu\n";
|
||||
print "cpu.type DERIVE\n";
|
||||
print "cpu.min 0\n";
|
||||
exit 0;
|
||||
}
|
||||
}
|
||||
|
||||
$counter=readstats($stats);
|
||||
|
||||
open (CPUINFO,$cpuinfo) or die "Unable to read $cpuinfo, $!";
|
||||
while (<CPUINFO>) {
|
||||
if (/^timebase\s+\:\s+(\d+)/) { $timebase=$1; }
|
||||
}
|
||||
close CPUINFO;
|
||||
|
||||
error() if $cpuinfo eq "";
|
||||
error() if $counter eq "";
|
||||
error() if $timebase eq "";
|
||||
|
||||
my $val=100*$counter/$timebase;
|
||||
$val =~ s/(\d+)\..+/$1/;
|
||||
print "cpu.value " . $val . "\n";
|
||||
exit 0;
|
||||
|
120
plugins/system/memory_by_process
Executable file
120
plugins/system/memory_by_process
Executable file
|
@ -0,0 +1,120 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Copyright (C) 2006 Holger Levsen
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# Configuration variables
|
||||
# vservers - specify the vservers to include in the graph (default: all)
|
||||
# limits - if true, turn on limit graphing (default: false)
|
||||
#
|
||||
# NOTE: If no configuration variables are set, the defaults will be used
|
||||
|
||||
# Example /etc/munin/plugin-conf.d/munin-node
|
||||
#
|
||||
# The first group monitors the vservers named "vserver1 vserver2
|
||||
# vserver3 vserver4" and looks to see if the resource limit has been
|
||||
# breached, if so it sends a message to nagios via send_nsca, and
|
||||
# sends an email to notify that this has happened.
|
||||
#
|
||||
# The second monitors the vservers "vserver5 vserver6 vserver7" and
|
||||
# has no limit notifications turned on.
|
||||
#
|
||||
# The third monitors all vservers on the system, in one graph, and it has
|
||||
# no limit notifications defined.
|
||||
#
|
||||
# You can use any combination of these to fit your needs.
|
||||
#
|
||||
#
|
||||
# [vsrmem_group1]
|
||||
# user root
|
||||
# env.vservers vserver1 vserver2 vserver3 vserver4
|
||||
# env.limits 1
|
||||
# contacts nagios email
|
||||
# contact.nagios.command /usr/bin/send_nsca -H your.nagios-host.here -c /etc/send_nsca.cfg
|
||||
# contact.email.command mail -s "Munin-notification for ${var:group} :: ${var:host}" your@email.address.here
|
||||
#
|
||||
# [vsrmem_group2]
|
||||
# user root
|
||||
# env.vservers vserver5 vserver6 vserver7
|
||||
# env.limits 0
|
||||
#
|
||||
# [vserver_rmemory]
|
||||
# user root
|
||||
#
|
||||
# Graph Vserver RSS usage and limits
|
||||
#
|
||||
# Changelog
|
||||
# version 0.1 - 2006 April xx - Holger Levsen
|
||||
# - initial author
|
||||
# version 0.2 - 2006 April 24 - Micah Anderson <micah@riseup.net>
|
||||
# - Add dynamic arch page size determination
|
||||
# - Some cleanup and clarification
|
||||
# version 0.3 - 2006 May 3 - Micah Anderson <micah@riseup.net>
|
||||
# - Add ability to group vservers via environment vars
|
||||
# - Fix missing close quotes and standardize indents
|
||||
# - Add limit notification
|
||||
# - Update documentation to include info on groups and limits
|
||||
# version 0.4 - 2006 Jun 22 - Micah Anderson <micah@riseup.net>
|
||||
# - Fix error that results if NodeName is set to include a domain name
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
echo "graph_title VM by Process"
|
||||
echo 'graph_args --base 1024k'
|
||||
echo 'graph_vlabel VM size'
|
||||
echo 'graph_category system'
|
||||
echo "graph_info Shows contribution of each process to VM size"
|
||||
|
||||
ps auxww | perl '
|
||||
$junk = <>;
|
||||
while (<>)
|
||||
{
|
||||
@a = split;
|
||||
$proc = $a[10];
|
||||
$proc =~ s|.*/||;
|
||||
$proc =~ s/:.*//;
|
||||
$proc =~ tr/[]//d;
|
||||
$proc =~ tr/A-Za-z0-9/_/c;
|
||||
$vsz = $a[4];
|
||||
$total{$proc} += $vsz;
|
||||
}
|
||||
my $stack = 0;
|
||||
sub draw() { return $stack++ ? "STACK" : "AREA" }
|
||||
print map
|
||||
{
|
||||
"$_.label $_\n" .
|
||||
"$_.min 0\n" .
|
||||
"$_.draw " . draw() . "\n" .
|
||||
"$_.cdef $_,1024,*\n"
|
||||
}
|
||||
sort keys %total;
|
||||
'
|
||||
exit 0
|
||||
else
|
||||
ps auxww | perl -e '
|
||||
$junk = <>;
|
||||
while (<>)
|
||||
{
|
||||
@a = split;
|
||||
$proc = $a[10];
|
||||
$proc =~ s|.*/||;
|
||||
$proc =~ s/:.*//;
|
||||
$proc =~ tr/[]//d;
|
||||
$proc =~ tr/A-Za-z0-9/_/c;
|
||||
$vsz = $a[4];
|
||||
$total{$proc} += $vsz;
|
||||
}
|
||||
print map {"$_.value $total{$_}\n"} sort keys %total'
|
||||
fi
|
36
plugins/system/openbsd-memory
Executable file
36
plugins/system/openbsd-memory
Executable file
|
@ -0,0 +1,36 @@
|
|||
#!/bin/sh
|
||||
if [ "$1" = "config" ]; then
|
||||
echo "graph_title Memory usage (in MB)"
|
||||
echo 'graph_category system'
|
||||
echo "acti.label Active"
|
||||
echo "used.label Used"
|
||||
echo "total.label Total"
|
||||
echo "free.label Free"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Memory: Real: 14M/69M act/tot Free: 173M Swap: 0K/612M used/tot
|
||||
|
||||
top -un | nawk '
|
||||
function scale(v) {
|
||||
if (v ~ /G$/) { sub("G", "", v);v *= 1024 }
|
||||
else if (v ~ /M$/) sub("M", "", v)
|
||||
else if (v ~ /K$/) { sub("K", "", v);v /= 1024 }
|
||||
else v /= 1024 * 1024;
|
||||
return v;
|
||||
}
|
||||
function spliter(v, i) {
|
||||
split(v, a, "/");
|
||||
return(a[i]);
|
||||
}
|
||||
/^Memory/ {
|
||||
acti = scale(spliter($3,1));
|
||||
used = scale(spliter($3,2));
|
||||
free = scale($6);
|
||||
total = used + free;
|
||||
|
||||
print "acti.value", acti
|
||||
print "used.value", used
|
||||
print "total.value", total
|
||||
print "free.value", free
|
||||
}'
|
33
plugins/system/openbsd-swap
Executable file
33
plugins/system/openbsd-swap
Executable file
|
@ -0,0 +1,33 @@
|
|||
#!/bin/sh
|
||||
# @author northox <northox@mantor.org>
|
||||
# Mantor Organization
|
||||
#
|
||||
if [ "$1" = "config" ]; then
|
||||
echo "graph_title Swap usage (in MB)"
|
||||
echo 'graph_category system'
|
||||
echo "swap.label Swap used"
|
||||
echo "swapt.label Swap total"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Memory: Real: 14M/69M act/tot Free: 173M Swap: 0K/612M used/tot
|
||||
|
||||
top -un | nawk '
|
||||
function scale(v) {
|
||||
if (value ~ /G$/) { sub("G", "", v); v *= 1024 }
|
||||
else if (v ~ /M$/) sub("M", "", v)
|
||||
else if (v ~ /K$/) { sub("K", "", v); v /= 1024 }
|
||||
else v /= 1024 * 1024;
|
||||
return v;
|
||||
}
|
||||
function spliter(v, i) {
|
||||
split(v,a,"/");
|
||||
return(a[i]);
|
||||
}
|
||||
/^Memory/ {
|
||||
swap = scale(spliter($8,1));
|
||||
swapt = scale(spliter($8,2));
|
||||
|
||||
print "swap.value", swap
|
||||
print "swapt.value", swapt
|
||||
}'
|
64
plugins/system/proc_memory_status
Executable file
64
plugins/system/proc_memory_status
Executable file
|
@ -0,0 +1,64 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Julien Francoz CoCoZ <julien@francoz.net>
|
||||
|
||||
# graph memory usage detail for a process using /proc/$PID/status
|
||||
# create a link to this plugin with the syntax proc_yourprocessname_status
|
||||
# example : proc_master_status pour postfix master process
|
||||
|
||||
cmd=`basename "$0"`
|
||||
process=`echo "$cmd"| cut -d'_' -f 2`
|
||||
pid=`pgrep -o -x "$process"`
|
||||
#echo $pid
|
||||
|
||||
if [ "$1" = "autoconf" ]; then
|
||||
if [ -r /proc/$pid/status ]; then
|
||||
echo yes
|
||||
exit 0
|
||||
else
|
||||
echo no
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
|
||||
echo "graph_title Memory usage for process $process"
|
||||
echo "graph_order VmExe VmLib VmStk VmData VmRSS VmSize"
|
||||
echo 'graph_vlabel Ko'
|
||||
echo 'graph_scale no'
|
||||
echo "graph_info This graph display memory usage for a process"
|
||||
echo 'graph_category system'
|
||||
echo 'graph_period second'
|
||||
|
||||
echo 'VmExe.label VmExe'
|
||||
echo 'VmExe.draw AREA'
|
||||
echo "VmExe.info The size of the executable segment"
|
||||
|
||||
echo 'VmLib.label VmLib'
|
||||
echo 'VmLib.draw STACK'
|
||||
echo 'VmLib.info The size of the library code'
|
||||
|
||||
echo 'VmStk.label VmStk'
|
||||
echo 'VmStk.draw STACK'
|
||||
echo 'VmStk.info The stack size'
|
||||
|
||||
echo 'VmLck.label VmLck'
|
||||
echo 'VmLck.draw STACK'
|
||||
echo 'VmLck.info The amount of locked memory'
|
||||
|
||||
echo 'VmData.label VmData'
|
||||
echo 'VmData.draw STACK'
|
||||
echo 'VmData.info The size of the Data segment'
|
||||
|
||||
echo 'VmRSS.label VmRSS'
|
||||
echo 'VmRSS.draw LINE2'
|
||||
echo 'VmRSS.info The amount of memory mapped in RAM ( instead of swapped out)'
|
||||
|
||||
echo 'VmSize.label VmSize'
|
||||
echo 'VmSize.draw LINE2'
|
||||
echo 'VmSize.info The size of the virtual memory allocated to the process'
|
||||
exit 0
|
||||
fi
|
||||
|
||||
cat /proc/$pid/status |grep -E '^Vm' | sed -e 's/:/.value/' -e 's/\s\+kB$//' -e 's/\s\+/ /'
|
27
plugins/system/quagga_routes
Executable file
27
plugins/system/quagga_routes
Executable file
|
@ -0,0 +1,27 @@
|
|||
#!/bin/sh
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
echo 'graph_title quagga routes'
|
||||
echo 'graph_args -l 0'
|
||||
echo 'graph_vlabel routes'
|
||||
echo 'graph_category System'
|
||||
echo 'graph_scale no'
|
||||
/usr/local/bin/vtysh -e "sh ip ro sum" | awk '
|
||||
/connected/ {print $1 ".label " $1 "\n" $1 ".draw AREASTACK"}
|
||||
/static/ {print $1 ".label " $1 "\n" $1 ".draw AREASTACK"}
|
||||
/ebgp/ {print $1 ".label " $1 "\n" $1 ".draw AREASTACK"}
|
||||
/ibgp/ {print $1 ".label " $1 "\n" $1 ".draw AREASTACK"}
|
||||
/ospf/ {print $1 ".label " $1 "\n" $1 ".draw AREASTACK"}
|
||||
/Totals/ {print $1 ".label " $1 "\n" $1 ".draw LINE1"}
|
||||
'
|
||||
exit 0
|
||||
fi
|
||||
|
||||
/usr/local/bin/vtysh -e "sh ip ro sum" | awk '
|
||||
/connected/ {print $1 ".value "$2}
|
||||
/static/ {print $1 ".value "$2}
|
||||
/ebgp/ {print $1 ".value "$2}
|
||||
/ibgp/ {print $1 ".value "$2}
|
||||
/ospf/ {print $1 ".value "$2}
|
||||
/Totals/ {print $1 ".value "$2}
|
||||
'
|
219
plugins/system/raminfo
Executable file
219
plugins/system/raminfo
Executable file
|
@ -0,0 +1,219 @@
|
|||
#!/usr/bin/perl
|
||||
# Munin plugin for monitoring memory usage.
|
||||
#
|
||||
# FIELDS:
|
||||
# RAM Kernel Kernel resident in RAM (and usually lobel swap_total\n";
|
||||
# RAM Locked Locked memory pages from swap (Anon)
|
||||
# RAM Used Anon, Exec + Libs, Page cache
|
||||
# RAM Avail Free memory that can be immediately used
|
||||
#
|
||||
# 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
|
||||
|
||||
raminfo - Plugin for monitoring memory 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 # get value for variables
|
||||
{
|
||||
my %h_ramvalues;
|
||||
use 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 $PAGETOKB = $PAGESIZE / (1024);
|
||||
my $PAGETOBYTE = $PAGESIZE;
|
||||
my $BLOCKTOP = 512 / $PAGESIZE;
|
||||
|
||||
### RAM total
|
||||
my $ram_total = 0;
|
||||
foreach my $i (keys(%{$Kstat->{lgrp}})) { # instance
|
||||
foreach my $c (keys(%{$Kstat->{lgrp}->{$i}})) { # class
|
||||
$ram_total += $Kstat->{lgrp}->{$i}->{$c}->{"pages installed"};
|
||||
}
|
||||
}
|
||||
|
||||
### RAM available for the OS
|
||||
my $pagestotal = $Kstat->{unix}->{0}->{system_pages}->{pagestotal};
|
||||
|
||||
|
||||
# --- Fetch VM info ---
|
||||
my %VMnow;
|
||||
my %VMinfo;
|
||||
my %VMold;
|
||||
|
||||
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 ( "freemem" )
|
||||
{
|
||||
$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();
|
||||
}
|
||||
|
||||
my $freemem = $Kstat->{unix}->{0}->{system_pages}->{freemem};
|
||||
my $pageslocked = $Kstat->{unix}->{0}->{system_pages}->{pageslocked};
|
||||
my $pp_kernel = $Kstat->{unix}->{0}->{system_pages}->{pp_kernel};
|
||||
|
||||
### ---RAM Calculations ---
|
||||
my $ram_unusable = $ram_total - $pagestotal;
|
||||
my $ram_kernel;
|
||||
my $ram_locked;
|
||||
|
||||
if ($pp_kernel < $pageslocked) {
|
||||
# here we assume all pp_kernel pages are in memory,
|
||||
$ram_kernel = $pp_kernel;
|
||||
$ram_locked = $pageslocked - $pp_kernel;
|
||||
} else {
|
||||
# here we assume pageslocked is entirerly kernel,
|
||||
$ram_kernel = $pageslocked;
|
||||
$ram_locked = 0;
|
||||
}
|
||||
|
||||
my $ram_used = $pagestotal - $freemem - $ram_kernel - $ram_locked;
|
||||
|
||||
### format values
|
||||
|
||||
my $freemem_B = sprintf( "%d ", $freemem * $PAGETOBYTE );
|
||||
my $pp_kernel_B = sprintf( "%d ", $pp_kernel * $PAGETOBYTE );
|
||||
my $pageslocked_B = sprintf( "%d ", $pageslocked * $PAGETOBYTE );
|
||||
my $pagestotal_B = sprintf( "%d ", $pagestotal * $PAGETOBYTE );
|
||||
my $ram_unusable_B = sprintf( "%d ", $ram_unusable * $PAGETOBYTE );
|
||||
my $ram_kernel_B = sprintf( "%d ", $ram_kernel * $PAGETOBYTE );
|
||||
my $ram_locked_B = sprintf( "%d ", $ram_locked * $PAGETOBYTE );
|
||||
my $ram_used_B = sprintf( "%d ", $ram_used * $PAGETOBYTE );
|
||||
my $ram_total_B = sprintf( "%d ", $ram_total * $PAGETOBYTE );
|
||||
|
||||
# --- assign the variables ---
|
||||
$h_ramvalues{"Unusable.value"} = "$ram_unusable_B";
|
||||
$h_ramvalues{"Kernel.value"} = "$ram_kernel_B";
|
||||
$h_ramvalues{"Locked.value"} = "$ram_locked_B";
|
||||
$h_ramvalues{"Used.value"} = "$ram_used_B";
|
||||
$h_ramvalues{"Avail.value"} = "$freemem_B";
|
||||
$h_ramvalues{"Total.value"} = "$ram_total_B";
|
||||
|
||||
return %h_ramvalues;
|
||||
} # sub value
|
||||
|
||||
sub output # print out the values of the variables.
|
||||
{
|
||||
my %h_ramvalue=value();
|
||||
|
||||
print "Unusable.value " . $h_ramvalue{"Unusable.value"} . "\n";
|
||||
print "Kernel.value " . $h_ramvalue{"Kernel.value"} . "\n";
|
||||
print "Locked.value " . $h_ramvalue{"Locked.value"} . "\n";
|
||||
print "Used.value " . $h_ramvalue{"Used.value"} . "\n";
|
||||
print "Avail.value " . $h_ramvalue{"Avail.value"} . "\n";
|
||||
}
|
||||
|
||||
sub config # print config message and exit.
|
||||
{
|
||||
my %h_ramvalue=value();
|
||||
|
||||
print "graph_args --base 1024 -l 0 --upper-limit " . $h_ramvalue{"Total.value"}. "--rigid" . "\n";
|
||||
print "graph_vlabel Bytes\n";
|
||||
print "graph_title RAM usage\n";
|
||||
print "graph_category system\n";
|
||||
print "graph_info This graph shows what the machine uses RAM for.\n";
|
||||
print "graph_order ";
|
||||
|
||||
#print "vmalloc_used " if exists $mems{'VmallocUsed'};
|
||||
|
||||
|
||||
print "Unusable ",
|
||||
"Kernel ",
|
||||
"Locked ",
|
||||
"Used ",
|
||||
"Avail ",
|
||||
"\n";
|
||||
|
||||
print "Unusable.label Unusable \n";
|
||||
print "Unusable.draw AREA \n";
|
||||
print "Unusable.info RAM consumed by the OBP and TSBs.\n";
|
||||
print "Kernel.label Kernel \n";
|
||||
print "Kernel.draw STACK \n";
|
||||
print "Kernel.info Kernel resident in RAM.\n";
|
||||
print "Locked.label Locked \n";
|
||||
print "Locked.draw STACK \n";
|
||||
print "Locked.info Locked memory pages from swap.\n";
|
||||
print "Used.label Used\n";
|
||||
print "Used.draw STACK\n";
|
||||
print "Used.info RAM used.\n";
|
||||
print "Avail.label Avail\n";
|
||||
print "Avail.draw STACK\n";
|
||||
print "Avail.info Free RAM.\n";
|
||||
} # sub config
|
53
plugins/system/read_serial_temperature
Executable file
53
plugins/system/read_serial_temperature
Executable file
|
@ -0,0 +1,53 @@
|
|||
#!/usr/bin/env python
|
||||
"""
|
||||
Paul Wiegmans (p.wiegmans@bonhoeffer.nl)
|
||||
2009 dec 18
|
||||
This munin-node plugin reads a temperature value from a serial port,
|
||||
provided by a Arduino with temperature sensor.
|
||||
For details see: http://amber.bonhoeffer.nl/temperatuur/
|
||||
|
||||
|
||||
Linux: "/dev/usb/ttyUSB[n]" or "/dev/ttyUSB[n]"
|
||||
first for for RedHat, second form for Debian.
|
||||
e.g. "/dev/usb/ttyUSB0"
|
||||
"""
|
||||
|
||||
import sys, serial
|
||||
|
||||
# Open named port at "19200,8,N,1", 1s timeout::
|
||||
|
||||
def gettemperature():
|
||||
ser = serial.Serial('/dev/ttyUSB0', 9600, timeout=1)
|
||||
t = 0
|
||||
while t<1:
|
||||
line = ser.readline().strip()
|
||||
if line:
|
||||
temp = str(line.split(" ")[0]) # temperature in tenths celsius
|
||||
i = len(temp)-1
|
||||
temp = temp[:i] # return only integer value (as a string)
|
||||
return temp
|
||||
t += 1
|
||||
ser.close()
|
||||
|
||||
# shamelessly copied from weather_temp_
|
||||
|
||||
if len(sys.argv) == 2 and sys.argv[1] == "autoconf":
|
||||
|
||||
print "yes"
|
||||
|
||||
elif len(sys.argv) == 2 and sys.argv[1] == "config":
|
||||
|
||||
print 'graph_title Temperatuur in de serverruimte'
|
||||
print 'graph_vlabel temperature in C'
|
||||
print 'graph_category System'
|
||||
print 'temperature.label temperature'
|
||||
print 'graph_info Dit is de temperatuur in het rek in de serverruimte B104'
|
||||
print 'graph_scale no'
|
||||
# lower limit 10, upper limit 50
|
||||
print 'graph_args --base 1000 -l 10 -u 50'
|
||||
|
||||
else:
|
||||
|
||||
print 'temperature.value %s' % gettemperature()
|
||||
|
||||
|
111
plugins/system/selinux_avcstat
Executable file
111
plugins/system/selinux_avcstat
Executable file
|
@ -0,0 +1,111 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Plugin to monitor SELinux' Access Vector Cache (AVC).
|
||||
#
|
||||
# config (required)
|
||||
# autoconf (optional - used by munin-config)
|
||||
#
|
||||
# GNU GPL, Lars Strand
|
||||
#
|
||||
#
|
||||
# Magic markers (used by munin-config and some installation scripts (i.e.
|
||||
# optional)):
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf
|
||||
|
||||
|
||||
AVCSTATS="/selinux/avc/cache_stats"
|
||||
|
||||
if [ "$1" = "autoconf" ]; then
|
||||
if [ -r $AVCSTATS ]; then
|
||||
echo yes
|
||||
exit 0
|
||||
else
|
||||
echo no
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
|
||||
echo "graph_title SELinux' Access Vector Cache"
|
||||
echo 'graph_args -l 0 --base 1000'
|
||||
echo 'graph_vlabel AVC operations'
|
||||
echo 'graph_category system'
|
||||
echo 'graph_order lookups hits misses allocations reclaims frees lookups'
|
||||
|
||||
echo 'lookups.label lookups'
|
||||
echo 'lookups.type DERIVE'
|
||||
echo 'lookups.min 0'
|
||||
echo 'lookups.max 1000000000'
|
||||
echo 'lookups.draw AREA'
|
||||
echo 'lookups.colour ff0000' # Red
|
||||
echo 'lookups.info Number of access vector lookups. This number is a good indicator of the load beeing placed on the AVC.'
|
||||
|
||||
echo 'hits.label hits'
|
||||
echo 'hits.type DERIVE'
|
||||
echo 'hits.min 0'
|
||||
echo 'hits.max 1000000000'
|
||||
echo 'hits.draw STACK'
|
||||
echo 'hits.colour 0022ff' # Blue
|
||||
echo 'hits.info Number of access vector hits.'
|
||||
|
||||
echo 'misses.label misses'
|
||||
echo 'misses.type DERIVE'
|
||||
echo 'misses.min 0'
|
||||
echo 'misses.max 1000000000'
|
||||
echo 'misses.draw STACK'
|
||||
echo 'misses.colour 990000' # Darker red
|
||||
echo 'misses.info Number of cache misses.'
|
||||
|
||||
echo 'allocations.label allocations'
|
||||
echo 'allocations.type DERIVE'
|
||||
echo 'allocations.min 0'
|
||||
echo 'allocations.max 100000000'
|
||||
echo 'allocations.draw STACK'
|
||||
echo 'allocations.colour ffa500' # Orange
|
||||
echo 'allocations.info Number of AVC entries allocated.'
|
||||
|
||||
echo 'reclaims.label reclaims'
|
||||
echo 'reclaims.type DERIVE'
|
||||
echo 'reclaims.min 0'
|
||||
echo 'reclaims.max 1000000000'
|
||||
echo 'reclaims.draw STACK'
|
||||
echo 'reclaims.colour 00aaaa' # Darker turquoise
|
||||
echo 'reclaims.info Number of current total reclaimed AVC entries. If this keeps changing, you may need to increase the cache size (/selinux/avc/cache_threshold).'
|
||||
|
||||
echo 'frees.label frees'
|
||||
echo 'frees.type DERIVE'
|
||||
echo 'frees.min 0'
|
||||
echo 'frees.max 1000000000'
|
||||
echo 'frees.draw STACK'
|
||||
echo 'frees.colour 00ff7f' # Spring green
|
||||
echo 'frees.info Number of free AVC entries.'
|
||||
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ -r $AVCSTATS ]; then
|
||||
awk ' NR > 1 {
|
||||
lookups += $1;
|
||||
hits += $2;
|
||||
misses += $3;
|
||||
allocations += $4;
|
||||
reclaims += $5;
|
||||
frees += $6;
|
||||
} END {
|
||||
print "lookups.value " lookups;
|
||||
print "hits.value " hits;
|
||||
print "misses.value " misses;
|
||||
print "allocations.value " allocations;
|
||||
print "reclaims.value " reclaims;
|
||||
print "frees.value " frees;
|
||||
} ' < $AVCSTATS
|
||||
else
|
||||
echo "lookups.value U"
|
||||
echo "hits.value U"
|
||||
echo "misses.value U"
|
||||
echo "allocations.value U"
|
||||
echo "reclaims.value U"
|
||||
echo "frees.value U"
|
||||
fi
|
110
plugins/system/selinux_avcstats
Executable file
110
plugins/system/selinux_avcstats
Executable file
|
@ -0,0 +1,110 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Plugin to monitor SELinux's Access Vector Cache (AVC).
|
||||
#
|
||||
# config (required)
|
||||
# autoconf (optional - used by munin-config)
|
||||
#
|
||||
# Lars Strand, 2007
|
||||
#
|
||||
#
|
||||
# Magic markers (used by munin-config and some installation scripts (i.e.
|
||||
# optional)):
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf
|
||||
|
||||
|
||||
AVCSTATS="/selinux/avc/cache_stats"
|
||||
|
||||
if [ "$1" = "autoconf" ]; then
|
||||
if [ -r $AVCSTATS ]; then
|
||||
echo yes
|
||||
exit 0
|
||||
else
|
||||
echo no
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
|
||||
echo "graph_title SELinux's Access Vector Cache"
|
||||
echo 'graph_args -l 0 --base 1000'
|
||||
echo 'graph_vlabel AVC operations'
|
||||
echo 'graph_category system'
|
||||
|
||||
echo 'lookups.label lookups'
|
||||
echo 'lookups.type DERIVE'
|
||||
echo 'lookups.min 0'
|
||||
echo 'lookups.max 1000000000'
|
||||
echo 'lookups.draw AREA'
|
||||
echo 'lookups.colour ff0000' # Red
|
||||
echo 'lookups.info Number of access vector lookups. This number is a good indicator of the load beeing placed on the AVC.'
|
||||
|
||||
echo 'hits.label hits'
|
||||
echo 'hits.type DERIVE'
|
||||
echo 'hits.min 0'
|
||||
echo 'hits.max 1000000000'
|
||||
echo 'hits.draw STACK'
|
||||
echo 'hits.colour 0022ff' # Blue
|
||||
echo 'hits.info Number of access vector hits.'
|
||||
|
||||
echo 'misses.label misses'
|
||||
echo 'misses.type DERIVE'
|
||||
echo 'misses.min 0'
|
||||
echo 'misses.max 1000000000'
|
||||
echo 'misses.draw STACK'
|
||||
echo 'misses.colour 990000' # Darker red
|
||||
echo 'misses.info Number of cache misses.'
|
||||
|
||||
echo 'allocations.label allocations'
|
||||
echo 'allocations.type DERIVE'
|
||||
echo 'allocations.min 0'
|
||||
echo 'allocations.max 100000000'
|
||||
echo 'allocations.draw STACK'
|
||||
echo 'allocations.colour ffa500' # Orange
|
||||
echo 'allocations.info Number of AVC entries allocated.'
|
||||
|
||||
echo 'reclaims.label reclaims'
|
||||
echo 'reclaims.type DERIVE'
|
||||
echo 'reclaims.min 0'
|
||||
echo 'reclaims.max 1000000000'
|
||||
echo 'reclaims.draw STACK'
|
||||
echo 'reclaims.colour 00aaaa' # Darker turquoise
|
||||
echo 'reclaims.info Number of current total reclaimed AVC entries. If this keeps changing, you may need to increase the cache size (/selinux/avc/cache_threshold).'
|
||||
|
||||
echo 'frees.label frees'
|
||||
echo 'frees.type DERIVE'
|
||||
echo 'frees.min 0'
|
||||
echo 'frees.max 1000000000'
|
||||
echo 'frees.draw STACK'
|
||||
echo 'frees.colour 00ff7f' # Spring green
|
||||
echo 'frees.info Number of free AVC entries.'
|
||||
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ -r $AVCSTATS ]; then
|
||||
awk ' NR > 1 {
|
||||
lookups += $1;
|
||||
hits += $2;
|
||||
misses += $3;
|
||||
allocations += $4;
|
||||
reclaims += $5;
|
||||
frees += $6;
|
||||
} END {
|
||||
print "lookups.value " lookups;
|
||||
print "hits.value " hits;
|
||||
print "misses.value " misses;
|
||||
print "allocations.value " allocations;
|
||||
print "reclaims.value " reclaims;
|
||||
print "frees.value " frees;
|
||||
} ' < $AVCSTATS
|
||||
else
|
||||
echo "lookups.value U"
|
||||
echo "hits.value U"
|
||||
echo "misses.value U"
|
||||
echo "allocations.value U"
|
||||
echo "reclaims.value U"
|
||||
echo "frees.value U"
|
||||
fi
|
107
plugins/system/snmp__cpu
Executable file
107
plugins/system/snmp__cpu
Executable file
|
@ -0,0 +1,107 @@
|
|||
#!/usr/bin/perl -w
|
||||
#
|
||||
# Copyright (C) 2006 Lars Strand
|
||||
#
|
||||
# Munin plugin to monitor CPU-load by use of SNMP.
|
||||
# Based on snmp__df plugin.
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# $Log$
|
||||
#
|
||||
#
|
||||
#
|
||||
#%# family=snmpauto
|
||||
#%# capabilities=snmpconf
|
||||
|
||||
use strict;
|
||||
use Net::SNMP;
|
||||
|
||||
my $DEBUG = 0;
|
||||
|
||||
my $host = $ENV{host} || undef;
|
||||
my $port = $ENV{port} || 161;
|
||||
my $community = $ENV{community} || "public";
|
||||
|
||||
my $response;
|
||||
|
||||
if (defined $ARGV[0] and $ARGV[0] eq "snmpconf")
|
||||
{
|
||||
print "index 1.3.6.1.2.1.25.3.3.1.2.\n";
|
||||
print "require 1.3.6.1.2.1.25.3.3.1.2.1\n"; # CPU #1
|
||||
exit 0;
|
||||
}
|
||||
|
||||
if ($0 =~ /^(?:|.*\/)snmp_([^_]+)_cpu$/)
|
||||
{
|
||||
$host = $1;
|
||||
if ($host =~ /^([^:]+):(\d+)$/)
|
||||
{
|
||||
$host = $1;
|
||||
$port = $2;
|
||||
}
|
||||
}
|
||||
|
||||
elsif (!defined($host))
|
||||
{
|
||||
print "# Debug: $0 -- $1\n" if $DEBUG;
|
||||
die "# Error: couldn't understand what I'm supposed to monitor.";
|
||||
}
|
||||
|
||||
my ($session, $error) = Net::SNMP->session(
|
||||
-hostname => $host,
|
||||
-community => $community,
|
||||
-port => $port
|
||||
);
|
||||
|
||||
if (!defined ($session))
|
||||
{
|
||||
die "Croaking: $error";
|
||||
}
|
||||
|
||||
# CPUs
|
||||
my $hrProcessorLoad = "1.3.6.1.2.1.25.3.3.1.2.";
|
||||
$response = $session->get_table($hrProcessorLoad);
|
||||
|
||||
if (!defined ($response))
|
||||
{
|
||||
die "Croaking: $error";
|
||||
}
|
||||
|
||||
if (defined $ARGV[0] and $ARGV[0] eq "config")
|
||||
{
|
||||
print "host_name $host\n";
|
||||
print "graph_title CPU usage (in %)
|
||||
graph_category system
|
||||
graph_args --upper-limit 100 -l 0
|
||||
graph_vlabel %
|
||||
graph_info This graph shows the CPU load on the system.
|
||||
";
|
||||
foreach my $cpuoid (keys %$response) {
|
||||
my @oid = split(/\./, $cpuoid);
|
||||
my $cpu = pop @oid;
|
||||
print "cpu$cpu.label CPU $cpu\n";
|
||||
print "cpu$cpu.info CPU load on CPU $cpu\n";
|
||||
}
|
||||
exit 0;
|
||||
}
|
||||
|
||||
# the values
|
||||
while (my ($cpuoid, $load) = each(%$response)) {
|
||||
my @oid = split(/\./, $cpuoid);
|
||||
my $cpu = pop @oid;
|
||||
print "cpu$cpu.value $load\n";
|
||||
}
|
||||
|
175
plugins/system/snmp__cpu_usage
Executable file
175
plugins/system/snmp__cpu_usage
Executable file
|
@ -0,0 +1,175 @@
|
|||
#!/usr/bin/perl -w
|
||||
#
|
||||
# Copyright (C) 2004 Jimmy Olsen
|
||||
# Copyright (C) 2009 Xavier Montagutelli
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
#
|
||||
# $Log: snmp__cpu_usage,v $
|
||||
# Revision 1.1 2009/09/21 06:59:33 root
|
||||
# Initial revision
|
||||
#
|
||||
# Revision 1.1 2009/09/17 13:43:35 root
|
||||
# Initial revision
|
||||
#
|
||||
# Revision 1.11 2004/12/10 18:51:43 jimmyo
|
||||
# linux/apt* has been forced to LANG=C, to get predictable output.
|
||||
#
|
||||
# Revision 1.10 2004/12/10 10:47:47 jimmyo
|
||||
# Change name from ${scale} to ${graph_period}, to be more consistent.
|
||||
#
|
||||
# Revision 1.9 2004/12/09 22:12:55 jimmyo
|
||||
# Added "graph_period" option, to make "graph_sums" usable.
|
||||
#
|
||||
# Revision 1.8 2004/11/21 00:16:56 jimmyo
|
||||
# Changed a lot of plugins so they use DERIVE instead of COUNTER.
|
||||
#
|
||||
# Revision 1.7 2004/11/16 20:08:26 jimmyo
|
||||
# License cleanups.
|
||||
#
|
||||
# Revision 1.6 2004/11/12 20:28:03 ilmari
|
||||
# No debugging info by default
|
||||
#
|
||||
# Revision 1.5 2004/09/08 15:25:33 ilmari
|
||||
# Use /usr/bin/perl in all perl shebang lines.
|
||||
#
|
||||
# Revision 1.4 2004/09/07 13:19:22 ilmari
|
||||
# SNMP plugins now honour the "host" environment variable if they can't deduce the hostname from zsh.
|
||||
#
|
||||
# Revision 1.3 2004/09/05 12:00:18 jimmyo
|
||||
# Set family and capabilities.
|
||||
#
|
||||
# Revision 1.2 2004/09/04 21:58:28 jimmyo
|
||||
# Set category and info fields.
|
||||
#
|
||||
# Revision 1.1 2004/04/30 22:22:07 jimmyo
|
||||
# Added to SNMP based fibre-channel plugins: fc_if and fc_if_err.
|
||||
#
|
||||
# Revision 1.4 2004/04/30 16:58:14 jimmyo
|
||||
# Added max.
|
||||
#
|
||||
# Revision 1.3 2004/02/22 20:17:58 jimmyo
|
||||
# Typo fix
|
||||
#
|
||||
# Revision 1.2 2004/02/18 21:54:56 jimmyo
|
||||
# Did a bit of work on the snmp-thingie.
|
||||
#
|
||||
# Revision 1.1 2004/01/02 18:50:00 jimmyo
|
||||
# Renamed occurrances 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.1 2003/12/19 20:53:45 jimmyo
|
||||
# Created by jo
|
||||
#
|
||||
#
|
||||
#%# family=snmpauto
|
||||
#%# capabilities=snmpconf
|
||||
|
||||
use strict;
|
||||
use Munin::Plugin::SNMP;
|
||||
|
||||
my $DEBUG = 0;
|
||||
|
||||
my $host = $ENV{host} || undef;
|
||||
my $port = $ENV{port} || 161;
|
||||
my $community = $ENV{community} || "public";
|
||||
my $iface = $ENV{interface} || undef;
|
||||
|
||||
my $response;
|
||||
|
||||
if (defined $ARGV[0] and $ARGV[0] eq "snmpconf")
|
||||
{
|
||||
print "number 1.3.6.1.4.1.2021.11.9\n";
|
||||
exit 0;
|
||||
}
|
||||
|
||||
if ($0 =~ /^(?:|.*\/)snmp_([^_]+)_cpu_usage$/)
|
||||
{
|
||||
$host = $1;
|
||||
if ($host =~ /^([^:]+):(\d+)$/)
|
||||
{
|
||||
$host = $1;
|
||||
$port = $2;
|
||||
}
|
||||
}
|
||||
elsif (!defined($host))
|
||||
{
|
||||
print "# Debug: $0 -- $1 -- $2\n" if $DEBUG;
|
||||
die "# Error: couldn't understand what I'm supposed to monitor.";
|
||||
}
|
||||
|
||||
my $cpuUser = "1.3.6.1.4.1.2021.11.9";
|
||||
my $cpuSystem = "1.3.6.1.4.1.2021.11.10";
|
||||
my $cpuIdle = "1.3.6.1.4.1.2021.11.11";
|
||||
|
||||
my $cpu = 0;
|
||||
|
||||
my %cpuCounters = (
|
||||
cpuUser => "1.3.6.1.4.1.2021.11.9.$cpu", # The percentage of CPU time spent processing user-level code, calculated over the last minute
|
||||
cpuSystem => "1.3.6.1.4.1.2021.11.10.$cpu", # The percentage of CPU time spent processing system-level code, calculated over the last minute
|
||||
cpuIdle => "1.3.6.1.4.1.2021.11.11.$cpu", # The percentage of processor time spent idle, calculated over the last minute
|
||||
);
|
||||
|
||||
my $session = Munin::Plugin::SNMP->session(-translate =>
|
||||
[ -timeticks => 0x0 ]);
|
||||
|
||||
if (!defined ($session))
|
||||
{
|
||||
die "Croaking: could not establish SNMP object";
|
||||
}
|
||||
|
||||
|
||||
if (!defined ($session))
|
||||
{
|
||||
die "Croaking: $error";
|
||||
}
|
||||
|
||||
if ($ARGV[0] and $ARGV[0] eq "config")
|
||||
{
|
||||
print "host_name $host\n";
|
||||
my $warn = undef;
|
||||
print "graph_title CPU Usage on $host\n";
|
||||
print "graph_args --base 1000 --lower-limit 0\n";
|
||||
print "graph_vlabel Percentage on one minute\n";
|
||||
print "graph_category system\n";
|
||||
print "graph_info This graph shows the CPU usage on one minute\n";
|
||||
|
||||
my $firstCounter = 1;
|
||||
foreach my $c (keys %cpuCounters) {
|
||||
print $c . ".label $c\n";
|
||||
print $c . ".type GAUGE\n";
|
||||
if ($firstCounter) {
|
||||
print $c . ".draw AREA\n";
|
||||
$firstCounter = 0;
|
||||
} else {
|
||||
print $c . ".draw STACK\n";
|
||||
}
|
||||
print $c . ".min 0\n";
|
||||
}
|
||||
|
||||
exit 0;
|
||||
}
|
||||
|
||||
foreach my $c (keys %cpuCounters) {
|
||||
if (defined ($response = $session->get_request($cpuCounters{$c})) && $response->{$cpuCounters{$c}} =~ /^[0-9]*$/) {
|
||||
print $c . ".value ", $response->{$cpuCounters{$c}}, "\n";
|
||||
} else {
|
||||
print $c . ".value U\n";
|
||||
}
|
||||
}
|
||||
|
173
plugins/system/snmp__fn
Executable file
173
plugins/system/snmp__fn
Executable file
|
@ -0,0 +1,173 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# File: snmp__fn
|
||||
# Description: SNMP plugin to monitor open sessions, sslvpn, CPU and Memory on a
|
||||
# Fortigate firewall.
|
||||
#
|
||||
# Author: Thom Diener <munin@tmd.ch>
|
||||
# License: 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.
|
||||
#
|
||||
# Version: v1.00 30.10.2011 First draft of the fortigate plugin
|
||||
# v1.01 19.01.2012 OID to MIB changed, plugins gets faster
|
||||
# v1.02 25.01.2012 MIB file availability check added
|
||||
#
|
||||
# Parameters: config (required)
|
||||
# autoconf (optional)
|
||||
#
|
||||
# Usage: place in /etc/munin/plugins/ (or link it there using ln -s)
|
||||
# (Example: ln -s /usr/share/munin/plugins/snmp__fn \
|
||||
# /etc/munin/plugins/snmp_foo.example.com_fn)
|
||||
#
|
||||
# Global community string /etc/munin/plugin-conf.d/munin-node
|
||||
# [snmp_*]
|
||||
# env.community private
|
||||
# timeout 45 # In case low latency or timeout
|
||||
#
|
||||
# Fortigate Activate snmp on your Fortigate firewall. Fortigate documentation
|
||||
# at https://support.fortinet.com
|
||||
#
|
||||
# MIB Download and copy the original Fortigate MIB defintion file to
|
||||
# /usr/share/snmp/mibs/FORTINET-300-MIB.txt (Filename depends on
|
||||
# used Version)
|
||||
#
|
||||
# Tested with Fortinet Fortigate-50B, Firmware 3.00(MR6) on Ubuntu 10.04 LTS
|
||||
# with Munin 1.4.4 installed.
|
||||
#
|
||||
#%# family=manual
|
||||
#
|
||||
|
||||
|
||||
#set -x
|
||||
|
||||
### Constants ------------------------------------------------------------------
|
||||
SNMPCLIENT=`basename $0 | sed 's/^snmp_//g' | cut -d "_" -f1`
|
||||
MIBFILE="/usr/share/snmp/mibs/FORTINET-300-MIB.20080414.txt"
|
||||
FNTYPE=`echo $MIBFILE | cut -d "." -f1 | cut -d "/" -f6`
|
||||
if [ -r $MIBFILE ]; then
|
||||
SNMPGET="/usr/bin/snmpget -m $MIBFILE -c $community -v 2c $SNMPCLIENT"
|
||||
else
|
||||
echo no, MIB definition file not available or readable.
|
||||
exit 1
|
||||
fi
|
||||
|
||||
### Variables ------------------------------------------------------------------
|
||||
fnSysVersion="1.3.6.1.4.1.12356.1.3.0"
|
||||
FGTcpu="$FNTYPE::fnSysCpuUsage.0"
|
||||
fnSysVersion="$FNTYPE::fnSysVersion.0"
|
||||
fnSysMemUsage="$FNTYPE::fnSysMemUsage.0"
|
||||
fnSysSesCount="$FNTYPE::fnSysSesCount.0"
|
||||
fnVPNSslStatsLoginUsers="$FNTYPE::fnVpnSslStatsLoginUsers.1"
|
||||
fnVPNSslStatsActiveWebSessions="$FNTYPE::fnVpnSslStatsActiveWebSessions.1"
|
||||
fnVPNSslStatsActiveTunnels="$FNTYPE::fnVpnSslStatsActiveTunnels.1"
|
||||
|
||||
UNIT=`$SNMPGET $fnSysVersion | cut -d ":" -f4 | cut -d " " -f2 | cut -d "\"" -f2`
|
||||
SCPU=`$SNMPGET $FGTcpu | cut -d ":" -f4 | cut -d " " -f2`
|
||||
SMEM=`$SNMPGET $fnSysMemUsage | cut -d ":" -f4 | cut -d " " -f2`
|
||||
SCNT=`$SNMPGET $fnSysSesCount | cut -d ":" -f4 | cut -d " " -f2`
|
||||
USER=`$SNMPGET $fnVPNSslStatsLoginUsers | cut -d ":" -f4 | cut -d " " -f2`
|
||||
WEBS=`$SNMPGET $fnVPNSslStatsActiveWebSessions | cut -d ":" -f4 | cut -d " " -f2`
|
||||
ATUN=`$SNMPGET $fnVPNSslStatsActiveTunnels | cut -d ":" -f4 | cut -d " " -f2`
|
||||
|
||||
|
||||
### Functions ------------------------------------------------------------------
|
||||
|
||||
autoconf()
|
||||
{
|
||||
if [ $SCPU ]; then
|
||||
echo yes, OID $FGTcpu can be readed.
|
||||
else
|
||||
echo no, one or multiple OID can not be readed.
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ $SMEM ]; then
|
||||
echo yes, OID $fnSysMemUsage can be readed.
|
||||
else
|
||||
echo no, one or multiple OID can not be readed.
|
||||
exit 1
|
||||
fi
|
||||
if [ $SCNT ]; then
|
||||
echo yes, OID $fnSysSesCount can be readed.
|
||||
else
|
||||
echo no, one or multiple OID can not be read.
|
||||
exit 1
|
||||
fi
|
||||
exit 0
|
||||
}
|
||||
|
||||
config()
|
||||
{
|
||||
echo "multigraph fn_cpu"
|
||||
echo "host_name $SNMPCLIENT"
|
||||
echo "graph_title $UNIT - CPU usage"
|
||||
echo 'graph_category system'
|
||||
echo 'graph_vlabel %'
|
||||
echo 'graph_info This graph shows current CPU usage.'
|
||||
echo 'graph_args --base 1000 -r --lower-limit 0 --upper-limit 100'
|
||||
echo 'forticpu.label CPU'
|
||||
echo 'forticpu.info CPU usage'
|
||||
echo 'forticpu.draw AREA'
|
||||
echo ''
|
||||
echo "multigraph fn_memory"
|
||||
echo "host_name $SNMPCLIENT"
|
||||
echo "graph_title $UNIT - Memory usage"
|
||||
echo 'graph_category system'
|
||||
echo 'graph_vlabel %'
|
||||
echo 'graph_info This graph shows current memory usage.'
|
||||
echo 'graph_args --base 1000 -r --lower-limit 0 --upper-limit 100'
|
||||
echo 'fortimemory.label Memory'
|
||||
echo 'fortimemory.info Memory usage'
|
||||
echo 'fortimemory.draw AREA'
|
||||
echo ''
|
||||
echo "multigraph fn_sessions"
|
||||
echo "host_name $SNMPCLIENT"
|
||||
echo "graph_title $UNIT - Sessions"
|
||||
echo 'graph_category Other'
|
||||
echo 'graph_vlabel Active Sessions'
|
||||
echo 'graph_info Active session count on the Fortigate firewall'
|
||||
echo 'fortisessions.label Sessions'
|
||||
echo 'fortisessions.info Active session count'
|
||||
echo 'fortisessions.draw AREA'
|
||||
echo ''
|
||||
echo "multigraph fn_vpnsessions"
|
||||
echo "host_name $SNMPCLIENT"
|
||||
echo "graph_title $UNIT - SSLvpn Sessions"
|
||||
echo 'graph_category Other'
|
||||
echo 'graph_vlabel Sessions/Users'
|
||||
echo 'graph_info Loged in users with SSLvpn (WebSession or Tunnel-Mode)'
|
||||
echo 'fortiuser.label Users'
|
||||
echo 'fortiuser.info Loged in SSLvpn users'
|
||||
echo 'fortiwebs.label WebSessions'
|
||||
echo 'fortiwebs.info Active SSLvpn WebSessions'
|
||||
echo 'fortiatun.label ActiveTunnels'
|
||||
echo 'fortiatun.info Active SSLvpn Tunnels'
|
||||
exit 0
|
||||
}
|
||||
|
||||
values()
|
||||
{
|
||||
echo "multigraph fn_cpu"
|
||||
echo "forticpu.value $SCPU"
|
||||
echo ""
|
||||
echo "multigraph fn_memory"
|
||||
echo "fortimemory.value $SMEM"
|
||||
echo ""
|
||||
echo "multigraph fn_sessions"
|
||||
echo "fortisessions.value $SCNT"
|
||||
echo ""
|
||||
echo "multigraph fn_vpnsessions"
|
||||
echo "fortiuser.value $USER"
|
||||
echo "fortiwebs.value $WEBS"
|
||||
echo "fortiatun.value $ATUN"
|
||||
}
|
||||
|
||||
### Main -----------------------------------------------------------------------
|
||||
|
||||
if [ "$1" = "autoconf" ]; then autoconf
|
||||
fi
|
||||
if [ "$1" = "config" ]; then config
|
||||
fi
|
||||
values
|
445
plugins/system/snmp__ipoman_
Executable file
445
plugins/system/snmp__ipoman_
Executable file
|
@ -0,0 +1,445 @@
|
|||
#!/usr/bin/perl -w
|
||||
#
|
||||
# What is snmp__ipoman_
|
||||
# ----------------------
|
||||
# snmp__ipoman is a munin plugin written for the Ingrasys IpomanII 1202
|
||||
# Power Distribution Unit. It should work on any PDU conforming to
|
||||
# the IPOMANII-MIB.
|
||||
#
|
||||
# How do I use it
|
||||
# ---------------
|
||||
# You can use this plugin on a system with a working munin-node. Here's
|
||||
# how:
|
||||
#
|
||||
# 1. Copy snmp__ipoman_ to the directory where all your munin plugins
|
||||
# reside, for example /usr/share/munin/plugins.
|
||||
#
|
||||
# 2. Make the following symlinks to snmp__ipoman_ in that same directory
|
||||
#
|
||||
# snmp__ipoman_inletcurrent_
|
||||
# snmp__ipoman_inletpower_
|
||||
# snmp__ipoman_inletvoltage_
|
||||
# snmp__ipoman_outletpower_
|
||||
# snmp__ipoman_outletcurrent_
|
||||
#
|
||||
# (If you wonder why. I did not manage to make a plugin which has both
|
||||
# the 'snmpconf' and the 'suggest' capabilities. So either I had to make
|
||||
# separate plugins for all graph types, or I would have to make
|
||||
# assumptions on the number of ports and the address of the ipoman in
|
||||
# the script.)
|
||||
#
|
||||
# 3. Change to the directory where the links to munin plugins reside
|
||||
# that are to be run by munin-node, for example /etc/munin/plugins/
|
||||
#
|
||||
# 4. Run munin-node-configure-snmp:
|
||||
#
|
||||
# $ munin-node-configure-snmp --snmpversion=1 <hostname> | sh -x
|
||||
#
|
||||
# where <hostname> is the hostname or ip address of your ipoman. This
|
||||
# will create and print a bunch of symlinks to snmp__ipoman_ which will
|
||||
# output current and power usage for all available outlets of the
|
||||
# ipoman, and current, power usage and voltage/frequency on all inlets
|
||||
# of the ipoman.
|
||||
#
|
||||
# 5. Restart munin-node
|
||||
#
|
||||
# 6. Make an entry in your munin server's munin.conf:
|
||||
#
|
||||
# [<hostname of ipoman as entered in 4.>]
|
||||
# address <address of munin-node>
|
||||
# use_node_name no
|
||||
#
|
||||
# 7. Done.
|
||||
#
|
||||
# Copyright (C) 2009 Rien Broekstra <rien@rename-it.nl>
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# Munin plugin to monitor power consumption and current of the sockets of an
|
||||
# Ingrasys IpomanII 1202 Power Distribution Unit, or any power distribution
|
||||
# unit that conforms to IPOMANII-MIB via SNMP.
|
||||
#
|
||||
# Parameters:
|
||||
#
|
||||
# config
|
||||
# snmpconf
|
||||
#
|
||||
# Relevant OID's under .iso.org.dod.internet.private.enterprises.ingrasys.product.pduAgent.iPoManII
|
||||
# .ipmObjects.ipmDevice.ipmDeviceOutlet.ipmDeviceOutletNumber.0
|
||||
# .ipmObjects.ipmDevice.ipmDeviceOutlet.ipmDeviceOutletStatusTable.ipmDeviceOutletStatusEntry.outletStatusIndex.1
|
||||
# .ipmObjects.ipmDevice.ipmDeviceOutlet.ipmDeviceOutletStatusTable.ipmDeviceOutletStatusEntry.outletStatusCurrent.1
|
||||
# .ipmObjects.ipmDevice.ipmDeviceOutlet.ipmDeviceOutletStatusTable.ipmDeviceOutletStatusEntry.outletStatusKwatt.1
|
||||
# .ipmObjects.ipmDevice.ipmDeviceOutlet.ipmDeviceOutletStatusTable.ipmDeviceOutletStatusEntry.outletStatusWH.1
|
||||
#
|
||||
# Version 0.1, Aug 4, 2009
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
# MAGIC MARKERS:
|
||||
#
|
||||
#%# family=snmpauto
|
||||
#%# capabilities=snmpconf
|
||||
|
||||
use strict;
|
||||
use Net::SNMP;
|
||||
|
||||
my $DEBUG = 0;
|
||||
|
||||
my $host = $ENV{host} || undef;
|
||||
my $port = $ENV{port} || 161;
|
||||
my $community = $ENV{community} || "public";
|
||||
my $iface = $ENV{interface} || undef;
|
||||
|
||||
my $socketnumber;
|
||||
my $response;
|
||||
my $graphtype;
|
||||
|
||||
#
|
||||
# Infer host, inlet/socketnumber and graphtype from the symlink name to this plugin.
|
||||
#
|
||||
if ($0 =~ /^(?:|.*\/)snmp_([^_]*)_ipoman_([^_]*)_(.*)$/)
|
||||
{
|
||||
$host = $1;
|
||||
$graphtype = $2;
|
||||
$socketnumber = $3;
|
||||
if ($host =~ /^([^:]+):(\d+)$/) {
|
||||
$host = $1;
|
||||
$port = $2;
|
||||
}
|
||||
}
|
||||
|
||||
if (!defined($graphtype)) {
|
||||
die "# Error: couldn't understand what quantity I'm supposed to monitor.";
|
||||
}
|
||||
|
||||
#
|
||||
# The relevant OID's on the IPOMAN
|
||||
#
|
||||
my $oid_inletnumber = ".1.3.6.1.4.1.2468.1.4.2.1.3.1.1.0";
|
||||
my $oid_inletindextable = ".1.3.6.1.4.1.2468.1.4.2.1.3.1.2.1.1.";
|
||||
my $oid_inletvoltage = ".1.3.6.1.4.1.2468.1.4.2.1.3.1.3.1.2.";
|
||||
my $oid_inletcurrent = ".1.3.6.1.4.1.2468.1.4.2.1.3.1.3.1.3.";
|
||||
my $oid_inletfrequency = ".1.3.6.1.4.1.2468.1.4.2.1.3.1.3.1.4.";
|
||||
my $oid_inletenergy = ".1.3.6.1.4.1.2468.1.4.2.1.3.1.3.1.5.";
|
||||
|
||||
my $oid_outletnumber = ".1.3.6.1.4.1.2468.1.4.2.1.3.2.1.0";
|
||||
my $oid_outletindextable = ".1.3.6.1.4.1.2468.1.4.2.1.3.2.3.1.1.";
|
||||
my $oid_outletdescription = ".1.3.6.1.4.1.2468.1.4.2.1.3.2.2.1.2.";
|
||||
my $oid_outletcurrent = ".1.3.6.1.4.1.2468.1.4.2.1.3.2.3.1.3.";
|
||||
my $oid_outletenergy = ".1.3.6.1.4.1.2468.1.4.2.1.3.2.3.1.4.";
|
||||
# FIXME: The voltage is not defined per outlet. For now we just assume that all sockets have the voltage on inlet 1.
|
||||
my $oid_outletvoltage = ".1.3.6.1.4.1.2468.1.4.2.1.3.1.3.1.2.1";
|
||||
|
||||
#
|
||||
# The snmpconf section prints out what oid's we need for the quantity we want to monitor, and where we find out how many ports the device has.
|
||||
#
|
||||
if (defined $ARGV[0] and $ARGV[0] eq "snmpconf") {
|
||||
if ($graphtype eq "inletvoltage") {
|
||||
print "number $oid_inletnumber\n";
|
||||
print "index $oid_inletindextable\n";
|
||||
print "require $oid_inletvoltage [0-9]+\n";
|
||||
print "require $oid_inletfrequency [0-9]+\n";
|
||||
}
|
||||
elsif ($graphtype eq "inletcurrent") {
|
||||
print "number $oid_inletnumber\n";
|
||||
print "index $oid_inletindextable\n";
|
||||
print "require $oid_inletcurrent [0-9]+\n";
|
||||
}
|
||||
elsif ($graphtype eq "inletpower") {
|
||||
print "number $oid_inletnumber\n";
|
||||
print "index $oid_inletindextable\n";
|
||||
print "require $oid_inletvoltage [0-9]+\n";
|
||||
print "require $oid_inletcurrent [0-9]+\n";
|
||||
}
|
||||
elsif ($graphtype eq "outletcurrent") {
|
||||
print "number $oid_outletnumber\n";
|
||||
print "index $oid_outletindextable\n";
|
||||
print "require $oid_outletcurrent [0-9]+\n";
|
||||
}
|
||||
elsif ($graphtype eq "outletpower") {
|
||||
print "number $oid_outletnumber\n";
|
||||
print "index $oid_outletindextable\n";
|
||||
print "require $oid_outletvoltage [0-9]+\n";
|
||||
print "require $oid_outletcurrent [0-9]+\n";
|
||||
}
|
||||
else {
|
||||
print "require dont.graph.anything [0-9]+\n"
|
||||
}
|
||||
exit 0;
|
||||
}
|
||||
|
||||
#
|
||||
# For all other options we need to connect to the host in our $0. if we cannot, bail out.
|
||||
#
|
||||
if (!defined($host))
|
||||
{
|
||||
print "# Debug: $0 -- $1 -- $2\n" if $DEBUG;
|
||||
die "# Error: couldn't understand what I'm supposed to monitor.";
|
||||
}
|
||||
|
||||
my ($session, $error) = Net::SNMP->session(
|
||||
-hostname => $host,
|
||||
-community => $community,
|
||||
-port => $port
|
||||
);
|
||||
|
||||
if (!defined ($session))
|
||||
{
|
||||
die "Croaking: $error";
|
||||
}
|
||||
|
||||
#
|
||||
# Output graph configuration depending on what quantity we want to plot
|
||||
#
|
||||
if (defined $ARGV[0] and $ARGV[0] eq "config") {
|
||||
print "host_name $host\n";
|
||||
if ($graphtype eq "inletvoltage") {
|
||||
|
||||
print "graph_title Inlet $socketnumber voltage/frequency\n";
|
||||
|
||||
print "graph_args --base 1000 -l 0\n";
|
||||
print "graph_category system\n";
|
||||
print "graph_info This graph shows the tension and frequency to inlet $socketnumber on the Power Distribution Unit\n";
|
||||
|
||||
print "voltage.label Tension (V)\n";
|
||||
print "voltage.draw LINE2\n";
|
||||
print "voltage.type GAUGE\n";
|
||||
|
||||
print "frequency.label Frequency (Hz)\n";
|
||||
print "frequency.draw LINE2\n";
|
||||
print "frequency.type GAUGE\n";
|
||||
|
||||
}
|
||||
elsif ($graphtype eq "inletcurrent") {
|
||||
print "graph_title Inlet $socketnumber current\n";
|
||||
|
||||
print "graph_args --base 1000 -l 0\n";
|
||||
print "graph_category system\n";
|
||||
print "graph_info This graph shows the delivered current to inlet $socketnumber on the Power Distribution Unit\n";
|
||||
|
||||
print "current.label Current (A)\n";
|
||||
print "current.draw AREA\n";
|
||||
print "current.type GAUGE\n";
|
||||
|
||||
}
|
||||
elsif ($graphtype eq "inletpower") {
|
||||
print "graph_title Inlet $socketnumber power\n";
|
||||
|
||||
print "graph_args --base 1000 -l 0\n";
|
||||
print "graph_category system\n";
|
||||
print "graph_info This graph shows the delivered apparent and real power to inlet $socketnumber of the Power Distribution Unit\n";
|
||||
|
||||
print "apparentpower.label Apparent power (kVA)\n";
|
||||
print "apparentpower.draw LINE3\n";
|
||||
print "apparentpower.type GAUGE\n";
|
||||
|
||||
print "realpower.label Real power (kW)\n";
|
||||
print "realpower.draw AREA\n";
|
||||
print "realpower.type COUNTER\n";
|
||||
|
||||
exit 0;
|
||||
}
|
||||
elsif ($graphtype eq "outletcurrent") {
|
||||
print "graph_title Outlet $socketnumber current\n";
|
||||
|
||||
print "graph_args --base 1000 -l 0\n";
|
||||
print "graph_category system\n";
|
||||
print "graph_info This graph shows the delivered current to outlet $socketnumber of the Power Distribution Unit\n";
|
||||
|
||||
print "current.label Delivered current (A)\n";
|
||||
print "current.draw AREA\n";
|
||||
print "current.type GAUGE\n";
|
||||
}
|
||||
elsif ($graphtype eq "outletpower") {
|
||||
print "graph_title Outlet $socketnumber power\n";
|
||||
|
||||
print "graph_args --base 1000 -l 0\n";
|
||||
print "graph_category system\n";
|
||||
print "graph_info This graph shows the delivered apparent and real power to outlet $socketnumber of the Power Distribution Unit\n";
|
||||
|
||||
print "apparentpower.label Apparent power (kVA)\n";
|
||||
print "apparentpower.draw LINE3\n";
|
||||
print "apparentpower.type GAUGE\n";
|
||||
|
||||
print "realpower.label Real power (kW)\n";
|
||||
print "realpower.draw AREA\n";
|
||||
print "realpower.type COUNTER\n";
|
||||
|
||||
exit 0;
|
||||
}
|
||||
exit 0;
|
||||
}
|
||||
|
||||
if ($graphtype eq "inletvoltage") {
|
||||
my ($voltage, $frequency);
|
||||
|
||||
if (defined ($response = $session->get_request($oid_inletvoltage.$socketnumber))) {
|
||||
$voltage = $response->{$oid_inletvoltage.$socketnumber};
|
||||
}
|
||||
else {
|
||||
$voltage = 'U';
|
||||
}
|
||||
|
||||
if (defined ($response = $session->get_request($oid_inletfrequency.$socketnumber))) {
|
||||
$frequency = $response->{$oid_inletfrequency.$socketnumber};
|
||||
}
|
||||
else {
|
||||
$frequency = 'U';
|
||||
}
|
||||
|
||||
# The IPOMAN returns tension in 0.1V units.
|
||||
# Convert to V
|
||||
if ($voltage ne 'U') {
|
||||
$voltage = $voltage/10;
|
||||
}
|
||||
|
||||
# The IPOMAN returns frequency in 0.1Hz units.
|
||||
# Convert to Hz
|
||||
if ($frequency ne 'U') {
|
||||
$frequency = $frequency/10;
|
||||
}
|
||||
|
||||
print "voltage.value ", $voltage, "\n";
|
||||
print "frequency.value ", $frequency, "\n";
|
||||
}
|
||||
elsif ($graphtype eq "inletcurrent") {
|
||||
my $current;
|
||||
|
||||
if (defined ($response = $session->get_request($oid_inletcurrent.$socketnumber))) {
|
||||
$current = $response->{$oid_inletcurrent.$socketnumber};
|
||||
}
|
||||
else {
|
||||
$current = 'U';
|
||||
}
|
||||
|
||||
# The IPOMAN returns power in mA.
|
||||
# Convert to A:
|
||||
#
|
||||
if ($current ne 'U') {
|
||||
$current = $current/1000;
|
||||
}
|
||||
|
||||
print "current.value ", $current, "\n";
|
||||
}
|
||||
elsif ($graphtype eq "inletpower") {
|
||||
my ($current, $energy, $voltage, $apparentpower);
|
||||
|
||||
if (defined ($response = $session->get_request($oid_inletcurrent.$socketnumber))) {
|
||||
$current = $response->{$oid_inletcurrent.$socketnumber};
|
||||
}
|
||||
else {
|
||||
$current = 'U';
|
||||
}
|
||||
|
||||
if (defined ($response = $session->get_request($oid_inletenergy.$socketnumber))) {
|
||||
$energy = $response->{$oid_inletenergy.$socketnumber};
|
||||
}
|
||||
else {
|
||||
$energy = 'U';
|
||||
}
|
||||
|
||||
if (defined ($response = $session->get_request($oid_inletvoltage.$socketnumber))) {
|
||||
$voltage = $response->{$oid_inletvoltage.$socketnumber};
|
||||
}
|
||||
else {
|
||||
$voltage = 'U';
|
||||
}
|
||||
|
||||
# Calculate results
|
||||
# Apparent power (VA)= Voltage (V)* Current(A).
|
||||
# IPOMAN delivers voltage in units of 0.1V. and current in units of mA:
|
||||
if ($current ne 'U' && $voltage ne 'U') {
|
||||
$apparentpower = ($current/1000)*($voltage/10);
|
||||
}
|
||||
|
||||
#
|
||||
# The IPOMAN returns consumed energy in Wh. We want it in J (= Ws), in order for munin to graph in W.
|
||||
#
|
||||
if ($energy ne 'U') {
|
||||
$energy = $energy*3600;
|
||||
}
|
||||
|
||||
print "realpower.value ", $energy, "\n";
|
||||
print "apparentpower.value ", $apparentpower, "\n";
|
||||
}
|
||||
elsif ($graphtype eq "outletcurrent") {
|
||||
my $current;
|
||||
|
||||
if (defined ($response = $session->get_request($oid_outletcurrent.$socketnumber))) {
|
||||
$current = $response->{$oid_outletcurrent.$socketnumber};
|
||||
}
|
||||
else {
|
||||
$current = 'U';
|
||||
}
|
||||
|
||||
# The IPOMAN returns power in mA.
|
||||
# Convert to A:
|
||||
#
|
||||
if ($current ne 'U') {
|
||||
$current = $current/1000;
|
||||
}
|
||||
|
||||
print "current.value ", $current, "\n";
|
||||
}
|
||||
elsif ($graphtype eq "outletpower") {
|
||||
my ($current, $energy, $voltage, $apparentpower);
|
||||
|
||||
if (defined ($response = $session->get_request($oid_outletcurrent.$socketnumber))) {
|
||||
$current = $response->{$oid_outletcurrent.$socketnumber};
|
||||
}
|
||||
else {
|
||||
$current = 'U';
|
||||
}
|
||||
|
||||
if (defined ($response = $session->get_request($oid_outletenergy.$socketnumber))) {
|
||||
$energy = $response->{$oid_outletenergy.$socketnumber};
|
||||
}
|
||||
else {
|
||||
$energy = 'U';
|
||||
}
|
||||
|
||||
if (defined ($response = $session->get_request($oid_outletvoltage))) {
|
||||
$voltage = $response->{$oid_outletvoltage};
|
||||
}
|
||||
else {
|
||||
$voltage = 'U';
|
||||
}
|
||||
|
||||
#
|
||||
# Calculate results
|
||||
# Apparent power (VA)= Voltage (V)* Current(A).
|
||||
# IPOMAN delivers voltage in units of 0.1V. and current in units of mA:
|
||||
if ($current ne 'U' && $voltage ne 'U') {
|
||||
$apparentpower = ($current/1000)*($voltage/10);
|
||||
}
|
||||
|
||||
#
|
||||
# The IPOMAN returns consumed energy in Wh. We want it in J (= Ws), in order for munin to graph in W.
|
||||
#
|
||||
if ($energy ne 'U') {
|
||||
$energy = $energy*3600;
|
||||
}
|
||||
|
||||
print "realpower.value ", $energy, "\n";
|
||||
print "apparentpower.value ", $apparentpower, "\n";
|
||||
}
|
||||
exit 0;
|
109
plugins/system/snmp__memory_openwrt
Executable file
109
plugins/system/snmp__memory_openwrt
Executable file
|
@ -0,0 +1,109 @@
|
|||
#!/usr/bin/perl -w
|
||||
#
|
||||
# Copyright (C) 2008 J.M.Roth
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
#
|
||||
# $Log$
|
||||
#
|
||||
# Inspired by snmp__processes
|
||||
#
|
||||
#%# family=snmpauto
|
||||
#%# capabilities=snmpconf
|
||||
|
||||
use strict;
|
||||
use Net::SNMP;
|
||||
|
||||
my $DEBUG = 0;
|
||||
|
||||
my $host = $ENV{host} || undef;
|
||||
my $port = $ENV{port} || 161;
|
||||
my $community = $ENV{community} || "public";
|
||||
my $iface = $ENV{interface} || undef;
|
||||
|
||||
my $response;
|
||||
|
||||
if (defined $ARGV[0] and $ARGV[0] eq "snmpconf")
|
||||
{
|
||||
print "require 1.3.6.1.2.1.25.2.3.1.5.2\n"; # Number
|
||||
print "require 1.3.6.1.2.1.25.2.3.1.6.2\n"; # Number
|
||||
exit 0;
|
||||
}
|
||||
|
||||
my @split_result = split(/_/, $0);
|
||||
$host = $split_result[1];
|
||||
if ($host =~ /^([^:]+):(\d+)$/)
|
||||
{
|
||||
$host = $1;
|
||||
$port = $2;
|
||||
}
|
||||
if ($host eq '' || !defined $host)
|
||||
{
|
||||
print "# Debug: $0 -- $1\n" if $DEBUG;
|
||||
die "# Error: couldn't understand what I'm supposed to monitor.";
|
||||
}
|
||||
|
||||
my ($session, $error) = Net::SNMP->session(
|
||||
-hostname => $host,
|
||||
-community => $community,
|
||||
-port => $port
|
||||
);
|
||||
|
||||
if (!defined ($session))
|
||||
{
|
||||
die "Croaking: $error";
|
||||
}
|
||||
|
||||
if (defined $ARGV[0] and $ARGV[0] eq "config")
|
||||
{
|
||||
print "host_name $host\n";
|
||||
print "graph_title Memory usage
|
||||
graph_args --base 1000 -l 0
|
||||
graph_vlabel kB
|
||||
graph_category system
|
||||
graph_info This graph shows total and used memory on the host.
|
||||
memsize.label total
|
||||
memused.label used
|
||||
memsize.info The total memory.
|
||||
memused.info The memory in use.
|
||||
memsize.draw LINE1
|
||||
memused.draw LINE2
|
||||
";
|
||||
|
||||
exit 0;
|
||||
}
|
||||
|
||||
print "memsize.value ", &get_single ($session, "1.3.6.1.2.1.25.2.3.1.5.2"), "\n";
|
||||
print "memused.value ", &get_single ($session, "1.3.6.1.2.1.25.2.3.1.6.2"), "\n";
|
||||
|
||||
sub get_single
|
||||
{
|
||||
my $handle = shift;
|
||||
my $oid = shift;
|
||||
|
||||
print "# Getting single $oid...\n" if $DEBUG;
|
||||
|
||||
$response = $handle->get_request ($oid);
|
||||
|
||||
if (!defined $response->{$oid})
|
||||
{
|
||||
return undef;
|
||||
}
|
||||
else
|
||||
{
|
||||
return $response->{$oid};
|
||||
}
|
||||
}
|
266
plugins/system/snmp__memory_win
Executable file
266
plugins/system/snmp__memory_win
Executable file
|
@ -0,0 +1,266 @@
|
|||
#!/usr/bin/perl -w
|
||||
#
|
||||
# Copyright (C) 2004 Jimmy Olsen
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
#
|
||||
# $Log$
|
||||
# Revision 1.10 2004/11/16 20:08:26 jimmyo
|
||||
# License cleanups.
|
||||
#
|
||||
# Revision 1.9 2004/09/08 15:25:33 ilmari
|
||||
# Use /usr/bin/perl in all perl shebang lines.
|
||||
#
|
||||
# Revision 1.8 2004/09/07 13:19:22 ilmari
|
||||
# SNMP plugins now honour the "host" environment variable if they can't deduce the hostname from zsh.
|
||||
#
|
||||
# Revision 1.7 2004/09/07 12:58:41 ilmari
|
||||
# SNMP plugin "df" properly strips the label and serial number fromWindows drive labels.
|
||||
#
|
||||
# Revision 1.6 2004/09/05 12:00:18 jimmyo
|
||||
# Set family and capabilities.
|
||||
#
|
||||
# Revision 1.5 2004/09/04 21:58:28 jimmyo
|
||||
# Set category and info fields.
|
||||
#
|
||||
# Revision 1.4 2004/09/04 21:33:12 jimmyo
|
||||
# Handle strange characters better.
|
||||
#
|
||||
# Revision 1.3 2004/09/04 21:08:16 jimmyo
|
||||
# SNMP df plugin now talks Windowese.
|
||||
#
|
||||
# Revision 1.2 2004/09/03 22:56:51 jimmyo
|
||||
# Added support for SNMP probing.
|
||||
#
|
||||
# Revision 1.1 2004/04/29 22:29:57 jimmyo
|
||||
# New SNMP plugin for disk usage.
|
||||
#
|
||||
# Revision 1.3 2004/02/22 20:17:58 jimmyo
|
||||
# Typo fix
|
||||
#
|
||||
# Revision 1.2 2004/02/18 21:54:56 jimmyo
|
||||
# Did a bit of work on the snmp-thingie.
|
||||
#
|
||||
# Revision 1.1 2004/01/02 18:50:00 jimmyo
|
||||
# Renamed occurrances 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.1 2003/12/19 20:53:45 jimmyo
|
||||
# Created by jo
|
||||
#
|
||||
#%# family=snmpauto
|
||||
#%# capabilities=snmpconf
|
||||
|
||||
use strict;
|
||||
use Net::SNMP;
|
||||
|
||||
my $DEBUG = 0;
|
||||
my $MAXLABEL = 20;
|
||||
|
||||
my $host = $ENV{host} || undef;
|
||||
my $port = $ENV{port} || 161;
|
||||
my $community = $ENV{community} || "public";
|
||||
my $iface = $ENV{interface} || undef;
|
||||
|
||||
my $response;
|
||||
|
||||
if (defined $ARGV[0] and $ARGV[0] eq "snmpconf")
|
||||
{
|
||||
print "index 1.3.6.1.2.1.25.2.3.1.1.\n";
|
||||
print "index 1.3.6.1.2.1.25.5.1.1.2.\n";
|
||||
print "require 1.3.6.1.2.1.25.5.1.1.2. [1-9]\n";
|
||||
print "require 1.3.6.1.2.1.25.2.2.0\n"; # memsize
|
||||
print "require 1.3.6.1.2.1.25.2.3.1.2. 1.3.6.1.2.1.25.2.1.(2|3)\n"; # Type=fixed disk
|
||||
print "require 1.3.6.1.2.1.25.2.3.1.5. [1-9]\n"; # Size > 0
|
||||
exit 0;
|
||||
}
|
||||
|
||||
if ($0 =~ /^(?:|.*\/)snmp_([^_]+)_memory_win$/)
|
||||
{
|
||||
$host = $1;
|
||||
if ($host =~ /^([^:]+):(\d+)$/)
|
||||
{
|
||||
$host = $1;
|
||||
$port = $2;
|
||||
}
|
||||
}
|
||||
elsif (!defined($host))
|
||||
{
|
||||
print "# Debug: $0 -- $1\n" if $DEBUG;
|
||||
die "# Error: couldn't understand what I'm supposed to monitor.";
|
||||
}
|
||||
|
||||
# Disk level
|
||||
my $hrDeviceType = "1.3.6.1.2.1.25.3.2.1.2."; # Should be iso.3.6.1.2.1.25.3.1.6 (DiskStorage)
|
||||
my $hrDiskStorageRemoveble = "1.3.6.1.2.1.25.3.6.1.3."; # Should be false (2).
|
||||
# Windows reports 0.
|
||||
my $hrDiskStorageCapacity = "1.3.6.1.2.1.25.3.6.1.4."; # Should be more than 0
|
||||
|
||||
# Partition level
|
||||
my $hrPartitionFSIndex = "1.3.6.1.2.1.25.3.7.1.5."; # Should be more than 0
|
||||
my $hrFSMountPoint = "1.3.6.1.2.1.25.3.8.1.2."; # Used to look up filesystem
|
||||
|
||||
# Filesystem level
|
||||
my $hrStorageType = "1.3.6.1.2.1.25.2.3.1.2."; # Backup for hrFS*
|
||||
my $hrStorageDesc = "1.3.6.1.2.1.25.2.3.1.3."; # Used as key from partitions
|
||||
my $hrStorageSize = "1.3.6.1.2.1.25.2.3.1.5."; # Data point 1
|
||||
my $hrStorageUnit = "1.3.6.1.2.1.25.2.3.1.4."; # Data point 3
|
||||
my $hrStorageUsed = "1.3.6.1.2.1.25.2.3.1.6."; # Data point 2
|
||||
|
||||
# Memory
|
||||
my $hrSWRunPerfMem = "1.3.6.1.2.1.25.5.1.1.2.";
|
||||
|
||||
|
||||
my ($session, $error) = Net::SNMP->session(
|
||||
-hostname => $host,
|
||||
-community => $community,
|
||||
-port => $port
|
||||
);
|
||||
|
||||
if (!defined ($session))
|
||||
{
|
||||
die "Croaking: $error";
|
||||
}
|
||||
|
||||
my %partitions;
|
||||
my $stor_id;
|
||||
$stor_id = get_by_regex ($session, $hrStorageType, "1.3.6.1.2.1.25.2.1.(3|2)");
|
||||
%partitions = ();
|
||||
|
||||
foreach my $id (keys %$stor_id)
|
||||
{
|
||||
my $part = get_single ($session, $hrStorageDesc . $id);
|
||||
$partitions{$part}{storage} = $id;
|
||||
$partitions{$part}{extinfo} = $part;
|
||||
$stor_id->{$id} = $part;
|
||||
}
|
||||
|
||||
if (defined $ARGV[0] and $ARGV[0] eq "config")
|
||||
{
|
||||
print "host_name $host\n";
|
||||
print "graph_title Windows memory usage\n";
|
||||
print "graph_args -l 0 --base 1024\n";
|
||||
print "graph_vlabel Bytes\n";
|
||||
print "graph_category system\n";
|
||||
print "graph_info This graph shows Windows memory usage in bytes.\n";
|
||||
|
||||
foreach my $part (keys %partitions)
|
||||
{
|
||||
print (&get_name_by_mp ($part), ".label $part Usage\n");
|
||||
# print (&get_name_by_mp ($part), ".warning 92\n");
|
||||
# print (&get_name_by_mp ($part), ".critical 98\n");
|
||||
print (&get_name_by_mp ($part) . "_s", ".label $part Size\n");
|
||||
print (&get_name_by_mp ($part) . "_s", ".graph no\n");
|
||||
}
|
||||
print "pused.label In use by programs\n";
|
||||
print "pused.draw AREA\n";
|
||||
exit 0;
|
||||
}
|
||||
|
||||
foreach my $storage (keys %$stor_id)
|
||||
{
|
||||
$partitions{$stor_id->{$storage}}{storage} = $storage;
|
||||
$partitions{$stor_id->{$storage}}{size} = get_single ($session, $hrStorageSize . $storage);
|
||||
$partitions{$stor_id->{$storage}}{unit} = get_single ($session, $hrStorageUnit . $storage);
|
||||
$partitions{$stor_id->{$storage}}{used} = get_single ($session, $hrStorageUsed . $storage);
|
||||
}
|
||||
|
||||
foreach my $part (keys %partitions)
|
||||
{
|
||||
print (&get_name_by_mp ($part), ".value ", $partitions{$part}{used}*$partitions{$part}{unit}, "\n");
|
||||
print (&get_name_by_mp ($part) . "_s", ".value ", $partitions{$part}{size}*$partitions{$part}{unit}, "\n");
|
||||
}
|
||||
my $memsize = &get_single($session, "1.3.6.1.2.1.25.2.2.0") * 1024;
|
||||
my $processes = get_by_regex($session, $hrSWRunPerfMem, "[1-9]");
|
||||
# the values
|
||||
my $memtotal = 0;
|
||||
while (my ($pid, $mem) = each(%$processes)) {
|
||||
$memtotal += $mem;
|
||||
}
|
||||
$memtotal*=1024;
|
||||
printf "pused.value $memtotal\n";
|
||||
|
||||
sub get_single
|
||||
{
|
||||
my $handle = shift;
|
||||
my $oid = shift;
|
||||
|
||||
print "# Getting single $oid..." if $DEBUG;
|
||||
|
||||
$response = $handle->get_request ($oid);
|
||||
|
||||
if (!defined $response->{$oid})
|
||||
{
|
||||
print "undef\n" if $DEBUG;
|
||||
return undef;
|
||||
}
|
||||
else
|
||||
{
|
||||
print "\"$response->{$oid}\"\n" if $DEBUG;
|
||||
return $response->{$oid};
|
||||
}
|
||||
}
|
||||
|
||||
sub get_by_regex
|
||||
{
|
||||
my $handle = shift;
|
||||
my $oid = shift;
|
||||
my $regex = shift;
|
||||
my $result = {};
|
||||
my $num = 0;
|
||||
my $ret = $oid . "0";
|
||||
my $response;
|
||||
|
||||
print "# Starting browse of $oid...\n" if $DEBUG;
|
||||
|
||||
while (1)
|
||||
{
|
||||
if ($num == 0)
|
||||
{
|
||||
print "# Checking for $ret...\n" if $DEBUG;
|
||||
$response = $handle->get_request ($ret);
|
||||
}
|
||||
if ($num or !defined $response)
|
||||
{
|
||||
print "# Checking for sibling of $ret...\n" if $DEBUG;
|
||||
$response = $handle->get_next_request ($ret);
|
||||
}
|
||||
if (!$response)
|
||||
{
|
||||
return undef;
|
||||
}
|
||||
my @keys = keys %$response;
|
||||
$ret = $keys[0];
|
||||
print "# Analyzing $ret (compared to $oid)...\n" if $DEBUG;
|
||||
last unless ($ret =~ /^$oid/);
|
||||
$num++;
|
||||
next unless ($response->{$ret} =~ /$regex/);
|
||||
@keys = split (/\./, $ret);
|
||||
$result->{$keys[-1]} = ($1) ? $1 : $response->{$ret};
|
||||
print "# Index $num: ", $keys[-1], " (", $response->{$ret}, ")\n" if $DEBUG;
|
||||
};
|
||||
return $result;
|
||||
}
|
||||
|
||||
sub get_name_by_mp
|
||||
{
|
||||
my $mp = shift;
|
||||
$mp =~ s/[^a-z0-9_]/_/gi;
|
||||
$mp =~ tr/A-Z/a-z/;
|
||||
return "p" . $mp;
|
||||
}
|
350
plugins/system/snmp__ups_
Executable file
350
plugins/system/snmp__ups_
Executable file
|
@ -0,0 +1,350 @@
|
|||
#!/usr/bin/perl
|
||||
#
|
||||
# Copyright (C) 2008 Gorlow Maxim [Sheridan]
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
# ups_host_volt - IO voltage (volt)
|
||||
# ups_host_freq - IO frequency (hz)
|
||||
# ups_host_status - UPS status (online, off....)
|
||||
# ups_host_temp - Temperature (c)
|
||||
# ups_host_battcap - Battery capacity (%)
|
||||
# ups_host_load - UPS load (%)
|
||||
# ups_host_curr - Current (ampers)
|
||||
|
||||
|
||||
|
||||
|
||||
#
|
||||
#%# family=snmpauto
|
||||
#
|
||||
|
||||
use strict;
|
||||
use SNMP '5.0.2.pre1' || die("Cannot load module\n");
|
||||
$ENV{'MIBS'}="ALL";
|
||||
|
||||
my $host = $ENV{host} || undef;
|
||||
my $community = $ENV{community} || "public";
|
||||
my $type = "volt";
|
||||
my $response;
|
||||
|
||||
if ($0 =~ /^(?:|.*\/)snmp_([^_]+)_ups_(.+)$/)
|
||||
{
|
||||
$host = $1;
|
||||
$type = $2;
|
||||
if ($host =~ /^([^:]+):(\d+)$/)
|
||||
{
|
||||
$host = $1;
|
||||
$type = $2;
|
||||
}
|
||||
}
|
||||
elsif (!defined($host)) {
|
||||
die "# Error: couldn't understand what I'm supposed to monitor."; }
|
||||
|
||||
|
||||
my $session = new SNMP::Session (
|
||||
DestHost => $host,
|
||||
Community => $community,
|
||||
Version => 1
|
||||
);
|
||||
my $oidsList;
|
||||
my $modelList = new SNMP::VarList(['upsBasicIdentModel'],['upsAdvIdentSerialNumber']);
|
||||
if ($type eq "volt")
|
||||
{
|
||||
$oidsList = new SNMP::VarList (
|
||||
['upsAdvOutputVoltage'],
|
||||
['upsAdvInputLineVoltage'],
|
||||
['upsAdvInputMaxLineVoltage'],
|
||||
['upsAdvInputMinLineVoltage']
|
||||
);
|
||||
}
|
||||
elsif ($type eq "freq")
|
||||
{
|
||||
$oidsList = new SNMP::VarList (
|
||||
['upsAdvOutputFrequency'],
|
||||
['upsAdvInputFrequency']
|
||||
);
|
||||
}
|
||||
elsif ($type eq "status")
|
||||
{
|
||||
$oidsList = new SNMP::VarList (
|
||||
['upsBasicOutputStatus']
|
||||
);
|
||||
}
|
||||
elsif ($type eq "temp")
|
||||
{
|
||||
$oidsList = new SNMP::VarList (
|
||||
['upsAdvBatteryTemperature']
|
||||
);
|
||||
}
|
||||
elsif ($type eq "battcap")
|
||||
{
|
||||
$oidsList = new SNMP::VarList (
|
||||
['upsAdvBatteryCapacity']
|
||||
);
|
||||
}
|
||||
elsif ($type eq "load")
|
||||
{
|
||||
$oidsList = new SNMP::VarList (
|
||||
['upsAdvOutputLoad']
|
||||
);
|
||||
}
|
||||
elsif ($type eq "curr")
|
||||
{
|
||||
$oidsList = new SNMP::VarList (
|
||||
['upsAdvOutputCurrent']
|
||||
);
|
||||
}
|
||||
#if (defined $ARGV[0] and $ARGV[0] eq "snmpconf")
|
||||
#{}
|
||||
|
||||
if ($ARGV[0] and $ARGV[0] eq "config")
|
||||
{
|
||||
|
||||
my $model;
|
||||
my $vLabel;
|
||||
my $hLabel;
|
||||
if ($type eq "volt")
|
||||
{
|
||||
$vLabel = "Voltage";
|
||||
$hLabel = "IO Voltage";
|
||||
}
|
||||
elsif ($type eq "freq")
|
||||
{
|
||||
$vLabel = "Frequency";
|
||||
$hLabel = "IO Frequency";
|
||||
}
|
||||
elsif ($type eq "status")
|
||||
{
|
||||
$vLabel = "Status";
|
||||
$hLabel = "Status";
|
||||
}
|
||||
elsif ($type eq "temp")
|
||||
{
|
||||
$vLabel = "Temperature, C";
|
||||
$hLabel = "Temperature";
|
||||
}
|
||||
elsif ($type eq "battcap")
|
||||
{
|
||||
$vLabel = "Percent";
|
||||
$hLabel = "Batt. capacity";
|
||||
}
|
||||
elsif ($type eq "load")
|
||||
{
|
||||
$vLabel = "Percent";
|
||||
$hLabel = "UPS load";
|
||||
}
|
||||
elsif ($type eq "curr")
|
||||
{
|
||||
$vLabel = "Ampers";
|
||||
$hLabel = "Current";
|
||||
}
|
||||
print "host_name $host\n" unless $host eq 'localhost';
|
||||
my @response = $session->getnext($modelList);
|
||||
$response[0] =~ s/[\" ]//g; # Ditch the quotes.
|
||||
$response[1] =~ s/[\" ]//g;
|
||||
$model = "$response[0] [$response[1]]";
|
||||
print "graph_title $hLabel, $model\n";
|
||||
print "graph_args --base 1000\n";
|
||||
print "graph_vlabel $vLabel\n";
|
||||
print "graph_category system\n";
|
||||
print "graph_info This graph shows the $hLabel ($vLabel) of $model\n";
|
||||
if ($type eq "volt")
|
||||
{
|
||||
print "graph_order in out inmax inmin\n";
|
||||
print "in.label Input\n";
|
||||
print "in.type GAUGE\n";
|
||||
print "in.info Input voltage.\n";
|
||||
print "in.colour FFCC99\n";
|
||||
print "in.draw AREA\n";
|
||||
print "out.label Output\n";
|
||||
print "out.type GAUGE\n";
|
||||
print "out.info Output voltage.\n";
|
||||
print "out.colour 009BCC\n";
|
||||
print "out.draw AREA\n";
|
||||
print "inmax.label Input max\n";
|
||||
print "inmax.type GAUGE\n";
|
||||
print "inmax.info Input voltage maximum.\n";
|
||||
print "inmax.colour FF0033\n";
|
||||
print "inmax.draw LINE1\n";
|
||||
print "inmin.label Input min\n";
|
||||
print "inmin.type GAUGE\n";
|
||||
print "inmin.info Input voltage minimum.\n";
|
||||
print "inmin.colour 66FF00\n";
|
||||
print "inmin.draw LINE1\n";
|
||||
|
||||
}
|
||||
elsif ($type eq "freq")
|
||||
{
|
||||
print "graph_order in out\n";
|
||||
print "out.label Output\n";
|
||||
print "out.type GAUGE\n";
|
||||
print "out.info Output frequency.\n";
|
||||
print "out.draw LINE2\n";
|
||||
print "in.label Input\n";
|
||||
print "in.type GAUGE\n";
|
||||
print "in.info Input frequency.\n";
|
||||
print "in.draw LINE2\n";
|
||||
}
|
||||
elsif ($type eq "status")
|
||||
{
|
||||
print "state.label Status\n";
|
||||
print "state.type GAUGE\n";
|
||||
print "state.draw AREA\n";
|
||||
print "state.min 1\n";
|
||||
print "state.max 12\n";
|
||||
print "unknown.label Unknown\n";
|
||||
print "unknown.type GAUGE\n";
|
||||
print "unknown.draw LINE3\n";
|
||||
print "onLine.label Online\n";
|
||||
print "onLine.type GAUGE\n";
|
||||
print "onLine.draw LINE3\n";
|
||||
print "onBattery.label On Battery\n";
|
||||
print "onBattery.type GAUGE\n";
|
||||
print "onBattery.draw LINE3\n";
|
||||
print "onSmartBoost.label On Smart Boost\n";
|
||||
print "onSmartBoost.type GAUGE\n";
|
||||
print "onSmartBoost.draw LINE3\n";
|
||||
print "timedSleeping.label Timed Sleeping\n";
|
||||
print "timedSleeping.type GAUGE\n";
|
||||
print "timedSleeping.draw LINE3\n";
|
||||
print "softwareBypass.label Software Bypass\n";
|
||||
print "softwareBypass.type GAUGE\n";
|
||||
print "softwareBypass.draw LINE3\n";
|
||||
print "off.label Off\n";
|
||||
print "off.type GAUGE\n";
|
||||
print "off.draw LINE3\n";
|
||||
print "rebooting.label Rebooting\n";
|
||||
print "rebooting.type GAUGE\n";
|
||||
print "rebooting.draw LINE3\n";
|
||||
print "switchedBypass.label Switched Bypass\n";
|
||||
print "switchedBypass.type GAUGE\n";
|
||||
print "switchedBypass.draw LINE3\n";
|
||||
print "hardwareFailureBypass.label HW Failure Bypass\n";
|
||||
print "hardwareFailureBypass.type GAUGE\n";
|
||||
print "hardwareFailureBypass.draw LINE3\n";
|
||||
print "sleepingUntilPowerReturn.label Sleep Until Power Return\n";
|
||||
print "sleepingUntilPowerReturn.type GAUGE\n";
|
||||
print "sleepingUntilPowerReturn.draw LINE3\n";
|
||||
print "onSmartTrim.label On Smart Trim\n";
|
||||
print "onSmartTrim.type GAUGE\n";
|
||||
print "onSmartTrim.draw LINE3\n";
|
||||
}
|
||||
elsif ($type eq "temp")
|
||||
{
|
||||
print "batt.label Battery temperature\n";
|
||||
print "batt.type GAUGE\n";
|
||||
print "batt.info Battery temperature.\n";
|
||||
print "batt.draw LINE2\n";
|
||||
}
|
||||
elsif ($type eq "battcap")
|
||||
{
|
||||
print "bcap.label Battery capacity\n";
|
||||
print "bcap.type GAUGE\n";
|
||||
print "bcap.info Battery capacity.\n";
|
||||
print "bcap.draw AREA\n";
|
||||
print "bcap.warning 30\n";
|
||||
print "bcap.critical 15\n";
|
||||
}
|
||||
elsif ($type eq "load")
|
||||
{
|
||||
print "load.label UPS load\n";
|
||||
print "load.type GAUGE\n";
|
||||
print "load.info UPS load.\n";
|
||||
print "load.draw AREA\n";
|
||||
print "load.warning 95\n";
|
||||
print "load.critical 100\n";
|
||||
}
|
||||
elsif ($type eq "curr")
|
||||
{
|
||||
print "out.label Output\n";
|
||||
print "out.type GAUGE\n";
|
||||
print "out.info Output current\n";
|
||||
print "out.draw LINE2\n";
|
||||
}
|
||||
exit 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
my @response = $session->getnext($oidsList);
|
||||
if ($type eq "volt")
|
||||
{
|
||||
print "out.value $response[0]\n";
|
||||
print "in.value $response[1]\n";
|
||||
print "inmax.value $response[2]\n";
|
||||
print "inmin.value $response[3]\n";
|
||||
}
|
||||
elsif ($type eq "freq")
|
||||
{
|
||||
print "out.value $response[0]\n";
|
||||
print "in.value $response[1]\n";
|
||||
}
|
||||
elsif ($type eq "status")
|
||||
{
|
||||
my $unknown = $response[0]==1 || "U";
|
||||
my $onLine = $response[0]==2 || "U";
|
||||
my $onBattery = $response[0]==3 || "U";
|
||||
my $onSmartBoost = $response[0]==4 || "U";
|
||||
my $timedSleeping = $response[0]==5 || "U";
|
||||
my $softwareBypass = $response[0]==6 || "U";
|
||||
my $off = $response[0]==7 || "U";
|
||||
my $rebooting = $response[0]==8 || "U";
|
||||
my $switchedBypass = $response[0]==9 || "U";
|
||||
my $hardwareFailureBypass = $response[0]==10 || "U";
|
||||
my $sleepingUntilPowerReturn = $response[0]==11 || "U";
|
||||
my $onSmartTrim = $response[0]==12 || "U";
|
||||
|
||||
print "state.value $response[0]\n";
|
||||
print "unknown.value $unknown\n";
|
||||
print "onLine.value $onLine\n";
|
||||
print "onBattery.value $onBattery\n";
|
||||
print "onSmartBoost.value $onSmartBoost\n";
|
||||
print "timedSleeping.value $timedSleeping\n";
|
||||
print "softwareBypass.value $softwareBypass\n";
|
||||
print "off.value $off\n";
|
||||
print "rebooting.value $rebooting\n";
|
||||
print "switchedBypass.value $switchedBypass\n";
|
||||
print "hardwareFailureBypass.value $hardwareFailureBypass\n";
|
||||
print "sleepingUntilPowerReturn.value $sleepingUntilPowerReturn\n";
|
||||
print "onSmartTrim.value $onSmartTrim\n";
|
||||
}
|
||||
elsif ($type eq "temp")
|
||||
{
|
||||
print "batt.value $response[0]\n";
|
||||
}
|
||||
elsif ($type eq "battcap")
|
||||
{
|
||||
print "bcap.value $response[0]\n";
|
||||
}
|
||||
elsif ($type eq "load")
|
||||
{
|
||||
print "load.value $response[0]\n";
|
||||
}
|
||||
elsif ($type eq "curr")
|
||||
{
|
||||
print "out.value $response[0]\n";
|
||||
}
|
||||
|
||||
__END__
|
||||
if (defined $ARGV[0] and $ARGV[0] eq "snmpconf")
|
||||
{
|
||||
print "number 1.3.6.1.2.1.2.1.0\n";
|
||||
print "index 1.3.6.1.2.1.2.2.1.1.\n";
|
||||
print "require 1.3.6.1.2.1.2.2.1.3. ^(6|23)\$\n"; # Type
|
||||
print "require 1.3.6.1.2.1.2.2.1.5. [1-9]\n"; # Speed
|
||||
exit 0;
|
||||
}
|
105
plugins/system/snmp__uptime
Executable file
105
plugins/system/snmp__uptime
Executable file
|
@ -0,0 +1,105 @@
|
|||
#!/usr/bin/perl -w
|
||||
#
|
||||
# Copyright (C) 2006 Lars Strand
|
||||
#
|
||||
# Munin plugin to monitor uptime by use of SNMP.
|
||||
# Based on snmp__users plugin.
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# $Log$
|
||||
#
|
||||
#%# family=snmpauto
|
||||
#%# capabilities=snmpconf
|
||||
|
||||
use strict;
|
||||
use Net::SNMP;
|
||||
|
||||
my $DEBUG = 0;
|
||||
|
||||
my $host = $ENV{host} || undef;
|
||||
my $port = $ENV{port} || 161;
|
||||
my $community = $ENV{community} || "public";
|
||||
|
||||
my $response;
|
||||
|
||||
if (defined $ARGV[0] and $ARGV[0] eq "snmpconf")
|
||||
{
|
||||
print "require 1.3.6.1.2.1.1.3.0 \n";
|
||||
exit 0;
|
||||
}
|
||||
|
||||
if ($0 =~ /^(?:|.*\/)snmp_([^_]+)_uptime$/)
|
||||
{
|
||||
$host = $1;
|
||||
if ($host =~ /^([^:]+):(\d+)$/)
|
||||
{
|
||||
$host = $1;
|
||||
$port = $2;
|
||||
}
|
||||
}
|
||||
elsif (!defined($host))
|
||||
{
|
||||
print "# Debug: $0 -- $1\n" if $DEBUG;
|
||||
die "# Error: couldn't understand what I'm supposed to monitor.";
|
||||
}
|
||||
|
||||
if (defined $ARGV[0] and $ARGV[0] eq "config")
|
||||
{
|
||||
print "host_name $host\n";
|
||||
print "graph_title Uptime
|
||||
graph_category system
|
||||
graph_args --base 1000 -l 0
|
||||
graph_vlabel uptime
|
||||
graph_info This graph shows the uptime (in days) of the system.
|
||||
uptime.label uptime
|
||||
uptime.draw AREA
|
||||
";
|
||||
exit 0;
|
||||
}
|
||||
|
||||
my ($session, $error) = Net::SNMP->session(
|
||||
-hostname => $host,
|
||||
-community => $community,
|
||||
-port => $port,
|
||||
-translate => ['-timeticks']
|
||||
);
|
||||
|
||||
if (!defined ($session))
|
||||
{
|
||||
die "Croaking: $error";
|
||||
}
|
||||
|
||||
printf "uptime.value %.2f\n", &get_single($session, "1.3.6.1.2.1.1.3.0");
|
||||
|
||||
sub get_single
|
||||
{
|
||||
my $handle = shift;
|
||||
my $oid = shift;
|
||||
|
||||
print "# Getting single $oid...\n" if $DEBUG;
|
||||
|
||||
|
||||
$response = $handle->get_request($oid);
|
||||
|
||||
if (!defined $response->{$oid})
|
||||
{
|
||||
return undef;
|
||||
}
|
||||
else
|
||||
{
|
||||
return (($response->{$oid}/100)/(60*60*24));
|
||||
}
|
||||
}
|
174
plugins/system/snmp_memory
Executable file
174
plugins/system/snmp_memory
Executable file
|
@ -0,0 +1,174 @@
|
|||
#!/usr/bin/perl -w
|
||||
#
|
||||
# Copyright (C) 2006 Lars Strand
|
||||
#
|
||||
# Munin plugin to monitor memory usage by use of SNMP.
|
||||
# Based on snmp__df plugin.
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# $Log$
|
||||
#
|
||||
#%# family=snmpauto
|
||||
#%# capabilities=snmpconf
|
||||
|
||||
use strict;
|
||||
use Net::SNMP;
|
||||
|
||||
my $DEBUG = 0;
|
||||
|
||||
my $host = $ENV{host} || undef;
|
||||
my $port = $ENV{port} || 161;
|
||||
my $community = $ENV{community} || "public";
|
||||
|
||||
my $response;
|
||||
|
||||
if (defined $ARGV[0] and $ARGV[0] eq "snmpconf")
|
||||
{
|
||||
print "index 1.3.6.1.2.1.25.5.1.1.2.\n";
|
||||
print "require 1.3.6.1.2.1.25.5.1.1.2. [1-9]\n";
|
||||
print "require 1.3.6.1.2.1.25.2.2.0\n"; # memsize
|
||||
exit 0;
|
||||
}
|
||||
|
||||
if ($0 =~ /^(?:|.*\/)snmp_([^_]+)_memory$/)
|
||||
{
|
||||
$host = $1;
|
||||
if ($host =~ /^([^:]+):(\d+)$/)
|
||||
{
|
||||
$host = $1;
|
||||
$port = $2;
|
||||
}
|
||||
}
|
||||
elsif (!defined($host))
|
||||
{
|
||||
print "# Debug: $0 -- $1\n" if $DEBUG;
|
||||
die "# Error: couldn't understand what I'm supposed to monitor.";
|
||||
}
|
||||
|
||||
# memory usage pr. process
|
||||
my $hrSWRunPerfMem = "1.3.6.1.2.1.25.5.1.1.2.";
|
||||
|
||||
my ($session, $error) = Net::SNMP->session(
|
||||
-hostname => $host,
|
||||
-community => $community,
|
||||
-port => $port
|
||||
);
|
||||
|
||||
if (!defined ($session))
|
||||
{
|
||||
die "Croaking: $error";
|
||||
}
|
||||
|
||||
# total memory
|
||||
my $memsize = &get_single($session, "1.3.6.1.2.1.25.2.2.0") * 1024;
|
||||
|
||||
if (defined $ARGV[0] and $ARGV[0] eq "config")
|
||||
{
|
||||
print "host_name $host\n";
|
||||
print "graph_title Memory usage\n";
|
||||
print "graph_category system\n";
|
||||
print "graph_vlabel Bytes\n";
|
||||
print "graph_info This grap shows memory usage.\n";
|
||||
|
||||
# some devices reports negative memtotal value
|
||||
print "# Total memsize reported $memsize..." if $DEBUG;
|
||||
|
||||
if ($memsize > 0)
|
||||
{
|
||||
print "graph_args --base 1024 -l 0 --upper-limit $memsize\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
print "graph_args --base 1024 -l 0\n";
|
||||
}
|
||||
|
||||
print "memory.draw AREA\n";
|
||||
print "memory.label memory\n";
|
||||
|
||||
exit 0;
|
||||
}
|
||||
|
||||
my $processes = get_by_regex($session, $hrSWRunPerfMem, "[1-9]");
|
||||
|
||||
# the values
|
||||
my $memtotal = 0;
|
||||
while (my ($pid, $mem) = each(%$processes)) {
|
||||
$memtotal += $mem;
|
||||
}
|
||||
$memtotal*=1024;
|
||||
printf "memory.value $memtotal\n";
|
||||
|
||||
sub get_single
|
||||
{
|
||||
my $handle = shift;
|
||||
my $oid = shift;
|
||||
|
||||
print "# Getting single $oid..." if $DEBUG;
|
||||
|
||||
$response = $handle->get_request ($oid);
|
||||
|
||||
if (!defined $response->{$oid})
|
||||
{
|
||||
print "undef\n" if $DEBUG;
|
||||
return undef;
|
||||
}
|
||||
else
|
||||
{
|
||||
print "\"$response->{$oid}\"\n" if $DEBUG;
|
||||
return $response->{$oid};
|
||||
}
|
||||
}
|
||||
|
||||
sub get_by_regex
|
||||
{
|
||||
my $handle = shift;
|
||||
my $oid = shift;
|
||||
my $regex = shift;
|
||||
my $result = {};
|
||||
my $num = 0;
|
||||
my $ret = $oid . "0";
|
||||
my $response;
|
||||
|
||||
print "# Starting browse of $oid...\n" if $DEBUG;
|
||||
|
||||
while (1)
|
||||
{
|
||||
if ($num == 0)
|
||||
{
|
||||
print "# Checking for $ret...\n" if $DEBUG;
|
||||
$response = $handle->get_request ($ret);
|
||||
}
|
||||
if ($num or !defined $response)
|
||||
{
|
||||
print "# Checking for sibling of $ret...\n" if $DEBUG;
|
||||
$response = $handle->get_next_request ($ret);
|
||||
}
|
||||
if (!$response)
|
||||
{
|
||||
return undef;
|
||||
}
|
||||
my @keys = keys %$response;
|
||||
$ret = $keys[0];
|
||||
print "# Analyzing $ret (compared to $oid)...\n" if $DEBUG;
|
||||
last unless ($ret =~ /^$oid/);
|
||||
$num++;
|
||||
next unless ($response->{$ret} =~ /$regex/);
|
||||
@keys = split (/\./, $ret);
|
||||
$result->{$keys[-1]} = $response->{$ret};;
|
||||
print "# Index $num: ", $keys[-1], " (", $response->{$ret}, ")\n" if $DEBUG;
|
||||
};
|
||||
return $result;
|
||||
}
|
139
plugins/system/snmp_zyxel_usg__cpu
Executable file
139
plugins/system/snmp_zyxel_usg__cpu
Executable file
|
@ -0,0 +1,139 @@
|
|||
#!/usr/bin/perl -w
|
||||
#
|
||||
# Copyright (C) 2009 Branislav Bozgai
|
||||
#
|
||||
# Munin plugin to monitor ZyXel USG series routers CPU utilization.
|
||||
# Based on snmp__if_ plugin.
|
||||
#
|
||||
# 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.
|
||||
|
||||
|
||||
#%# family=snmpauto
|
||||
#%# capabilities=snmpconf
|
||||
|
||||
use strict;
|
||||
use Net::SNMP;
|
||||
|
||||
my $DEBUG = 0;
|
||||
|
||||
my $host = $ENV{host} || undef;
|
||||
my $port = $ENV{port} || 161;
|
||||
my $community = $ENV{community} || "public";
|
||||
|
||||
my $response;
|
||||
|
||||
if (defined $ARGV[0] and $ARGV[0] eq "snmpconf")
|
||||
{
|
||||
print "require 1.3.6.1.4.1.890.1.6.22.1.1.0 \n";
|
||||
exit 0;
|
||||
}
|
||||
|
||||
if ($0 =~ /^(?:|.*\/)snmp_zyxel_usg_([^_]+)_cpu$/)
|
||||
{
|
||||
$host = $1;
|
||||
if ($host =~ /^([^:]+):(\d+)$/)
|
||||
{
|
||||
$host = $1;
|
||||
$port = $2;
|
||||
}
|
||||
}
|
||||
elsif (!defined($host))
|
||||
{
|
||||
print "# Debug: $0 -- $1\n" if $DEBUG;
|
||||
die "# Error: couldn't understand what I'm supposed to monitor.";
|
||||
}
|
||||
|
||||
my $sysCPUUsage = "1.3.6.1.4.1.890.1.6.22.1.1.0";
|
||||
my $sysCPU5SecUsage = "1.3.6.1.4.1.890.1.6.22.1.3.0";
|
||||
my $sysCPU1MinUsage = "1.3.6.1.4.1.890.1.6.22.1.4.0";
|
||||
my $sysCPU5MinUsage = "1.3.6.1.4.1.890.1.6.22.1.5.0";
|
||||
|
||||
my ($session, $error) = Net::SNMP->session(
|
||||
-hostname => $host,
|
||||
-community => $community,
|
||||
-port => $port
|
||||
);
|
||||
|
||||
|
||||
if (!defined ($session))
|
||||
{
|
||||
die "Croaking: $error";
|
||||
}
|
||||
|
||||
|
||||
if ($ARGV[0] and $ARGV[0] eq "config")
|
||||
{
|
||||
print "host_name $host\n";
|
||||
if (!defined ($response = $session->get_request($sysCPUUsage)))
|
||||
{
|
||||
die "Croaking: " . $session->error();
|
||||
}
|
||||
print "graph_title CPU usage\n";
|
||||
print "graph_category system\n";
|
||||
print "graph_args --base 1000 -r --lower-limit 0 --upper-limit 100\n";
|
||||
print "graph_vlabel %\n";
|
||||
print "graph_scale no\n";
|
||||
print "graph_period second\n";
|
||||
print "graph_info CPU usage\n";
|
||||
print "sysCPUUsage.label CPU Usage\n";
|
||||
print "sysCPU5SecUsage.label CPU 5 sec Avg Usage\n";
|
||||
print "sysCPU1MinUsage.label CPU 1 min Avg Usage\n";
|
||||
print "sysCPU5MinUsage.label CPU 5 min Avg Usage\n";
|
||||
print "sysCPUUsage.draw AREA\n";
|
||||
print "sysCPU5SecUsage.draw AREA\n";
|
||||
print "sysCPU1MinUsage.draw AREA\n";
|
||||
print "sysCPU5MinUsage.draw AREA\n";
|
||||
exit 0;
|
||||
}
|
||||
|
||||
|
||||
if (defined ($response = $session->get_request($sysCPUUsage)))
|
||||
{
|
||||
print "sysCPUUsage.value ", $response->{$sysCPUUsage}, "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
print "sysCPUUsage.value U\n";
|
||||
}
|
||||
|
||||
if (defined ($response = $session->get_request($sysCPU5SecUsage)))
|
||||
{
|
||||
print "sysCPU5SecUsage.value ", $response->{$sysCPU5SecUsage}, "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
print "sysCPU5SecUsage.value U\n";
|
||||
}
|
||||
|
||||
if (defined ($response = $session->get_request($sysCPU1MinUsage)))
|
||||
{
|
||||
print "sysCPU1MinUsage.value ", $response->{$sysCPU1MinUsage}, "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
print "sysCPU1MinUsage.value U\n";
|
||||
}
|
||||
|
||||
if (defined ($response = $session->get_request($sysCPU5MinUsage)))
|
||||
{
|
||||
print "sysCPU5MinUsage.value ", $response->{$sysCPU5MinUsage}, "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
print "sysCPU5MinUsage.value U\n";
|
||||
}
|
||||
|
||||
|
||||
# vim:syntax=perl
|
102
plugins/system/snmp_zyxel_usg__ram
Executable file
102
plugins/system/snmp_zyxel_usg__ram
Executable file
|
@ -0,0 +1,102 @@
|
|||
#!/usr/bin/perl -w
|
||||
#
|
||||
# Copyright (C) 2009 Branislav Bozgai
|
||||
#
|
||||
# Munin plugin to monitor ZyXel USG series routers RAM utilization.
|
||||
# Based on snmp__if_ plugin.
|
||||
#
|
||||
# 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.
|
||||
|
||||
|
||||
#%# family=snmpauto
|
||||
#%# capabilities=snmpconf
|
||||
|
||||
use strict;
|
||||
use Net::SNMP;
|
||||
|
||||
my $DEBUG = 0;
|
||||
|
||||
my $host = $ENV{host} || undef;
|
||||
my $port = $ENV{port} || 161;
|
||||
my $community = $ENV{community} || "public";
|
||||
|
||||
my $response;
|
||||
|
||||
if (defined $ARGV[0] and $ARGV[0] eq "snmpconf")
|
||||
{
|
||||
print "require 1.3.6.1.4.1.890.1.6.22.1.2.0 \n";
|
||||
exit 0;
|
||||
}
|
||||
|
||||
if ($0 =~ /^(?:|.*\/)snmp_zyxel_usg_([^_]+)_ram$/)
|
||||
{
|
||||
$host = $1;
|
||||
if ($host =~ /^([^:]+):(\d+)$/)
|
||||
{
|
||||
$host = $1;
|
||||
$port = $2;
|
||||
}
|
||||
}
|
||||
elsif (!defined($host))
|
||||
{
|
||||
print "# Debug: $0 -- $1\n" if $DEBUG;
|
||||
die "# Error: couldn't understand what I'm supposed to monitor.";
|
||||
}
|
||||
|
||||
my $sysRAMUsage = "1.3.6.1.4.1.890.1.6.22.1.2.0";
|
||||
|
||||
my ($session, $error) = Net::SNMP->session(
|
||||
-hostname => $host,
|
||||
-community => $community,
|
||||
-port => $port
|
||||
);
|
||||
|
||||
|
||||
if (!defined ($session))
|
||||
{
|
||||
die "Croaking: $error";
|
||||
}
|
||||
|
||||
|
||||
if ($ARGV[0] and $ARGV[0] eq "config")
|
||||
{
|
||||
print "host_name $host\n";
|
||||
if (!defined ($response = $session->get_request($sysRAMUsage)))
|
||||
{
|
||||
die "Croaking: " . $session->error();
|
||||
}
|
||||
print "graph_title RAM usage\n";
|
||||
print "graph_category system\n";
|
||||
print "graph_args --base 1000 -r --lower-limit 0 --upper-limit 100\n";
|
||||
print "graph_vlabel %\n";
|
||||
print "graph_scale no\n";
|
||||
print "graph_period second\n";
|
||||
print "graph_info RAM usage\n";
|
||||
print "sysRAMUsage.label RAM Usage\n";
|
||||
print "sysRAMUsage.draw AREA\n";
|
||||
exit 0;
|
||||
}
|
||||
|
||||
|
||||
if (defined ($response = $session->get_request($sysRAMUsage)))
|
||||
{
|
||||
print "sysRAMUsage.value ", $response->{$sysRAMUsage}, "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
print "sysRAMUsage.value U\n";
|
||||
}
|
||||
|
||||
# vim:syntax=perl
|
101
plugins/system/snmp_zyxel_usg__sessions
Executable file
101
plugins/system/snmp_zyxel_usg__sessions
Executable file
|
@ -0,0 +1,101 @@
|
|||
#!/usr/bin/perl -w
|
||||
#
|
||||
# Copyright (C) 2009 Branislav Bozgai
|
||||
#
|
||||
# Munin plugin to monitor ZyXel USG series routers Sessions utilization.
|
||||
# Based on snmp__if_ plugin.
|
||||
#
|
||||
# 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.
|
||||
|
||||
|
||||
#%# family=snmpauto
|
||||
#%# capabilities=snmpconf
|
||||
|
||||
use strict;
|
||||
use Net::SNMP;
|
||||
|
||||
my $DEBUG = 0;
|
||||
|
||||
my $host = $ENV{host} || undef;
|
||||
my $port = $ENV{port} || 161;
|
||||
my $community = $ENV{community} || "public";
|
||||
|
||||
my $response;
|
||||
|
||||
if (defined $ARGV[0] and $ARGV[0] eq "snmpconf")
|
||||
{
|
||||
print "require 1.3.6.1.4.1.890.1.6.22.1.6.0 \n";
|
||||
exit 0;
|
||||
}
|
||||
|
||||
if ($0 =~ /^(?:|.*\/)snmp_zyxel_usg_([^_]+)_sessions$/)
|
||||
{
|
||||
$host = $1;
|
||||
if ($host =~ /^([^:]+):(\d+)$/)
|
||||
{
|
||||
$host = $1;
|
||||
$port = $2;
|
||||
}
|
||||
}
|
||||
elsif (!defined($host))
|
||||
{
|
||||
print "# Debug: $0 -- $1\n" if $DEBUG;
|
||||
die "# Error: couldn't understand what I'm supposed to monitor.";
|
||||
}
|
||||
|
||||
my $sysActiveSessions = "1.3.6.1.4.1.890.1.6.22.1.6.0";
|
||||
|
||||
my ($session, $error) = Net::SNMP->session(
|
||||
-hostname => $host,
|
||||
-community => $community,
|
||||
-port => $port
|
||||
);
|
||||
|
||||
|
||||
if (!defined ($session))
|
||||
{
|
||||
die "Croaking: $error";
|
||||
}
|
||||
|
||||
|
||||
if ($ARGV[0] and $ARGV[0] eq "config")
|
||||
{
|
||||
print "host_name $host\n";
|
||||
if (!defined ($response = $session->get_request($sysActiveSessions)))
|
||||
{
|
||||
die "Croaking: " . $session->error();
|
||||
}
|
||||
print "graph_title Active Sessions\n";
|
||||
print "graph_category system\n";
|
||||
print "graph_args --base 1000 --lower-limit 0\n";
|
||||
print "graph_vlabel Active Sessions\n";
|
||||
print "graph_period second\n";
|
||||
print "graph_info Active Sessions\n";
|
||||
print "sysActiveSessions.label Sessions\n";
|
||||
print "sysActiveSessions.draw AREA\n";
|
||||
exit 0;
|
||||
}
|
||||
|
||||
|
||||
if (defined ($response = $session->get_request($sysActiveSessions)))
|
||||
{
|
||||
print "sysActiveSessions.value ", $response->{$sysActiveSessions}, "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
print "sysActiveSessions.value U\n";
|
||||
}
|
||||
|
||||
# vim:syntax=perl
|
102
plugins/system/snmp_zyxel_zywall__cpu
Executable file
102
plugins/system/snmp_zyxel_zywall__cpu
Executable file
|
@ -0,0 +1,102 @@
|
|||
#!/usr/bin/perl -w
|
||||
#
|
||||
# Copyright (C) 2009 Branislav Bozgai
|
||||
#
|
||||
# Munin plugin to monitor ZyXel ZyWall series routers CPU utilization.
|
||||
# Based on snmp__if_ plugin.
|
||||
#
|
||||
# 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.
|
||||
|
||||
|
||||
#%# family=snmpauto
|
||||
#%# capabilities=snmpconf
|
||||
|
||||
use strict;
|
||||
use Net::SNMP;
|
||||
|
||||
my $DEBUG = 0;
|
||||
|
||||
my $host = $ENV{host} || undef;
|
||||
my $port = $ENV{port} || 161;
|
||||
my $community = $ENV{community} || "public";
|
||||
|
||||
my $response;
|
||||
|
||||
if (defined $ARGV[0] and $ARGV[0] eq "snmpconf")
|
||||
{
|
||||
print "require 1.3.6.1.4.1.890.1.6.1.1.1.0 \n";
|
||||
exit 0;
|
||||
}
|
||||
|
||||
if ($0 =~ /^(?:|.*\/)snmp_zyxel_zywall_([^_]+)_cpu$/)
|
||||
{
|
||||
$host = $1;
|
||||
if ($host =~ /^([^:]+):(\d+)$/)
|
||||
{
|
||||
$host = $1;
|
||||
$port = $2;
|
||||
}
|
||||
}
|
||||
elsif (!defined($host))
|
||||
{
|
||||
print "# Debug: $0 -- $1\n" if $DEBUG;
|
||||
die "# Error: couldn't understand what I'm supposed to monitor.";
|
||||
}
|
||||
|
||||
my $sysCPUUsage = "1.3.6.1.4.1.890.1.6.1.1.1.0";
|
||||
|
||||
my ($session, $error) = Net::SNMP->session(
|
||||
-hostname => $host,
|
||||
-community => $community,
|
||||
-port => $port
|
||||
);
|
||||
|
||||
|
||||
if (!defined ($session))
|
||||
{
|
||||
die "Croaking: $error";
|
||||
}
|
||||
|
||||
|
||||
if ($ARGV[0] and $ARGV[0] eq "config")
|
||||
{
|
||||
print "host_name $host\n";
|
||||
if (!defined ($response = $session->get_request($sysCPUUsage)))
|
||||
{
|
||||
die "Croaking: " . $session->error();
|
||||
}
|
||||
print "graph_title CPU usage\n";
|
||||
print "graph_category system\n";
|
||||
print "graph_args --base 1000 -r --lower-limit 0 --upper-limit 100\n";
|
||||
print "graph_vlabel %\n";
|
||||
print "graph_scale no\n";
|
||||
print "graph_period second\n";
|
||||
print "graph_info CPU usage\n";
|
||||
print "sysCPUUsage.label CPU Usage\n";
|
||||
print "sysCPUUsage.draw AREA\n";
|
||||
exit 0;
|
||||
}
|
||||
|
||||
|
||||
if (defined ($response = $session->get_request($sysCPUUsage)))
|
||||
{
|
||||
print "sysCPUUsage.value ", $response->{$sysCPUUsage}, "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
print "sysCPUUsage.value U\n";
|
||||
}
|
||||
|
||||
# vim:syntax=perl
|
102
plugins/system/snmp_zyxel_zywall__flash
Executable file
102
plugins/system/snmp_zyxel_zywall__flash
Executable file
|
@ -0,0 +1,102 @@
|
|||
#!/usr/bin/perl -w
|
||||
#
|
||||
# Copyright (C) 2009 Branislav Bozgai
|
||||
#
|
||||
# Munin plugin to monitor ZyXel ZyWall series routers Flash memory utilization.
|
||||
# Based on snmp__if_ plugin.
|
||||
#
|
||||
# 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.
|
||||
|
||||
|
||||
#%# family=snmpauto
|
||||
#%# capabilities=snmpconf
|
||||
|
||||
use strict;
|
||||
use Net::SNMP;
|
||||
|
||||
my $DEBUG = 0;
|
||||
|
||||
my $host = $ENV{host} || undef;
|
||||
my $port = $ENV{port} || 161;
|
||||
my $community = $ENV{community} || "public";
|
||||
|
||||
my $response;
|
||||
|
||||
if (defined $ARGV[0] and $ARGV[0] eq "snmpconf")
|
||||
{
|
||||
print "require 1.3.6.1.4.1.890.1.6.1.1.2.0 \n";
|
||||
exit 0;
|
||||
}
|
||||
|
||||
if ($0 =~ /^(?:|.*\/)snmp_zyxel_zywall_([^_]+)_flash$/)
|
||||
{
|
||||
$host = $1;
|
||||
if ($host =~ /^([^:]+):(\d+)$/)
|
||||
{
|
||||
$host = $1;
|
||||
$port = $2;
|
||||
}
|
||||
}
|
||||
elsif (!defined($host))
|
||||
{
|
||||
print "# Debug: $0 -- $1\n" if $DEBUG;
|
||||
die "# Error: couldn't understand what I'm supposed to monitor.";
|
||||
}
|
||||
|
||||
my $sysFLASHUsage = "1.3.6.1.4.1.890.1.6.1.1.2.0";
|
||||
|
||||
my ($session, $error) = Net::SNMP->session(
|
||||
-hostname => $host,
|
||||
-community => $community,
|
||||
-port => $port
|
||||
);
|
||||
|
||||
|
||||
if (!defined ($session))
|
||||
{
|
||||
die "Croaking: $error";
|
||||
}
|
||||
|
||||
|
||||
if ($ARGV[0] and $ARGV[0] eq "config")
|
||||
{
|
||||
print "host_name $host\n";
|
||||
if (!defined ($response = $session->get_request($sysFLASHUsage)))
|
||||
{
|
||||
die "Croaking: " . $session->error();
|
||||
}
|
||||
print "graph_title FLASH usage\n";
|
||||
print "graph_category system\n";
|
||||
print "graph_args --base 1000 -r --lower-limit 0 --upper-limit 100\n";
|
||||
print "graph_vlabel %\n";
|
||||
print "graph_scale no\n";
|
||||
print "graph_period second\n";
|
||||
print "graph_info FLASH usage\n";
|
||||
print "sysFLASHUsage.label FLASH Usage\n";
|
||||
print "sysFLASHUsage.draw AREA\n";
|
||||
exit 0;
|
||||
}
|
||||
|
||||
|
||||
if (defined ($response = $session->get_request($sysFLASHUsage)))
|
||||
{
|
||||
print "sysFLASHUsage.value ", $response->{$sysFLASHUsage}, "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
print "sysFLASHUsage.value U\n";
|
||||
}
|
||||
|
||||
# vim:syntax=perl
|
102
plugins/system/snmp_zyxel_zywall__ram
Executable file
102
plugins/system/snmp_zyxel_zywall__ram
Executable file
|
@ -0,0 +1,102 @@
|
|||
#!/usr/bin/perl -w
|
||||
#
|
||||
# Copyright (C) 2009 Branislav Bozgai
|
||||
#
|
||||
# Munin plugin to monitor ZyXel ZyWall series routers RAM utilization.
|
||||
# Based on snmp__if_ plugin.
|
||||
#
|
||||
# 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.
|
||||
|
||||
|
||||
#%# family=snmpauto
|
||||
#%# capabilities=snmpconf
|
||||
|
||||
use strict;
|
||||
use Net::SNMP;
|
||||
|
||||
my $DEBUG = 0;
|
||||
|
||||
my $host = $ENV{host} || undef;
|
||||
my $port = $ENV{port} || 161;
|
||||
my $community = $ENV{community} || "public";
|
||||
|
||||
my $response;
|
||||
|
||||
if (defined $ARGV[0] and $ARGV[0] eq "snmpconf")
|
||||
{
|
||||
print "require 1.3.6.1.4.1.890.1.6.1.1.3.0 \n";
|
||||
exit 0;
|
||||
}
|
||||
|
||||
if ($0 =~ /^(?:|.*\/)snmp_zyxel_zywall_([^_]+)_ram$/)
|
||||
{
|
||||
$host = $1;
|
||||
if ($host =~ /^([^:]+):(\d+)$/)
|
||||
{
|
||||
$host = $1;
|
||||
$port = $2;
|
||||
}
|
||||
}
|
||||
elsif (!defined($host))
|
||||
{
|
||||
print "# Debug: $0 -- $1\n" if $DEBUG;
|
||||
die "# Error: couldn't understand what I'm supposed to monitor.";
|
||||
}
|
||||
|
||||
my $sysRAMUsage = "1.3.6.1.4.1.890.1.6.1.1.3.0";
|
||||
|
||||
my ($session, $error) = Net::SNMP->session(
|
||||
-hostname => $host,
|
||||
-community => $community,
|
||||
-port => $port
|
||||
);
|
||||
|
||||
|
||||
if (!defined ($session))
|
||||
{
|
||||
die "Croaking: $error";
|
||||
}
|
||||
|
||||
|
||||
if ($ARGV[0] and $ARGV[0] eq "config")
|
||||
{
|
||||
print "host_name $host\n";
|
||||
if (!defined ($response = $session->get_request($sysRAMUsage)))
|
||||
{
|
||||
die "Croaking: " . $session->error();
|
||||
}
|
||||
print "graph_title RAM usage\n";
|
||||
print "graph_category system\n";
|
||||
print "graph_args --base 1000 -r --lower-limit 0 --upper-limit 100\n";
|
||||
print "graph_vlabel %\n";
|
||||
print "graph_scale no\n";
|
||||
print "graph_period second\n";
|
||||
print "graph_info RAM usage\n";
|
||||
print "sysRAMUsage.label RAM Usage\n";
|
||||
print "sysRAMUsage.draw AREA\n";
|
||||
exit 0;
|
||||
}
|
||||
|
||||
|
||||
if (defined ($response = $session->get_request($sysRAMUsage)))
|
||||
{
|
||||
print "sysRAMUsage.value ", $response->{$sysRAMUsage}, "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
print "sysRAMUsage.value U\n";
|
||||
}
|
||||
|
||||
# vim:syntax=perl
|
101
plugins/system/snmp_zyxel_zywall__sessions
Executable file
101
plugins/system/snmp_zyxel_zywall__sessions
Executable file
|
@ -0,0 +1,101 @@
|
|||
#!/usr/bin/perl -w
|
||||
#
|
||||
# Copyright (C) 2009 Branislav Bozgai
|
||||
#
|
||||
# Munin plugin to monitor ZyXel ZyWall series routers Sessions utilization.
|
||||
# Based on snmp__if_ plugin.
|
||||
#
|
||||
# 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.
|
||||
|
||||
|
||||
#%# family=snmpauto
|
||||
#%# capabilities=snmpconf
|
||||
|
||||
use strict;
|
||||
use Net::SNMP;
|
||||
|
||||
my $DEBUG = 0;
|
||||
|
||||
my $host = $ENV{host} || undef;
|
||||
my $port = $ENV{port} || 161;
|
||||
my $community = $ENV{community} || "public";
|
||||
|
||||
my $response;
|
||||
|
||||
if (defined $ARGV[0] and $ARGV[0] eq "snmpconf")
|
||||
{
|
||||
print "require 1.3.6.1.4.1.890.1.6.1.1.4.0\n";
|
||||
exit 0;
|
||||
}
|
||||
|
||||
if ($0 =~ /^(?:|.*\/)snmp_zyxel_zywall_([^_]+)_sessions$/)
|
||||
{
|
||||
$host = $1;
|
||||
if ($host =~ /^([^:]+):(\d+)$/)
|
||||
{
|
||||
$host = $1;
|
||||
$port = $2;
|
||||
}
|
||||
}
|
||||
elsif (!defined($host))
|
||||
{
|
||||
print "# Debug: $0 -- $1\n" if $DEBUG;
|
||||
die "# Error: couldn't understand what I'm supposed to monitor.";
|
||||
}
|
||||
|
||||
my $sysActiveSessions = "1.3.6.1.4.1.890.1.6.1.1.4.0";
|
||||
|
||||
my ($session, $error) = Net::SNMP->session(
|
||||
-hostname => $host,
|
||||
-community => $community,
|
||||
-port => $port
|
||||
);
|
||||
|
||||
|
||||
if (!defined ($session))
|
||||
{
|
||||
die "Croaking: $error";
|
||||
}
|
||||
|
||||
|
||||
if ($ARGV[0] and $ARGV[0] eq "config")
|
||||
{
|
||||
print "host_name $host\n";
|
||||
if (!defined ($response = $session->get_request($sysActiveSessions)))
|
||||
{
|
||||
die "Croaking: " . $session->error();
|
||||
}
|
||||
print "graph_title Active Sessions\n";
|
||||
print "graph_category system\n";
|
||||
print "graph_args --base 1000 --lower-limit 0\n";
|
||||
print "graph_vlabel Active Sessions\n";
|
||||
print "graph_period second\n";
|
||||
print "graph_info Active Sessions\n";
|
||||
print "sysActiveSessions.label Sessions\n";
|
||||
print "sysActiveSessions.draw AREA\n";
|
||||
exit 0;
|
||||
}
|
||||
|
||||
|
||||
if (defined ($response = $session->get_request($sysActiveSessions)))
|
||||
{
|
||||
print "sysActiveSessions.value ", $response->{$sysActiveSessions}, "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
print "sysActiveSessions.value U\n";
|
||||
}
|
||||
|
||||
# vim:syntax=perl
|
118
plugins/system/solaris-memstat
Executable file
118
plugins/system/solaris-memstat
Executable file
|
@ -0,0 +1,118 @@
|
|||
#! /bin/ksh
|
||||
# Copyright (c) 2010, Wikimedia Deutschland
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# * Neither the name of Wikimedia Deutschland nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY WIKIMEDIA DEUTSCHLAND ''AS IS'' AND ANY
|
||||
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL WIKIMEDIA DEUTSCHLAND BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
# NOTE: This software is not released as a product. It was written primarily for
|
||||
# Wikimedia Deutschland's own use, and is made public as is, in the hope it may
|
||||
# be useful. Wikimedia Deutschland may at any time discontinue developing or
|
||||
# supporting this software. There is no guarantee any new versions or even fixes
|
||||
# for security issues will be released.
|
||||
###
|
||||
# Munin plugin to report Solaris memory usage via mdb's memstat.
|
||||
# Must be run as root.
|
||||
#
|
||||
# river@tamara.tcx.org.uk 2010-08-28
|
||||
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf
|
||||
|
||||
if [ "$1" = "autoconf" ]; then
|
||||
if [ -e /usr/bin/mdb ]; then
|
||||
echo yes
|
||||
exit 0
|
||||
else
|
||||
echo /usr/bin/mdb not found
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
echo '
|
||||
graph_args --base 1024 -l 0 --vertical-label Bytes
|
||||
graph_title Memory usage
|
||||
graph_category system
|
||||
graph_info This graph shows system memory use.
|
||||
graph_order kernel anon exec cacheused zfs cachefree free
|
||||
|
||||
kernel.label kernel
|
||||
kernel.draw AREA
|
||||
kernel.info Memory used by kernel
|
||||
|
||||
anon.label anon
|
||||
anon.draw STACK
|
||||
anon.info Memory used by programs
|
||||
|
||||
exec.label exec_and_libs
|
||||
exec.draw STACK
|
||||
exec.info Memory used by executable files and libraries
|
||||
|
||||
cacheused.label cacheused
|
||||
cacheused.draw STACK
|
||||
cacheused.info Memory used by page cache
|
||||
|
||||
zfs.label zfs
|
||||
zfs.draw STACK
|
||||
zfs.info Memory used for ZFS file cache
|
||||
|
||||
cachefree.label cachefree
|
||||
cachefree.draw STACK
|
||||
cachefree.info Free memory in cache list
|
||||
|
||||
free.label free
|
||||
free.draw STACK
|
||||
free.info Free memory
|
||||
'
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "::memstat" | mdb -k | nawk '
|
||||
BEGIN {
|
||||
pagesize='$(getconf PAGESIZE)'
|
||||
kernel=0
|
||||
zfs=0
|
||||
anon=0
|
||||
exec=0
|
||||
cache=0
|
||||
phys=0
|
||||
}
|
||||
|
||||
/^Kernel/ { kernel=$2 }
|
||||
/^ZFS File Data/ { zfs=$4 }
|
||||
/^Anon/ { anon=$2 }
|
||||
/^Exec and libs/ { exec=$4 }
|
||||
/^Page cache/ { cacheused=$3 }
|
||||
/^Free \(cachelist\)/ { cachefree=$3 }
|
||||
/^Free \(freelist\)/ { free=$3 }
|
||||
|
||||
END {
|
||||
print "kernel.value " (kernel * pagesize)
|
||||
print "zfs.value " (zfs * pagesize)
|
||||
print "anon.value " (anon * pagesize)
|
||||
print "exec.value " (exec * pagesize)
|
||||
print "cacheused.value " (cacheused * pagesize)
|
||||
print "cachefree.value " (cachefree * pagesize)
|
||||
print "free.value " (free * pagesize)
|
||||
}
|
||||
'
|
86
plugins/system/sshd_invalid_countries
Executable file
86
plugins/system/sshd_invalid_countries
Executable file
|
@ -0,0 +1,86 @@
|
|||
#!/usr/bin/php
|
||||
<?php
|
||||
# Plugin to monitor the number of invalid access to sshd per country
|
||||
#
|
||||
# Require read permitions for SYSLOG
|
||||
# ref) ls -l /var/log/secure
|
||||
# Require PEAR library Net_GeoIP
|
||||
# ref) http://pear.php.net/package/Net_GeoIP/redirected
|
||||
# Require GeoIP-database to find out the geolocation from ip or host
|
||||
# ref) http://www.maxmind.com/app/geoip_country
|
||||
#
|
||||
# Parameters:
|
||||
# config (required)
|
||||
# autoconf (optional - used by munin-config)
|
||||
#
|
||||
# $Log$
|
||||
# Revision 1.0 2010/12/23 23:55:01 hirata yoshiyuki
|
||||
# released.
|
||||
#
|
||||
# Magick markers (optional):
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf
|
||||
#
|
||||
# config example for /etc/munin/plugin-conf.d/munin-node
|
||||
#[sshd_invalid_countries]
|
||||
#user root
|
||||
#group root
|
||||
#env.logfile /var/log/secure
|
||||
#env.geoip /home/you/GeoIP.dat
|
||||
#env.peardir /usr/share/pear/
|
||||
|
||||
require (isset($_SERVER['peardir']) && $_SERVER['peardir'] != '' ? $_SERVER['peardir'] : '') . 'Net/GeoIP.php';
|
||||
|
||||
define('SYSLOG', isset($_SERVER['syslog']) && $_SERVER['syslog'] != '' ? $_SERVER['syslog'] : '/var/log/secure');
|
||||
define('GEOIP_DB', isset($_SERVER['geoip']) && $_SERVER['geoip'] != '' ? $_SERVER['geoip'] : 'GeoIP.dat');
|
||||
define('AWK_CMD', 'awk \'/sshd\[.*Did not receive identification string/{print $12} ' .
|
||||
'/sshd\[.*Failed password for (root|ROOT)/{print $11} ' .
|
||||
'/sshd\[.*Invalid user/{print $10}a\' < ' . SYSLOG);
|
||||
|
||||
if (isset($argv[1]) && $argv[1] == 'autoconf') {
|
||||
$fh = @fopen(SYSLOG, 'r');
|
||||
if ($fh) {
|
||||
echo "yes\n";
|
||||
fclose($fh);
|
||||
exit(0);
|
||||
} else {
|
||||
echo "no\n";
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
if (isset($argv[1]) && $argv[1] == 'config') {
|
||||
echo 'graph_title SSHD invalid countries from ' . SYSLOG . "\n";
|
||||
echo 'graph_args --base 1000 -l 0' . "\n";
|
||||
echo 'graph_vlabel number of invalid access per country' . "\n";
|
||||
echo 'graph_category system' . "\n";
|
||||
echo 'graph_info This graph shows the countries of invalid access to sshd.' . "\n";
|
||||
foreach (get_sshd_invalid_countries() as $country => $cnt) {
|
||||
echo $country . '.label ' . $country . "\n";
|
||||
}
|
||||
exit(0);
|
||||
}
|
||||
|
||||
foreach (get_sshd_invalid_countries() as $country => $cnt) {
|
||||
echo $country . '.value ' . $cnt . "\n";
|
||||
}
|
||||
|
||||
function get_sshd_invalid_countries() {
|
||||
$countries = array();
|
||||
exec(AWK_CMD, $wholeips, $ret);
|
||||
|
||||
if ($ret != 0) return $countries;
|
||||
|
||||
$uniqueips = array_count_values($wholeips);
|
||||
$GeoIP = Net_GeoIP::getInstance(GEOIP_DB);
|
||||
foreach ($uniqueips as $ip => $cnt) {
|
||||
try {
|
||||
$country = $GeoIP->lookupCountryName($ip);
|
||||
$countries[$country] = isset($countries[$country]) ? $countries[$country] + $cnt : $cnt;
|
||||
} catch (Exception $e) {
|
||||
$countries['Unknown'] = isset($countries['Unknown']) ? $countries['Unknown'] + $cnt : $cnt;
|
||||
}
|
||||
}
|
||||
ksort($countries);
|
||||
|
||||
return $countries;
|
||||
}
|
80
plugins/system/sshd_invalid_countries_ruby
Executable file
80
plugins/system/sshd_invalid_countries_ruby
Executable file
|
@ -0,0 +1,80 @@
|
|||
#!/usr/local/bin/ruby
|
||||
# Plugin to monitor the number of invalid access to sshd per country
|
||||
#
|
||||
# Require read permitions for SYSLOG
|
||||
# ref) ls -l /var/log/secure
|
||||
# Require geoip rubygem
|
||||
# ref) http://geoip.rubyforge.org/
|
||||
# Require GeoIP-database for searching ip or host for the country
|
||||
# ref) http://www.maxmind.com/app/geoip_country
|
||||
#
|
||||
# Parameters:
|
||||
# config (required)
|
||||
# autoconf (optional - used by munin-config)
|
||||
#
|
||||
# $Log$
|
||||
# Revision 1.0 2010/12/25 11:56:12 hirata yoshiyuki
|
||||
# released.
|
||||
#
|
||||
# Magick markers (optional):
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf
|
||||
#
|
||||
# config example for /etc/munin/plugin-conf.d/munin-node
|
||||
#[sshd_invalid_countries_ruby]
|
||||
#user root
|
||||
#group root
|
||||
#env.logfile /var/log/secure
|
||||
#env.geoip /home/you/GeoIP.dat
|
||||
#env.loadpath /usr/local/lib/ruby/gems/1.9.1/gems/geoip-0.8.8/lib/
|
||||
|
||||
require (ENV['loadpath'] || '') + 'geoip'
|
||||
|
||||
SYSLOG = ENV['syslog'] || '/var/log/secure'
|
||||
GEOIP_DB = ENV['geoip'] || '/var/www/conf/bbs/GeoIP.dat'
|
||||
AWK_CMD = 'awk \'/sshd\[.*Did not receive identification string/{print $12} ' +
|
||||
'/sshd\[.*Failed password for (root|ROOT)/{print $11} ' +
|
||||
'/sshd\[.*Invalid user/{print $10}a\' < ' + SYSLOG
|
||||
|
||||
def getInvalids
|
||||
c={}
|
||||
wholeips = `#{AWK_CMD}`.split("\n")
|
||||
uniqueips = wholeips.inject({}) do |hash, key|
|
||||
hash.include?(key) ? hash[key] += 1 : hash[key] = 1;
|
||||
hash
|
||||
end
|
||||
geoip = GeoIP.new(GEOIP_DB)
|
||||
uniqueips.each do |ip,cnt|
|
||||
begin
|
||||
country = geoip.country(ip)[5]
|
||||
c[country] = c[country] ? c[country] + cnt : cnt
|
||||
rescue
|
||||
c['Unknown'] = c['Unknown'] ? c['Unknown'] + cnt : cnt
|
||||
end
|
||||
end
|
||||
c = c.to_a.sort {|a,b| a[0] <=> b[0]}
|
||||
c
|
||||
end
|
||||
|
||||
case ARGV[0]
|
||||
when 'autoconf'
|
||||
begin
|
||||
fh = open(SYSLOG, 'r')
|
||||
rescue
|
||||
puts 'no'
|
||||
exit 1
|
||||
else
|
||||
puts 'yes'
|
||||
exit 0
|
||||
end
|
||||
when 'config'
|
||||
puts 'graph_title SSHD invalid countries from ' + SYSLOG
|
||||
puts 'graph_args --base 1000 -l 0'
|
||||
puts 'graph_vlabel number of invalid access per country'
|
||||
puts 'graph_category system'
|
||||
puts 'graph_info This graph shows the countries of invalid access to sshd.'
|
||||
getInvalids.each {|k,v| puts k + '.label ' + k}
|
||||
exit 0
|
||||
else
|
||||
getInvalids.each {|k,v| puts k + '.value ' + v.to_s}
|
||||
end
|
164
plugins/system/swapspace-info
Executable file
164
plugins/system/swapspace-info
Executable file
|
@ -0,0 +1,164 @@
|
|||
#!/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;
|
||||
use 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";
|
||||
}
|
64
plugins/system/systat
Executable file
64
plugins/system/systat
Executable file
|
@ -0,0 +1,64 @@
|
|||
#!/bin/sh
|
||||
# System statistics for FreeBSD
|
||||
# Author: Gergely Czuczy <phoemix@harmless.hu>
|
||||
#
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf
|
||||
|
||||
sysctl='/sbin/sysctl'
|
||||
|
||||
case $1 in
|
||||
config)
|
||||
cat <<EOF
|
||||
graph_title System Statistics
|
||||
graph_vlabel per second
|
||||
graph_scale no
|
||||
graph_category system
|
||||
graph_args -l 0
|
||||
graph_info FreeBSD systat plugin
|
||||
softint.label Software interrupts
|
||||
softint.type DERIVE
|
||||
softint.min 0
|
||||
hardint.label Hardware interrupts
|
||||
hardint.type DERIVE
|
||||
hardint.min 0
|
||||
syscall.label System calls
|
||||
syscall.type DERIVE
|
||||
syscall.min 0
|
||||
cs.label Context switches
|
||||
cs.type DERIVE
|
||||
cs.min 0
|
||||
forks.label Fork rate
|
||||
forks.type DERIVE
|
||||
forks.min 0
|
||||
EOF
|
||||
exit 0
|
||||
;;
|
||||
autoconf)
|
||||
if [ ! -x ${sysctl} ]; then
|
||||
echo "no (${sysctl} is not executable)"
|
||||
exit 1
|
||||
fi
|
||||
ostype=`uname -s`
|
||||
if [ ${ostype} = "FreeBSD" ]; then
|
||||
echo "yes"
|
||||
exit 0
|
||||
fi
|
||||
echo "no (You're OS is not supported by this plugin)"
|
||||
exit 1
|
||||
;;
|
||||
suggest)
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
|
||||
${sysctl} vm.stats.sys.v_soft vm.stats.sys.v_intr vm.stats.sys.v_syscall vm.stats.sys.v_trap vm.stats.sys.v_swtch \
|
||||
vm.stats.vm.v_forks vm.stats.vm.v_rforks vm.stats.vm.v_vforks| awk '
|
||||
BEGIN {forks=0;}
|
||||
/^vm.stats.sys.v_soft/{print "softint.value",$2}
|
||||
/^vm.stats.sys.v_intr/{print "hardint.value",$2}
|
||||
/^vm.stats.sys.v_syscall/{print "syscall.value",$2}
|
||||
/^vm.stats.sys.v_swtch/{print "cs.value",$2}
|
||||
/^vm.stats.vm.v_[rv]?forks/ {forks+=$2}
|
||||
END {print "forks.value",forks;}
|
||||
'
|
50
plugins/system/system_users
Executable file
50
plugins/system/system_users
Executable file
|
@ -0,0 +1,50 @@
|
|||
#!/bin/sh
|
||||
# Plugin to get the number of logged in users
|
||||
# Written by Henrik Andersén 2010 <code@henrikandersen.se>
|
||||
#
|
||||
# Copyright (c) 2010, Henrik Andersen
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# * Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL Henrik Andersen BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
case $1 in
|
||||
config)
|
||||
cat <<'EOM'
|
||||
graph_args --base 1000 -l 0
|
||||
graph_scale no
|
||||
graph_category system
|
||||
graph_info The number of users currently logged into the system
|
||||
graph_title Logged in users
|
||||
graph_vlabel users
|
||||
user.info Number of users currently logged in
|
||||
user.label users
|
||||
user.min 0
|
||||
EOM
|
||||
exit 0;;
|
||||
esac
|
||||
|
||||
count=$(/usr/bin/who -q )
|
||||
printf "user.value %i\n" ${count#*=}
|
||||
|
||||
exit 0
|
35
plugins/system/top-free-memory
Executable file
35
plugins/system/top-free-memory
Executable file
|
@ -0,0 +1,35 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Initial Version 1.0 2009/05/18 14:00:01 BANT
|
||||
# Anzeige von FREE Memory mit dem TOP Befehl aus SUN OS
|
||||
#
|
||||
#%# family=manual
|
||||
|
||||
|
||||
TOP=/usr/local/bin/top
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
|
||||
echo "graph_title FREE Memory usage (in MB)"
|
||||
echo 'graph_category system'
|
||||
echo "free.label Free memory"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Linjen som grep'es ut kan se ut som dette:
|
||||
#
|
||||
# Memory: 16G phys mem, 6030M free mem, 32G swap, 32G free swap
|
||||
|
||||
$TOP -n -u | nawk '
|
||||
function scale(value) {
|
||||
if (value ~ /G$/) { sub("G", "", value); value *= 1024 }
|
||||
else if (value ~ /M$/) sub("M", "", value)
|
||||
else if (value ~ /K$/) { sub("K", "", value); value /= 1024 }
|
||||
else value /= 1024 * 1024;
|
||||
return value;
|
||||
}
|
||||
/^Memory/ {
|
||||
free = scale($5);
|
||||
|
||||
print "free.value", free
|
||||
}'
|
66
plugins/system/top-memory
Executable file
66
plugins/system/top-memory
Executable file
|
@ -0,0 +1,66 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# $Log$
|
||||
# Revision 1.4.2.1 2005/03/07 19:06:13 jimmyo
|
||||
# sunos/memory repaired (SF#1143610).
|
||||
#
|
||||
# Revision 1.4 2004/05/20 19:02:38 jimmyo
|
||||
# Set categories on a bunch of plugins
|
||||
#
|
||||
# Revision 1.3 2004/05/15 21:33:30 jimmyo
|
||||
# "Upped" som plugins from contrib/manual to manual or auto.
|
||||
#
|
||||
# Revision 1.2 2004/05/09 20:42:08 jimmyo
|
||||
# Fixed problem with sunos/memory, when memory was reported in gigabytes (SF#930964).
|
||||
#
|
||||
# Revision 1.1 2004/01/02 18:50:01 jimmyo
|
||||
# Renamed occurrances 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.2 2003/11/07 17:43:16 jimmyo
|
||||
# Cleanups and log entries
|
||||
#
|
||||
# Revision 1.3 2009/05/18 14:00:01 BANT
|
||||
# Update for Free Memory
|
||||
#
|
||||
#%# family=manual
|
||||
|
||||
|
||||
TOP=/usr/local/bin/top
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
|
||||
echo "graph_title Memory usage (in MB)"
|
||||
echo 'graph_category system'
|
||||
echo "real.label Physical memory"
|
||||
echo "free.label Free memory"
|
||||
echo "swap.label Swap in use"
|
||||
echo "swapf.label Swap free"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Linjen som grep'es ut kan se ut som dette:
|
||||
#
|
||||
# Memory: 16G phys mem, 6030M free mem, 32G swap, 32G free swap
|
||||
|
||||
$TOP -n -u | nawk '
|
||||
function scale(value) {
|
||||
if (value ~ /G$/) { sub("G", "", value); value *= 1024 }
|
||||
else if (value ~ /M$/) sub("M", "", value)
|
||||
else if (value ~ /K$/) { sub("K", "", value); value /= 1024 }
|
||||
else value /= 1024 * 1024;
|
||||
return value;
|
||||
}
|
||||
/^Memory/ {
|
||||
real = scale($2);
|
||||
free = scale($5);
|
||||
swap = scale($8);
|
||||
swapf = scale($10);
|
||||
|
||||
print "real.value", real
|
||||
print "free.value", free
|
||||
print "swap.value", swap
|
||||
print "swapf.value", swapf
|
||||
}'
|
50
plugins/system/uptime
Executable file
50
plugins/system/uptime
Executable file
|
@ -0,0 +1,50 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Plugin to get system uptime and kernel age
|
||||
#
|
||||
# Magic markers - optional - used by installation scripts and
|
||||
# munin-config:
|
||||
#
|
||||
#%# family=manual
|
||||
#%# capabilities=autoconf
|
||||
|
||||
if [ "$1" = "autoconf" ]; then
|
||||
echo "yes"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
|
||||
cat <<EOT
|
||||
graph_title Uptime
|
||||
graph_args --base 1000 -l 0
|
||||
graph_vlabel days
|
||||
graph_category System
|
||||
compile.label kernel age
|
||||
compile.type GAUGE
|
||||
compile.min 0
|
||||
compile.max 1000
|
||||
compile.draw AREA
|
||||
uptime.label uptime
|
||||
uptime.type GAUGE
|
||||
uptime.min 0
|
||||
uptime.max 1000
|
||||
uptime.draw AREA
|
||||
EOT
|
||||
exit 0
|
||||
fi
|
||||
|
||||
LANG=C
|
||||
(
|
||||
/bin/date -j +'%s'
|
||||
/bin/date -jf '%a %b %d %T %Z %Y' \
|
||||
"`/sbin/sysctl kern.version | /usr/bin/sed -Ee '2,9d;s/^kern.version: [^:]+: //'`" +'%s'
|
||||
/sbin/sysctl kern.boottime | /usr/bin/sed -Ee 's/.* sec = ([0-9+].*)\,.*/\1/'
|
||||
) | /usr/bin/awk '
|
||||
BEGIN {
|
||||
getline; now=$0;
|
||||
getline; compile=$0
|
||||
getline; boot=$0;
|
||||
printf "compile.value %.3f\n", (now-compile)/86400
|
||||
printf "uptime.value %.3f\n", (now-boot)/86400
|
||||
}'
|
58
plugins/system/uptime_bsd
Executable file
58
plugins/system/uptime_bsd
Executable file
|
@ -0,0 +1,58 @@
|
|||
#!/usr/local/bin/perl -w
|
||||
# -*- perl -*-
|
||||
# Plugin to monitor number of irqs
|
||||
#
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf
|
||||
|
||||
use strict;
|
||||
|
||||
my %IN;
|
||||
|
||||
my $sysctl = defined($ENV{sysctl}) ? $ENV{sysctl} : '/sbin/sysctl';
|
||||
|
||||
if (defined($ARGV[0]) and ($ARGV[0] eq 'autoconf')) {
|
||||
if ( -x $sysctl ) {
|
||||
print "yes\n";
|
||||
}else{
|
||||
print "no (sysctl binary not found)\n";
|
||||
};
|
||||
exit;
|
||||
};
|
||||
|
||||
if (defined($ARGV[0]) and ($ARGV[0] eq 'config')) {
|
||||
print <<EOT ;
|
||||
graph_title Uptime
|
||||
graph_args --base 1000 -l 0
|
||||
graph_vlabel days
|
||||
graph_category system
|
||||
compile.label kernel age
|
||||
compile.type GAUGE
|
||||
compile.min 0
|
||||
compile.max 1000
|
||||
compile.draw AREA
|
||||
uptime.label uptime
|
||||
uptime.type GAUGE
|
||||
uptime.min 0
|
||||
uptime.max 1000
|
||||
uptime.draw AREA
|
||||
EOT
|
||||
exit;
|
||||
}
|
||||
|
||||
use Date::Parse;
|
||||
|
||||
my $kern=`sysctl -n kern.version`;
|
||||
$kern=~ /:\s+(.*\S)\s+\w+\@/;
|
||||
print "Compile: $1\n";
|
||||
$kern=str2time($1);
|
||||
|
||||
my $boot=`sysctl -n kern.boottime`;
|
||||
$boot=~ / sec = (\d+)/;
|
||||
print "Boot: $1\n";
|
||||
$boot=$1;
|
||||
|
||||
my $now=time;
|
||||
|
||||
print "compile.value ",($now-$kern)/60/60/24,"\n";
|
||||
print "uptime.value ",($now-$boot)/60/60/24,"\n";
|
30
plugins/system/users
Executable file
30
plugins/system/users
Executable file
|
@ -0,0 +1,30 @@
|
|||
#!/bin/sh
|
||||
|
||||
#Plugin created by:
|
||||
# Stephen Hodgson
|
||||
# Malone College - CPSC
|
||||
|
||||
#This script is provided as-is with no warranty or guarantee of any kind.
|
||||
|
||||
#-This simple plugin figures out how many users are logged into the linux box and writes it to a simple Gauge-style graph.
|
||||
#-The plugin takes advantage of the linux 'who' command.
|
||||
# -The who command is cut into the first field (to the first space).
|
||||
# -This is the username field.
|
||||
# -Unfortunately this will log multiples for the same user if multiple terminals are open.
|
||||
# -Then we need to sort the results since uniq only deals with unique elements next in line to each other.
|
||||
# -We find the uniqe usernames logged on.
|
||||
# -Then wc -l counts how many lines (users) we're left with.
|
||||
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
echo 'graph_title Users Online'
|
||||
echo 'graph_args --base 1000 -l 0 '
|
||||
echo 'graph_vlabel Number of users'
|
||||
echo 'graph_category system'
|
||||
echo 'users.label users'
|
||||
echo 'graph_args --base 1000 -l 0'
|
||||
echo 'graph_scale no'
|
||||
exit 0
|
||||
fi
|
||||
echo -n "users.value "
|
||||
echo `who | cut -f -1 -d ' ' | sort | uniq | wc -l`
|
61
plugins/system/usersv2
Executable file
61
plugins/system/usersv2
Executable file
|
@ -0,0 +1,61 @@
|
|||
#!/usr/bin/perl -w
|
||||
|
||||
#Plugin created by:
|
||||
# Stephen Hodgson
|
||||
# Malone College - CPSC
|
||||
# ported to perl and extended by Thomas Gutzler, 2008 (thomas.gutzler@gmail.com)
|
||||
|
||||
# Feel free to modify this plugin, but if you do, be kind and email it back to me. I'm all for improvements that anyone can make.
|
||||
|
||||
# - This simple plugin figures out how many users are logged into the linux box
|
||||
# - The plugin takes advantage of the linux 'who' command.
|
||||
# - The who command is used to list all login names and number of users logged on.
|
||||
# - This information is used to output to values:
|
||||
# 1. total amount of users logged in
|
||||
# 2. amount of unique users logged in
|
||||
|
||||
# Even though this plugin should run without configuration, it is possible to tell it the location of the who command
|
||||
# Configuration example
|
||||
# [usersv2]
|
||||
# env.who_cmd /usr/bin/who
|
||||
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf
|
||||
|
||||
use strict;
|
||||
|
||||
my $who_cmd = exists $ENV{who_cmd} ? $ENV{who_cmd} : 'who';
|
||||
|
||||
if ((exists $ARGV[0]) && ($ARGV[0] eq "autoconf")) {
|
||||
my @who = ("$who_cmd -q >/dev/null 2>&1");
|
||||
my $ret = system(@who);
|
||||
if ($ret == 0) {
|
||||
print "yes\n";
|
||||
exit 0;
|
||||
} else {
|
||||
print "no\n";
|
||||
exit 1;
|
||||
}
|
||||
}
|
||||
|
||||
if ((exists $ARGV[0]) && ($ARGV[0] eq "config")) {
|
||||
print "graph_title Users Online\n";
|
||||
print "graph_args --base 1000 -l 0\n";
|
||||
print "graph_scale no\n";
|
||||
print "graph_vlabel Number of users\n";
|
||||
print "graph_category system\n";
|
||||
print "graph_info This graph shows the amount of (unique) users logged in\n";
|
||||
print "users.label total users\n";
|
||||
print "users.info something like who | wc -l\n";
|
||||
print "uusers.label unique users\n";
|
||||
print "uusers.info something like who | cut -f -1 -d ' ' | sort | uniq | wc -l\n";
|
||||
exit 0;
|
||||
}
|
||||
|
||||
my @who = split(/\s+/, `$who_cmd -q | head -1`);
|
||||
print "users.value ".scalar(@who)."\n";
|
||||
|
||||
my %who;
|
||||
$who{$_} = 1 foreach (@who);
|
||||
print "uusers.value ".scalar(keys %who)."\n";
|
||||
|
64
plugins/system/vpsmem
Executable file
64
plugins/system/vpsmem
Executable file
|
@ -0,0 +1,64 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Monitors memory usage in openVZ or Virtuozzo
|
||||
# based on http://www.huschi.net/archiv/speicher-anzeigen-mit-vzfree.html
|
||||
# Author: Michael Richter, http://osor.de/
|
||||
# Cleaned up and translated to english by: Marian Sigler <m@qjym.de>, 2010-08-13
|
||||
#
|
||||
#%# capabilities=autoconf
|
||||
|
||||
BEANCOUNTERS=/proc/user_beancounters
|
||||
|
||||
if [ "$1" == "autoconf" ]; then
|
||||
if [ -e $BEANCOUNTERS ]; then
|
||||
echo yes
|
||||
exit 0
|
||||
else
|
||||
echo no
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! -r $BEANCOUNTERS ]; then
|
||||
echo "$BEANCOUNTERS not readable" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$1" == "config" ]; then
|
||||
limit=$(awk '/privvmpages/ {print $5*4096}' $BEANCOUNTERS)
|
||||
cut -c9- <<EOF
|
||||
graph_args --base 1024 -l 0 --vertical-label bytes --upper-limit $limit
|
||||
graph_title VPS memory usage
|
||||
graph_category system
|
||||
graph_info Shows memory usage and VPS memory limits.
|
||||
graph_order maxheld held oomguar barrier limit
|
||||
|
||||
held.label held
|
||||
held.draw AREA
|
||||
held.info currently held memory
|
||||
maxheld.label maxheld
|
||||
maxheld.draw AREA
|
||||
maxheld.info maximum held memory
|
||||
oomguar.label guaranteed
|
||||
oomguar.draw LINE2
|
||||
oomguar.info memory guaranteed for OOM
|
||||
barrier.label barrier
|
||||
barrier.draw LINE2
|
||||
barrier.info memory usage barrier
|
||||
limit.label limit
|
||||
limit.draw LINE2
|
||||
limit.info memory usage limit
|
||||
EOF
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ -n "$1" ]; then
|
||||
echo "Invalid argument: $1" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
awk '/privvmpages/ {print "held.value", $2*4096 "\nmaxheld.value", $3*4096 "\nbarrier.value", $4*4096 "\nlimit.value", $5*4096}' $BEANCOUNTERS
|
||||
awk '/oomguarpages/ { print "oomguar.value", $4*4096 }' $BEANCOUNTERS
|
59
plugins/system/zones_cpu
Executable file
59
plugins/system/zones_cpu
Executable file
|
@ -0,0 +1,59 @@
|
|||
#!/bin/sh
|
||||
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf
|
||||
|
||||
PRSTAT=/usr/bin/prstat
|
||||
PRSTAT_OPTS="-Z 1 1"
|
||||
|
||||
if [ "$1" = 'autoconf' ]; then
|
||||
if [ -f $PRSTAT ]; then
|
||||
zones=`/usr/sbin/zoneadm list | wc -l`
|
||||
if [ $zones -gt 1 ]; then
|
||||
echo yes
|
||||
else
|
||||
echo yes
|
||||
fi
|
||||
exit 0
|
||||
else
|
||||
echo no
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$1" = 'config' ]; then
|
||||
echo 'graph_title zone cpu usage'
|
||||
echo 'graph_args --upper-limit 100'
|
||||
echo 'graph_category system'
|
||||
stack=AREA
|
||||
$PRSTAT $PRSTAT_OPTS | sed '1,/^ZONEID/d' | grep -v '^Total' | while read i; do
|
||||
oIFS="$IFS"
|
||||
IFS='
|
||||
'
|
||||
set -$- $i
|
||||
name=$1
|
||||
label=$8
|
||||
printf "$name.label $label\n$name.draw $stack\n$name.warn 95\n"
|
||||
IFS="$oIFS"
|
||||
stack=STACK
|
||||
done
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
# ZONEID NPROC SWAP RSS MEMORY TIME CPU ZONE $
|
||||
# 0 48 470M 482M 1.5% 4:05:57 0.0% global $
|
||||
# 3 85 2295M 2369M 7.2% 0:36:36 0.0% pearljam $
|
||||
# 6 74 13G 3273M 10% 16:51:18 0.0% ministry $
|
||||
# Total: 207 processes, 709 lwps, load averages: 0.05, 0.06, 0.11$
|
||||
|
||||
$PRSTAT $PRSTAT_OPTS | sed '1,/^ZONEID/d' | grep -v '^Total' | while read i; do
|
||||
oIFS="$IFS"
|
||||
IFS='%
|
||||
'
|
||||
set -$- $i
|
||||
name=$1
|
||||
value=$7
|
||||
printf "$name.value $value\n"
|
||||
IFS="$oIFS"
|
||||
done
|
59
plugins/system/zones_mem
Executable file
59
plugins/system/zones_mem
Executable file
|
@ -0,0 +1,59 @@
|
|||
#!/bin/sh
|
||||
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf
|
||||
|
||||
PRSTAT=/usr/bin/prstat
|
||||
PRSTAT_OPTS="-Z 1 1"
|
||||
|
||||
if [ "$1" = 'autoconf' ]; then
|
||||
if [ -f $PRSTAT ]; then
|
||||
zones=`/usr/sbin/zoneadm list | wc -l`
|
||||
if [ $zones -gt 1 ]; then
|
||||
echo yes
|
||||
else
|
||||
echo yes
|
||||
fi
|
||||
exit 0
|
||||
else
|
||||
echo no
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$1" = 'config' ]; then
|
||||
echo 'graph_title zone memory usage'
|
||||
echo 'graph_args --upper-limit 100'
|
||||
echo 'graph_category system'
|
||||
stack=AREA
|
||||
$PRSTAT $PRSTAT_OPTS | sed '1,/^ZONEID/d' | grep -v '^Total' | while read i; do
|
||||
oIFS="$IFS"
|
||||
IFS='
|
||||
'
|
||||
set -$- $i
|
||||
name=$1
|
||||
label=$8
|
||||
printf "$name.label $label\n$name.draw $stack\n$name.warn 95\n"
|
||||
IFS="$oIFS"
|
||||
stack=STACK
|
||||
done
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
# ZONEID NPROC SWAP RSS MEMORY TIME CPU ZONE $
|
||||
# 0 48 470M 482M 1.5% 4:05:57 0.0% global $
|
||||
# 3 85 2295M 2369M 7.2% 0:36:36 0.0% pearljam $
|
||||
# 6 74 13G 3273M 10% 16:51:18 0.0% ministry $
|
||||
# Total: 207 processes, 709 lwps, load averages: 0.05, 0.06, 0.11$
|
||||
|
||||
$PRSTAT $PRSTAT_OPTS | sed '1,/^ZONEID/d' | grep -v '^Total' | while read i; do
|
||||
oIFS="$IFS"
|
||||
IFS='%
|
||||
'
|
||||
set -$- $i
|
||||
name=$1
|
||||
value=$5
|
||||
printf "$name.value $value\n"
|
||||
IFS="$oIFS"
|
||||
done
|
Loading…
Add table
Add a link
Reference in a new issue