Révision 62d43835
remove plugins existing in the main munin distribution
| plugins/disk/snmp__netapp_diskusage_ | ||
|---|---|---|
| 1 |
#!/usr/bin/perl |
|
| 2 |
|
|
| 3 |
=head1 NAME |
|
| 4 |
|
|
| 5 |
snmp__netapp_diskusage_ - Munin plugin to retrieve file systems usage on |
|
| 6 |
NetApp storage appliances. |
|
| 7 |
|
|
| 8 |
=head1 APPLICABLE SYSTEMS |
|
| 9 |
|
|
| 10 |
File systems usage stats should be reported by any NetApp storage |
|
| 11 |
appliance with SNMP agent daemon activated. See na_snmp(8) for details. |
|
| 12 |
|
|
| 13 |
=head1 CONFIGURATION |
|
| 14 |
|
|
| 15 |
Unfortunately, SNMPv3 is not fully supported on all NetApp equipments. |
|
| 16 |
For this reason, this plugin will use SNMPv2 by default, which is |
|
| 17 |
insecure because it doesn't encrypt the community string. |
|
| 18 |
|
|
| 19 |
The following parameters will help you get this plugin working : |
|
| 20 |
|
|
| 21 |
[snmp_*] |
|
| 22 |
env.community MyCommunity |
|
| 23 |
|
|
| 24 |
If your community name is 'public', you should really worry about |
|
| 25 |
security and immediately reconfigure your appliance. |
|
| 26 |
|
|
| 27 |
Please see 'perldoc Munin::Plugin::SNMP' for further configuration. |
|
| 28 |
|
|
| 29 |
=head1 INTERPRETATION |
|
| 30 |
|
|
| 31 |
The plugin reports file systems usage. This can help you monitoring file |
|
| 32 |
systems usage in a given period of time. |
|
| 33 |
|
|
| 34 |
=head1 MIB INFORMATION |
|
| 35 |
|
|
| 36 |
This plugin requires support for the NETWORK-APPLIANCE-MIB issued by |
|
| 37 |
Network Appliance. It reports the content of the DfEntry OID. |
|
| 38 |
|
|
| 39 |
=head1 MAGIC MARKERS |
|
| 40 |
|
|
| 41 |
#%# family=snmpauto |
|
| 42 |
#%# capabilities=snmpconf |
|
| 43 |
|
|
| 44 |
=head1 VERSION |
|
| 45 |
|
|
| 46 |
v1.0 - 06/22/2009 14:05:03 CEST |
|
| 47 |
Initial revision |
|
| 48 |
|
|
| 49 |
=head1 AUTHOR |
|
| 50 |
|
|
| 51 |
This plugin is copyright (c) 2009 by Guillaume Blairon. |
|
| 52 |
|
|
| 53 |
NetApp is a registered trademark and Network Appliance is a trademark |
|
| 54 |
of Network Appliance, Inc. in the U.S. and other countries. |
|
| 55 |
|
|
| 56 |
=head1 BUGS |
|
| 57 |
|
|
| 58 |
This plugin wasn't tested on many hardware. If you encounter bugs, |
|
| 59 |
please report them to Guillaume Blairon E<lt>L<g@yom.be>E<gt>. |
|
| 60 |
|
|
| 61 |
=head1 LICENSE |
|
| 62 |
|
|
| 63 |
GPLv2 or (at your option) any later version. |
|
| 64 |
|
|
| 65 |
=cut |
|
| 66 |
|
|
| 67 |
use strict; |
|
| 68 |
use warnings; |
|
| 69 |
use Munin::Plugin::SNMP; |
|
| 70 |
use vars qw($DEBUG); |
|
| 71 |
|
|
| 72 |
$DEBUG = $ENV{'MUNIN_DEBUG'};
|
|
| 73 |
|
|
| 74 |
my @palette = |
|
| 75 |
#Better colours from munin 1.3.x |
|
| 76 |
#Greens Blues Oranges Dk yel Dk blu Purple Lime Reds Gray |
|
| 77 |
qw(00CC00 0066B3 FF8000 FFCC00 330099 990099 CCFF00 FF0000 808080 |
|
| 78 |
008F00 00487D B35A00 B38F00 6B006B 8FB300 B30000 BEBEBE |
|
| 79 |
80FF80 80C9FF FFC080 FFE680 AA80FF EE00CC FF8080 |
|
| 80 |
666600 FFBFFF 00FFCC CC6699 999900); |
|
| 81 |
|
|
| 82 |
my %oids = ( |
|
| 83 |
|
|
| 84 |
# - dfHigh.* : 32 most significant bits counters |
|
| 85 |
# - dfLow.* : 32 least significant bits counters |
|
| 86 |
|
|
| 87 |
dfHighTotalKBytes => '1.3.6.1.4.1.789.1.5.4.1.14.', |
|
| 88 |
dfLowTotalKBytes => '1.3.6.1.4.1.789.1.5.4.1.15.', |
|
| 89 |
dfHighUsedKBytes => '1.3.6.1.4.1.789.1.5.4.1.16.', |
|
| 90 |
dfLowUsedKBytes => '1.3.6.1.4.1.789.1.5.4.1.17.', |
|
| 91 |
dfHighAvailKBytes => '1.3.6.1.4.1.789.1.5.4.1.18.', |
|
| 92 |
dfLowAvailKBytes => '1.3.6.1.4.1.789.1.5.4.1.19.', |
|
| 93 |
|
|
| 94 |
); |
|
| 95 |
|
|
| 96 |
sub to_32bit_int {
|
|
| 97 |
my ($l, $h) = @_; |
|
| 98 |
return "U" if ((!defined $l) || (!defined $h)); |
|
| 99 |
my $bin = unpack( 'B32', pack('N', $l) . pack('N', $h) );
|
|
| 100 |
return unpack( 'N', pack('B32', $bin) );
|
|
| 101 |
} |
|
| 102 |
|
|
| 103 |
if (defined $ARGV[0] and $ARGV[0] eq 'snmpconf') {
|
|
| 104 |
print "number 1.3.6.1.4.1.789.1.5.6.0\n"; |
|
| 105 |
print "index 1.3.6.1.4.1.789.1.5.4.1.1.\n"; |
|
| 106 |
foreach (keys %oids) {
|
|
| 107 |
print "require $oids{$_} [0-9]\n";
|
|
| 108 |
} |
|
| 109 |
exit 0; |
|
| 110 |
} |
|
| 111 |
|
|
| 112 |
my $session = Munin::Plugin::SNMP->session(); |
|
| 113 |
my ($host, undef, undef, $tail) = Munin::Plugin::SNMP->config_session(); |
|
| 114 |
my ($df_id, $name_oid); |
|
| 115 |
|
|
| 116 |
if ($tail =~ /^netapp_diskusage_(\d+)$/) {
|
|
| 117 |
$df_id = $1; |
|
| 118 |
$name_oid = '1.3.6.1.4.1.789.1.5.4.1.2.' . $df_id; |
|
| 119 |
} else {
|
|
| 120 |
die "Couldn't understand what I'm supposed to monitor"; |
|
| 121 |
} |
|
| 122 |
|
|
| 123 |
if (defined $ARGV[0] and $ARGV[0] eq "config") {
|
|
| 124 |
my $df_name = $session->get_single($name_oid); |
|
| 125 |
|
|
| 126 |
print "host_name $host\n" unless $host eq 'localhost'; |
|
| 127 |
print "graph_title $host disk usage on $df_name\n"; |
|
| 128 |
print "graph_args --base 1024 --lower-limit 0\n"; |
|
| 129 |
print "graph_vlabel bytes\n"; |
|
| 130 |
print "graph_category disk\n"; |
|
| 131 |
print "graph_info This graph shows the disk usage for $df_name on NetApp host $host\n"; |
|
| 132 |
print "graph_order used avail total\n"; |
|
| 133 |
print "used.info The total disk space in KBytes that is in use on the $df_name file system.\n"; |
|
| 134 |
print "used.type GAUGE\n"; |
|
| 135 |
print "used.draw AREA\n"; |
|
| 136 |
print "used.label Used\n"; |
|
| 137 |
print "used.cdef used,1024,*\n"; |
|
| 138 |
print "used.min 0\n"; |
|
| 139 |
print "used.colour $palette[1]\n"; |
|
| 140 |
print "avail.info The total disk space in KBytes that is free for use on the $df_name file system.\n"; |
|
| 141 |
print "avail.type GAUGE\n"; |
|
| 142 |
print "avail.draw STACK\n"; |
|
| 143 |
print "avail.label Available\n"; |
|
| 144 |
print "avail.cdef avail,1024,*\n"; |
|
| 145 |
print "avail.min 0\n"; |
|
| 146 |
print "avail.colour $palette[3]\n"; |
|
| 147 |
print "total.info The total capacity in KBytes for the $df_name file system.\n"; |
|
| 148 |
print "total.type GAUGE\n"; |
|
| 149 |
print "total.draw LINE2\n"; |
|
| 150 |
print "total.label Total\n"; |
|
| 151 |
print "total.cdef total,1024,*\n"; |
|
| 152 |
print "total.min 0\n"; |
|
| 153 |
print "total.colour $palette[7]\n"; |
|
| 154 |
|
|
| 155 |
exit 0; |
|
| 156 |
} |
|
| 157 |
|
|
| 158 |
my $used_l = $session->get_single($oids{dfLowUsedKBytes}.$df_id);
|
|
| 159 |
my $used_h = $session->get_single($oids{dfHighUsedKBytes}.$df_id);
|
|
| 160 |
my $avail_l = $session->get_single($oids{dfLowAvailKBytes}.$df_id);
|
|
| 161 |
my $avail_h = $session->get_single($oids{dfHighAvailKBytes}.$df_id);
|
|
| 162 |
my $total_l = $session->get_single($oids{dfLowTotalKBytes}.$df_id);
|
|
| 163 |
my $total_h = $session->get_single($oids{dfHighTotalKBytes}.$df_id);
|
|
| 164 |
|
|
| 165 |
my $used = to_32bit_int($used_l, $used_h); |
|
| 166 |
my $avail = to_32bit_int($avail_l, $avail_h); |
|
| 167 |
my $total = to_32bit_int($total_l, $total_h); |
|
| 168 |
|
|
| 169 |
print "used.value $used\n"; |
|
| 170 |
print "avail.value $avail\n"; |
|
| 171 |
print "total.value $total\n"; |
|
| 172 |
|
|
| 173 |
exit 0; |
|
| 174 |
|
|
| 175 |
__END__ |
|
| plugins/disk/snmp__netapp_inodeusage_ | ||
|---|---|---|
| 1 |
#!/usr/bin/perl |
|
| 2 |
|
|
| 3 |
=head1 NAME |
|
| 4 |
|
|
| 5 |
snmp__netapp_inodeusage_ - Munin plugin to retrieve inodes usage on |
|
| 6 |
NetApp storage appliances. |
|
| 7 |
|
|
| 8 |
=head1 APPLICABLE SYSTEMS |
|
| 9 |
|
|
| 10 |
Inodes usage stats should be reported by any NetApp storage appliance |
|
| 11 |
with SNMP agent daemon activated. See na_snmp(8) for details. |
|
| 12 |
|
|
| 13 |
=head1 CONFIGURATION |
|
| 14 |
|
|
| 15 |
Unfortunately, SNMPv3 is not fully supported on all NetApp equipments. |
|
| 16 |
For this reason, this plugin will use SNMPv2 by default, which is |
|
| 17 |
insecure because it doesn't encrypt the community string. |
|
| 18 |
|
|
| 19 |
The following parameters will help you get this plugin working : |
|
| 20 |
|
|
| 21 |
[snmp_*] |
|
| 22 |
env.community MyCommunity |
|
| 23 |
|
|
| 24 |
If your community name is 'public', you should really worry about |
|
| 25 |
security and immediately reconfigure your appliance. |
|
| 26 |
|
|
| 27 |
Please see 'perldoc Munin::Plugin::SNMP' for further configuration. |
|
| 28 |
|
|
| 29 |
=head1 MIB INFORMATION |
|
| 30 |
|
|
| 31 |
This plugin requires support for the NETWORK-APPLIANCE-MIB issued by |
|
| 32 |
Network Appliance. It reports the content of the DfEntry OID. |
|
| 33 |
|
|
| 34 |
=head1 MAGIC MARKERS |
|
| 35 |
|
|
| 36 |
#%# family=snmpauto |
|
| 37 |
#%# capabilities=snmpconf |
|
| 38 |
|
|
| 39 |
=head1 VERSION |
|
| 40 |
|
|
| 41 |
v1.0 - 06/22/2009 14:05:03 CEST |
|
| 42 |
Initial revision |
|
| 43 |
|
|
| 44 |
=head1 AUTHOR |
|
| 45 |
|
|
| 46 |
This plugin is copyright (c) 2009 by Guillaume Blairon. |
|
| 47 |
|
|
| 48 |
NetApp is a registered trademark and Network Appliance is a trademark |
|
| 49 |
of Network Appliance, Inc. in the U.S. and other countries. |
|
| 50 |
|
|
| 51 |
=head1 BUGS |
|
| 52 |
|
|
| 53 |
This plugin wasn't tested on many hardware. If you encounter bugs, |
|
| 54 |
please report them to Guillaume Blairon E<lt>L<g@yom.be>E<gt>. |
|
| 55 |
|
|
| 56 |
=head1 LICENSE |
|
| 57 |
|
|
| 58 |
GPLv2 or (at your option) any later version. |
|
| 59 |
|
|
| 60 |
=cut |
|
| 61 |
|
|
| 62 |
use strict; |
|
| 63 |
use warnings; |
|
| 64 |
use Munin::Plugin::SNMP; |
|
| 65 |
use vars qw($DEBUG); |
|
| 66 |
|
|
| 67 |
$DEBUG = $ENV{'MUNIN_DEBUG'};
|
|
| 68 |
|
|
| 69 |
my @palette = |
|
| 70 |
#Better colours from munin 1.3.x |
|
| 71 |
#Greens Blues Oranges Dk yel Dk blu Purple Lime Reds Gray |
|
| 72 |
qw(00CC00 0066B3 FF8000 FFCC00 330099 990099 CCFF00 FF0000 808080 |
|
| 73 |
008F00 00487D B35A00 B38F00 6B006B 8FB300 B30000 BEBEBE |
|
| 74 |
80FF80 80C9FF FFC080 FFE680 AA80FF EE00CC FF8080 |
|
| 75 |
666600 FFBFFF 00FFCC CC6699 999900); |
|
| 76 |
|
|
| 77 |
my %oids = ( |
|
| 78 |
dfInodesUsed => '1.3.6.1.4.1.789.1.5.4.1.7.', |
|
| 79 |
dfInodesFree => '1.3.6.1.4.1.789.1.5.4.1.8.', |
|
| 80 |
); |
|
| 81 |
|
|
| 82 |
if (defined $ARGV[0] and $ARGV[0] eq 'snmpconf') {
|
|
| 83 |
print "number 1.3.6.1.4.1.789.1.5.6.0\n"; |
|
| 84 |
print "index 1.3.6.1.4.1.789.1.5.4.1.1.\n"; |
|
| 85 |
foreach (keys %oids) {
|
|
| 86 |
print "require $oids{$_} [0-9]\n";
|
|
| 87 |
} |
|
| 88 |
exit 0; |
|
| 89 |
} |
|
| 90 |
|
|
| 91 |
my $session = Munin::Plugin::SNMP->session(); |
|
| 92 |
my ($host, undef, undef, $tail) = Munin::Plugin::SNMP->config_session(); |
|
| 93 |
my ($df_id, $name_oid); |
|
| 94 |
|
|
| 95 |
if ($tail =~ /^netapp_inodeusage_(\d+)$/) {
|
|
| 96 |
$df_id = $1; |
|
| 97 |
$name_oid = '1.3.6.1.4.1.789.1.5.4.1.2.' . $df_id; |
|
| 98 |
} else {
|
|
| 99 |
die "Couldn't understand what I'm supposed to monitor"; |
|
| 100 |
} |
|
| 101 |
|
|
| 102 |
if (defined $ARGV[0] and $ARGV[0] eq "config") {
|
|
| 103 |
my $df_name = $session->get_single($name_oid); |
|
| 104 |
|
|
| 105 |
print "host_name $host\n" unless $host eq 'localhost'; |
|
| 106 |
print "graph_title $host inodes usage on $df_name\n"; |
|
| 107 |
print "graph_args --base 1000 --lower-limit 0\n"; |
|
| 108 |
print "graph_vlabel bytes\n"; |
|
| 109 |
print "graph_category disk\n"; |
|
| 110 |
print "graph_info This graph shows the inodes usage for $df_name on NetApp host $host\n"; |
|
| 111 |
print "graph_order used avail total\n"; |
|
| 112 |
print "used.info The total inodes number of inodes in use on the $df_name file system.\n"; |
|
| 113 |
print "used.type GAUGE\n"; |
|
| 114 |
print "used.draw AREA\n"; |
|
| 115 |
print "used.label Used\n"; |
|
| 116 |
print "used.min 0\n"; |
|
| 117 |
print "used.colour $palette[1]\n"; |
|
| 118 |
print "avail.info The total number of inodes that are free for use on the $df_name file system.\n"; |
|
| 119 |
print "avail.type GAUGE\n"; |
|
| 120 |
print "avail.draw STACK\n"; |
|
| 121 |
print "avail.label Available\n"; |
|
| 122 |
print "avail.min 0\n"; |
|
| 123 |
print "avail.colour $palette[3]\n"; |
|
| 124 |
print "total.info The total capacity for the $df_name file system.\n"; |
|
| 125 |
print "total.type GAUGE\n"; |
|
| 126 |
print "total.draw LINE2\n"; |
|
| 127 |
print "total.label Total\n"; |
|
| 128 |
print "total.min 0\n"; |
|
| 129 |
print "total.colour $palette[7]\n"; |
|
| 130 |
|
|
| 131 |
exit 0; |
|
| 132 |
} |
|
| 133 |
|
|
| 134 |
my $used = $session->get_single($oids{dfInodesUsed}.$df_id);
|
|
| 135 |
my $avail = $session->get_single($oids{dfInodesFree}.$df_id);
|
|
| 136 |
my $total = $used + $avail; |
|
| 137 |
|
|
| 138 |
print "used.value $used\n"; |
|
| 139 |
print "avail.value $avail\n"; |
|
| 140 |
print "total.value $total\n"; |
|
| 141 |
|
|
| 142 |
exit 0; |
|
| 143 |
|
|
| 144 |
__END__ |
|
| plugins/disk/snmp__swap | ||
|---|---|---|
| 1 |
#!/usr/bin/perl -w |
|
| 2 |
# |
|
| 3 |
# Copyright (C) 2006 Lars Strand |
|
| 4 |
# |
|
| 5 |
# Munin plugin to monitor swap usage by use of SNMP. |
|
| 6 |
# Based on the snmp__df plugin |
|
| 7 |
# |
|
| 8 |
# This program is free software; you can redistribute it and/or |
|
| 9 |
# modify it under the terms of the GNU General Public License |
|
| 10 |
# as published by the Free Software Foundation; version 2 dated June, |
|
| 11 |
# 1991. |
|
| 12 |
# |
|
| 13 |
# This program is distributed in the hope that it will be useful, |
|
| 14 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 15 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 16 |
# GNU General Public License for more details. |
|
| 17 |
# |
|
| 18 |
# You should have received a copy of the GNU General Public License |
|
| 19 |
# along with this program; if not, write to the Free Software |
|
| 20 |
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
| 21 |
# |
|
| 22 |
# $Log$ |
|
| 23 |
# |
|
| 24 |
#%# family=snmpauto |
|
| 25 |
#%# capabilities=snmpconf |
|
| 26 |
|
|
| 27 |
use strict; |
|
| 28 |
use Net::SNMP; |
|
| 29 |
|
|
| 30 |
my $DEBUG = 0; |
|
| 31 |
my $MAXLABEL = 20; |
|
| 32 |
|
|
| 33 |
my $host = $ENV{host} || undef;
|
|
| 34 |
my $port = $ENV{port} || 161;
|
|
| 35 |
my $community = $ENV{community} || "public";
|
|
| 36 |
my $iface = $ENV{interface} || undef;
|
|
| 37 |
|
|
| 38 |
my $response; |
|
| 39 |
|
|
| 40 |
if (defined $ARGV[0] and $ARGV[0] eq "snmpconf") |
|
| 41 |
{
|
|
| 42 |
# HOST-RESOURCES-MIB::hrStorage |
|
| 43 |
# HOST-RESOURCES-TYPES::hrStorageVirtualMemory |
|
| 44 |
print "require 1.3.6.1.2.1.25.2. 1.3.6.1.2.1.25.2.1.3\n"; |
|
| 45 |
exit 0; |
|
| 46 |
} |
|
| 47 |
|
|
| 48 |
if ($0 =~ /^(?:|.*\/)snmp_([^_]+)_swap$/) |
|
| 49 |
{
|
|
| 50 |
$host = $1; |
|
| 51 |
if ($host =~ /^([^:]+):(\d+)$/) |
|
| 52 |
{
|
|
| 53 |
$host = $1; |
|
| 54 |
$port = $2; |
|
| 55 |
} |
|
| 56 |
} |
|
| 57 |
elsif (!defined($host)) |
|
| 58 |
{
|
|
| 59 |
print "# Debug: $0 -- $1\n" if $DEBUG; |
|
| 60 |
die "# Error: couldn't understand what I'm supposed to monitor."; |
|
| 61 |
} |
|
| 62 |
|
|
| 63 |
my ($session, $error) = Net::SNMP->session( |
|
| 64 |
-hostname => $host, |
|
| 65 |
-community => $community, |
|
| 66 |
-port => $port |
|
| 67 |
); |
|
| 68 |
|
|
| 69 |
if (!defined ($session)) |
|
| 70 |
{
|
|
| 71 |
die "Croaking: $error"; |
|
| 72 |
} |
|
| 73 |
|
|
| 74 |
my $hrStorage = "1.3.6.1.2.1.25.2."; |
|
| 75 |
my $hrStorageVirtualMemory = "1.3.6.1.2.1.25.2.1.3"; |
|
| 76 |
my $hrStorageSize = "1.3.6.1.2.1.25.2.3.1.5."; |
|
| 77 |
my $hrStorageUsed = "1.3.6.1.2.1.25.2.3.1.6."; |
|
| 78 |
|
|
| 79 |
my $swap_d = get_by_regex($session, $hrStorage, $hrStorageVirtualMemory); |
|
| 80 |
|
|
| 81 |
my $swapsize = 0; my $swapused = 0; |
|
| 82 |
|
|
| 83 |
foreach my $swap (keys %$swap_d) |
|
| 84 |
{
|
|
| 85 |
$swapsize += get_single($session, $hrStorageSize . $swap); |
|
| 86 |
$swapused += get_single($session, $hrStorageUsed . $swap); |
|
| 87 |
} |
|
| 88 |
|
|
| 89 |
if (defined $ARGV[0] and $ARGV[0] eq "config") |
|
| 90 |
{
|
|
| 91 |
print "host_name $host\n"; |
|
| 92 |
print "graph_title Virtual memory usage\n"; |
|
| 93 |
if ($swapsize > 0) |
|
| 94 |
{
|
|
| 95 |
print "graph_args -l 0 --base 1000 --upper-limit $swapsize\n"; |
|
| 96 |
} |
|
| 97 |
else |
|
| 98 |
{
|
|
| 99 |
print "graph_args -l 0 --base 1000\n"; |
|
| 100 |
} |
|
| 101 |
print "graph_vlabel Bytes\n"; |
|
| 102 |
print "graph_category disk\n"; |
|
| 103 |
print "graph_info This graph shows swap usage in bytes.\n"; |
|
| 104 |
print "swap.label swap\n"; |
|
| 105 |
print "swap.type DERIVE\n"; |
|
| 106 |
print "swap.min 0\n"; |
|
| 107 |
exit 0; |
|
| 108 |
} |
|
| 109 |
|
|
| 110 |
print "swap.value $swapused\n"; |
|
| 111 |
|
|
| 112 |
sub get_single |
|
| 113 |
{
|
|
| 114 |
my $handle = shift; |
|
| 115 |
my $oid = shift; |
|
| 116 |
|
|
| 117 |
print "# Getting single $oid..." if $DEBUG; |
|
| 118 |
|
|
| 119 |
$response = $handle->get_request ($oid); |
|
| 120 |
|
|
| 121 |
if (!defined $response->{$oid})
|
|
| 122 |
{
|
|
| 123 |
print "undef\n" if $DEBUG; |
|
| 124 |
return undef; |
|
| 125 |
} |
|
| 126 |
else |
|
| 127 |
{
|
|
| 128 |
print "\"$response->{$oid}\"\n" if $DEBUG;
|
|
| 129 |
return $response->{$oid};
|
|
| 130 |
} |
|
| 131 |
} |
|
| 132 |
|
|
| 133 |
sub get_by_regex |
|
| 134 |
{
|
|
| 135 |
my $handle = shift; |
|
| 136 |
my $oid = shift; |
|
| 137 |
my $regex = shift; |
|
| 138 |
my $result = {};
|
|
| 139 |
my $num = 0; |
|
| 140 |
my $ret = $oid . "0"; |
|
| 141 |
my $response; |
|
| 142 |
|
|
| 143 |
print "# Starting browse of $oid...\n" if $DEBUG; |
|
| 144 |
|
|
| 145 |
while (1) |
|
| 146 |
{
|
|
| 147 |
if ($num == 0) |
|
| 148 |
{
|
|
| 149 |
print "# Checking for $ret...\n" if $DEBUG; |
|
| 150 |
$response = $handle->get_request ($ret); |
|
| 151 |
} |
|
| 152 |
if ($num or !defined $response) |
|
| 153 |
{
|
|
| 154 |
print "# Checking for sibling of $ret...\n" if $DEBUG; |
|
| 155 |
$response = $handle->get_next_request ($ret); |
|
| 156 |
} |
|
| 157 |
if (!$response) |
|
| 158 |
{
|
|
| 159 |
return undef; |
|
| 160 |
} |
|
| 161 |
my @keys = keys %$response; |
|
| 162 |
$ret = $keys[0]; |
|
| 163 |
print "# Analyzing $ret (compared to $oid)...\n" if $DEBUG; |
|
| 164 |
last unless ($ret =~ /^$oid/); |
|
| 165 |
$num++; |
|
| 166 |
next unless ($response->{$ret} =~ /$regex/);
|
|
| 167 |
@keys = split (/\./, $ret); |
|
| 168 |
$result->{$keys[-1]} = $response->{$ret};;
|
|
| 169 |
print "# Index $num: ", $keys[-1], " (", $response->{$ret}, ")\n" if $DEBUG;
|
|
| 170 |
}; |
|
| 171 |
return $result; |
|
| 172 |
} |
|
| plugins/mysql/mysql_innodb | ||
|---|---|---|
| 1 |
#!/bin/bash |
|
| 2 |
# |
|
| 3 |
# Munin plugin to monitor free space in MySQL's InnoDB tablespace. |
|
| 4 |
# Mostly useful if you use InnoDB on a block device, or if you for |
|
| 5 |
# some reason don't want to do autoextend on the last file. |
|
| 6 |
# |
|
| 7 |
# 2007-03-18 Stig Sandbeck Mathisen <ssm@fnord.no> |
|
| 8 |
# |
|
| 9 |
# Configuration parameters for /etc/munin/plugin-conf.d/mysql_innodb, |
|
| 10 |
# if you need to override the defaults below: |
|
| 11 |
# |
|
| 12 |
# [mysql_innodb] |
|
| 13 |
# env.mysqlopts - Options to pass to mysql (host, username, password) |
|
| 14 |
# env.warning - Generate a warning if free space goes below this level |
|
| 15 |
# env.critical - Generate a critical if free space goes below this level |
|
| 16 |
# |
|
| 17 |
# For security reasons, this plugin uses its own schema with a simple, |
|
| 18 |
# empty table using the InnoDB engine. |
|
| 19 |
# |
|
| 20 |
# You need to run this to get this plugin to work: |
|
| 21 |
# mysql> CREATE DATABASE munin_innodb; |
|
| 22 |
# mysql> USE munin_innodb |
|
| 23 |
# mysql> CREATE TABLE something (anything int) ENGINE=InnoDB; |
|
| 24 |
|
|
| 25 |
## Tunable parameters with defaults |
|
| 26 |
MYSQL="${mysql:-/usr/bin/mysql}"
|
|
| 27 |
MYSQLOPTS="${mysqlopts:---user=munin --password=munin --host=localhost}"
|
|
| 28 |
|
|
| 29 |
WARNING=${warning:-2147483648} # 2GB
|
|
| 30 |
CRITICAL=${critical:-1073741824} # 1GB
|
|
| 31 |
|
|
| 32 |
## No user serviceable parts below |
|
| 33 |
if [ "$1" = "config" ]; then |
|
| 34 |
echo 'graph_title MySQL InnoDB free tablespace' |
|
| 35 |
echo 'graph_args --base 1024' |
|
| 36 |
echo 'graph_vlabel Bytes' |
|
| 37 |
echo 'graph_category mysql' |
|
| 38 |
echo 'graph_info Amount of free bytes in the InnoDB tablespace' |
|
| 39 |
echo 'free.label Bytes free' |
|
| 40 |
echo 'free.type GAUGE' |
|
| 41 |
echo 'free.min 0' |
|
| 42 |
echo 'free.warning' $WARNING: |
|
| 43 |
echo 'free.critical' $CRITICAL: |
|
| 44 |
exit 0 |
|
| 45 |
fi |
|
| 46 |
|
|
| 47 |
# Get freespace from mysql |
|
| 48 |
freespace=$($MYSQL $MYSQLOPTS --batch --skip-column-names --execute \ |
|
| 49 |
"SELECT table_comment FROM tables WHERE TABLE_SCHEMA = 'munin_innodb'" \ |
|
| 50 |
information_schema); |
|
| 51 |
retval=$? |
|
| 52 |
|
|
| 53 |
# Sanity checks |
|
| 54 |
if (( retval > 0 )); then |
|
| 55 |
echo "Error: mysql command returned status $retval" 1>&2 |
|
| 56 |
exit -1 |
|
| 57 |
fi |
|
| 58 |
if [ -z "$freespace" ]; then |
|
| 59 |
echo "Error: mysql command returned no output" 1>&2 |
|
| 60 |
exit -1 |
|
| 61 |
fi |
|
| 62 |
|
|
| 63 |
# Return freespace |
|
| 64 |
echo $freespace | awk '/InnoDB free:/ {print "free.value", $3 * 1024}'
|
|
| plugins/network/snmp__netstat | ||
|---|---|---|
| 1 |
#!/usr/bin/perl -w |
|
| 2 |
# |
|
| 3 |
# Copyright (C) 2006 Lars Strand |
|
| 4 |
# |
|
| 5 |
# Munin plugin to monitor network connection by use of SNMP. |
|
| 6 |
# Based on snmp__df plugin. |
|
| 7 |
# |
|
| 8 |
# This program is free software; you can redistribute it and/or |
|
| 9 |
# modify it under the terms of the GNU General Public License |
|
| 10 |
# as published by the Free Software Foundation; version 2 dated June, |
|
| 11 |
# 1991. |
|
| 12 |
# |
|
| 13 |
# This program is distributed in the hope that it will be useful, |
|
| 14 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 15 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 16 |
# GNU General Public License for more details. |
|
| 17 |
# |
|
| 18 |
# You should have received a copy of the GNU General Public License |
|
| 19 |
# along with this program; if not, write to the Free Software |
|
| 20 |
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
| 21 |
# |
|
| 22 |
# $Log$ |
|
| 23 |
# |
|
| 24 |
#%# family=snmpauto |
|
| 25 |
#%# capabilities=snmpconf |
|
| 26 |
|
|
| 27 |
use strict; |
|
| 28 |
use Net::SNMP; |
|
| 29 |
|
|
| 30 |
my $DEBUG = 1; |
|
| 31 |
|
|
| 32 |
my $host = $ENV{host} || undef;
|
|
| 33 |
my $port = $ENV{port} || 161;
|
|
| 34 |
my $community = $ENV{community} || "public";
|
|
| 35 |
|
|
| 36 |
my $response; |
|
| 37 |
|
|
| 38 |
my %tcpStates = ( 1 => [0, "GAUGE", "closed", "Connections waiting for a termination request acknowledgment from the remote TCP."], |
|
| 39 |
2 => [0, "GAUGE", "listen", "Connections waiting for a request from any remote TCP and port."], |
|
| 40 |
3 => [0, "GAUGE", "synSent", "Connections waiting for a matching request after having sent a connection request."], |
|
| 41 |
4 => [0, "GAUGE", "synReceived", "Connections waiting for a confirming request acknowledgment after having both received and sent a connection request."], |
|
| 42 |
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."], |
|
| 43 |
6 => [0, "GAUGE", "finWait1", "Connections waiting for a termination request from the remote TCP, or an acknowledgment of the connection termination request previously sent."], |
|
| 44 |
7 => [0, "GAUGE", "finWait2", "Connections waiting for a termination request from the remote TCP."], |
|
| 45 |
8 => [0, "GAUGE", "closeWait", "Connections waiting for a termination request from the local user."], |
|
| 46 |
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)."], |
|
| 47 |
10 => [0, "GAUGE", "closing", "Connections waiting for a termination request acknowledgment from the remote TCP."], |
|
| 48 |
11 => [0, "GAUGE", "timeWait", "Connections waiting for enough time to pass to be sure the remote TCP received the acknowledgment of its termination request."], |
|
| 49 |
12 => [0, "GAUGE", "deleteTCP", "Connections terminated by a SNMP Managment Station (put)"] |
|
| 50 |
); |
|
| 51 |
|
|
| 52 |
if (defined $ARGV[0] and $ARGV[0] eq "snmpconf") |
|
| 53 |
{
|
|
| 54 |
print "require 1.3.6.1.2.1.6.13.1.1. [0-9]\n"; |
|
| 55 |
exit 0; |
|
| 56 |
} |
|
| 57 |
|
|
| 58 |
if ($0 =~ /^(?:|.*\/)snmp_([^_]+)_netstat$/) |
|
| 59 |
{
|
|
| 60 |
$host = $1; |
|
| 61 |
if ($host =~ /^([^:]+):(\d+)$/) |
|
| 62 |
{
|
|
| 63 |
$host = $1; |
|
| 64 |
$port = $2; |
|
| 65 |
} |
|
| 66 |
} |
|
| 67 |
elsif (!defined($host)) |
|
| 68 |
{
|
|
| 69 |
print "# Debug: $0 -- $1\n" if $DEBUG; |
|
| 70 |
die "# Error: couldn't understand what I'm supposed to monitor."; |
|
| 71 |
} |
|
| 72 |
|
|
| 73 |
if (defined $ARGV[0] and $ARGV[0] eq "config") |
|
| 74 |
{
|
|
| 75 |
print "host_name $host\n"; |
|
| 76 |
print "graph_title Netstat\n"; |
|
| 77 |
print "graph_args -l 0 --base 1000\n"; |
|
| 78 |
print "graph_period seconds\n"; |
|
| 79 |
print "graph_category network\n"; |
|
| 80 |
print "graph_order closed listen synSent synReceived established finWait1 finWait2 closeWait lastAck closing timeWait deleteTCP\n"; |
|
| 81 |
print "graph_vlabel active connection\n"; |
|
| 82 |
print "graph_info This graph shows the TCP activity of all the network interfaces combined.\n"; |
|
| 83 |
|
|
| 84 |
foreach my $state (keys %tcpStates) {
|
|
| 85 |
print "$tcpStates{$state}[2].label $tcpStates{$state}[2]\n";
|
|
| 86 |
print "$tcpStates{$state}[2].type $tcpStates{$state}[1]\n";
|
|
| 87 |
print "$tcpStates{$state}[2].max 50000\n";
|
|
| 88 |
print "$tcpStates{$state}[2].min 0\n";
|
|
| 89 |
print "$tcpStates{$state}[2].info $tcpStates{$state}[3]\n";
|
|
| 90 |
} |
|
| 91 |
|
|
| 92 |
exit 0; |
|
| 93 |
} |
|
| 94 |
|
|
| 95 |
my $tcpConnState = "1.3.6.1.2.1.6.13.1.1."; |
|
| 96 |
|
|
| 97 |
my ($session, $error) = Net::SNMP->session( |
|
| 98 |
-hostname => $host, |
|
| 99 |
-community => $community, |
|
| 100 |
-port => $port |
|
| 101 |
); |
|
| 102 |
|
|
| 103 |
if (!defined ($session)) |
|
| 104 |
{
|
|
| 105 |
die "Croaking: $error"; |
|
| 106 |
} |
|
| 107 |
|
|
| 108 |
my $connections = get_by_regex($session, $tcpConnState, "[1-9]"); |
|
| 109 |
|
|
| 110 |
# the values |
|
| 111 |
while (my ($id, $state) = each(%$connections)) {
|
|
| 112 |
$tcpStates{$state}[0] += 1;
|
|
| 113 |
} |
|
| 114 |
|
|
| 115 |
foreach my $state (keys %tcpStates) {
|
|
| 116 |
print "$tcpStates{$state}[2].value $tcpStates{$state}[0]\n";
|
|
| 117 |
} |
|
| 118 |
|
|
| 119 |
sub get_by_regex |
|
| 120 |
{
|
|
| 121 |
my $handle = shift; |
|
| 122 |
my $oid = shift; |
|
| 123 |
my $regex = shift; |
|
| 124 |
my $result = {};
|
|
| 125 |
my $num = 0; |
|
| 126 |
my $ret = $oid . "0"; |
|
| 127 |
my $response; |
|
| 128 |
|
|
| 129 |
print "# Starting browse of $oid...\n" if $DEBUG; |
|
| 130 |
|
|
| 131 |
while (1) |
|
| 132 |
{
|
|
| 133 |
if ($num == 0) |
|
| 134 |
{
|
|
| 135 |
print "# Checking for $ret...\n" if $DEBUG; |
|
| 136 |
$response = $handle->get_request ($ret); |
|
| 137 |
} |
|
| 138 |
if ($num or !defined $response) |
|
| 139 |
{
|
|
| 140 |
print "# Checking for sibling of $ret...\n" if $DEBUG; |
|
| 141 |
$response = $handle->get_next_request ($ret); |
|
| 142 |
} |
|
| 143 |
if (!$response) |
|
| 144 |
{
|
|
| 145 |
return undef; |
|
| 146 |
} |
|
| 147 |
my @keys = keys %$response; |
|
| 148 |
$ret = $keys[0]; |
|
| 149 |
print "# Analyzing $ret (compared to $oid)...\n" if $DEBUG; |
|
| 150 |
last unless ($ret =~ /^$oid/); |
|
| 151 |
$num++; |
|
| 152 |
next unless ($response->{$ret} =~ /$regex/);
|
|
| 153 |
@keys = split (/\./, $ret); |
|
| 154 |
$result->{$num} = $response->{$ret};;
|
|
| 155 |
print "# Index $num: ", $keys[-1], " (", $response->{$ret}, ")\n" if $DEBUG;
|
|
| 156 |
}; |
|
| 157 |
return $result; |
|
| 158 |
} |
|
| plugins/nfs/nfs4_client | ||
|---|---|---|
| 1 |
#!/bin/sh |
|
| 2 |
# |
|
| 3 |
# Plugin to monitor NFS client traffic |
|
| 4 |
# |
|
| 5 |
# $Log$ |
|
| 6 |
# Revision 1.8.2.1 2005/03/16 13:45:45 ilmari |
|
| 7 |
# Fix autoconf for linux/{nfsd,nfs_client}.
|
|
| 8 |
# |
|
| 9 |
# Revision 1.8 2004/12/10 10:47:49 jimmyo |
|
| 10 |
# Change name from ${scale} to ${graph_period}, to be more consistent.
|
|
| 11 |
# |
|
| 12 |
# Revision 1.7 2004/12/09 22:12:56 jimmyo |
|
| 13 |
# Added "graph_period" option, to make "graph_sums" usable. |
|
| 14 |
# |
|
| 15 |
# Revision 1.6 2004/11/21 00:17:12 jimmyo |
|
| 16 |
# Changed a lot of plugins so they use DERIVE instead of COUNTER. |
|
| 17 |
# |
|
| 18 |
# Revision 1.5 2004/10/01 12:32:09 ilmari |
|
| 19 |
# complete "rpc" removal |
|
| 20 |
# |
|
| 21 |
# Revision 1.4 2004/10/01 08:40:50 ilmari |
|
| 22 |
# Remove useless 'rpc' field, add total field |
|
| 23 |
# |
|
| 24 |
# Revision 1.3 2004/05/20 19:02:37 jimmyo |
|
| 25 |
# Set categories on a bunch of plugins |
|
| 26 |
# |
|
| 27 |
# Revision 1.2 2004/05/15 21:33:29 jimmyo |
|
| 28 |
# "Upped" som plugins from contrib/manual to manual or auto. |
|
| 29 |
# |
|
| 30 |
# |
|
| 31 |
#%# family=auto |
|
| 32 |
#%# capabilities=autoconf |
|
| 33 |
|
|
| 34 |
NFS=/proc/net/rpc/nfs |
|
| 35 |
|
|
| 36 |
#proc="getattr setattr lookup access readlink read write create mkdir symlink mknod remove rmdir rename link readdir readdirplus fsstat fsinfo pathconf commit" |
|
| 37 |
|
|
| 38 |
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" |
|
| 39 |
|
|
| 40 |
if [ "$1" = "autoconf" ]; then |
|
| 41 |
if [ -f "$NFS" ]; then |
|
| 42 |
echo yes |
|
| 43 |
exit 0 |
|
| 44 |
else |
|
| 45 |
echo "no (no $NFS)" |
|
| 46 |
exit 1 |
|
| 47 |
fi |
|
| 48 |
fi |
|
| 49 |
|
|
| 50 |
if [ "$1" = "config" ]; then |
|
| 51 |
|
|
| 52 |
echo 'graph_title NFS4 Client' |
|
| 53 |
echo 'graph_args --base 1000 -l 0' |
|
| 54 |
echo 'graph_vlabel requests / ${graph_period}'
|
|
| 55 |
echo 'graph_total total' |
|
| 56 |
echo 'graph_category NFS' |
|
| 57 |
for a in $proc ; do echo "$a.label $a" ; echo "$a.type DERIVE"; echo "$a.min 0"; done |
|
| 58 |
exit 0 |
|
| 59 |
fi |
|
| 60 |
|
|
| 61 |
i=4; |
|
| 62 |
|
|
| 63 |
for a in $proc; do |
|
| 64 |
echo -n "$a.value " |
|
| 65 |
grep proc4 $NFS \ |
|
| 66 |
| cut -f $i -d ' ' \ |
|
| 67 |
| awk '{print $1}'
|
|
| 68 |
i=$(expr $i + 1) |
|
| 69 |
done |
|
| plugins/nginx/nginx_request | ||
|---|---|---|
| 1 |
#!/usr/bin/perl -w |
|
| 2 |
# -*- mode: cperl; mode: autopair -*- |
|
| 3 |
# Magic markers: |
|
| 4 |
#%# family=auto |
|
| 5 |
#%# capabilities=autoconf |
|
| 6 |
# nginx_request --- Determine the current connection rate for |
|
| 7 |
# nginx. Based on a nginx_request plugin by unknown |
|
| 8 |
# author. |
|
| 9 |
|
|
| 10 |
# Copyright (C) 2010 António P. P. Almeida <appa@perusio.net> |
|
| 11 |
|
|
| 12 |
# Author: António P. P. Almeida <appa@perusio.net> |
|
| 13 |
|
|
| 14 |
# Permission is hereby granted, free of charge, to any person obtaining a |
|
| 15 |
# copy of this software and associated documentation files (the "Software"), |
|
| 16 |
# to deal in the Software without restriction, including without limitation |
|
| 17 |
# the rights to use, copy, modify, merge, publish, distribute, sublicense, |
|
| 18 |
# and/or sell copies of the Software, and to permit persons to whom the |
|
| 19 |
# Software is furnished to do so, subject to the following conditions: |
|
| 20 |
|
|
| 21 |
# The above copyright notice and this permission notice shall be included in |
|
| 22 |
# all copies or substantial portions of the Software. |
|
| 23 |
|
|
| 24 |
# Except as contained in this notice, the name(s) of the above copyright |
|
| 25 |
# holders shall not be used in advertising or otherwise to promote the sale, |
|
| 26 |
# use or other dealings in this Software without prior written authorization. |
|
| 27 |
|
|
| 28 |
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
| 29 |
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
| 30 |
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
|
| 31 |
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
| 32 |
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|
| 33 |
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
|
| 34 |
# DEALINGS IN THE SOFTWARE. |
|
| 35 |
|
|
| 36 |
=head1 NAME |
|
| 37 |
|
|
| 38 |
nginx_request - Munin plugin to show number of requests/connection served by nginx. |
|
| 39 |
=encoding utf8 |
|
| 40 |
|
|
| 41 |
=head1 APPLICABLE SYSTEMS |
|
| 42 |
|
|
| 43 |
Any nginx host |
|
| 44 |
|
|
| 45 |
=head1 CONFIGURATION |
|
| 46 |
|
|
| 47 |
This shows the default configuration of this plugin. You can override |
|
| 48 |
the status URL and User Agent. |
|
| 49 |
|
|
| 50 |
[nginx*] |
|
| 51 |
env.url http://localhost/nginx_status |
|
| 52 |
env.ua nginx-status-verifier/0.1 |
|
| 53 |
|
|
| 54 |
Nginx must also be configured. Firstly the stub-status module must be |
|
| 55 |
compiled, and secondly it must be configured like this: |
|
| 56 |
|
|
| 57 |
server {
|
|
| 58 |
listen 127.0.0.1; |
|
| 59 |
server_name localhost; |
|
| 60 |
location /nginx_status {
|
|
| 61 |
stub_status on; |
|
| 62 |
access_log off; |
|
| 63 |
allow 127.0.0.1; |
|
| 64 |
deny all; |
|
| 65 |
} |
|
| 66 |
} |
|
| 67 |
|
|
| 68 |
=head1 MAGIC MARKERS |
|
| 69 |
|
|
| 70 |
#%# family=auto |
|
| 71 |
#%# capabilities=autoconf |
|
| 72 |
|
|
| 73 |
=head1 VERSION |
|
| 74 |
|
|
| 75 |
1.1 |
|
| 76 |
|
|
| 77 |
=head1 BUGS |
|
| 78 |
|
|
| 79 |
None known |
|
| 80 |
|
|
| 81 |
=head1 AUTHOR |
|
| 82 |
|
|
| 83 |
Unknown. Modified by António Almeida <appa@perusio.net> |
|
| 84 |
|
|
| 85 |
=head1 REPOSITORY |
|
| 86 |
|
|
| 87 |
Source code at http://github.com/perusio/nginx-munin |
|
| 88 |
|
|
| 89 |
=head1 LICENSE |
|
| 90 |
|
|
| 91 |
MIT |
|
| 92 |
|
|
| 93 |
=cut |
|
| 94 |
|
|
| 95 |
|
|
| 96 |
my $ret = undef; |
|
| 97 |
|
|
| 98 |
if (! eval "require LWP::UserAgent;") {
|
|
| 99 |
$ret = "LWP::UserAgent not found"; |
|
| 100 |
} |
|
| 101 |
|
|
| 102 |
chomp(my $fqdn=`hostname -f`); |
|
| 103 |
|
|
| 104 |
|
|
| 105 |
## Environment defined variables. |
|
| 106 |
## The default URL is nginx_status if different set it in the environment. |
|
| 107 |
my $URL = exists $ENV{'url'} ? $ENV{'url'} : "http://$fqdn/nginx_status";
|
|
| 108 |
## The default user agent is ngnix-status-verifier/0.1 if different |
|
| 109 |
## set it in the environment. |
|
| 110 |
my $UA = exists $ENV{'ua'} ? $ENV{'ua'} : 'nginx-status-verifier/0.1';
|
|
| 111 |
|
|
| 112 |
if (exists $ARGV[0] and $ARGV[0] eq "autoconf") {
|
|
| 113 |
if ($ret) {
|
|
| 114 |
print "no ($ret)\n"; |
|
| 115 |
exit 1; |
|
| 116 |
} |
|
| 117 |
|
|
| 118 |
my $ua = LWP::UserAgent->new(timeout => 30); |
|
| 119 |
# Set the UA to something different from the libwww-perl. |
|
| 120 |
# That UA is blocked. |
|
| 121 |
$ua->agent($UA); |
|
| 122 |
my $response = $ua->request(HTTP::Request->new('GET',$URL));
|
|
| 123 |
|
|
| 124 |
unless ($response->is_success and $response->content =~ /server/im) |
|
| 125 |
{
|
|
| 126 |
print "no (no nginx status on $URL)\n"; |
|
| 127 |
exit 1; |
|
| 128 |
} else {
|
|
| 129 |
print "yes\n"; |
|
| 130 |
exit 0; |
|
| 131 |
} |
|
| 132 |
} |
|
| 133 |
|
|
| 134 |
## Munin config method. |
|
| 135 |
if (exists $ARGV[0] and $ARGV[0] eq "config") {
|
|
| 136 |
print "graph_title NGINX requests\n"; |
|
| 137 |
print "graph_args --base 1000\n"; |
|
| 138 |
print "graph_category nginx\n"; |
|
| 139 |
print "graph_vlabel Request per second\n"; |
|
| 140 |
print "request.label req/sec\n"; |
|
| 141 |
print "request.type DERIVE\n"; |
|
| 142 |
print "request.min 0\n"; |
|
| 143 |
print "request.draw LINE2\n"; |
|
| 144 |
|
|
| 145 |
exit 0; |
|
| 146 |
} |
|
| 147 |
|
|
| 148 |
my $ua = LWP::UserAgent->new(timeout => 30); |
|
| 149 |
# Set the UA to something different from the libwww-perl. |
|
| 150 |
# That UA is blocked. |
|
| 151 |
$ua->agent($UA); |
|
| 152 |
my $response = $ua->request(HTTP::Request->new('GET',$URL));
|
|
| 153 |
|
|
| 154 |
if ($response->content =~ /^\s+(\d+)\s+(\d+)\s+(\d+)/m) {
|
|
| 155 |
print "request.value $3\n"; |
|
| 156 |
} else {
|
|
| 157 |
print "request.value U\n"; |
|
| 158 |
} |
|
| plugins/nginx/nginx_status | ||
|---|---|---|
| 1 |
#!/usr/bin/perl -w |
|
| 2 |
# -*- cperl -*- |
|
| 3 |
# Magic markers: |
|
| 4 |
#%# family=auto |
|
| 5 |
#%# capabilities=autoconf |
|
| 6 |
# nginx_status --- Determine the current status of Nginx |
|
| 7 |
# using the http_stub_status module. |
|
| 8 |
|
|
| 9 |
# Copyright (C) 2010 António P. P. Almeida <appa@perusio.net> |
|
| 10 |
|
|
| 11 |
# Author: António P. P. Almeida <appa@perusio.net> |
|
| 12 |
|
|
| 13 |
# Permission is hereby granted, free of charge, to any person obtaining a |
|
| 14 |
# copy of this software and associated documentation files (the "Software"), |
|
| 15 |
# to deal in the Software without restriction, including without limitation |
|
| 16 |
# the rights to use, copy, modify, merge, publish, distribute, sublicense, |
|
| 17 |
# and/or sell copies of the Software, and to permit persons to whom the |
|
| 18 |
# Software is furnished to do so, subject to the following conditions: |
|
| 19 |
|
|
| 20 |
# The above copyright notice and this permission notice shall be included in |
|
| 21 |
# all copies or substantial portions of the Software. |
|
| 22 |
|
|
| 23 |
# Except as contained in this notice, the name(s) of the above copyright |
|
| 24 |
# holders shall not be used in advertising or otherwise to promote the sale, |
|
| 25 |
# use or other dealings in this Software without prior written authorization. |
|
| 26 |
|
|
| 27 |
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
| 28 |
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
| 29 |
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
|
| 30 |
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
| 31 |
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|
| 32 |
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
|
| 33 |
# DEALINGS IN THE SOFTWARE. |
|
| 34 |
|
|
| 35 |
=head1 NAME |
|
| 36 |
|
|
| 37 |
nginx_status - Munin plugin to show the connection status for nginx |
|
| 38 |
|
|
| 39 |
=encoding utf8 |
|
| 40 |
|
|
| 41 |
=head1 APPLICABLE SYSTEMS |
|
| 42 |
|
|
| 43 |
Any nginx host |
|
| 44 |
|
|
| 45 |
=head1 CONFIGURATION |
|
| 46 |
|
|
| 47 |
This shows the default configuration of this plugin. You can override |
|
| 48 |
the status URL and the User Agent. |
|
| 49 |
|
|
| 50 |
[nginx*] |
|
| 51 |
env.url http://localhost/nginx_status |
|
| 52 |
env.ua nginx-status-verifier/0.1 |
|
| 53 |
|
|
| 54 |
Nginx must also be configured. Firstly the stub-status module must be |
|
| 55 |
compiled, and secondly it must be configured like this: |
|
| 56 |
|
|
| 57 |
server {
|
|
| 58 |
listen 127.0.0.1; |
|
| 59 |
server_name localhost; |
|
| 60 |
location /nginx_status {
|
|
| 61 |
stub_status on; |
|
| 62 |
access_log off; |
|
| 63 |
allow 127.0.0.1; |
|
| 64 |
deny all; |
|
| 65 |
} |
|
| 66 |
} |
|
| 67 |
|
|
| 68 |
=head1 MAGIC MARKERS |
|
| 69 |
|
|
| 70 |
#%# family=auto |
|
| 71 |
#%# capabilities=autoconf |
|
| 72 |
|
|
| 73 |
=head1 VERSION |
|
| 74 |
|
|
| 75 |
1.1 |
|
| 76 |
|
|
| 77 |
=head1 BUGS |
|
| 78 |
|
|
| 79 |
None known |
|
| 80 |
|
|
| 81 |
=head1 AUTHOR |
|
| 82 |
|
|
| 83 |
Unknown. Mantained by António Almeida <appa@perusio.net> |
|
| 84 |
|
|
| 85 |
=head1 REPOSITORY |
|
| 86 |
|
|
| 87 |
Source code at http://github.com/perusio/nginx-munin |
|
| 88 |
|
|
| 89 |
=head1 LICENSE |
|
| 90 |
|
|
| 91 |
MIT |
|
| 92 |
|
|
| 93 |
=cut |
|
| 94 |
|
|
| 95 |
my $ret = undef; |
|
| 96 |
|
|
| 97 |
if (! eval "require LWP::UserAgent;") {
|
|
| 98 |
$ret = "LWP::UserAgent not found"; |
|
| 99 |
} |
|
| 100 |
|
|
| 101 |
chomp(my $fqdn=`hostname -f`); |
|
| 102 |
|
|
| 103 |
## Environment defined variables. |
|
| 104 |
## The default URL is nginx_status if different set it in the environment. |
|
| 105 |
my $URL = exists $ENV{'url'} ? $ENV{'url'} : "http://$fqdn/nginx_status";
|
|
| 106 |
## The default user agent is ngnix-status-verifier/0.1 if different |
|
| 107 |
## set it in the environment. |
|
| 108 |
my $UA = exists $ENV{'ua'} ? $ENV{'ua'} : 'nginx-status-verifier/0.1';
|
|
| 109 |
|
|
| 110 |
|
|
| 111 |
## Munin autoconf method. |
|
| 112 |
if (exists $ARGV[0] and $ARGV[0] eq "autoconf" ) {
|
|
| 113 |
if ($ret) {
|
|
| 114 |
print "no ($ret)\n"; |
|
| 115 |
exit 1; |
|
| 116 |
} |
|
| 117 |
|
|
| 118 |
my $ua = LWP::UserAgent->new(timeout => 30); |
|
| 119 |
# Set the UA to something different from the libwww-perl. |
|
| 120 |
# This UA is blocked. |
|
| 121 |
$ua->agent($UA); |
|
| 122 |
my $response = $ua->request(HTTP::Request->new('GET',$URL));
|
|
| 123 |
|
|
| 124 |
unless ($response->is_success and $response->content =~ /server/im) {
|
|
| 125 |
print "no (no nginx status on $URL)\n"; |
|
| 126 |
exit 1; |
|
| 127 |
} else {
|
|
| 128 |
print "yes\n"; |
|
| 129 |
exit 0; |
|
| 130 |
} |
|
| 131 |
} |
|
| 132 |
|
|
| 133 |
## Munin config method. |
|
| 134 |
if (exists $ARGV[0] and $ARGV[0] eq "config") {
|
|
| 135 |
print "graph_title NGINX status\n"; |
|
| 136 |
print "graph_args --base 1000\n"; |
|
| 137 |
print "graph_category nginx\n"; |
|
| 138 |
print "graph_vlabel Connections\n"; |
|
| 139 |
|
|
| 140 |
print "total.label Active connections\n"; |
|
| 141 |
print "total.info Active connections\n"; |
|
| 142 |
print "total.draw LINE2\n"; |
|
| 143 |
|
|
| 144 |
print "reading.label Reading\n"; |
|
| 145 |
print "reading.info Reading\n"; |
|
| 146 |
print "reading.draw LINE2\n"; |
|
| 147 |
|
|
| 148 |
print "writing.label Writing\n"; |
|
| 149 |
print "writing.info Writing\n"; |
|
| 150 |
print "writing.draw LINE2\n"; |
|
| 151 |
|
|
| 152 |
print "waiting.label Waiting\n"; |
|
| 153 |
print "waiting.info Waiting\n"; |
|
| 154 |
print "waiting.draw LINE2\n"; |
|
| 155 |
|
|
| 156 |
exit 0; |
|
| 157 |
} |
|
| 158 |
|
|
| 159 |
my $ua = LWP::UserAgent->new(timeout => 30); |
|
| 160 |
# Set the UA to something different from the libwww-perl. |
|
| 161 |
# That UA is blocked. |
|
| 162 |
$ua->agent($UA); |
|
| 163 |
my $response = $ua->request(HTTP::Request->new('GET',$URL));
|
|
| 164 |
|
|
| 165 |
# Active connections: 1845 |
|
| 166 |
# server accepts handled requests |
|
| 167 |
# 4566318 4566318 84218236 |
|
| 168 |
# Reading: 2 Writing: 278 Waiting: 1565 |
|
| 169 |
if ($response->content =~ /Active connections:\s+(\d+).*Reading:\s+(\d+).*Writing:\s+(\d+).*Waiting:\s+(\d+)/s) {
|
|
| 170 |
print "total.value $1\n"; |
|
| 171 |
print "reading.value $2\n"; |
|
| 172 |
print "writing.value $3\n"; |
|
| 173 |
print "waiting.value $4\n"; |
|
| 174 |
} else {
|
|
| 175 |
foreach (qw(total reading writing waiting)) {
|
|
| 176 |
print "$_.value U\n"; |
|
| 177 |
} |
|
| 178 |
} |
|
| plugins/other/ircu | ||
|---|---|---|
| 1 |
#!/usr/bin/perl |
|
| 2 |
# |
|
| 3 |
# $Log$ |
|
| 4 |
# Revision 1.1 2004/01/02 18:50:00 jimmyo |
|
| 5 |
# Renamed occurrances of lrrd -> munin |
|
| 6 |
# |
|
| 7 |
# Revision 1.1.1.1 2004/01/02 15:18:07 jimmyo |
|
| 8 |
# Import of LRRD CVS tree after renaming to Munin |
|
| 9 |
# |
|
| 10 |
# Revision 1.3 2003/12/18 19:02:36 jimmyo |
|
| 11 |
# Typo |
|
| 12 |
# |
|
| 13 |
# Revision 1.2 2003/12/18 17:14:24 jimmyo |
|
| 14 |
# Added autoconf-support |
|
| 15 |
# |
|
| 16 |
# Revision 1.1 2003/11/10 18:51:50 jimmyo |
|
| 17 |
# Initial entries |
|
| 18 |
# |
|
| 19 |
#%# family=manual |
|
| 20 |
#%# capabilities=autoconf |
|
| 21 |
|
|
| 22 |
my $ret = undef; |
|
| 23 |
|
|
| 24 |
if (! eval "require Net::IRC;") |
|
| 25 |
{
|
|
| 26 |
$ret = "Net::IRC not found"; |
|
| 27 |
} |
|
| 28 |
|
|
| 29 |
if ($ARGV[0] and $ARGV[0] eq "autoconf") |
|
| 30 |
{
|
|
| 31 |
if ($ret) |
|
| 32 |
{
|
|
| 33 |
print "no ($ret)\n"; |
|
| 34 |
exit 1; |
|
| 35 |
} |
|
| 36 |
my $irc = new Net::IRC; |
|
| 37 |
my $conn; |
|
| 38 |
|
|
| 39 |
$irc = new Net::IRC; $conn = $irc->newconn(Nick => 'munin', Server => '192.168.1.1'); |
|
| 40 |
if (!$conn) |
|
| 41 |
{
|
|
| 42 |
print "no (Couldn't connect to IRC server)\n"; |
|
| 43 |
exit 1; |
|
| 44 |
} |
|
| 45 |
print "yes\n"; |
|
| 46 |
exit 0; |
|
| 47 |
} |
|
| 48 |
|
|
| 49 |
if($ARGV[0] and $ARGV[0] eq "config") {
|
|
| 50 |
print "host_name $ENV{FQDN}\n";
|
|
| 51 |
print "graph_title ircd status\n"; |
|
| 52 |
print "graph_order clients channels\n"; |
|
| 53 |
print "graph_args -l 0\n"; |
|
| 54 |
print "clients.label clients\n"; |
|
| 55 |
print "clients.draw LINE2\n"; |
|
| 56 |
print "channels.label channels\n"; |
|
| 57 |
print "channels.draw LINE2\n"; |
|
| 58 |
exit 0; |
|
| 59 |
} |
|
| 60 |
|
|
| 61 |
my $irc = new Net::IRC; |
|
| 62 |
my $conn = $irc->newconn(Nick => 'munin', |
|
| 63 |
Server => '192.168.1.1'); |
|
| 64 |
|
|
| 65 |
my %result; |
|
| 66 |
#$conn->debug(1); |
|
| 67 |
|
|
| 68 |
sub luserclient {
|
|
| 69 |
my($self, $event) = @_; |
|
| 70 |
if(($event->args)[1] =~ /There are (\d+) users and (\d+) invisible/) {
|
|
| 71 |
$result{'clients'} = $1 + $2 - 1; # don't count this script
|
|
| 72 |
} |
|
| 73 |
} |
|
| 74 |
|
|
| 75 |
sub luserchannels {
|
|
| 76 |
my($self, $event) = @_; |
|
| 77 |
if(($event->args)[1] =~ /^(\d+)/) {
|
|
| 78 |
$result{'channels'} = $1;
|
|
| 79 |
} |
|
| 80 |
} |
|
| 81 |
|
|
| 82 |
sub quit {
|
|
| 83 |
my($self, $event) = @_; |
|
| 84 |
open(STDERR, ">/dev/null"); |
|
| 85 |
$self->quit(); |
|
| 86 |
print "clients.value " . $result{'clients'} . "\n";
|
|
| 87 |
print "channels.value " . $result{'channels'} . "\n";
|
|
| 88 |
} |
|
| 89 |
|
|
| 90 |
$conn->add_global_handler('endofmotd', \&quit);
|
|
| 91 |
$conn->add_global_handler('luserclient', \&luserclient);
|
|
| 92 |
$conn->add_global_handler('luserchannels', \&luserchannels);
|
|
| 93 |
|
|
| 94 |
|
|
| 95 |
while(1) {
|
|
| 96 |
$irc->do_one_loop(); |
|
| 97 |
} |
|
| 98 |
|
|
| 99 |
# vim:syntax=perl |
|
| plugins/other/perdition | ||
|---|---|---|
| 1 |
#!/bin/sh |
|
| 2 |
# |
|
| 3 |
# Plugin to graph perdition connections and errors |
|
| 4 |
# Requires: logtail |
|
| 5 |
# |
|
| 6 |
# Copyright Micah Anderson <micah@riseup.net> |
|
| 7 |
# Jan 23, 2005 |
|
| 8 |
# |
|
| 9 |
# |
|
| 10 |
#%# family=contrib |
|
| 11 |
#%# capabilities=autoconf |
|
| 12 |
|
|
| 13 |
# The different log lines we are interested in: |
|
| 14 |
# |
|
| 15 |
# buffy perdition[7583]: Connect: 64.45.82.181->69.50.164.185 |
|
| 16 |
# buffy perdition[20097]: Close: 217.19.50.108->69.50.74.154 user="mek" received=12 sent=23 |
|
| 17 |
# buffy perdition[7435]: Auth: 130.22.173.20->69.90.134.185 user="gotn" server="192.168.0.2" port="143" status="ok" |
|
| 18 |
# buffy perdition[26986]: Auth: 72.13.2.186->69.92.134.215 user="moves" server="192.168.0.2" port="110" status="ok" |
|
| 19 |
|
|
| 20 |
# Then there are some errors, I'm just going to put these all into one line, they could easily be |
|
| 21 |
# separate out if we were interested in how many of each type of error, but 7 lines for this graph is a lot |
|
| 22 |
# buffy perdition[20908]: Fatal Error reading authentication information from client "203.52.112.34->68.92.124.155": Exiting child |
|
| 23 |
# buffy perdition[27754]: Fatal error establishing SSL connection to client |
|
| 24 |
# buffy perdition[5139]: Fatal error negotiating setup. Exiting child. |
|
| 25 |
|
|
| 26 |
# Changelog |
|
| 27 |
# version 0.1 - Jan 23, 2005 |
|
| 28 |
# Micah Anderson <micah@riseup.net> |
|
| 29 |
# - initial author |
|
| 30 |
# version 0.2 - Oct 10, 2007 |
|
| 31 |
# Micah Anderson <micah@riseup.net> |
|
| 32 |
# - fixed copyright and added changelog |
|
| 33 |
# - added TMP env variable |
|
| 34 |
# - set all TEMP_FILE variables to use $TMP |
|
| 35 |
|
|
| 36 |
# Set the location of the perdition logs |
|
| 37 |
PERDITION_LOG=${logfile:-/var/log/perdition.log}
|
|
| 38 |
OFFSET_FILE=/var/lib/munin/plugin-state/perdition.offset |
|
| 39 |
LOGTAIL=${logtail:-/usr/sbin/logtail}
|
|
| 40 |
TMP=${TMP:-/tmp}
|
|
| 41 |
|
|
| 42 |
case `uname -s` in |
|
| 43 |
Linux) |
|
| 44 |
TEMP_FILE=`mktemp -p $TMP/ munin-perdition.XXXXXX` |
|
| 45 |
if [ $? != 0 ]; then |
|
| 46 |
TEMP_FILE=`mktemp $TMP/munin-perdition.XXXXXX` |
|
| 47 |
fi |
|
| 48 |
;; |
|
| 49 |
FreeBSD) |
|
| 50 |
TEMP_FILE=`mktemp -t $TMP` |
|
| 51 |
STATUS=$? |
|
| 52 |
;; |
|
| 53 |
esac |
|
| 54 |
|
|
| 55 |
if [ -z "$TEMP_FILE" ]; then |
|
| 56 |
# Yes, this is unsafe |
|
| 57 |
TEMP_FILE=$TMP/munin-perdition.$$ |
|
| 58 |
rm -rf $TEMP_FILE |
|
| 59 |
touch $TEMP_FILE |
|
| 60 |
fi |
|
| 61 |
|
|
| 62 |
if [ ! -f "$TEMP_FILE" ]; then |
|
| 63 |
exit 3 |
|
| 64 |
fi |
|
| 65 |
|
|
| 66 |
case $1 in |
|
| 67 |
autoconf|detect) |
|
| 68 |
if [ -f ${PERDITION_LOG} -a -x ${LOGTAIL} ]
|
|
| 69 |
then |
|
| 70 |
echo yes |
|
| 71 |
exit 0 |
|
| 72 |
else |
|
| 73 |
echo "no (either $PERDITION_LOG was not found, or logtail was not in your path)" |
|
| 74 |
exit 1 |
|
| 75 |
fi |
|
| 76 |
;; |
|
| 77 |
config) |
|
| 78 |
cat <<EOF |
|
| 79 |
graph_title Perdition Connections |
|
| 80 |
graph_vlabel Number of Connections |
|
| 81 |
graph_total Total |
|
| 82 |
connection.label connections |
|
| 83 |
disconnected.label disconnections |
|
| 84 |
imap.label IMAP Auths |
|
| 85 |
pop.label POP Auths |
|
| 86 |
fatal.label Fatal Errors |
|
| 87 |
EOF |
|
| 88 |
exit 0 |
|
| 89 |
;; |
|
| 90 |
esac |
|
| 91 |
|
|
| 92 |
ARGS=0 |
|
| 93 |
`$LOGTAIL /etc/hosts 2>/dev/null >/dev/null` |
|
| 94 |
if [ $? = 66 ]; then |
|
| 95 |
if [ ! -n "$logtail" ]; then |
|
| 96 |
ARGS=1 |
|
| 97 |
fi |
|
| 98 |
fi |
|
| 99 |
|
|
| 100 |
if [ $ARGS != 0 ]; then |
|
| 101 |
${LOGTAIL} -f ${PERDITION_LOG} -o ${OFFSET_FILE} > ${TEMP_FILE}
|
|
| 102 |
else |
|
| 103 |
${LOGTAIL} ${PERDITION_LOG} ${OFFSET_FILE} > ${TEMP_FILE}
|
|
| 104 |
fi |
|
| 105 |
connection=`grep "Connect:" ${TEMP_FILE} | wc -l`
|
|
| 106 |
disconnected=`grep "Close:" ${TEMP_FILE} | wc -l`
|
|
| 107 |
imap=`grep 'port="143" status="ok"' ${TEMP_FILE} | wc -l`
|
|
| 108 |
pop=`grep 'port="110" status="ok"' ${TEMP_FILE} | wc -l`
|
|
| 109 |
fatal=`grep 'Fatal [e|E]rror' ${TEMP_FILE} | wc -l`
|
|
| 110 |
|
|
| 111 |
rm ${TEMP_FILE}
|
|
| 112 |
|
|
| 113 |
echo "connection.value ${connection}"
|
|
| 114 |
echo "disconnected.value ${disconnected}"
|
|
| 115 |
echo "imap.value ${imap}"
|
|
| 116 |
echo "pop.value ${pop}"
|
|
| 117 |
echo "fatal.value ${fatal}"
|
|
| plugins/processes/multips | ||
|---|---|---|
| 1 |
#!/bin/bash |
|
| 2 |
# |
|
| 3 |
# Script to monitor number of processes. Programs are configured |
|
| 4 |
# in /etc/munin/plugin-conf.d/munin-node |
|
| 5 |
# |
|
| 6 |
# Parameters: |
|
| 7 |
# |
|
| 8 |
# config (required) |
|
| 9 |
# autoconf (optional - used by lrrd-config) |
|
| 10 |
# |
|
| 11 |
# Configuration example |
|
| 12 |
# |
|
| 13 |
# [multips] |
|
| 14 |
# env.multipsnames pop3d imapd sslwrap |
|
| 15 |
# env.regex_imapd ^[0-9]* imapd: |
|
| 16 |
# env.regex_pop3d ^[0-9]* pop3d: |
|
| 17 |
# |
|
| 18 |
# $Log$ |
|
| 19 |
# Revision 1.1 2004/01/29 19:42:45 jimmyo |
|
| 20 |
# Added a new plugin generic/multips to count several procs in one graph. (SF#885579) |
|
| 21 |
# |
|
| 22 |
# |
|
| 23 |
# Magic markers (optional): |
|
| 24 |
#%# family=manual |
|
| 25 |
#%# capabilities=autoconf |
|
| 26 |
|
|
| 27 |
if [ "$1" = "autoconf" ]; then |
|
| 28 |
if [ -z "$multipsnames" ]; then |
|
| 29 |
echo "Configuration required $multipsnames" |
|
| 30 |
else |
|
| 31 |
echo yes |
|
| 32 |
fi |
|
| 33 |
exit 0 |
|
| 34 |
fi |
|
| 35 |
|
|
| 36 |
if [ "$1" = "config" ]; then |
|
| 37 |
|
|
| 38 |
echo graph_title Number of selected processes |
|
| 39 |
echo 'graph_category processes' |
|
| 40 |
echo 'graph_args --base 1000 --vertical-label processes -l 0' |
|
| 41 |
for name in $multipsnames; do |
|
| 42 |
echo "$name.label $name" |
|
| 43 |
echo "$name.draw LINE2" |
|
| 44 |
done |
|
| 45 |
exit 0 |
|
| 46 |
fi |
|
| 47 |
|
|
| 48 |
for name in $multipsnames; do |
|
| 49 |
printf "$name.value " |
|
| 50 |
|
|
| 51 |
eval REGEX='"${regex_'$name'-\<'$name'\>}"'
|
|
| 52 |
PGREP=`which pgrep` |
|
| 53 |
if [ -n "$PGREP" ]; then |
|
| 54 |
$PGREP -f -l "$name" | grep "$REGEX" | wc -l |
|
| 55 |
elif [ -x /usr/ucb/ps ]; then |
|
| 56 |
# Solaris without pgrep. How old is that? |
|
| 57 |
/usr/ucb/ps auxwww | grep "$REGEX" | grep -v grep | wc -l |
|
| 58 |
else |
|
| 59 |
ps auxwww | grep "$REGEX" | grep -v grep | wc -l |
|
| 60 |
fi |
|
| 61 |
done |
|
| plugins/system/lpar_cpu | ||
|---|---|---|
| 1 |
#!/usr/bin/perl -w |
|
| 2 |
# |
|
| 3 |
# Plugin to monitor physical cpu usage in an IBM POWER P5 / OpenPower LPAR |
|
| 4 |
# |
|
| 5 |
# Usage: Place in /etc/munin/plugins (or make a symlink to it there) |
|
| 6 |
# |
|
| 7 |
# Parameters understood: |
|
| 8 |
# |
|
| 9 |
# config |
|
| 10 |
# autoconf |
|
| 11 |
# |
|
| 12 |
# This should be run as root, so drop a file with something like this in |
|
| 13 |
# /etc/munin/plugin-conf.d/lpar_cpu: |
|
| 14 |
# [lpar_cpu] |
|
| 15 |
# user root |
|
| 16 |
# |
|
| 17 |
# Great thanks to Nigel Griffith of IBM for the magic to get these values |
|
| 18 |
# |
|
| 19 |
# Author: Ingvar Hagelund <ingvar(at)linpro.no> |
|
| 20 |
# |
|
| 21 |
# Licence: GNU General Public Licence v2.0, |
|
| 22 |
# see http://www.gnu.org/copyleft/gpl.html |
|
| 23 |
|
|
| 24 |
use strict; |
|
| 25 |
|
|
| 26 |
my $stats="/proc/ppc64/lparcfg"; |
|
| 27 |
my $cpuinfo="/proc/cpuinfo"; |
|
| 28 |
my $seconds=2; |
|
Formats disponibles : Unified diff