mirror of
https://github.com/munin-monitoring/contrib.git
synced 2018-11-08 00:59:34 +01:00
remove plugins existing in the main munin distribution
This commit is contained in:
parent
b084f05b70
commit
62d43835d4
@ -1,175 +0,0 @@
|
|||||||
#!/usr/bin/perl
|
|
||||||
|
|
||||||
=head1 NAME
|
|
||||||
|
|
||||||
snmp__netapp_diskusage_ - Munin plugin to retrieve file systems usage on
|
|
||||||
NetApp storage appliances.
|
|
||||||
|
|
||||||
=head1 APPLICABLE SYSTEMS
|
|
||||||
|
|
||||||
File systems usage stats should be reported by any NetApp storage
|
|
||||||
appliance with SNMP agent daemon activated. See na_snmp(8) for details.
|
|
||||||
|
|
||||||
=head1 CONFIGURATION
|
|
||||||
|
|
||||||
Unfortunately, SNMPv3 is not fully supported on all NetApp equipments.
|
|
||||||
For this reason, this plugin will use SNMPv2 by default, which is
|
|
||||||
insecure because it doesn't encrypt the community string.
|
|
||||||
|
|
||||||
The following parameters will help you get this plugin working :
|
|
||||||
|
|
||||||
[snmp_*]
|
|
||||||
env.community MyCommunity
|
|
||||||
|
|
||||||
If your community name is 'public', you should really worry about
|
|
||||||
security and immediately reconfigure your appliance.
|
|
||||||
|
|
||||||
Please see 'perldoc Munin::Plugin::SNMP' for further configuration.
|
|
||||||
|
|
||||||
=head1 INTERPRETATION
|
|
||||||
|
|
||||||
The plugin reports file systems usage. This can help you monitoring file
|
|
||||||
systems usage in a given period of time.
|
|
||||||
|
|
||||||
=head1 MIB INFORMATION
|
|
||||||
|
|
||||||
This plugin requires support for the NETWORK-APPLIANCE-MIB issued by
|
|
||||||
Network Appliance. It reports the content of the DfEntry OID.
|
|
||||||
|
|
||||||
=head1 MAGIC MARKERS
|
|
||||||
|
|
||||||
#%# family=snmpauto
|
|
||||||
#%# capabilities=snmpconf
|
|
||||||
|
|
||||||
=head1 VERSION
|
|
||||||
|
|
||||||
v1.0 - 06/22/2009 14:05:03 CEST
|
|
||||||
Initial revision
|
|
||||||
|
|
||||||
=head1 AUTHOR
|
|
||||||
|
|
||||||
This plugin is copyright (c) 2009 by Guillaume Blairon.
|
|
||||||
|
|
||||||
NetApp is a registered trademark and Network Appliance is a trademark
|
|
||||||
of Network Appliance, Inc. in the U.S. and other countries.
|
|
||||||
|
|
||||||
=head1 BUGS
|
|
||||||
|
|
||||||
This plugin wasn't tested on many hardware. If you encounter bugs,
|
|
||||||
please report them to Guillaume Blairon E<lt>L<g@yom.be>E<gt>.
|
|
||||||
|
|
||||||
=head1 LICENSE
|
|
||||||
|
|
||||||
GPLv2 or (at your option) any later version.
|
|
||||||
|
|
||||||
=cut
|
|
||||||
|
|
||||||
use strict;
|
|
||||||
use warnings;
|
|
||||||
use Munin::Plugin::SNMP;
|
|
||||||
use vars qw($DEBUG);
|
|
||||||
|
|
||||||
$DEBUG = $ENV{'MUNIN_DEBUG'};
|
|
||||||
|
|
||||||
my @palette =
|
|
||||||
#Better colours from munin 1.3.x
|
|
||||||
#Greens Blues Oranges Dk yel Dk blu Purple Lime Reds Gray
|
|
||||||
qw(00CC00 0066B3 FF8000 FFCC00 330099 990099 CCFF00 FF0000 808080
|
|
||||||
008F00 00487D B35A00 B38F00 6B006B 8FB300 B30000 BEBEBE
|
|
||||||
80FF80 80C9FF FFC080 FFE680 AA80FF EE00CC FF8080
|
|
||||||
666600 FFBFFF 00FFCC CC6699 999900);
|
|
||||||
|
|
||||||
my %oids = (
|
|
||||||
|
|
||||||
# - dfHigh.* : 32 most significant bits counters
|
|
||||||
# - dfLow.* : 32 least significant bits counters
|
|
||||||
|
|
||||||
dfHighTotalKBytes => '1.3.6.1.4.1.789.1.5.4.1.14.',
|
|
||||||
dfLowTotalKBytes => '1.3.6.1.4.1.789.1.5.4.1.15.',
|
|
||||||
dfHighUsedKBytes => '1.3.6.1.4.1.789.1.5.4.1.16.',
|
|
||||||
dfLowUsedKBytes => '1.3.6.1.4.1.789.1.5.4.1.17.',
|
|
||||||
dfHighAvailKBytes => '1.3.6.1.4.1.789.1.5.4.1.18.',
|
|
||||||
dfLowAvailKBytes => '1.3.6.1.4.1.789.1.5.4.1.19.',
|
|
||||||
|
|
||||||
);
|
|
||||||
|
|
||||||
sub to_32bit_int {
|
|
||||||
my ($l, $h) = @_;
|
|
||||||
return "U" if ((!defined $l) || (!defined $h));
|
|
||||||
my $bin = unpack( 'B32', pack('N', $l) . pack('N', $h) );
|
|
||||||
return unpack( 'N', pack('B32', $bin) );
|
|
||||||
}
|
|
||||||
|
|
||||||
if (defined $ARGV[0] and $ARGV[0] eq 'snmpconf') {
|
|
||||||
print "number 1.3.6.1.4.1.789.1.5.6.0\n";
|
|
||||||
print "index 1.3.6.1.4.1.789.1.5.4.1.1.\n";
|
|
||||||
foreach (keys %oids) {
|
|
||||||
print "require $oids{$_} [0-9]\n";
|
|
||||||
}
|
|
||||||
exit 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
my $session = Munin::Plugin::SNMP->session();
|
|
||||||
my ($host, undef, undef, $tail) = Munin::Plugin::SNMP->config_session();
|
|
||||||
my ($df_id, $name_oid);
|
|
||||||
|
|
||||||
if ($tail =~ /^netapp_diskusage_(\d+)$/) {
|
|
||||||
$df_id = $1;
|
|
||||||
$name_oid = '1.3.6.1.4.1.789.1.5.4.1.2.' . $df_id;
|
|
||||||
} else {
|
|
||||||
die "Couldn't understand what I'm supposed to monitor";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (defined $ARGV[0] and $ARGV[0] eq "config") {
|
|
||||||
my $df_name = $session->get_single($name_oid);
|
|
||||||
|
|
||||||
print "host_name $host\n" unless $host eq 'localhost';
|
|
||||||
print "graph_title $host disk usage on $df_name\n";
|
|
||||||
print "graph_args --base 1024 --lower-limit 0\n";
|
|
||||||
print "graph_vlabel bytes\n";
|
|
||||||
print "graph_category disk\n";
|
|
||||||
print "graph_info This graph shows the disk usage for $df_name on NetApp host $host\n";
|
|
||||||
print "graph_order used avail total\n";
|
|
||||||
print "used.info The total disk space in KBytes that is in use on the $df_name file system.\n";
|
|
||||||
print "used.type GAUGE\n";
|
|
||||||
print "used.draw AREA\n";
|
|
||||||
print "used.label Used\n";
|
|
||||||
print "used.cdef used,1024,*\n";
|
|
||||||
print "used.min 0\n";
|
|
||||||
print "used.colour $palette[1]\n";
|
|
||||||
print "avail.info The total disk space in KBytes that is free for use on the $df_name file system.\n";
|
|
||||||
print "avail.type GAUGE\n";
|
|
||||||
print "avail.draw STACK\n";
|
|
||||||
print "avail.label Available\n";
|
|
||||||
print "avail.cdef avail,1024,*\n";
|
|
||||||
print "avail.min 0\n";
|
|
||||||
print "avail.colour $palette[3]\n";
|
|
||||||
print "total.info The total capacity in KBytes for the $df_name file system.\n";
|
|
||||||
print "total.type GAUGE\n";
|
|
||||||
print "total.draw LINE2\n";
|
|
||||||
print "total.label Total\n";
|
|
||||||
print "total.cdef total,1024,*\n";
|
|
||||||
print "total.min 0\n";
|
|
||||||
print "total.colour $palette[7]\n";
|
|
||||||
|
|
||||||
exit 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
my $used_l = $session->get_single($oids{dfLowUsedKBytes}.$df_id);
|
|
||||||
my $used_h = $session->get_single($oids{dfHighUsedKBytes}.$df_id);
|
|
||||||
my $avail_l = $session->get_single($oids{dfLowAvailKBytes}.$df_id);
|
|
||||||
my $avail_h = $session->get_single($oids{dfHighAvailKBytes}.$df_id);
|
|
||||||
my $total_l = $session->get_single($oids{dfLowTotalKBytes}.$df_id);
|
|
||||||
my $total_h = $session->get_single($oids{dfHighTotalKBytes}.$df_id);
|
|
||||||
|
|
||||||
my $used = to_32bit_int($used_l, $used_h);
|
|
||||||
my $avail = to_32bit_int($avail_l, $avail_h);
|
|
||||||
my $total = to_32bit_int($total_l, $total_h);
|
|
||||||
|
|
||||||
print "used.value $used\n";
|
|
||||||
print "avail.value $avail\n";
|
|
||||||
print "total.value $total\n";
|
|
||||||
|
|
||||||
exit 0;
|
|
||||||
|
|
||||||
__END__
|
|
@ -1,144 +0,0 @@
|
|||||||
#!/usr/bin/perl
|
|
||||||
|
|
||||||
=head1 NAME
|
|
||||||
|
|
||||||
snmp__netapp_inodeusage_ - Munin plugin to retrieve inodes usage on
|
|
||||||
NetApp storage appliances.
|
|
||||||
|
|
||||||
=head1 APPLICABLE SYSTEMS
|
|
||||||
|
|
||||||
Inodes usage stats should be reported by any NetApp storage appliance
|
|
||||||
with SNMP agent daemon activated. See na_snmp(8) for details.
|
|
||||||
|
|
||||||
=head1 CONFIGURATION
|
|
||||||
|
|
||||||
Unfortunately, SNMPv3 is not fully supported on all NetApp equipments.
|
|
||||||
For this reason, this plugin will use SNMPv2 by default, which is
|
|
||||||
insecure because it doesn't encrypt the community string.
|
|
||||||
|
|
||||||
The following parameters will help you get this plugin working :
|
|
||||||
|
|
||||||
[snmp_*]
|
|
||||||
env.community MyCommunity
|
|
||||||
|
|
||||||
If your community name is 'public', you should really worry about
|
|
||||||
security and immediately reconfigure your appliance.
|
|
||||||
|
|
||||||
Please see 'perldoc Munin::Plugin::SNMP' for further configuration.
|
|
||||||
|
|
||||||
=head1 MIB INFORMATION
|
|
||||||
|
|
||||||
This plugin requires support for the NETWORK-APPLIANCE-MIB issued by
|
|
||||||
Network Appliance. It reports the content of the DfEntry OID.
|
|
||||||
|
|
||||||
=head1 MAGIC MARKERS
|
|
||||||
|
|
||||||
#%# family=snmpauto
|
|
||||||
#%# capabilities=snmpconf
|
|
||||||
|
|
||||||
=head1 VERSION
|
|
||||||
|
|
||||||
v1.0 - 06/22/2009 14:05:03 CEST
|
|
||||||
Initial revision
|
|
||||||
|
|
||||||
=head1 AUTHOR
|
|
||||||
|
|
||||||
This plugin is copyright (c) 2009 by Guillaume Blairon.
|
|
||||||
|
|
||||||
NetApp is a registered trademark and Network Appliance is a trademark
|
|
||||||
of Network Appliance, Inc. in the U.S. and other countries.
|
|
||||||
|
|
||||||
=head1 BUGS
|
|
||||||
|
|
||||||
This plugin wasn't tested on many hardware. If you encounter bugs,
|
|
||||||
please report them to Guillaume Blairon E<lt>L<g@yom.be>E<gt>.
|
|
||||||
|
|
||||||
=head1 LICENSE
|
|
||||||
|
|
||||||
GPLv2 or (at your option) any later version.
|
|
||||||
|
|
||||||
=cut
|
|
||||||
|
|
||||||
use strict;
|
|
||||||
use warnings;
|
|
||||||
use Munin::Plugin::SNMP;
|
|
||||||
use vars qw($DEBUG);
|
|
||||||
|
|
||||||
$DEBUG = $ENV{'MUNIN_DEBUG'};
|
|
||||||
|
|
||||||
my @palette =
|
|
||||||
#Better colours from munin 1.3.x
|
|
||||||
#Greens Blues Oranges Dk yel Dk blu Purple Lime Reds Gray
|
|
||||||
qw(00CC00 0066B3 FF8000 FFCC00 330099 990099 CCFF00 FF0000 808080
|
|
||||||
008F00 00487D B35A00 B38F00 6B006B 8FB300 B30000 BEBEBE
|
|
||||||
80FF80 80C9FF FFC080 FFE680 AA80FF EE00CC FF8080
|
|
||||||
666600 FFBFFF 00FFCC CC6699 999900);
|
|
||||||
|
|
||||||
my %oids = (
|
|
||||||
dfInodesUsed => '1.3.6.1.4.1.789.1.5.4.1.7.',
|
|
||||||
dfInodesFree => '1.3.6.1.4.1.789.1.5.4.1.8.',
|
|
||||||
);
|
|
||||||
|
|
||||||
if (defined $ARGV[0] and $ARGV[0] eq 'snmpconf') {
|
|
||||||
print "number 1.3.6.1.4.1.789.1.5.6.0\n";
|
|
||||||
print "index 1.3.6.1.4.1.789.1.5.4.1.1.\n";
|
|
||||||
foreach (keys %oids) {
|
|
||||||
print "require $oids{$_} [0-9]\n";
|
|
||||||
}
|
|
||||||
exit 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
my $session = Munin::Plugin::SNMP->session();
|
|
||||||
my ($host, undef, undef, $tail) = Munin::Plugin::SNMP->config_session();
|
|
||||||
my ($df_id, $name_oid);
|
|
||||||
|
|
||||||
if ($tail =~ /^netapp_inodeusage_(\d+)$/) {
|
|
||||||
$df_id = $1;
|
|
||||||
$name_oid = '1.3.6.1.4.1.789.1.5.4.1.2.' . $df_id;
|
|
||||||
} else {
|
|
||||||
die "Couldn't understand what I'm supposed to monitor";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (defined $ARGV[0] and $ARGV[0] eq "config") {
|
|
||||||
my $df_name = $session->get_single($name_oid);
|
|
||||||
|
|
||||||
print "host_name $host\n" unless $host eq 'localhost';
|
|
||||||
print "graph_title $host inodes usage on $df_name\n";
|
|
||||||
print "graph_args --base 1000 --lower-limit 0\n";
|
|
||||||
print "graph_vlabel bytes\n";
|
|
||||||
print "graph_category disk\n";
|
|
||||||
print "graph_info This graph shows the inodes usage for $df_name on NetApp host $host\n";
|
|
||||||
print "graph_order used avail total\n";
|
|
||||||
print "used.info The total inodes number of inodes in use on the $df_name file system.\n";
|
|
||||||
print "used.type GAUGE\n";
|
|
||||||
print "used.draw AREA\n";
|
|
||||||
print "used.label Used\n";
|
|
||||||
print "used.min 0\n";
|
|
||||||
print "used.colour $palette[1]\n";
|
|
||||||
print "avail.info The total number of inodes that are free for use on the $df_name file system.\n";
|
|
||||||
print "avail.type GAUGE\n";
|
|
||||||
print "avail.draw STACK\n";
|
|
||||||
print "avail.label Available\n";
|
|
||||||
print "avail.min 0\n";
|
|
||||||
print "avail.colour $palette[3]\n";
|
|
||||||
print "total.info The total capacity for the $df_name file system.\n";
|
|
||||||
print "total.type GAUGE\n";
|
|
||||||
print "total.draw LINE2\n";
|
|
||||||
print "total.label Total\n";
|
|
||||||
print "total.min 0\n";
|
|
||||||
print "total.colour $palette[7]\n";
|
|
||||||
|
|
||||||
exit 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
my $used = $session->get_single($oids{dfInodesUsed}.$df_id);
|
|
||||||
my $avail = $session->get_single($oids{dfInodesFree}.$df_id);
|
|
||||||
my $total = $used + $avail;
|
|
||||||
|
|
||||||
print "used.value $used\n";
|
|
||||||
print "avail.value $avail\n";
|
|
||||||
print "total.value $total\n";
|
|
||||||
|
|
||||||
exit 0;
|
|
||||||
|
|
||||||
__END__
|
|
@ -1,172 +0,0 @@
|
|||||||
#!/usr/bin/perl -w
|
|
||||||
#
|
|
||||||
# Copyright (C) 2006 Lars Strand
|
|
||||||
#
|
|
||||||
# Munin plugin to monitor swap usage by use of SNMP.
|
|
||||||
# Based on the 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 $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")
|
|
||||||
{
|
|
||||||
# HOST-RESOURCES-MIB::hrStorage
|
|
||||||
# HOST-RESOURCES-TYPES::hrStorageVirtualMemory
|
|
||||||
print "require 1.3.6.1.2.1.25.2. 1.3.6.1.2.1.25.2.1.3\n";
|
|
||||||
exit 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($0 =~ /^(?:|.*\/)snmp_([^_]+)_swap$/)
|
|
||||||
{
|
|
||||||
$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";
|
|
||||||
}
|
|
||||||
|
|
||||||
my $hrStorage = "1.3.6.1.2.1.25.2.";
|
|
||||||
my $hrStorageVirtualMemory = "1.3.6.1.2.1.25.2.1.3";
|
|
||||||
my $hrStorageSize = "1.3.6.1.2.1.25.2.3.1.5.";
|
|
||||||
my $hrStorageUsed = "1.3.6.1.2.1.25.2.3.1.6.";
|
|
||||||
|
|
||||||
my $swap_d = get_by_regex($session, $hrStorage, $hrStorageVirtualMemory);
|
|
||||||
|
|
||||||
my $swapsize = 0; my $swapused = 0;
|
|
||||||
|
|
||||||
foreach my $swap (keys %$swap_d)
|
|
||||||
{
|
|
||||||
$swapsize += get_single($session, $hrStorageSize . $swap);
|
|
||||||
$swapused += get_single($session, $hrStorageUsed . $swap);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (defined $ARGV[0] and $ARGV[0] eq "config")
|
|
||||||
{
|
|
||||||
print "host_name $host\n";
|
|
||||||
print "graph_title Virtual memory usage\n";
|
|
||||||
if ($swapsize > 0)
|
|
||||||
{
|
|
||||||
print "graph_args -l 0 --base 1000 --upper-limit $swapsize\n";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
print "graph_args -l 0 --base 1000\n";
|
|
||||||
}
|
|
||||||
print "graph_vlabel Bytes\n";
|
|
||||||
print "graph_category disk\n";
|
|
||||||
print "graph_info This graph shows swap usage in bytes.\n";
|
|
||||||
print "swap.label swap\n";
|
|
||||||
print "swap.type DERIVE\n";
|
|
||||||
print "swap.min 0\n";
|
|
||||||
exit 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
print "swap.value $swapused\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;
|
|
||||||
}
|
|
@ -1,64 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
#
|
|
||||||
# Munin plugin to monitor free space in MySQL's InnoDB tablespace.
|
|
||||||
# Mostly useful if you use InnoDB on a block device, or if you for
|
|
||||||
# some reason don't want to do autoextend on the last file.
|
|
||||||
#
|
|
||||||
# 2007-03-18 Stig Sandbeck Mathisen <ssm@fnord.no>
|
|
||||||
#
|
|
||||||
# Configuration parameters for /etc/munin/plugin-conf.d/mysql_innodb,
|
|
||||||
# if you need to override the defaults below:
|
|
||||||
#
|
|
||||||
# [mysql_innodb]
|
|
||||||
# env.mysqlopts - Options to pass to mysql (host, username, password)
|
|
||||||
# env.warning - Generate a warning if free space goes below this level
|
|
||||||
# env.critical - Generate a critical if free space goes below this level
|
|
||||||
#
|
|
||||||
# For security reasons, this plugin uses its own schema with a simple,
|
|
||||||
# empty table using the InnoDB engine.
|
|
||||||
#
|
|
||||||
# You need to run this to get this plugin to work:
|
|
||||||
# mysql> CREATE DATABASE munin_innodb;
|
|
||||||
# mysql> USE munin_innodb
|
|
||||||
# mysql> CREATE TABLE something (anything int) ENGINE=InnoDB;
|
|
||||||
|
|
||||||
## Tunable parameters with defaults
|
|
||||||
MYSQL="${mysql:-/usr/bin/mysql}"
|
|
||||||
MYSQLOPTS="${mysqlopts:---user=munin --password=munin --host=localhost}"
|
|
||||||
|
|
||||||
WARNING=${warning:-2147483648} # 2GB
|
|
||||||
CRITICAL=${critical:-1073741824} # 1GB
|
|
||||||
|
|
||||||
## No user serviceable parts below
|
|
||||||
if [ "$1" = "config" ]; then
|
|
||||||
echo 'graph_title MySQL InnoDB free tablespace'
|
|
||||||
echo 'graph_args --base 1024'
|
|
||||||
echo 'graph_vlabel Bytes'
|
|
||||||
echo 'graph_category mysql'
|
|
||||||
echo 'graph_info Amount of free bytes in the InnoDB tablespace'
|
|
||||||
echo 'free.label Bytes free'
|
|
||||||
echo 'free.type GAUGE'
|
|
||||||
echo 'free.min 0'
|
|
||||||
echo 'free.warning' $WARNING:
|
|
||||||
echo 'free.critical' $CRITICAL:
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Get freespace from mysql
|
|
||||||
freespace=$($MYSQL $MYSQLOPTS --batch --skip-column-names --execute \
|
|
||||||
"SELECT table_comment FROM tables WHERE TABLE_SCHEMA = 'munin_innodb'" \
|
|
||||||
information_schema);
|
|
||||||
retval=$?
|
|
||||||
|
|
||||||
# Sanity checks
|
|
||||||
if (( retval > 0 )); then
|
|
||||||
echo "Error: mysql command returned status $retval" 1>&2
|
|
||||||
exit -1
|
|
||||||
fi
|
|
||||||
if [ -z "$freespace" ]; then
|
|
||||||
echo "Error: mysql command returned no output" 1>&2
|
|
||||||
exit -1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Return freespace
|
|
||||||
echo $freespace | awk '/InnoDB free:/ {print "free.value", $3 * 1024}'
|
|
@ -1,158 +0,0 @@
|
|||||||
#!/usr/bin/perl -w
|
|
||||||
#
|
|
||||||
# Copyright (C) 2006 Lars Strand
|
|
||||||
#
|
|
||||||
# Munin plugin to monitor network connection 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 = 1;
|
|
||||||
|
|
||||||
my $host = $ENV{host} || undef;
|
|
||||||
my $port = $ENV{port} || 161;
|
|
||||||
my $community = $ENV{community} || "public";
|
|
||||||
|
|
||||||
my $response;
|
|
||||||
|
|
||||||
my %tcpStates = ( 1 => [0, "GAUGE", "closed", "Connections waiting for a termination request acknowledgment from the remote TCP."],
|
|
||||||
2 => [0, "GAUGE", "listen", "Connections waiting for a request from any remote TCP and port."],
|
|
||||||
3 => [0, "GAUGE", "synSent", "Connections waiting for a matching request after having sent a connection request."],
|
|
||||||
4 => [0, "GAUGE", "synReceived", "Connections waiting for a confirming request acknowledgment after having both received and sent a connection request."],
|
|
||||||
5 => [0, "GAUGE", "established", "Connections opened and data received can be delivered to the user. The normal state for the data transfer phase of the connection."],
|
|
||||||
6 => [0, "GAUGE", "finWait1", "Connections waiting for a termination request from the remote TCP, or an acknowledgment of the connection termination request previously sent."],
|
|
||||||
7 => [0, "GAUGE", "finWait2", "Connections waiting for a termination request from the remote TCP."],
|
|
||||||
8 => [0, "GAUGE", "closeWait", "Connections waiting for a termination request from the local user."],
|
|
||||||
9 => [0, "GAUGE", "lastAck", "Connections waiting for an acknowledgment of the termination request previously sent to the remote TCP (which includes an acknowledgment of its connection termination request)."],
|
|
||||||
10 => [0, "GAUGE", "closing", "Connections waiting for a termination request acknowledgment from the remote TCP."],
|
|
||||||
11 => [0, "GAUGE", "timeWait", "Connections waiting for enough time to pass to be sure the remote TCP received the acknowledgment of its termination request."],
|
|
||||||
12 => [0, "GAUGE", "deleteTCP", "Connections terminated by a SNMP Managment Station (put)"]
|
|
||||||
);
|
|
||||||
|
|
||||||
if (defined $ARGV[0] and $ARGV[0] eq "snmpconf")
|
|
||||||
{
|
|
||||||
print "require 1.3.6.1.2.1.6.13.1.1. [0-9]\n";
|
|
||||||
exit 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($0 =~ /^(?:|.*\/)snmp_([^_]+)_netstat$/)
|
|
||||||
{
|
|
||||||
$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 Netstat\n";
|
|
||||||
print "graph_args -l 0 --base 1000\n";
|
|
||||||
print "graph_period seconds\n";
|
|
||||||
print "graph_category network\n";
|
|
||||||
print "graph_order closed listen synSent synReceived established finWait1 finWait2 closeWait lastAck closing timeWait deleteTCP\n";
|
|
||||||
print "graph_vlabel active connection\n";
|
|
||||||
print "graph_info This graph shows the TCP activity of all the network interfaces combined.\n";
|
|
||||||
|
|
||||||
foreach my $state (keys %tcpStates) {
|
|
||||||
print "$tcpStates{$state}[2].label $tcpStates{$state}[2]\n";
|
|
||||||
print "$tcpStates{$state}[2].type $tcpStates{$state}[1]\n";
|
|
||||||
print "$tcpStates{$state}[2].max 50000\n";
|
|
||||||
print "$tcpStates{$state}[2].min 0\n";
|
|
||||||
print "$tcpStates{$state}[2].info $tcpStates{$state}[3]\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
exit 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
my $tcpConnState = "1.3.6.1.2.1.6.13.1.1.";
|
|
||||||
|
|
||||||
my ($session, $error) = Net::SNMP->session(
|
|
||||||
-hostname => $host,
|
|
||||||
-community => $community,
|
|
||||||
-port => $port
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!defined ($session))
|
|
||||||
{
|
|
||||||
die "Croaking: $error";
|
|
||||||
}
|
|
||||||
|
|
||||||
my $connections = get_by_regex($session, $tcpConnState, "[1-9]");
|
|
||||||
|
|
||||||
# the values
|
|
||||||
while (my ($id, $state) = each(%$connections)) {
|
|
||||||
$tcpStates{$state}[0] += 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach my $state (keys %tcpStates) {
|
|
||||||
print "$tcpStates{$state}[2].value $tcpStates{$state}[0]\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
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->{$num} = $response->{$ret};;
|
|
||||||
print "# Index $num: ", $keys[-1], " (", $response->{$ret}, ")\n" if $DEBUG;
|
|
||||||
};
|
|
||||||
return $result;
|
|
||||||
}
|
|
@ -1,69 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
#
|
|
||||||
# Plugin to monitor NFS client traffic
|
|
||||||
#
|
|
||||||
# $Log$
|
|
||||||
# Revision 1.8.2.1 2005/03/16 13:45:45 ilmari
|
|
||||||
# Fix autoconf for linux/{nfsd,nfs_client}.
|
|
||||||
#
|
|
||||||
# Revision 1.8 2004/12/10 10:47:49 jimmyo
|
|
||||||
# Change name from ${scale} to ${graph_period}, to be more consistent.
|
|
||||||
#
|
|
||||||
# Revision 1.7 2004/12/09 22:12:56 jimmyo
|
|
||||||
# Added "graph_period" option, to make "graph_sums" usable.
|
|
||||||
#
|
|
||||||
# Revision 1.6 2004/11/21 00:17:12 jimmyo
|
|
||||||
# Changed a lot of plugins so they use DERIVE instead of COUNTER.
|
|
||||||
#
|
|
||||||
# Revision 1.5 2004/10/01 12:32:09 ilmari
|
|
||||||
# complete "rpc" removal
|
|
||||||
#
|
|
||||||
# Revision 1.4 2004/10/01 08:40:50 ilmari
|
|
||||||
# Remove useless 'rpc' field, add total field
|
|
||||||
#
|
|
||||||
# Revision 1.3 2004/05/20 19:02:37 jimmyo
|
|
||||||
# Set categories on a bunch of plugins
|
|
||||||
#
|
|
||||||
# Revision 1.2 2004/05/15 21:33:29 jimmyo
|
|
||||||
# "Upped" som plugins from contrib/manual to manual or auto.
|
|
||||||
#
|
|
||||||
#
|
|
||||||
#%# family=auto
|
|
||||||
#%# capabilities=autoconf
|
|
||||||
|
|
||||||
NFS=/proc/net/rpc/nfs
|
|
||||||
|
|
||||||
#proc="getattr setattr lookup access readlink read write create mkdir symlink mknod remove rmdir rename link readdir readdirplus fsstat fsinfo pathconf commit"
|
|
||||||
|
|
||||||
proc="access close commit create delegpurge delegreturn getattr getfh link lock lockt locku lookup lookup_root nverify open openattr open_conf open_dgrd putfh putpubfh putrootfh read readdir readlink remove rename renew restorefh savefh secinfo setattr setcltid setcltidconf verify write rellockowner"
|
|
||||||
|
|
||||||
if [ "$1" = "autoconf" ]; then
|
|
||||||
if [ -f "$NFS" ]; then
|
|
||||||
echo yes
|
|
||||||
exit 0
|
|
||||||
else
|
|
||||||
echo "no (no $NFS)"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$1" = "config" ]; then
|
|
||||||
|
|
||||||
echo 'graph_title NFS4 Client'
|
|
||||||
echo 'graph_args --base 1000 -l 0'
|
|
||||||
echo 'graph_vlabel requests / ${graph_period}'
|
|
||||||
echo 'graph_total total'
|
|
||||||
echo 'graph_category NFS'
|
|
||||||
for a in $proc ; do echo "$a.label $a" ; echo "$a.type DERIVE"; echo "$a.min 0"; done
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
i=4;
|
|
||||||
|
|
||||||
for a in $proc; do
|
|
||||||
echo -n "$a.value "
|
|
||||||
grep proc4 $NFS \
|
|
||||||
| cut -f $i -d ' ' \
|
|
||||||
| awk '{print $1}'
|
|
||||||
i=$(expr $i + 1)
|
|
||||||
done
|
|
@ -1,158 +0,0 @@
|
|||||||
#!/usr/bin/perl -w
|
|
||||||
# -*- mode: cperl; mode: autopair -*-
|
|
||||||
# Magic markers:
|
|
||||||
#%# family=auto
|
|
||||||
#%# capabilities=autoconf
|
|
||||||
# nginx_request --- Determine the current connection rate for
|
|
||||||
# nginx. Based on a nginx_request plugin by unknown
|
|
||||||
# author.
|
|
||||||
|
|
||||||
# Copyright (C) 2010 António P. P. Almeida <appa@perusio.net>
|
|
||||||
|
|
||||||
# Author: António P. P. Almeida <appa@perusio.net>
|
|
||||||
|
|
||||||
# Permission is hereby granted, free of charge, to any person obtaining a
|
|
||||||
# copy of this software and associated documentation files (the "Software"),
|
|
||||||
# to deal in the Software without restriction, including without limitation
|
|
||||||
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
||||||
# and/or sell copies of the Software, and to permit persons to whom the
|
|
||||||
# Software is furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
# The above copyright notice and this permission notice shall be included in
|
|
||||||
# all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
# Except as contained in this notice, the name(s) of the above copyright
|
|
||||||
# holders shall not be used in advertising or otherwise to promote the sale,
|
|
||||||
# use or other dealings in this Software without prior written authorization.
|
|
||||||
|
|
||||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
||||||
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
||||||
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
# DEALINGS IN THE SOFTWARE.
|
|
||||||
|
|
||||||
=head1 NAME
|
|
||||||
|
|
||||||
nginx_request - Munin plugin to show number of requests/connection served by nginx.
|
|
||||||
=encoding utf8
|
|
||||||
|
|
||||||
=head1 APPLICABLE SYSTEMS
|
|
||||||
|
|
||||||
Any nginx host
|
|
||||||
|
|
||||||
=head1 CONFIGURATION
|
|
||||||
|
|
||||||
This shows the default configuration of this plugin. You can override
|
|
||||||
the status URL and User Agent.
|
|
||||||
|
|
||||||
[nginx*]
|
|
||||||
env.url http://localhost/nginx_status
|
|
||||||
env.ua nginx-status-verifier/0.1
|
|
||||||
|
|
||||||
Nginx must also be configured. Firstly the stub-status module must be
|
|
||||||
compiled, and secondly it must be configured like this:
|
|
||||||
|
|
||||||
server {
|
|
||||||
listen 127.0.0.1;
|
|
||||||
server_name localhost;
|
|
||||||
location /nginx_status {
|
|
||||||
stub_status on;
|
|
||||||
access_log off;
|
|
||||||
allow 127.0.0.1;
|
|
||||||
deny all;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
=head1 MAGIC MARKERS
|
|
||||||
|
|
||||||
#%# family=auto
|
|
||||||
#%# capabilities=autoconf
|
|
||||||
|
|
||||||
=head1 VERSION
|
|
||||||
|
|
||||||
1.1
|
|
||||||
|
|
||||||
=head1 BUGS
|
|
||||||
|
|
||||||
None known
|
|
||||||
|
|
||||||
=head1 AUTHOR
|
|
||||||
|
|
||||||
Unknown. Modified by António Almeida <appa@perusio.net>
|
|
||||||
|
|
||||||
=head1 REPOSITORY
|
|
||||||
|
|
||||||
Source code at http://github.com/perusio/nginx-munin
|
|
||||||
|
|
||||||
=head1 LICENSE
|
|
||||||
|
|
||||||
MIT
|
|
||||||
|
|
||||||
=cut
|
|
||||||
|
|
||||||
|
|
||||||
my $ret = undef;
|
|
||||||
|
|
||||||
if (! eval "require LWP::UserAgent;") {
|
|
||||||
$ret = "LWP::UserAgent not found";
|
|
||||||
}
|
|
||||||
|
|
||||||
chomp(my $fqdn=`hostname -f`);
|
|
||||||
|
|
||||||
|
|
||||||
## Environment defined variables.
|
|
||||||
## The default URL is nginx_status if different set it in the environment.
|
|
||||||
my $URL = exists $ENV{'url'} ? $ENV{'url'} : "http://$fqdn/nginx_status";
|
|
||||||
## The default user agent is ngnix-status-verifier/0.1 if different
|
|
||||||
## set it in the environment.
|
|
||||||
my $UA = exists $ENV{'ua'} ? $ENV{'ua'} : 'nginx-status-verifier/0.1';
|
|
||||||
|
|
||||||
if (exists $ARGV[0] and $ARGV[0] eq "autoconf") {
|
|
||||||
if ($ret) {
|
|
||||||
print "no ($ret)\n";
|
|
||||||
exit 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
my $ua = LWP::UserAgent->new(timeout => 30);
|
|
||||||
# Set the UA to something different from the libwww-perl.
|
|
||||||
# That UA is blocked.
|
|
||||||
$ua->agent($UA);
|
|
||||||
my $response = $ua->request(HTTP::Request->new('GET',$URL));
|
|
||||||
|
|
||||||
unless ($response->is_success and $response->content =~ /server/im)
|
|
||||||
{
|
|
||||||
print "no (no nginx status on $URL)\n";
|
|
||||||
exit 1;
|
|
||||||
} else {
|
|
||||||
print "yes\n";
|
|
||||||
exit 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
## Munin config method.
|
|
||||||
if (exists $ARGV[0] and $ARGV[0] eq "config") {
|
|
||||||
print "graph_title NGINX requests\n";
|
|
||||||
print "graph_args --base 1000\n";
|
|
||||||
print "graph_category nginx\n";
|
|
||||||
print "graph_vlabel Request per second\n";
|
|
||||||
print "request.label req/sec\n";
|
|
||||||
print "request.type DERIVE\n";
|
|
||||||
print "request.min 0\n";
|
|
||||||
print "request.draw LINE2\n";
|
|
||||||
|
|
||||||
exit 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
my $ua = LWP::UserAgent->new(timeout => 30);
|
|
||||||
# Set the UA to something different from the libwww-perl.
|
|
||||||
# That UA is blocked.
|
|
||||||
$ua->agent($UA);
|
|
||||||
my $response = $ua->request(HTTP::Request->new('GET',$URL));
|
|
||||||
|
|
||||||
if ($response->content =~ /^\s+(\d+)\s+(\d+)\s+(\d+)/m) {
|
|
||||||
print "request.value $3\n";
|
|
||||||
} else {
|
|
||||||
print "request.value U\n";
|
|
||||||
}
|
|
@ -1,178 +0,0 @@
|
|||||||
#!/usr/bin/perl -w
|
|
||||||
# -*- cperl -*-
|
|
||||||
# Magic markers:
|
|
||||||
#%# family=auto
|
|
||||||
#%# capabilities=autoconf
|
|
||||||
# nginx_status --- Determine the current status of Nginx
|
|
||||||
# using the http_stub_status module.
|
|
||||||
|
|
||||||
# Copyright (C) 2010 António P. P. Almeida <appa@perusio.net>
|
|
||||||
|
|
||||||
# Author: António P. P. Almeida <appa@perusio.net>
|
|
||||||
|
|
||||||
# Permission is hereby granted, free of charge, to any person obtaining a
|
|
||||||
# copy of this software and associated documentation files (the "Software"),
|
|
||||||
# to deal in the Software without restriction, including without limitation
|
|
||||||
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
||||||
# and/or sell copies of the Software, and to permit persons to whom the
|
|
||||||
# Software is furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
# The above copyright notice and this permission notice shall be included in
|
|
||||||
# all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
# Except as contained in this notice, the name(s) of the above copyright
|
|
||||||
# holders shall not be used in advertising or otherwise to promote the sale,
|
|
||||||
# use or other dealings in this Software without prior written authorization.
|
|
||||||
|
|
||||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
||||||
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
||||||
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
# DEALINGS IN THE SOFTWARE.
|
|
||||||
|
|
||||||
=head1 NAME
|
|
||||||
|
|
||||||
nginx_status - Munin plugin to show the connection status for nginx
|
|
||||||
|
|
||||||
=encoding utf8
|
|
||||||
|
|
||||||
=head1 APPLICABLE SYSTEMS
|
|
||||||
|
|
||||||
Any nginx host
|
|
||||||
|
|
||||||
=head1 CONFIGURATION
|
|
||||||
|
|
||||||
This shows the default configuration of this plugin. You can override
|
|
||||||
the status URL and the User Agent.
|
|
||||||
|
|
||||||
[nginx*]
|
|
||||||
env.url http://localhost/nginx_status
|
|
||||||
env.ua nginx-status-verifier/0.1
|
|
||||||
|
|
||||||
Nginx must also be configured. Firstly the stub-status module must be
|
|
||||||
compiled, and secondly it must be configured like this:
|
|
||||||
|
|
||||||
server {
|
|
||||||
listen 127.0.0.1;
|
|
||||||
server_name localhost;
|
|
||||||
location /nginx_status {
|
|
||||||
stub_status on;
|
|
||||||
access_log off;
|
|
||||||
allow 127.0.0.1;
|
|
||||||
deny all;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
=head1 MAGIC MARKERS
|
|
||||||
|
|
||||||
#%# family=auto
|
|
||||||
#%# capabilities=autoconf
|
|
||||||
|
|
||||||
=head1 VERSION
|
|
||||||
|
|
||||||
1.1
|
|
||||||
|
|
||||||
=head1 BUGS
|
|
||||||
|
|
||||||
None known
|
|
||||||
|
|
||||||
=head1 AUTHOR
|
|
||||||
|
|
||||||
Unknown. Mantained by António Almeida <appa@perusio.net>
|
|
||||||
|
|
||||||
=head1 REPOSITORY
|
|
||||||
|
|
||||||
Source code at http://github.com/perusio/nginx-munin
|
|
||||||
|
|
||||||
=head1 LICENSE
|
|
||||||
|
|
||||||
MIT
|
|
||||||
|
|
||||||
=cut
|
|
||||||
|
|
||||||
my $ret = undef;
|
|
||||||
|
|
||||||
if (! eval "require LWP::UserAgent;") {
|
|
||||||
$ret = "LWP::UserAgent not found";
|
|
||||||
}
|
|
||||||
|
|
||||||
chomp(my $fqdn=`hostname -f`);
|
|
||||||
|
|
||||||
## Environment defined variables.
|
|
||||||
## The default URL is nginx_status if different set it in the environment.
|
|
||||||
my $URL = exists $ENV{'url'} ? $ENV{'url'} : "http://$fqdn/nginx_status";
|
|
||||||
## The default user agent is ngnix-status-verifier/0.1 if different
|
|
||||||
## set it in the environment.
|
|
||||||
my $UA = exists $ENV{'ua'} ? $ENV{'ua'} : 'nginx-status-verifier/0.1';
|
|
||||||
|
|
||||||
|
|
||||||
## Munin autoconf method.
|
|
||||||
if (exists $ARGV[0] and $ARGV[0] eq "autoconf" ) {
|
|
||||||
if ($ret) {
|
|
||||||
print "no ($ret)\n";
|
|
||||||
exit 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
my $ua = LWP::UserAgent->new(timeout => 30);
|
|
||||||
# Set the UA to something different from the libwww-perl.
|
|
||||||
# This UA is blocked.
|
|
||||||
$ua->agent($UA);
|
|
||||||
my $response = $ua->request(HTTP::Request->new('GET',$URL));
|
|
||||||
|
|
||||||
unless ($response->is_success and $response->content =~ /server/im) {
|
|
||||||
print "no (no nginx status on $URL)\n";
|
|
||||||
exit 1;
|
|
||||||
} else {
|
|
||||||
print "yes\n";
|
|
||||||
exit 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
## Munin config method.
|
|
||||||
if (exists $ARGV[0] and $ARGV[0] eq "config") {
|
|
||||||
print "graph_title NGINX status\n";
|
|
||||||
print "graph_args --base 1000\n";
|
|
||||||
print "graph_category nginx\n";
|
|
||||||
print "graph_vlabel Connections\n";
|
|
||||||
|
|
||||||
print "total.label Active connections\n";
|
|
||||||
print "total.info Active connections\n";
|
|
||||||
print "total.draw LINE2\n";
|
|
||||||
|
|
||||||
print "reading.label Reading\n";
|
|
||||||
print "reading.info Reading\n";
|
|
||||||
print "reading.draw LINE2\n";
|
|
||||||
|
|
||||||
print "writing.label Writing\n";
|
|
||||||
print "writing.info Writing\n";
|
|
||||||
print "writing.draw LINE2\n";
|
|
||||||
|
|
||||||
print "waiting.label Waiting\n";
|
|
||||||
print "waiting.info Waiting\n";
|
|
||||||
print "waiting.draw LINE2\n";
|
|
||||||
|
|
||||||
exit 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
my $ua = LWP::UserAgent->new(timeout => 30);
|
|
||||||
# Set the UA to something different from the libwww-perl.
|
|
||||||
# That UA is blocked.
|
|
||||||
$ua->agent($UA);
|
|
||||||
my $response = $ua->request(HTTP::Request->new('GET',$URL));
|
|
||||||
|
|
||||||
# Active connections: 1845
|
|
||||||
# server accepts handled requests
|
|
||||||
# 4566318 4566318 84218236
|
|
||||||
# Reading: 2 Writing: 278 Waiting: 1565
|
|
||||||
if ($response->content =~ /Active connections:\s+(\d+).*Reading:\s+(\d+).*Writing:\s+(\d+).*Waiting:\s+(\d+)/s) {
|
|
||||||
print "total.value $1\n";
|
|
||||||
print "reading.value $2\n";
|
|
||||||
print "writing.value $3\n";
|
|
||||||
print "waiting.value $4\n";
|
|
||||||
} else {
|
|
||||||
foreach (qw(total reading writing waiting)) {
|
|
||||||
print "$_.value U\n";
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,99 +0,0 @@
|
|||||||
#!/usr/bin/perl
|
|
||||||
#
|
|
||||||
# $Log$
|
|
||||||
# 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.3 2003/12/18 19:02:36 jimmyo
|
|
||||||
# Typo
|
|
||||||
#
|
|
||||||
# Revision 1.2 2003/12/18 17:14:24 jimmyo
|
|
||||||
# Added autoconf-support
|
|
||||||
#
|
|
||||||
# Revision 1.1 2003/11/10 18:51:50 jimmyo
|
|
||||||
# Initial entries
|
|
||||||
#
|
|
||||||
#%# family=manual
|
|
||||||
#%# capabilities=autoconf
|
|
||||||
|
|
||||||
my $ret = undef;
|
|
||||||
|
|
||||||
if (! eval "require Net::IRC;")
|
|
||||||
{
|
|
||||||
$ret = "Net::IRC not found";
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($ARGV[0] and $ARGV[0] eq "autoconf")
|
|
||||||
{
|
|
||||||
if ($ret)
|
|
||||||
{
|
|
||||||
print "no ($ret)\n";
|
|
||||||
exit 1;
|
|
||||||
}
|
|
||||||
my $irc = new Net::IRC;
|
|
||||||
my $conn;
|
|
||||||
|
|
||||||
$irc = new Net::IRC; $conn = $irc->newconn(Nick => 'munin', Server => '192.168.1.1');
|
|
||||||
if (!$conn)
|
|
||||||
{
|
|
||||||
print "no (Couldn't connect to IRC server)\n";
|
|
||||||
exit 1;
|
|
||||||
}
|
|
||||||
print "yes\n";
|
|
||||||
exit 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if($ARGV[0] and $ARGV[0] eq "config") {
|
|
||||||
print "host_name $ENV{FQDN}\n";
|
|
||||||
print "graph_title ircd status\n";
|
|
||||||
print "graph_order clients channels\n";
|
|
||||||
print "graph_args -l 0\n";
|
|
||||||
print "clients.label clients\n";
|
|
||||||
print "clients.draw LINE2\n";
|
|
||||||
print "channels.label channels\n";
|
|
||||||
print "channels.draw LINE2\n";
|
|
||||||
exit 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
my $irc = new Net::IRC;
|
|
||||||
my $conn = $irc->newconn(Nick => 'munin',
|
|
||||||
Server => '192.168.1.1');
|
|
||||||
|
|
||||||
my %result;
|
|
||||||
#$conn->debug(1);
|
|
||||||
|
|
||||||
sub luserclient {
|
|
||||||
my($self, $event) = @_;
|
|
||||||
if(($event->args)[1] =~ /There are (\d+) users and (\d+) invisible/) {
|
|
||||||
$result{'clients'} = $1 + $2 - 1; # don't count this script
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sub luserchannels {
|
|
||||||
my($self, $event) = @_;
|
|
||||||
if(($event->args)[1] =~ /^(\d+)/) {
|
|
||||||
$result{'channels'} = $1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sub quit {
|
|
||||||
my($self, $event) = @_;
|
|
||||||
open(STDERR, ">/dev/null");
|
|
||||||
$self->quit();
|
|
||||||
print "clients.value " . $result{'clients'} . "\n";
|
|
||||||
print "channels.value " . $result{'channels'} . "\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
$conn->add_global_handler('endofmotd', \&quit);
|
|
||||||
$conn->add_global_handler('luserclient', \&luserclient);
|
|
||||||
$conn->add_global_handler('luserchannels', \&luserchannels);
|
|
||||||
|
|
||||||
|
|
||||||
while(1) {
|
|
||||||
$irc->do_one_loop();
|
|
||||||
}
|
|
||||||
|
|
||||||
# vim:syntax=perl
|
|
@ -1,117 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
#
|
|
||||||
# Plugin to graph perdition connections and errors
|
|
||||||
# Requires: logtail
|
|
||||||
#
|
|
||||||
# Copyright Micah Anderson <micah@riseup.net>
|
|
||||||
# Jan 23, 2005
|
|
||||||
#
|
|
||||||
#
|
|
||||||
#%# family=contrib
|
|
||||||
#%# capabilities=autoconf
|
|
||||||
|
|
||||||
# The different log lines we are interested in:
|
|
||||||
#
|
|
||||||
# buffy perdition[7583]: Connect: 64.45.82.181->69.50.164.185
|
|
||||||
# buffy perdition[20097]: Close: 217.19.50.108->69.50.74.154 user="mek" received=12 sent=23
|
|
||||||
# buffy perdition[7435]: Auth: 130.22.173.20->69.90.134.185 user="gotn" server="192.168.0.2" port="143" status="ok"
|
|
||||||
# buffy perdition[26986]: Auth: 72.13.2.186->69.92.134.215 user="moves" server="192.168.0.2" port="110" status="ok"
|
|
||||||
|
|
||||||
# Then there are some errors, I'm just going to put these all into one line, they could easily be
|
|
||||||
# separate out if we were interested in how many of each type of error, but 7 lines for this graph is a lot
|
|
||||||
# buffy perdition[20908]: Fatal Error reading authentication information from client "203.52.112.34->68.92.124.155": Exiting child
|
|
||||||
# buffy perdition[27754]: Fatal error establishing SSL connection to client
|
|
||||||
# buffy perdition[5139]: Fatal error negotiating setup. Exiting child.
|
|
||||||
|
|
||||||
# Changelog
|
|
||||||
# version 0.1 - Jan 23, 2005
|
|
||||||
# Micah Anderson <micah@riseup.net>
|
|
||||||
# - initial author
|
|
||||||
# version 0.2 - Oct 10, 2007
|
|
||||||
# Micah Anderson <micah@riseup.net>
|
|
||||||
# - fixed copyright and added changelog
|
|
||||||
# - added TMP env variable
|
|
||||||
# - set all TEMP_FILE variables to use $TMP
|
|
||||||
|
|
||||||
# Set the location of the perdition logs
|
|
||||||
PERDITION_LOG=${logfile:-/var/log/perdition.log}
|
|
||||||
OFFSET_FILE=/var/lib/munin/plugin-state/perdition.offset
|
|
||||||
LOGTAIL=${logtail:-/usr/sbin/logtail}
|
|
||||||
TMP=${TMP:-/tmp}
|
|
||||||
|
|
||||||
case `uname -s` in
|
|
||||||
Linux)
|
|
||||||
TEMP_FILE=`mktemp -p $TMP/ munin-perdition.XXXXXX`
|
|
||||||
if [ $? != 0 ]; then
|
|
||||||
TEMP_FILE=`mktemp $TMP/munin-perdition.XXXXXX`
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
FreeBSD)
|
|
||||||
TEMP_FILE=`mktemp -t $TMP`
|
|
||||||
STATUS=$?
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
if [ -z "$TEMP_FILE" ]; then
|
|
||||||
# Yes, this is unsafe
|
|
||||||
TEMP_FILE=$TMP/munin-perdition.$$
|
|
||||||
rm -rf $TEMP_FILE
|
|
||||||
touch $TEMP_FILE
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -f "$TEMP_FILE" ]; then
|
|
||||||
exit 3
|
|
||||||
fi
|
|
||||||
|
|
||||||
case $1 in
|
|
||||||
autoconf|detect)
|
|
||||||
if [ -f ${PERDITION_LOG} -a -x ${LOGTAIL} ]
|
|
||||||
then
|
|
||||||
echo yes
|
|
||||||
exit 0
|
|
||||||
else
|
|
||||||
echo "no (either $PERDITION_LOG was not found, or logtail was not in your path)"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
config)
|
|
||||||
cat <<EOF
|
|
||||||
graph_title Perdition Connections
|
|
||||||
graph_vlabel Number of Connections
|
|
||||||
graph_total Total
|
|
||||||
connection.label connections
|
|
||||||
disconnected.label disconnections
|
|
||||||
imap.label IMAP Auths
|
|
||||||
pop.label POP Auths
|
|
||||||
fatal.label Fatal Errors
|
|
||||||
EOF
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
ARGS=0
|
|
||||||
`$LOGTAIL /etc/hosts 2>/dev/null >/dev/null`
|
|
||||||
if [ $? = 66 ]; then
|
|
||||||
if [ ! -n "$logtail" ]; then
|
|
||||||
ARGS=1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ $ARGS != 0 ]; then
|
|
||||||
${LOGTAIL} -f ${PERDITION_LOG} -o ${OFFSET_FILE} > ${TEMP_FILE}
|
|
||||||
else
|
|
||||||
${LOGTAIL} ${PERDITION_LOG} ${OFFSET_FILE} > ${TEMP_FILE}
|
|
||||||
fi
|
|
||||||
connection=`grep "Connect:" ${TEMP_FILE} | wc -l`
|
|
||||||
disconnected=`grep "Close:" ${TEMP_FILE} | wc -l`
|
|
||||||
imap=`grep 'port="143" status="ok"' ${TEMP_FILE} | wc -l`
|
|
||||||
pop=`grep 'port="110" status="ok"' ${TEMP_FILE} | wc -l`
|
|
||||||
fatal=`grep 'Fatal [e|E]rror' ${TEMP_FILE} | wc -l`
|
|
||||||
|
|
||||||
rm ${TEMP_FILE}
|
|
||||||
|
|
||||||
echo "connection.value ${connection}"
|
|
||||||
echo "disconnected.value ${disconnected}"
|
|
||||||
echo "imap.value ${imap}"
|
|
||||||
echo "pop.value ${pop}"
|
|
||||||
echo "fatal.value ${fatal}"
|
|
@ -1,61 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
#
|
|
||||||
# Script to monitor number of processes. Programs are configured
|
|
||||||
# in /etc/munin/plugin-conf.d/munin-node
|
|
||||||
#
|
|
||||||
# Parameters:
|
|
||||||
#
|
|
||||||
# config (required)
|
|
||||||
# autoconf (optional - used by lrrd-config)
|
|
||||||
#
|
|
||||||
# Configuration example
|
|
||||||
#
|
|
||||||
# [multips]
|
|
||||||
# env.multipsnames pop3d imapd sslwrap
|
|
||||||
# env.regex_imapd ^[0-9]* imapd:
|
|
||||||
# env.regex_pop3d ^[0-9]* pop3d:
|
|
||||||
#
|
|
||||||
# $Log$
|
|
||||||
# Revision 1.1 2004/01/29 19:42:45 jimmyo
|
|
||||||
# Added a new plugin generic/multips to count several procs in one graph. (SF#885579)
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# Magic markers (optional):
|
|
||||||
#%# family=manual
|
|
||||||
#%# capabilities=autoconf
|
|
||||||
|
|
||||||
if [ "$1" = "autoconf" ]; then
|
|
||||||
if [ -z "$multipsnames" ]; then
|
|
||||||
echo "Configuration required $multipsnames"
|
|
||||||
else
|
|
||||||
echo yes
|
|
||||||
fi
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$1" = "config" ]; then
|
|
||||||
|
|
||||||
echo graph_title Number of selected processes
|
|
||||||
echo 'graph_category processes'
|
|
||||||
echo 'graph_args --base 1000 --vertical-label processes -l 0'
|
|
||||||
for name in $multipsnames; do
|
|
||||||
echo "$name.label $name"
|
|
||||||
echo "$name.draw LINE2"
|
|
||||||
done
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
for name in $multipsnames; do
|
|
||||||
printf "$name.value "
|
|
||||||
|
|
||||||
eval REGEX='"${regex_'$name'-\<'$name'\>}"'
|
|
||||||
PGREP=`which pgrep`
|
|
||||||
if [ -n "$PGREP" ]; then
|
|
||||||
$PGREP -f -l "$name" | grep "$REGEX" | wc -l
|
|
||||||
elif [ -x /usr/ucb/ps ]; then
|
|
||||||
# Solaris without pgrep. How old is that?
|
|
||||||
/usr/ucb/ps auxwww | grep "$REGEX" | grep -v grep | wc -l
|
|
||||||
else
|
|
||||||
ps auxwww | grep "$REGEX" | grep -v grep | wc -l
|
|
||||||
fi
|
|
||||||
done
|
|
@ -1,97 +0,0 @@
|
|||||||
#!/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;
|
|
||||||
|
|
@ -1,111 +0,0 @@
|
|||||||
#!/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
|
|
@ -1,110 +0,0 @@
|
|||||||
#!/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
|
|
@ -1,105 +0,0 @@
|
|||||||
#!/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));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,806 +0,0 @@
|
|||||||
#!/usr/bin/perl -w
|
|
||||||
#
|
|
||||||
# varnish_ - Munin plugin for Multiple Varnish Servers
|
|
||||||
# Copyright (C) 2009 Redpill Linpro AS
|
|
||||||
#
|
|
||||||
# Author: Kristian Lyngstøl <kristian@redpill-linpro.com>
|
|
||||||
# Modified by Paul Mansfield so that it can be used with multiple
|
|
||||||
# varnish instances
|
|
||||||
#
|
|
||||||
# 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.,
|
|
||||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
|
|
||||||
use strict;
|
|
||||||
|
|
||||||
# Set to 1 to enable output when a variable is defined in a graph but
|
|
||||||
# omitted because it doesn't exist in varnishstat.
|
|
||||||
my $DEBUG = 0;
|
|
||||||
|
|
||||||
# Set to 1 to ignore 'DEBUG' and suggest all available aspects.
|
|
||||||
my $FULL_SUGGEST = 0;
|
|
||||||
|
|
||||||
# Varnishstat executable. Include full path if it's not in your path.
|
|
||||||
my $varnishstatexec = exists $ENV{'varnishstat'} ? $ENV{'varnishstat'} : "varnishstat";
|
|
||||||
|
|
||||||
# For multiple instances
|
|
||||||
my $varnishname = exists $ENV{'name'} ? $ENV{'name'} : undef;
|
|
||||||
|
|
||||||
my %varnishstat = ();
|
|
||||||
my %varnishstatnames = ();
|
|
||||||
my $self; # Haha, myself, what a clever pun.
|
|
||||||
|
|
||||||
# Parameters that can be defined on top level of a graph. Config will print
|
|
||||||
# them as "graph_$foo $value\n"
|
|
||||||
my @graph_parameters = ('title','total','order','scale','vlabel','args');
|
|
||||||
|
|
||||||
# Parameters that can be defined on a value-to-value basis and will be
|
|
||||||
# blindly passed to config. Printed as "$fieldname.$param $value\n".
|
|
||||||
#
|
|
||||||
# 'label' is hardcoded as it defaults to a varnishstat-description if not
|
|
||||||
# set.
|
|
||||||
my @field_parameters = ('graph', 'min', 'max', 'draw', 'cdef', 'warning',
|
|
||||||
'colour', 'info', 'type');
|
|
||||||
|
|
||||||
# Data structure that defines all possible graphs (aspects) and how they
|
|
||||||
# are to be plotted. Every top-level entry is a graph/aspect. Each top-level graph
|
|
||||||
# MUST have title set and 'values'.
|
|
||||||
#
|
|
||||||
# The 'values' hash must have at least one value definition. The actual
|
|
||||||
# value used is either fetched from varnishstat based on the value-name, or
|
|
||||||
# if 'rpn' is defined: calculated. 'type' SHOULD be set.
|
|
||||||
#
|
|
||||||
# Graphs with 'DEBUG' set to anything is omitted from 'suggest'.
|
|
||||||
#
|
|
||||||
# 'rpn' on values allows easy access to graphs consisting of multiple
|
|
||||||
# values from varnishstat. (Reverse polish notation). The RPN
|
|
||||||
# implementation only accepts +-*/ and varnishstat-values.
|
|
||||||
#
|
|
||||||
# With the exception of 'label', which is filled with the
|
|
||||||
# varnishstat-description if left undefined, any value left undefined will
|
|
||||||
# be left up to Munin to define/ignore/yell about.
|
|
||||||
#
|
|
||||||
# See munin documentation or rrdgraph/rrdtool for more information.
|
|
||||||
my %ASPECTS = (
|
|
||||||
'request_rate' => {
|
|
||||||
'title' => 'Request rates',
|
|
||||||
'order' => 'cache_hit cache_hitpass cache_miss '
|
|
||||||
. 'backend_conn backend_unhealthy '
|
|
||||||
. 'client_req client_conn' ,
|
|
||||||
'values' => {
|
|
||||||
'client_conn' => {
|
|
||||||
'type' => 'DERIVE',
|
|
||||||
'min' => '0',
|
|
||||||
'colour' => '444444',
|
|
||||||
'graph' => 'ON'
|
|
||||||
},
|
|
||||||
'client_req' => {
|
|
||||||
'type' => 'DERIVE',
|
|
||||||
'colour' => '111111',
|
|
||||||
'min' => '0'
|
|
||||||
},
|
|
||||||
'cache_hit' => {
|
|
||||||
'type' => 'DERIVE',
|
|
||||||
'draw' => 'AREA',
|
|
||||||
'colour' => '00FF00',
|
|
||||||
'min' => '0'
|
|
||||||
},
|
|
||||||
'cache_hitpass' => {
|
|
||||||
'info' => 'Hitpass are cached passes: An '
|
|
||||||
. 'entry in the cache instructing '
|
|
||||||
. 'Varnish to pass. Typically '
|
|
||||||
. 'achieved after a pass in '
|
|
||||||
. 'vcl_fetch.',
|
|
||||||
'type' => 'DERIVE',
|
|
||||||
'draw' => 'STACK',
|
|
||||||
'colour' => 'FFFF00',
|
|
||||||
'min' => '0'
|
|
||||||
},
|
|
||||||
'cache_miss' => {
|
|
||||||
'type' => 'DERIVE',
|
|
||||||
'colour' => 'FF0000',
|
|
||||||
'draw' => 'STACK',
|
|
||||||
'min' => '0'
|
|
||||||
},
|
|
||||||
'backend_conn' => {
|
|
||||||
'type' => 'DERIVE',
|
|
||||||
'colour' => '995599',
|
|
||||||
'min' => '0'
|
|
||||||
},
|
|
||||||
'backend_unhealthy' => {
|
|
||||||
'colour' => 'FF55FF',
|
|
||||||
'type' => 'GAUGE'
|
|
||||||
},
|
|
||||||
's_pipe' => {
|
|
||||||
'type' => 'DERIVE',
|
|
||||||
'min' => '0',
|
|
||||||
'colour' => '1d2bdf'
|
|
||||||
},
|
|
||||||
's_pass' => {
|
|
||||||
'type' => 'DERIVE',
|
|
||||||
'min' => '0',
|
|
||||||
'colour' => '785d0d'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'hit_rate' => {
|
|
||||||
'title' => 'Hit rates',
|
|
||||||
'order' => 'client_req cache_hit cache_miss '
|
|
||||||
. 'cache_hitpass' ,
|
|
||||||
'vlabel' => '%',
|
|
||||||
'args' => '-u 100 --rigid',
|
|
||||||
'scale' => 'no',
|
|
||||||
'values' => {
|
|
||||||
'client_req' => {
|
|
||||||
'type' => 'DERIVE',
|
|
||||||
'min' => '0',
|
|
||||||
'graph' => 'off'
|
|
||||||
},
|
|
||||||
'cache_hit' => {
|
|
||||||
'type' => 'DERIVE',
|
|
||||||
'min' => '0',
|
|
||||||
'draw' => 'AREA',
|
|
||||||
'cdef' => 'cache_hit,client_req,/,100,*'
|
|
||||||
},
|
|
||||||
'cache_miss' => {
|
|
||||||
'type' => 'DERIVE',
|
|
||||||
'draw' => 'STACK',
|
|
||||||
'min' => '0',
|
|
||||||
'cdef' => 'cache_miss,client_req,/,100,*'
|
|
||||||
},
|
|
||||||
'cache_hitpass' => {
|
|
||||||
'type' => 'DERIVE',
|
|
||||||
'draw' => 'STACK',
|
|
||||||
'min' => '0',
|
|
||||||
'cdef' => 'cache_hitpass,client_req,/,100,*'
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'backend_traffic' => {
|
|
||||||
'title' => 'Backend traffic',
|
|
||||||
'values' => {
|
|
||||||
'backend_conn' => {
|
|
||||||
'type' => 'DERIVE',
|
|
||||||
'min' => '0'
|
|
||||||
},
|
|
||||||
'backend_unhealthy' => {
|
|
||||||
'type' => 'GAUGE',
|
|
||||||
'min' => '0',
|
|
||||||
'warning' => ':1'
|
|
||||||
},
|
|
||||||
'backend_busy' => {
|
|
||||||
'type' => 'DERIVE',
|
|
||||||
'min' => '0'
|
|
||||||
},
|
|
||||||
'backend_fail' => {
|
|
||||||
'type' => 'DERIVE',
|
|
||||||
'min' => '0'
|
|
||||||
},
|
|
||||||
'backend_reuse' => {
|
|
||||||
'type' => 'DERIVE',
|
|
||||||
'min' => 0
|
|
||||||
},
|
|
||||||
'backend_recycle' => {
|
|
||||||
'type' => 'DERIVE',
|
|
||||||
'min' => 0
|
|
||||||
},
|
|
||||||
'backend_unused' => {
|
|
||||||
'type' => 'DERIVE',
|
|
||||||
'min' => '0'
|
|
||||||
},
|
|
||||||
'backend_req' => {
|
|
||||||
'type' => 'DERIVE',
|
|
||||||
'min' => '0'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'objects' => {
|
|
||||||
'title' => 'Number of objects',
|
|
||||||
'values' => {
|
|
||||||
'n_object' => {
|
|
||||||
'type' => 'GAUGE',
|
|
||||||
'label' => 'Number of objects'
|
|
||||||
},
|
|
||||||
'n_objecthead' => {
|
|
||||||
'type' => 'GAUGE',
|
|
||||||
'label' => 'Number of object heads',
|
|
||||||
'info' => 'Each object head can have one '
|
|
||||||
. 'or more ojbect attached, '
|
|
||||||
. 'typically based on the Vary: header'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'transfer_rates' => {
|
|
||||||
'title' => 'Transfer rates',
|
|
||||||
'order' => 's_bodybytes s_hdrbytes',
|
|
||||||
'args' => '-l 0',
|
|
||||||
'vlabel' => 'bit/s',
|
|
||||||
'values' => {
|
|
||||||
's_hdrbytes' => {
|
|
||||||
'type' => 'DERIVE',
|
|
||||||
'label' => 'Header traffic',
|
|
||||||
'draw' => 'STACK',
|
|
||||||
'min' => '0',
|
|
||||||
'info' => 'HTTP Header traffic. TCP/IP '
|
|
||||||
. 'overhead is not included.',
|
|
||||||
'cdef' => 's_hdrbytes,8,*'
|
|
||||||
},
|
|
||||||
's_bodybytes' => {
|
|
||||||
'type' => 'DERIVE',
|
|
||||||
'draw' => 'AREA',
|
|
||||||
'label' => 'Body traffic',
|
|
||||||
'min' => '0',
|
|
||||||
'cdef' => 's_bodybytes,8,*'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'threads' => {
|
|
||||||
'title' => 'Thread status',
|
|
||||||
'values' => {
|
|
||||||
'n_wrk' => {
|
|
||||||
'type' => 'GAUGE',
|
|
||||||
'min' => '0',
|
|
||||||
'warning' => '1:'
|
|
||||||
},
|
|
||||||
'n_wrk_create' => {
|
|
||||||
'type' => 'DERIVE',
|
|
||||||
'min' => '0'
|
|
||||||
},
|
|
||||||
'n_wrk_failed' => {
|
|
||||||
'type' => 'DERIVE',
|
|
||||||
'min' => '0',
|
|
||||||
'warning' => ':1'
|
|
||||||
},
|
|
||||||
'n_wrk_max' => {
|
|
||||||
'type' => 'DERIVE',
|
|
||||||
'min' => '0'
|
|
||||||
},
|
|
||||||
'n_wrk_overflow' => {
|
|
||||||
'type' => 'DERIVE',
|
|
||||||
'min' => '0'
|
|
||||||
},
|
|
||||||
'n_wrk_drop' => {
|
|
||||||
'type' => 'DERIVE',
|
|
||||||
'min' => '0',
|
|
||||||
'warning' => ':1'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'memory_usage' => {
|
|
||||||
'title' => 'Memory usage',
|
|
||||||
'order' => 'sm_balloc sma_nbytes sms_nbytes',
|
|
||||||
'total' => 'Total',
|
|
||||||
'args' => '--base 1024',
|
|
||||||
'values' => {
|
|
||||||
'sm_balloc' => {
|
|
||||||
'type' => 'GAUGE',
|
|
||||||
'draw' => 'AREA'
|
|
||||||
},
|
|
||||||
'sma_nbytes' => {
|
|
||||||
'type' => 'GAUGE',
|
|
||||||
'draw' => 'STACK'
|
|
||||||
},
|
|
||||||
'sms_nbytes' => {
|
|
||||||
'type' => 'GAUGE',
|
|
||||||
'draw' => 'STACK'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'uptime' => {
|
|
||||||
'title' => 'Varnish uptime',
|
|
||||||
'vlabel' => 'days',
|
|
||||||
'scale' => 'no',
|
|
||||||
'values' => {
|
|
||||||
'uptime' => {
|
|
||||||
'type' => 'GAUGE',
|
|
||||||
'cdef' => 'uptime,86400,/'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'objects_per_objhead' => {
|
|
||||||
'title' => 'Objects per objecthead',
|
|
||||||
'DEBUG' => 'yes',
|
|
||||||
'values' => {
|
|
||||||
'obj_per_objhead' => {
|
|
||||||
'type' => 'GAUGE',
|
|
||||||
'label' => 'Objects per object heads',
|
|
||||||
'rpn' => [ 'n_object','n_objecthead','/' ]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'losthdr' => {
|
|
||||||
'title' => 'HTTP Header overflows',
|
|
||||||
'DEBUG' => 'yes',
|
|
||||||
'values' => {
|
|
||||||
'losthdr' => {
|
|
||||||
'type' => 'DERIVE',
|
|
||||||
'min' => '0'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'obj_sendfile_vs_write' => {
|
|
||||||
'title' => 'Objects delivered with sendfile() versus '
|
|
||||||
. 'write()',
|
|
||||||
'DEBUG' => 'yes',
|
|
||||||
'values' => {
|
|
||||||
'n_objsendfile' => {
|
|
||||||
'type' => 'DERIVE',
|
|
||||||
'min' => '0',
|
|
||||||
},
|
|
||||||
'n_objwrite' => {
|
|
||||||
'type' => 'DERIVE',
|
|
||||||
'min' => '0'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'hcb' => {
|
|
||||||
'title' => 'Critbit data',
|
|
||||||
'DEBUG' => 'yes',
|
|
||||||
'values' => {
|
|
||||||
'hcb_nolock' => {
|
|
||||||
'type' => 'DERIVE',
|
|
||||||
'min' => '0'
|
|
||||||
},
|
|
||||||
'hcb_lock' => {
|
|
||||||
'type' => 'DERIVE',
|
|
||||||
'min' => '0'
|
|
||||||
},
|
|
||||||
'hcb_insert' => {
|
|
||||||
'type' => 'DERIVE',
|
|
||||||
'min' => '0'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'esi' => {
|
|
||||||
'title' => 'ESI',
|
|
||||||
'DEBUG' => 'yes',
|
|
||||||
'values' => {
|
|
||||||
'esi_parse' => {
|
|
||||||
'type' => 'DERIVE',
|
|
||||||
'min' => '0'
|
|
||||||
},
|
|
||||||
'esi_errors' => {
|
|
||||||
'type' => 'DERIVE',
|
|
||||||
'min' => '0'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'objoverflow' => {
|
|
||||||
'title' => 'Objects overflowing workspace',
|
|
||||||
'DEBUG' => 'yes',
|
|
||||||
'values' => {
|
|
||||||
'n_objoverflow' => {
|
|
||||||
'type' => 'DERIVE',
|
|
||||||
'min' => '0'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'session' => {
|
|
||||||
'title' => 'Sessions',
|
|
||||||
'DEBUG' => 'yes',
|
|
||||||
'values' => {
|
|
||||||
'sess_closed' => {
|
|
||||||
'type' => 'DERIVE',
|
|
||||||
'min' => '0'
|
|
||||||
},
|
|
||||||
'sess_pipeline' => {
|
|
||||||
'type' => 'DERIVE',
|
|
||||||
'min' => '0'
|
|
||||||
},
|
|
||||||
'sess_readahead' => {
|
|
||||||
'type' => 'DERIVE',
|
|
||||||
'min' => '0'
|
|
||||||
},
|
|
||||||
'sess_linger' => {
|
|
||||||
'type' => 'DERIVE',
|
|
||||||
'min' => '0'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'session_herd' => {
|
|
||||||
'title' => 'Session herd',
|
|
||||||
'DEBUG' => 'yes',
|
|
||||||
'values' => {
|
|
||||||
'sess_herd' => {
|
|
||||||
'type' => 'DERIVE',
|
|
||||||
'min' => '0'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'shm_writes' => {
|
|
||||||
'title' => 'SHM writes and records',
|
|
||||||
'DEBUG' => 'yes',
|
|
||||||
'values' => {
|
|
||||||
'shm_records' => {
|
|
||||||
'type' => 'DERIVE',
|
|
||||||
'min' => '0'
|
|
||||||
},
|
|
||||||
'shm_writes' => {
|
|
||||||
'type' => 'DERIVE',
|
|
||||||
'min' => '0'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'shm' => {
|
|
||||||
'title' => 'Shared memory activity',
|
|
||||||
'DEBUG' => 'yes',
|
|
||||||
'values' => {
|
|
||||||
'shm_flushes' => {
|
|
||||||
'type' => 'DERIVE',
|
|
||||||
'min' => '0'
|
|
||||||
},
|
|
||||||
'shm_cont' => {
|
|
||||||
'type' => 'DERIVE',
|
|
||||||
'min' => '0'
|
|
||||||
},
|
|
||||||
'shm_cycles' => {
|
|
||||||
'type' => 'DERIVE',
|
|
||||||
'min' => '0'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'allocations' => {
|
|
||||||
'title' => 'Memory allocation requests',
|
|
||||||
'DEBUG' => 'yes',
|
|
||||||
'values' => {
|
|
||||||
'sm_nreq' => {
|
|
||||||
'type' => 'DERIVE',
|
|
||||||
'min' => '0'
|
|
||||||
},
|
|
||||||
'sma_nreq' => {
|
|
||||||
'type' => 'DERIVE',
|
|
||||||
'min' => '0'
|
|
||||||
},
|
|
||||||
'sms_nreq' => {
|
|
||||||
'type' => 'DERIVE',
|
|
||||||
'min' => '0'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'vcl_and_purges' => {
|
|
||||||
'title' => 'VCL and purges',
|
|
||||||
'DEBUG' => 'yes',
|
|
||||||
'values' => {
|
|
||||||
'n_backend' => {
|
|
||||||
'type' => 'GAUGE'
|
|
||||||
},
|
|
||||||
'n_vcl' => {
|
|
||||||
'type' => 'DERIVE',
|
|
||||||
'min' => '0'
|
|
||||||
},
|
|
||||||
'n_vcl_avail' => {
|
|
||||||
'type' => 'DERIVE',
|
|
||||||
'min' => '0'
|
|
||||||
},
|
|
||||||
'n_vcl_discard' => {
|
|
||||||
'type' => 'DERIVE',
|
|
||||||
'min' => '0'
|
|
||||||
},
|
|
||||||
'n_purge' => {
|
|
||||||
'type' => 'GAUGE'
|
|
||||||
},
|
|
||||||
'n_purge_add' => {
|
|
||||||
'type' => 'DERIVE',
|
|
||||||
'min' => '0'
|
|
||||||
},
|
|
||||||
'n_purge_retire' => {
|
|
||||||
'type' => 'DERIVE',
|
|
||||||
'min' => '0'
|
|
||||||
},
|
|
||||||
'n_purge_obj_test' => {
|
|
||||||
'type' => 'DERIVE',
|
|
||||||
'min' => '0'
|
|
||||||
},
|
|
||||||
'n_purge_re_test' => {
|
|
||||||
'type' => 'DERIVE',
|
|
||||||
'min' => '0'
|
|
||||||
},
|
|
||||||
'n_purge_dups' => {
|
|
||||||
'type' => 'DERIVE',
|
|
||||||
'min' => '0'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'expunge' => {
|
|
||||||
'title' => 'Object expunging',
|
|
||||||
'values' => {
|
|
||||||
'n_expired' => {
|
|
||||||
'type' => 'DERIVE',
|
|
||||||
'min' => '0'
|
|
||||||
},
|
|
||||||
'n_lru_nuked' => {
|
|
||||||
'type' => 'DERIVE',
|
|
||||||
'min' => '0'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'lru' => {
|
|
||||||
'title' => 'LRU activity',
|
|
||||||
'DEBUG' => 'yes',
|
|
||||||
'values' => {
|
|
||||||
'n_lru_saved' => {
|
|
||||||
'type' => 'DERIVE',
|
|
||||||
'min' => '0'
|
|
||||||
},
|
|
||||||
'n_lru_moved' => {
|
|
||||||
'type' => 'DERIVE',
|
|
||||||
'min' => '0'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'data_structures' => {
|
|
||||||
'DEBUG' => 'YES',
|
|
||||||
'title' => 'Data structure sizes',
|
|
||||||
'values' => {
|
|
||||||
'n_srcaddr' => {
|
|
||||||
'type' => 'GAUGE'
|
|
||||||
},
|
|
||||||
'n_srcaddr_act' => {
|
|
||||||
'type' => 'GAUGE'
|
|
||||||
},
|
|
||||||
'n_sess_mem' => {
|
|
||||||
'type' => 'GAUGE'
|
|
||||||
},
|
|
||||||
'n_sess' => {
|
|
||||||
'type' => 'GAUGE'
|
|
||||||
},
|
|
||||||
'n_smf' => {
|
|
||||||
'type' => 'GAUGE'
|
|
||||||
},
|
|
||||||
'n_smf_frag' => {
|
|
||||||
'type' => 'GAUGE'
|
|
||||||
},
|
|
||||||
'n_smf_large' => {
|
|
||||||
'type' => 'GAUGE'
|
|
||||||
},
|
|
||||||
'n_vbe_conn' => {
|
|
||||||
'type' => 'GAUGE'
|
|
||||||
},
|
|
||||||
'n_bereq' => {
|
|
||||||
'type' => 'GAUGE'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
# Populate %varnishstat with values and %varnishstatnames with
|
|
||||||
# descriptions.
|
|
||||||
sub populate_stats
|
|
||||||
{
|
|
||||||
my $arg = "-1";
|
|
||||||
if ($varnishname) {
|
|
||||||
$arg .= " -n $varnishname";
|
|
||||||
}
|
|
||||||
foreach my $line (`$varnishstatexec $arg`) {
|
|
||||||
chomp($line);
|
|
||||||
if ($line =~ /^([^ ]*)\s+(\d+)\s+(\d*\.\d*)\s+(.*)$/) {
|
|
||||||
$varnishstat{"$1"} = $2;
|
|
||||||
$varnishstatnames{"$1"} = $4;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Bail-function.
|
|
||||||
sub usage
|
|
||||||
{
|
|
||||||
if (defined(@_) && "@_" ne "") {
|
|
||||||
print STDERR "@_" . "\n\n";
|
|
||||||
}
|
|
||||||
print STDERR "Known arguments: suggest, config, autoconf.\n";
|
|
||||||
print STDERR "Run with suggest to get a list of known aspects.\n";
|
|
||||||
exit 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
# Print 'yes' and exit true if it's reasonable to use this plugin.
|
|
||||||
# Otherwise exit with false and a human-readable reason.
|
|
||||||
sub autoconf
|
|
||||||
{
|
|
||||||
if (`which $varnishstatexec` eq '') {
|
|
||||||
print "no (which $varnishstatexec returns blank)\n";
|
|
||||||
exit 1;
|
|
||||||
}
|
|
||||||
print "yes\n";
|
|
||||||
exit 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
# Suggest relevant aspects/values of $self.
|
|
||||||
# 'DEBUG'-graphs are excluded.
|
|
||||||
sub suggest
|
|
||||||
{
|
|
||||||
foreach my $key (keys %ASPECTS) {
|
|
||||||
if (defined($ASPECTS{$key}{'DEBUG'}) && $FULL_SUGGEST != 1) {
|
|
||||||
next;
|
|
||||||
}
|
|
||||||
print "$key\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Print the value of a two-dimensional hash if it exist.
|
|
||||||
# Returns false if non-existant.
|
|
||||||
#
|
|
||||||
# Output is formatted for plugins if arg4 is blank, otherwise arg4 is used
|
|
||||||
# as the title/name of the field (ie: arg4=graph_titel).
|
|
||||||
sub print_if_exist
|
|
||||||
{
|
|
||||||
my %values = %{$_[0]};
|
|
||||||
my $value = $_[1];
|
|
||||||
my $field = $_[2];
|
|
||||||
my $title = "$value.$field";
|
|
||||||
if (defined($_[3])) {
|
|
||||||
$title = $_[3];
|
|
||||||
}
|
|
||||||
if (defined($values{$value}{$field})) {
|
|
||||||
print "$title $values{$value}{$field}";
|
|
||||||
print " - $varnishname" if ($title eq 'graph_title');
|
|
||||||
print "\n";
|
|
||||||
} else {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Walk through the relevant aspect and print all top-level configuration
|
|
||||||
# values and value-definitions.
|
|
||||||
sub get_config
|
|
||||||
{
|
|
||||||
my $graph = $_[0];
|
|
||||||
|
|
||||||
# Need to double-check since set_aspect only checks this if there
|
|
||||||
# is no argument (suggest/autoconf doesn't require a valid aspect)
|
|
||||||
if (!defined($ASPECTS{$graph})) {
|
|
||||||
usage "No such aspect";
|
|
||||||
}
|
|
||||||
my %values = %{$ASPECTS{$graph}{'values'}};
|
|
||||||
|
|
||||||
print "graph_category Varnish\n";
|
|
||||||
foreach my $field (@graph_parameters) {
|
|
||||||
print_if_exist(\%ASPECTS,$graph,$field,"graph_$field");
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach my $value (keys %values) {
|
|
||||||
# Need either RPN definition or a varnishstat value.
|
|
||||||
if (!defined($varnishstat{$value}) &&
|
|
||||||
!defined($values{$value}{'rpn'})) {
|
|
||||||
if ($DEBUG) {
|
|
||||||
print "ERROR: $value not part of varnishstat.\n"
|
|
||||||
}
|
|
||||||
next;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!print_if_exist(\%values,$value,'label')) {
|
|
||||||
print "$value.label $varnishstatnames{$value}\n";
|
|
||||||
}
|
|
||||||
foreach my $field (@field_parameters) {
|
|
||||||
print_if_exist(\%values,$value,$field);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Read and verify the aspect ($self) -
|
|
||||||
# the format is varnish_NAME__aspect or varnish_aspect
|
|
||||||
sub set_aspect
|
|
||||||
{
|
|
||||||
$self = $0;
|
|
||||||
$self =~ s/^.*\/varnish_//;
|
|
||||||
|
|
||||||
if ($self =~ /^(\w+)__(.*)$/)
|
|
||||||
{
|
|
||||||
$varnishname = $1;
|
|
||||||
$self = $2;
|
|
||||||
}
|
|
||||||
if (!defined($ASPECTS{$self}) && @ARGV == 0) {
|
|
||||||
usage "No such aspect";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Handle arguments (config, autoconf, suggest)
|
|
||||||
# Populate stats for config is necessary, but we want to avoid it for
|
|
||||||
# autoconf as it would generate a nasty error.
|
|
||||||
sub check_args
|
|
||||||
{
|
|
||||||
if (@ARGV && $ARGV[0] eq '') {
|
|
||||||
shift @ARGV;
|
|
||||||
}
|
|
||||||
if (@ARGV == 1) {
|
|
||||||
if ($ARGV[0] eq "config") {
|
|
||||||
populate_stats;
|
|
||||||
get_config($self);
|
|
||||||
exit 0;
|
|
||||||
} elsif ($ARGV[0] eq "autoconf") {
|
|
||||||
autoconf($self);
|
|
||||||
exit 0;
|
|
||||||
} elsif ($ARGV[0] eq "suggest") {
|
|
||||||
suggest;
|
|
||||||
exit 0;
|
|
||||||
}
|
|
||||||
usage "Unknown argument";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Braindead RPN: +,-,/,* will pop two items from @stack, and perform
|
|
||||||
# the relevant operation on the items. If the item in the array isn't one
|
|
||||||
# of the 4 basic math operations, a value from varnishstat is pushed on to
|
|
||||||
# the stack. IE: 'client_req','client_conn','/' will leave the value of
|
|
||||||
# "client_req/client_conn" on the stack.
|
|
||||||
#
|
|
||||||
# If only one item is left on the stack, it is printed. Otherwise, an error
|
|
||||||
# message is printed.
|
|
||||||
sub rpn
|
|
||||||
{
|
|
||||||
my @stack;
|
|
||||||
my $left;
|
|
||||||
my $right;
|
|
||||||
foreach my $item (@{$_[0]}) {
|
|
||||||
if ($item eq "+") {
|
|
||||||
$right = pop(@stack);
|
|
||||||
$left = pop(@stack);
|
|
||||||
push(@stack,$left+$right);
|
|
||||||
} elsif ($item eq "-") {
|
|
||||||
$right = pop(@stack);
|
|
||||||
$left = pop(@stack);
|
|
||||||
push(@stack,$left-$right);
|
|
||||||
} elsif ($item eq "/") {
|
|
||||||
$right = pop(@stack);
|
|
||||||
$left = pop(@stack);
|
|
||||||
push(@stack,$left/$right);
|
|
||||||
} elsif ($item eq "*") {
|
|
||||||
$right = pop(@stack);
|
|
||||||
$left = pop(@stack);
|
|
||||||
push(@stack,$left*$right);
|
|
||||||
} else {
|
|
||||||
push(@stack,int($varnishstat{$item}));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (@stack > 1)
|
|
||||||
{
|
|
||||||
print STDERR "RPN error: Stack has more than one item left.\n";
|
|
||||||
print STDERR "@stack\n";
|
|
||||||
exit 255;
|
|
||||||
}
|
|
||||||
print "@stack";
|
|
||||||
print "\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
################################
|
|
||||||
# Execution starts here #
|
|
||||||
################################
|
|
||||||
|
|
||||||
set_aspect;
|
|
||||||
check_args;
|
|
||||||
populate_stats;
|
|
||||||
|
|
||||||
# We only get here if we're supposed to.
|
|
||||||
|
|
||||||
# Walks through the relevant values and either prints the varnishstat, or
|
|
||||||
# if the 'rpn' variable is set, calls rpn() to execute ... the rpn.
|
|
||||||
#
|
|
||||||
# NOTE: Due to differences in varnish-versions, this checks if the value
|
|
||||||
# actually exist before using it.
|
|
||||||
foreach my $value (keys %{$ASPECTS{$self}{'values'}}) {
|
|
||||||
if (defined($ASPECTS{$self}{'values'}{$value}{'rpn'})) {
|
|
||||||
print "$value.value ";
|
|
||||||
rpn($ASPECTS{$self}{'values'}{$value}{'rpn'});
|
|
||||||
} else {
|
|
||||||
if (!defined($varnishstat{$value})) {
|
|
||||||
if ($DEBUG) {
|
|
||||||
print STDERR "Error: $value not part of "
|
|
||||||
. "varnishstat.\n";
|
|
||||||
}
|
|
||||||
next;
|
|
||||||
}
|
|
||||||
#print "$varnishname.$value.value ";
|
|
||||||
print "$value.value ";
|
|
||||||
print "$varnishstat{$value}\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# end varnish_ plugin
|
|
@ -1,190 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
#
|
|
||||||
# Copyright (C) 2006-2008 Holger Levsen and Micah Anderson
|
|
||||||
#
|
|
||||||
# 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.
|
|
||||||
|
|
||||||
# Graph Vserver cpu usage stats
|
|
||||||
#
|
|
||||||
# Configuration variables
|
|
||||||
# vservers - specify the vservers to include in the graph (default: all)
|
|
||||||
#
|
|
||||||
# NOTE: If no configuration variable is set, the default will be used
|
|
||||||
#
|
|
||||||
# see vserver_resources for example uses of configuration files
|
|
||||||
#
|
|
||||||
# or links to define what to monitor:
|
|
||||||
# vserver_cpu_ -> monitor cpu usage of all vservers on all cpus
|
|
||||||
# vserver_hold_ -> monitor hold on all vservers on all cpus
|
|
||||||
# vserver_hold_0 -> monitor hold on all vservers on cpu0
|
|
||||||
# vserver_hold_1 -> monitor hold on all vservers on cpu1
|
|
||||||
# vserver_hold_foo -> monitor hold on all cpus on vserver named foo
|
|
||||||
# vserver_sys_foo -> monitor cpu usage on all cpus on vserver named foo
|
|
||||||
|
|
||||||
# Changelog
|
|
||||||
# version 0.2 - 2006 October 02 Holger Levsen <debian@layer-acht.org>
|
|
||||||
# - label fixed: we measure jiffies not seconds
|
|
||||||
# - Fix error that results if NodeName is set to include a domain name
|
|
||||||
# - Fix hypens in NodeNames, replace them with underscores
|
|
||||||
# - whitespace cleanup
|
|
||||||
# version 0.3 - 2006 October 07 Holger Levsen <debian@layer-acht.org>
|
|
||||||
# - rewrite of vserver_usercpu
|
|
||||||
# - smp-aware
|
|
||||||
# - can display hold too (third value in the cpu line(s) of /proc/virtual/<xid>/sched)
|
|
||||||
# - no seperation between user and system cpu anymore
|
|
||||||
# - handle identical vserver-names by using the vserver-id internally
|
|
||||||
# version 0.4 - 2007, October 07
|
|
||||||
# Micah Anderson <micah@riseup.net>
|
|
||||||
# - fixed variable name (thanks pietro)
|
|
||||||
# version 0.5 - 2008, July 07
|
|
||||||
# Micah Anderson <micah@riseup.net>
|
|
||||||
# - fixed number of CPU regexp to be more accurate
|
|
||||||
# - added $NAMELOC - fixes plugin so it works with VCI_SPACES (> 2.6.19) as well as older version
|
|
||||||
|
|
||||||
# TODO:
|
|
||||||
# - comment the code or go mad
|
|
||||||
# - add info how many jiffies per second are available on a machine
|
|
||||||
# - user and system cpu are always added to each other, make it optional to split them?
|
|
||||||
# - use /proc less often (100 times more overhead than talking to the kernel directly)
|
|
||||||
# i.e. use something like pagesize=`perl -MPOSIX -e 'print POSIX::sysconf(_SC_PAGESIZE), "\n";'`
|
|
||||||
|
|
||||||
|
|
||||||
VSERVERS="$vservers"
|
|
||||||
|
|
||||||
INFO=(`sed 's/.*:\t//' /proc/virtual/info 2>/dev/null || echo '<none>'`)
|
|
||||||
KCIN="$[ 16#${INFO[2]} ]";
|
|
||||||
|
|
||||||
# If this is 1, then VCI_SPACES is present in the kernel (new in 2.6.19)
|
|
||||||
if [ $[ (KCIN >> 10) & 1 ] -eq 1 ]
|
|
||||||
then
|
|
||||||
NAMELOC="nsproxy"
|
|
||||||
else
|
|
||||||
NAMELOC="cvirt"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -z "$VSERVERS" ] ; then
|
|
||||||
XIDS=`find /proc/virtual/* -type d -exec basename {} \;`
|
|
||||||
else
|
|
||||||
# it's really more performant to specify vservers by ids or by linking but not in the configuration-file by name
|
|
||||||
XIDS=""
|
|
||||||
for i in $VSERVERS ; do
|
|
||||||
if [ -d /proc/virtual/$i ] ; then
|
|
||||||
XIDS="${XIDS}${i} "
|
|
||||||
else
|
|
||||||
for j in `find /proc/virtual/* -type d -exec basename {} \;` ; do
|
|
||||||
if [ "$i" = "`cat /proc/virtual/$j/$NAMELOC |grep NodeName |cut -f2`" ] ; then
|
|
||||||
XIDS="${XIDS}${j} "
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
|
|
||||||
BASEPARAM=`basename $0 | sed 's/^vserver_//'`
|
|
||||||
MODE=`echo $BASEPARAM | sed 's/^hold.*//'`
|
|
||||||
|
|
||||||
#debug=true
|
|
||||||
|
|
||||||
if [ -z "$MODE" ] ; then
|
|
||||||
MODE=hold
|
|
||||||
TARGET=`echo $BASEPARAM | sed 's/^hold_//'`
|
|
||||||
else
|
|
||||||
MODE=cpu
|
|
||||||
TARGET=`echo $BASEPARAM | sed 's/^cpu_//'`
|
|
||||||
fi
|
|
||||||
|
|
||||||
CPU1=0
|
|
||||||
if [ -n "$TARGET" ] ; then
|
|
||||||
if [ "${#TARGET}" == 1 ] ; then
|
|
||||||
if [ $debug ] ; then echo $MODE, only on cpu $TARGET, for all vservers ; fi
|
|
||||||
WHAT=ALLVSERVER
|
|
||||||
CPU1=$TARGET
|
|
||||||
else
|
|
||||||
if [ $debug ] ; then echo $MODE on all cpus together, only for vserver $TARGET ; fi
|
|
||||||
WHAT=VSERVER
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
if [ $debug ] ; then echo $MODE for all cpus, for all vservers ; fi
|
|
||||||
WHAT=ALLVSERVER
|
|
||||||
fi
|
|
||||||
|
|
||||||
CPUS=$[ `grep ^processor /proc/cpuinfo|wc -l` -1 ]
|
|
||||||
CPUS=`seq $CPU1 $CPUS`
|
|
||||||
|
|
||||||
if [ $debug ] ; then
|
|
||||||
echo cpus= $CPUS
|
|
||||||
echo baseparam= $BASEPARAM
|
|
||||||
echo mode= $MODE
|
|
||||||
echo target= $TARGET
|
|
||||||
echo what= $WHAT
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$1" = "config" ]; then
|
|
||||||
echo 'graph_category vserver'
|
|
||||||
echo 'graph_args --base 1000'
|
|
||||||
if [ "$MODE" == "cpu" ] ; then
|
|
||||||
echo 'graph_title Vserver cpu usage'
|
|
||||||
echo 'graph_vlabel jiffies used per cpu per ${graph_period}'
|
|
||||||
echo 'graph_info Shows jiffies used per cpu on each vserver.'
|
|
||||||
else
|
|
||||||
echo 'graph_title Vserver cpu on hold'
|
|
||||||
echo 'graph_vlabel jiffies on hold per cpu per ${graph_period}'
|
|
||||||
echo 'graph_info Shows jiffies on hold used per cpu on each vserver.'
|
|
||||||
fi
|
|
||||||
|
|
||||||
for j in $CPUS ; do
|
|
||||||
A=0
|
|
||||||
for i in $XIDS ; do
|
|
||||||
LABEL=`cat /proc/virtual/$i/$NAMELOC |grep NodeName |cut -f2`
|
|
||||||
if [ "$WHAT" == "ALLVSERVER" ] || [ "$TARGET" == "$LABEL" ] ; then
|
|
||||||
NAME=`echo $LABEL | cut -d. -f1 | tr '-' '_'`
|
|
||||||
if [ "$MODE" == "cpu" ] ; then
|
|
||||||
echo "${NAME}_$j.label cpu usage for cpu $j on $LABEL"
|
|
||||||
echo "${NAME}_$j.info cpu usage for cpu $j on $LABEL."
|
|
||||||
else
|
|
||||||
echo "${NAME}_$j.label on hold for cpu $j on $LABEL"
|
|
||||||
echo "${NAME}_$j.info on hold for cpu $j on $LABEL."
|
|
||||||
fi
|
|
||||||
echo "${NAME}_$j.type COUNTER"
|
|
||||||
if [ "$A" == 0 ] ; then
|
|
||||||
echo "${NAME}_$j.draw AREA"
|
|
||||||
A=1
|
|
||||||
else
|
|
||||||
echo "${NAME}_$j.draw STACK"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
done
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
for j in $CPUS ; do
|
|
||||||
for i in $XIDS ; do
|
|
||||||
LABEL=`cat /proc/virtual/$i/$NAMELOC |grep NodeName |cut -f2`
|
|
||||||
if [ "$WHAT" == "ALLVSERVER" ] || [ "$TARGET" == "$LABEL" ] ; then
|
|
||||||
NAME=`echo $LABEL | cut -d. -f1 | tr '-' '_'`
|
|
||||||
echo -n "${NAME}_$j.value "
|
|
||||||
if [ "$MODE" == "cpu" ] ; then
|
|
||||||
USERCPU=`cat /proc/virtual/$i/sched |grep "cpu $j"| cut -d' ' -f3`
|
|
||||||
SYSCPU=`cat /proc/virtual/$i/sched |grep "cpu $j"| cut -d' ' -f4`
|
|
||||||
echo $[$USERCPU + $SYSCPU]
|
|
||||||
else
|
|
||||||
cat /proc/virtual/$i/sched |grep "cpu $j"| cut -d' ' -f5
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
done
|
|
||||||
|
|
||||||
|
|
@ -1,123 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
#
|
|
||||||
# Copyright (C) 2007 Andrei Morgan
|
|
||||||
# Copyright (C) 2008 Micah Anderson
|
|
||||||
#
|
|
||||||
# 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.
|
|
||||||
|
|
||||||
# Graph Vserver load average
|
|
||||||
#
|
|
||||||
# Configuration variables
|
|
||||||
# vservers - specify the vservers to include in the graph (default: all)
|
|
||||||
#
|
|
||||||
# NOTE: If no configuration variables are set, the defaults will be used
|
|
||||||
|
|
||||||
# Example /etc/munin/plugin-conf.d/munin-node
|
|
||||||
#
|
|
||||||
# The following monitors the load average for vservers 1 and 3:
|
|
||||||
#
|
|
||||||
# [vserver_loadavg]
|
|
||||||
# user root
|
|
||||||
# env.vservers vserver1 vserver3
|
|
||||||
|
|
||||||
# Changelog
|
|
||||||
# version 0.1 - 2007 June 26
|
|
||||||
# Andrei Morgan <asm-debian@fifthhorseman.net>
|
|
||||||
# - initial author, based upon vserver_resources by Holger Levsen and
|
|
||||||
# Micah Anderson, and upon the examples in the munin wiki.
|
|
||||||
# version 0.2 - 2008 July 7
|
|
||||||
# Micah Anderson <micah@riseup.net>
|
|
||||||
# - fix cvirt vs. nsproxy issue with newer kernels by adding $NAMELOC which
|
|
||||||
# is aware of VCI_SPACES (> 2.6.19) as well as the older version
|
|
||||||
|
|
||||||
# If run with the "autoconf"-parameter, give our opinion on whether we
|
|
||||||
# should be run on this system or not. This is optional, and only used by
|
|
||||||
# munin-config. In the case of this plugin, we should most probably
|
|
||||||
# always be included whwn there is a vserver kernel.
|
|
||||||
|
|
||||||
if [ "$1" = "autoconf" ]; then
|
|
||||||
echo yes
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
# if vservers are specified, use them; the default is to use all.
|
|
||||||
VSERVERS="$vservers"
|
|
||||||
|
|
||||||
INFO=(`sed 's/.*:\t//' /proc/virtual/info 2>/dev/null || echo '<none>'`)
|
|
||||||
KCIN="$[ 16#${INFO[2]} ]";
|
|
||||||
|
|
||||||
# If this is 1, then VCI_SPACES is present in the kernel (new in 2.6.19)
|
|
||||||
if [ $[ (KCIN >> 10) & 1 ] -eq 1 ]
|
|
||||||
then
|
|
||||||
NAMELOC="nsproxy"
|
|
||||||
else
|
|
||||||
NAMELOC="cvirt"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -z "$VSERVERS" ] ; then
|
|
||||||
XIDS=`find /proc/virtual/* -type d -exec basename {} \;`
|
|
||||||
else
|
|
||||||
# it's really more performant to specify vservers by ids or not at all
|
|
||||||
XIDS=""
|
|
||||||
for i in $VSERVERS ; do
|
|
||||||
if [ -d /proc/virtual/$i ] ; then
|
|
||||||
XIDS="${XIDS}${i} "
|
|
||||||
else
|
|
||||||
for j in `find /proc/virtual/* -type d -exec basename {} \;` ; do
|
|
||||||
if [ "$i" = "`cat /proc/virtual/$j/$NAMELOC |grep NodeName |cut -f2`" ] ; then
|
|
||||||
XIDS="${XIDS}${j} "
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
|
|
||||||
# If run with the "config"-parameter, give out information on how the
|
|
||||||
# graphs should look.
|
|
||||||
if [ "$1" = "config" ]; then
|
|
||||||
# The title of the graph
|
|
||||||
echo 'graph_title loadavg of vserver'
|
|
||||||
# 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'
|
|
||||||
# We want Cur/Min/Avg/Max unscaled (i.e. 0.42 load instead of
|
|
||||||
# 420 milliload)
|
|
||||||
echo 'graph_scale no'
|
|
||||||
# The Y-axis label
|
|
||||||
echo 'graph_vlabel loadavg'
|
|
||||||
# graph information for the main table
|
|
||||||
echo 'graph_info Shows 5-minute load average per vserver.'
|
|
||||||
# Graph category. Defaults to 'other'
|
|
||||||
echo 'graph_category vserver'
|
|
||||||
for xid in $XIDS ; do
|
|
||||||
# Specify the vservers
|
|
||||||
LABEL=`cat /proc/virtual/$xid/$NAMELOC |grep NodeName |cut -f2`
|
|
||||||
NAME=`echo $LABEL | cut -d. -f1 | tr '-' '_'`
|
|
||||||
echo "$NAME.label $LABEL: load average"
|
|
||||||
echo "$NAME.info $NAME average load for the past 5 minutes"
|
|
||||||
done
|
|
||||||
# Last, if run with the "config"-parameter, quit here (don't
|
|
||||||
# display any data)
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
for xid in $XIDS ; do
|
|
||||||
LABEL=`cat /proc/virtual/$xid/$NAMELOC |grep NodeName |cut -f2`
|
|
||||||
NAME=`echo $LABEL | cut -d. -f1 | tr '-' '_'`
|
|
||||||
echo -n "$NAME.value ";
|
|
||||||
cat /proc/virtual/$xid/cvirt | grep loadavg: | cut -d' ' -f2
|
|
||||||
done
|
|
||||||
|
|
@ -1,317 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
#
|
|
||||||
# Copyright (C) 2006-2008 Holger Levsen, Micah Anderson
|
|
||||||
#
|
|
||||||
# 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.
|
|
||||||
|
|
||||||
# Graph Vserver resource usage and limits
|
|
||||||
#
|
|
||||||
# Configuration variables
|
|
||||||
# vservers - specify the vservers to include in the graph (default: all)
|
|
||||||
# resource - specify the resource to be monitored (no default)
|
|
||||||
# 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 following monitors the RSS value for 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:
|
|
||||||
#
|
|
||||||
# [vserver_resources]
|
|
||||||
# user root
|
|
||||||
# env.vservers vserver1 vserver2 vserver3 vserver4
|
|
||||||
# env.resource RSS
|
|
||||||
# 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
|
|
||||||
#
|
|
||||||
# This second example monitors the VM value for all vservers on the system and
|
|
||||||
# has no limit notifications turned on:
|
|
||||||
#
|
|
||||||
# [vserver_resources]
|
|
||||||
# user root
|
|
||||||
# env.vservers vserver5 vserver6 vserver7
|
|
||||||
# env.resource VM
|
|
||||||
# env.limits 0
|
|
||||||
#
|
|
||||||
# This last example monitors all the resources for vserver5. Note that
|
|
||||||
# this will be a busy graph, and it would be really useless if you
|
|
||||||
# specified more than one vserver when the resource is set to ALL:
|
|
||||||
#
|
|
||||||
# [vserver_resources]
|
|
||||||
# user root
|
|
||||||
# env.vservers vserver5
|
|
||||||
# env.resource ALL
|
|
||||||
# env.limits 0
|
|
||||||
|
|
||||||
# Possible values for env.resource are:
|
|
||||||
#
|
|
||||||
# ALL - all the below resources
|
|
||||||
# PROC - number of processes
|
|
||||||
# VM - sum of all virtual pages inside the guest
|
|
||||||
# VML - sum of all virtual pages locked into memory
|
|
||||||
# RSS - number of pages currently present in RAM
|
|
||||||
# ANON - number of anonymous memory pages
|
|
||||||
# FILES - number of open files
|
|
||||||
# OFD
|
|
||||||
# LOCKS
|
|
||||||
# SOCK
|
|
||||||
# MSGQ
|
|
||||||
# SHM - number of shared memory pages
|
|
||||||
|
|
||||||
# Changelog
|
|
||||||
# version 0.1 - 2006 April xx
|
|
||||||
# Holger Levsen <debian@layer-acht.org>
|
|
||||||
# - 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
|
|
||||||
# version 0.5 - 2006 Oct
|
|
||||||
# Micah Anderson <micah@riseup.net>
|
|
||||||
# - fixed changelog entries so more changes can happen per version
|
|
||||||
# - standardized changelog date and name format
|
|
||||||
# - added myself to copyright
|
|
||||||
# - standardized indentation
|
|
||||||
# - abstracted from just RSS to be usable for any resource specified
|
|
||||||
# Holger Levsen <debian@layer-acht.org>
|
|
||||||
# - Fix hypens in NodeNames, replace them with underscores
|
|
||||||
# - Fix the fix from version 0.4
|
|
||||||
# - allow specifying the ressource by linking
|
|
||||||
# (ln -s vserver_resources vserver_VM)
|
|
||||||
# - provided info about all resources
|
|
||||||
# - code cleaned
|
|
||||||
# - errors if an invalid resource is specified
|
|
||||||
# - handle identical vserver-names by using the vserver-id internally
|
|
||||||
# version 0.6 - 2007 Oct
|
|
||||||
# Micah Anderson <micah@riseup.net>
|
|
||||||
# - removed BASENAME - plugin isn't a wildcard plugin any longer
|
|
||||||
# - added $NAMELOC - fixes plugin so it works with VCI_SPACES (> 2.6.19) as well as older version
|
|
||||||
#
|
|
||||||
# TODO:
|
|
||||||
# - make it so you can specify more than one resource to be graphed?
|
|
||||||
# or define combined ressource-display: VM+RSS+ANON+SHM and FILES+OFD+LOCK+SOCK
|
|
||||||
# (for one vserver only)
|
|
||||||
# - and/or make it so you can graph all resources for one vserver
|
|
||||||
# - set a default for the resource if it is unset?
|
|
||||||
# - use /proc less often (100 times more overhead than talking to the kernel directly)
|
|
||||||
# i.e. use something like pagesize=`perl -MPOSIX -e 'print POSIX::sysconf(_SC_PAGESIZE), "\n";'`
|
|
||||||
# - ALL resource is broken
|
|
||||||
|
|
||||||
VSERVERS="$vservers"
|
|
||||||
LIMITS="$limits"
|
|
||||||
RESOURCE="$resource"
|
|
||||||
|
|
||||||
INFO=(`sed 's/.*:\t//' /proc/virtual/info 2>/dev/null || echo '<none>'`)
|
|
||||||
KCIN="$[ 16#${INFO[2]} ]";
|
|
||||||
|
|
||||||
# If this is 1, then VCI_SPACES is present in the kernel (new in 2.6.19)
|
|
||||||
if [ $[ (KCIN >> 10) & 1 ] -eq 1 ]
|
|
||||||
then
|
|
||||||
NAMELOC="nsproxy"
|
|
||||||
else
|
|
||||||
NAMELOC="cvirt"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -z "$VSERVERS" ] ; then
|
|
||||||
XIDS=`find /proc/virtual/* -type d -exec basename {} \;`
|
|
||||||
else
|
|
||||||
# it's really more performant to specify vservers by ids or not at all
|
|
||||||
XIDS=""
|
|
||||||
for i in $VSERVERS ; do
|
|
||||||
if [ -d /proc/virtual/$i ] ; then
|
|
||||||
XIDS="${XIDS}${i} "
|
|
||||||
else
|
|
||||||
for j in `find /proc/virtual/* -type d -exec basename {} \;` ; do
|
|
||||||
if [ "$i" = "`cat /proc/virtual/$j/$NAMELOC |grep NodeName |cut -f2`" ] ; then
|
|
||||||
XIDS="${XIDS}${j} "
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$1" = "config" ]; then
|
|
||||||
case "$RESOURCE" in
|
|
||||||
PROC)
|
|
||||||
echo 'graph_title Processes used by vserver'
|
|
||||||
echo 'graph_args --base 1024k -l 0'
|
|
||||||
echo 'graph_vlabel Processes'
|
|
||||||
echo 'graph_info Shows the number of processes used by each vserver.'
|
|
||||||
;;
|
|
||||||
VM)
|
|
||||||
echo 'graph_title Virtual memory used by vserver'
|
|
||||||
echo 'graph_args --base 1024k -l 0'
|
|
||||||
echo 'graph_vlabel VM pages'
|
|
||||||
echo 'graph_info Shows virtual memory (human readable) used by each vserver.'
|
|
||||||
;;
|
|
||||||
VML)
|
|
||||||
echo 'graph_title Locked memory used by vserver'
|
|
||||||
echo 'graph_args --base 1024k -l 0'
|
|
||||||
echo 'graph_vlabel VML pages'
|
|
||||||
echo 'graph_info Shows locked memory (human readable) used by each vserver.'
|
|
||||||
;;
|
|
||||||
RSS)
|
|
||||||
echo 'graph_title Resident set size used by vserver'
|
|
||||||
echo 'graph_args --base 1024k -l 0'
|
|
||||||
echo 'graph_vlabel RSS pages'
|
|
||||||
echo 'graph_info Shows resident set size (human readable) used by each vserver.'
|
|
||||||
;;
|
|
||||||
ANON)
|
|
||||||
echo 'graph_title Anonymous memory used by vserver'
|
|
||||||
echo 'graph_args --base 1024k -l 0'
|
|
||||||
echo 'graph_vlabel ANON pages'
|
|
||||||
echo 'graph_info Shows anonymous memory (human readable) used by each vserver.'
|
|
||||||
;;
|
|
||||||
FILES)
|
|
||||||
echo 'graph_title Files used by vserver'
|
|
||||||
echo 'graph_args --base 1024k -l 0'
|
|
||||||
echo 'graph_vlabel Files'
|
|
||||||
echo 'graph_info Shows files used by each vserver.'
|
|
||||||
;;
|
|
||||||
OFD)
|
|
||||||
echo 'graph_title Open filedescriptors used by vserver'
|
|
||||||
echo 'graph_args --base 1024k -l 0'
|
|
||||||
echo 'graph_vlabel Open filedescriptors'
|
|
||||||
echo 'graph_info Shows open filedescriptors used by each vserver.'
|
|
||||||
;;
|
|
||||||
LOCKS)
|
|
||||||
echo 'graph_title Locks used by vserver'
|
|
||||||
echo 'graph_args --base 1024k -l 0'
|
|
||||||
echo 'graph_vlabel Locks'
|
|
||||||
echo 'graph_info Shows locks used by each vserver.'
|
|
||||||
;;
|
|
||||||
SOCK)
|
|
||||||
echo 'graph_title Sockets used by vserver'
|
|
||||||
echo 'graph_args --base 1024k -l 0'
|
|
||||||
echo 'graph_vlabel Sockets'
|
|
||||||
echo 'graph_info Shows sockets used by each vserver.'
|
|
||||||
;;
|
|
||||||
MSGQ)
|
|
||||||
echo 'graph_title Message queues used by vserver'
|
|
||||||
echo 'graph_args --base 1024k -l 0'
|
|
||||||
echo 'graph_vlabel Message queues'
|
|
||||||
echo 'graph_info Shows message queues used by each vserver.'
|
|
||||||
;;
|
|
||||||
SHM)
|
|
||||||
echo 'graph_title Shared memory used by vserver'
|
|
||||||
echo 'graph_args --base 1024k -l 0'
|
|
||||||
echo 'graph_vlabel SHM pages'
|
|
||||||
echo 'graph_info Shows shared memory (human readable) used by each vserver.'
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "$RESOURCE not defined."
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
echo 'graph_category vserver'
|
|
||||||
|
|
||||||
|
|
||||||
# do not assume we are on i386 where pagesize is 4096...
|
|
||||||
pagesize=`perl -MPOSIX -e 'print POSIX::sysconf(_SC_PAGESIZE), "\n";'`
|
|
||||||
|
|
||||||
for xid in $XIDS ; do
|
|
||||||
|
|
||||||
LABEL=`cat /proc/virtual/$xid/$NAMELOC |grep NodeName |cut -f2`
|
|
||||||
NAME=`echo $LABEL | cut -d. -f1 | tr '-' '_'`
|
|
||||||
|
|
||||||
case "$RESOURCE" in
|
|
||||||
PROC)
|
|
||||||
echo "$NAME.label $LABEL: processes"
|
|
||||||
echo "$NAME.info Number of processes used by $LABEL."
|
|
||||||
;;
|
|
||||||
VM)
|
|
||||||
echo "$NAME.label $LABEL: Virtual memory"
|
|
||||||
echo "$NAME.info Size of virtual memory used by $LABEL. (Number multipled by $pagesize to make it human readable)"
|
|
||||||
echo "$NAME.cdef $NAME,$pagesize,*"
|
|
||||||
;;
|
|
||||||
VML)
|
|
||||||
echo "$NAME.label $LABEL: Locked memory"
|
|
||||||
echo "$NAME.info Size of locked memory used by $LABEL. (Number multipled by $pagesize to make it human readable)"
|
|
||||||
echo "$NAME.cdef $NAME,$pagesize,*"
|
|
||||||
;;
|
|
||||||
RSS)
|
|
||||||
echo "$NAME.label $LABEL: Resident set size"
|
|
||||||
echo "$NAME.info Size of resident set size used by $LABEL. (Number multiplied by $pagesize to make it human readable)"
|
|
||||||
echo "$NAME.cdef $NAME,$pagesize,*"
|
|
||||||
;;
|
|
||||||
ANON)
|
|
||||||
echo "$NAME.label $LABEL: Anonymous memory"
|
|
||||||
echo "$NAME.info Size of anonymous memory used by $LABEL. (Number multiplied by $pagesize to make it human readable)"
|
|
||||||
echo "$NAME.cdef $NAME,$pagesize,*"
|
|
||||||
;;
|
|
||||||
FILES)
|
|
||||||
echo "$NAME.label $LABEL: Files"
|
|
||||||
echo "$NAME.info Number of files used by $LABEL."
|
|
||||||
;;
|
|
||||||
OFD)
|
|
||||||
echo "$NAME.label $LABEL: Open filedescriptors"
|
|
||||||
echo "$NAME.info Number of open filedescriptors used by $LABEL."
|
|
||||||
;;
|
|
||||||
LOCKS)
|
|
||||||
echo "$NAME.label $LABEL: Locks"
|
|
||||||
echo "$NAME.info Number of locks used by $LABEL."
|
|
||||||
;;
|
|
||||||
SOCK)
|
|
||||||
echo "$NAME.label $LABEL: Sockets"
|
|
||||||
echo "$NAME.info Number of sockets used by $LABEL."
|
|
||||||
;;
|
|
||||||
MSGQ)
|
|
||||||
echo "$NAME.label $LABEL: Message queues"
|
|
||||||
echo "$NAME.info Number of message queues used by $LABEL."
|
|
||||||
;;
|
|
||||||
SHM)
|
|
||||||
echo "$NAME.label $LABEL: Shared memory"
|
|
||||||
echo "$NAME.info Size of shared memory used by $LABEL. (Number multiplied by $pagesize to make it human readable)"
|
|
||||||
echo "$NAME.cdef $1,$pagesize,*"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "$RESOURCE not defined."
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
if [ ! -z "$LIMITS" -a "$LIMITS" = 1 ]; then
|
|
||||||
LIMIT=`cat /proc/virtual/$xid/limit | grep $RESOURCE | cut -f4`
|
|
||||||
if [ ${LIMIT:-0} -gt 0 ]; then
|
|
||||||
echo "$NAME.critical $LIMIT"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
for xid in $XIDS ; do
|
|
||||||
LABEL=`cat /proc/virtual/$xid/$NAMELOC |grep NodeName |cut -f2`
|
|
||||||
NAME=`echo $LABEL | cut -d. -f1 | tr '-' '_'`
|
|
||||||
cat /proc/virtual/$xid/limit | awk -v name="${NAME}" -v resource="${RESOURCE}:" \
|
|
||||||
'{ if ( $1 == resource )
|
|
||||||
printf "%s.value %d\n", name, $2 }'
|
|
||||||
done
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user