вот тут мне стыдно..... не могу понять в каком месте нужно удалить... и что...
Код: Выделить всё
# File: $Id: map 323 2010-03-07 02:35:50Z mwall $
# License: OSI Artistic License
# http://www.opensource.org/licenses/artistic-license.php
# Author: (c) Soren Dossing, 2005
# Author: (c) 2008 Alan Brenner, Ithaka Harbors
# Author: (c) 2010 Matthew Wall
########################################################################
#
# INSTRUCTIONS:
#
# This file contains several examples of service types. Edit this file to
# add more service types. The data string from Nagios is in $_ . Use
# regular expressions to identify and extract data like the examples below
# below. Match on either output: or perfdata: . The code is pure perl,
# that will be run inside an eval{}. Results are expected in @s. The
# general format is:
#
# /output|perfdata:<servicetype> <key>=<value> <key2=value2> .../
# and push @s, [ <databasename>,
# [ <key>, GAUGE|DERIVE, <value> ],
# [ <key2>, GAUGE|DERIVE, <value2> ],
# [ . . . ],
# [ . . . ] ];
#
# Of course, more advanced code is possible, as long as the resulting
# data structure is correct.
#
########################################################################
# skip these quickly since Nagios will already notice (from Eric Gerbier)
# avoid unuseful timeout and errors
/output:CHECK_NRPE: Socket timeout/
and return;
/output:NRPE: Unable to read output/
and return;
/output:CRITICAL - Socket timeout after/
and return;
/output:Connection refused by host/
and return;
/output:CRITICAL - Plugin timed out after/
and return;
########################################################################
# Service type: ping
# output:PING OK - Packet loss = 0%, RTA = 0.00 ms
/output:PING.*?(\d+)%.+?([.\d]+)\sms/
and push @s, [ 'pingloss',
[ 'losspct', GAUGE, $1 ]]
and push @s, [ 'pingrta',
[ 'rta', GAUGE, $2/1000 ]];
# or for more detail (from Matthew Wall):
#/output:PING.*?(\d+)%.+?([.\d]+)\sms\s*perfdata:rta=([.\d]+)ms;([.\d]+);([.\d]+);([.\d]+)\s+pl=([.\d]+)%;([.\d]+);([.\d]+);([.\d]+)/
#and push @s, [ 'loss',
# [ 'losspct', GAUGE, $1 ],
# [ 'losswarn', GAUGE, $8 ],
# [ 'losscrit', GAUGE, $9 ]]
#and push @s, [ 'rta',
# [ 'rta', GAUGE, $2/1000 ],
# [ 'rtawarn', GAUGE, $4/1000 ],
# [ 'rtacrit', GAUGE, $5/1000 ] ];
# Service type: single disk
# output:DISK OK - free space: /tmp 663 MB (90%):
/output:DISK.*free space: (\S+) (\d+) MB \((\d+)\%\)/
and push @s, [ $1,
[ 'bytesfree', GAUGE, $2*1024**2 ],
[ 'bytesmax', GAUGE, $3 ? $2*1024**2/$3*100 : 'U' ],
[ 'pctfree', GAUGE, $3 ] ];
# Service type: all unix-disk
# Note: nagiosplugin requires the inode patch
# ouput:DISK OK - free space: / 12372 mB (77% inode=96%): /raid 882442 mB (88% inode=91%):
# perfdata: /=12372mB;14417;15698;96;16019 /raid=882441mB;999780;999780;91;999780
/output:DISK.*inode=/ and do {
my @_pct = /: (\/.*?) .*?(\d+)% inode=(\d+)%/g;
while ( my($_d,$_b,$_i) = splice @_pct,0,3 ) {
my @_s;
/perfdata:.*$_d=(\d+)\w*?;(\d+);(\d+);(\d+);(\d+)/;
push @s, [ $_d,
[ 'free', GAUGE, $1*1024**2 ],
[ 'user', GAUGE, $2*1024**2 ],
[ 'root', GAUGE, $3*1024**2 ],
[ 'max', GAUGE, $5*1024**2 ],
[ 'blockpct', GAUGE, $_b ],
[ 'inodepct', GAUGE, $_i ] ];
}
};
# Service type: unix-dns
# output:DNS OK - 0.008 seconds response time (test.test.1M IN A192.169.0.47)
# perfdata:time=8260us;;;0
/output:DNS.*?([.0-9]+) sec/
and push @s, [ 'dns',
[ 'response', GAUGE, $1 ] ];
# Service type: unix-imap
# output:IMAP OK - 0.009 second response time on port 143
/output:IMAP.*?([-.0-9]+) sec/
and push @s, [ 'imap',
[ 'response', GAUGE, $1 ] ];
# Service type: unix-ldap
# ouput:LDAP OK - 0.004 seconds response time
# perfdata:time=3657us;;;0
/output:LDAP.*?([.0-9]+) sec/
and push @s, [ 'ldap',
[ 'response', GAUGE, $1 ] ];
# Service type: unix-load
# output: OK - load average: 0.66, 0.70, 0.73
# perfdata:load1=0;15;30;0 load5=0;10;25;0 load15=0;5;20;0
/output:.*load average: ([.0-9]+), ([.0-9]+), ([.0-9]+)/
and push @s, [ 'load',
[ 'avg1min', GAUGE, $1 ],
[ 'avg5min', GAUGE, $2 ],
[ 'avg15min', GAUGE, $3 ] ];
# Service type: unix-mailq
# output:WARNING: mailq is 5717 (threshold w = 5000)
# perfdata:unsent=5717;5000;10000;0
/perfdata:unsent=(\d+);(\d+);(\d+);(\d+)/
and push @s, [ 'mailq',
[ 'qsize', GAUGE, $1 ],
[ 'qwarn', GAUGE, $2 ],
[ 'qcrit', GAUGE, $3 ] ];
# or, if you prefer (from Matthew Wall):
# [ 'size', GAUGE, $1 ],
# [ 'warn', GAUGE, $2 ],
# [ 'crit', GAUGE, $3 ] ];
# Service type: unix-netstat
# output:OK
# perfdata:udpInDatagrams=46517147, udpOutDatagrams=46192507, udpInErrors=0,
# tcpActiveOpens=1451583, tcpPassiveOpens=1076181, tcpAttemptFails=1909,
# tcpEstabResets=5045, tcpCurrEstab=6, tcpOutDataBytes=3162434373,
# tcpInDataBytes=1942718261, tcpRetransBytes=215439
/perfdata:.*udpInDatagrams=(\d+), udpOutDatagrams=(\d+), udpInErrors=(\d+), tcpActiveOpens=(\d+), tcpPassiveOpens=(\d+), tcpAttemptFails=(\d+), tcpEstabResets=(\d+), tcpCurrEstab=(\d+), tcpOutDataBytes=(\d+), tcpInDataBytes=(\d+), tcpRetransBytes=(\d+)/
and push @s, [ 'udp',
[ 'InPkts', DERIVE, int $1/300 ],
[ 'OutPkts', DERIVE, int $2/300 ],
[ 'Errors', DERIVE, int $3/300 ] ],
[ 'tcp',
[ 'ActOpens', DERIVE, int $4/300 ],
[ 'PsvOpens', DERIVE, int $5/300 ],
[ 'AttmptFails', DERIVE, int $6/300 ],
[ 'OutBytes', DERIVE, int $9/300*8 ],
[ 'InBytes', DERIVE, int $10/300*8 ] ];
# Service type: unix-ntp
# output:NTP OK: Offset 0.001083 secs, jitter 14.84 msec, peer is stratum 1
/output:NTP.*Offset ([-.0-9]+).*jitter ([-.0-9]+).*stratum (\d+)/
and push @s, [ 'ntp',
[ 'offset', GAUGE, $1 ],
[ 'jitter', GAUGE, $2/1000 ],
[ 'stratum', GAUGE, $3+1 ] ];
# Service type: unix-pop
# output:POP OK - 0.008 second response time on port 110
/output:POP.*?([.0-9]+) second/
and push @s, [ 'pop3',
[ 'response', GAUGE, $1 ] ];
# Service type: unix-procs
# output:PROCS OK: 43 processes
/output:PROCS.*?(\d+) processes\n/
and push @s, [ 'procs',
[ 'procs', GAUGE, $1 ] ];
# Service type: unix-smtp
# output:SMTP OK - 0.187 sec. response time
/output:SMTP.*?([-.0-9]+) sec/
and push @s, [ 'smtp',
[ 'response', GAUGE, $1 ] ];
# Service type: unix-swap
# output:SWAP OK: 96% free (2616 MB out of 2744 MB)
# perfdata:swap=2616MB;274;54;0;2744
/perfdata:swap=(\d+)MB;(\d+);(\d+);\d+;(\d+)/
and push @s, [ 'swap',
[ 'swapfree', GAUGE, $1*1024**2 ],
[ 'swapwarn', GAUGE, $2*1024**2 ],
[ 'swapcrit', GAUGE, $3*1024**2 ],
[ 'swapmax', GAUGE, $4*1024**2 ] ];
# or, if you prefer (from Matthew Wall):
# [ 'free', GAUGE, $1*1024**2 ],
# [ 'max', GAUGE, $4*1024**2 ],
# [ 'warn', GAUGE, $2*1024**2 ],
# [ 'crit', GAUGE, $3*1024**2 ] ];
# Service type: unix-users
# output:USERS OK - 4 users currently logged in
# perfdata:users=4;5;10;0
/perfdata:users=(\d+);(\d+);(\d+)/
and push @s, [ 'procs',
[ 'users', GAUGE, $1 ],
[ 'uwarn', GAUGE, $2 ],
[ 'ucrit', GAUGE, $3 ] ];
# or, if you prefer (from Matthew Wall):
#and push @s, [ 'procs',
# [ 'users', GAUGE, $1 ],
# [ 'warn', GAUGE, $2 ],
# [ 'crit', GAUGE, $3 ] ];
# Service type: unix-zombies
# ouput:PROCS OK: 0 processes with STATE = Z
/output:PROCS.*?(\d+) processes.*Z/
and push @s, [ 'zombie',
[ 'zombies', GAUGE, $1 ] ];
# Service type: unix-www
# ouput:HTTP OK HTTP/1.1 200 OK - 1456 bytes in 0.003 seconds
/output:HTTP.*?(\d+) byte.*?([.0-9]+) sec/
and push @s, [ 'http',
[ 'bps', GAUGE, $1/$2 ] ];
# Service type: unix-tcp
# output:TCP OK - 0.061 second response time on port 22
# perfdata:time=0.060777s;0.000000;0.000000;0.000000;10.000000
/output:TCP.*?on port (\d+)\s*perfdata:time=(\d+\.\d+).*(\d+\.\d+)\D*(\d+\.\d+)\D*(\d+\.\d+)\D*(\d+\.\d+)/
and push @s, [ "tcp_$1",
[ 'connect_time', GAUGE, $2 ],
[ 'warning_time', GAUGE, $3 ],
[ 'critical_time', GAUGE, $4 ],
[ 'socket_timeout', GAUGE, $6 ],
];
# more examples from Matthew Wall:
# Service type: apcupsd
# output:Battery Charge: 100.0%
# perfdata:charge=100.0;50;10
/output:.*Charge.*?([.\d]+)%/
and push @s, [ 'charge',
[ 'charge', GAUGE, $1 ] ];
# Service type: apcupsd
# output:OK - Time Left: 42.0 Minutes
# perfdata:timeleft=42.0;20;10
#/output:.*Time.*?([.\d]+)\sMinutes/
/perfdata:timeleft=([.\d]+);([.\d]+);([.\d]+)/
and push @s, [ 'time',
[ 'timeleft', GAUGE, $1 ],
[ 'warn', GAUGE, $2 ],
[ 'crit', GAUGE, $3 ] ];
# Service type: apcupsd
# output:OK - Load: 5.2%
# perfdata:load=3.6;30;40
#/output:.*Load.*?([.\d]+)%/
/perfdata:load=([.\d]+);([.\d]+);([.\d]+)/
and push @s, [ 'load',
[ 'load', GAUGE, $1 ],
[ 'warn', GAUGE, $2 ],
[ 'crit', GAUGE, $3 ] ];
# Service type: apcupsd
# output:OK - Internal Temperature: 25.6 C
# perfdata:temperature=25.6;30;40
#/output:.*Temperature.*?([.\d]+)\sC/
/perfdata:temperature=([.\d]+);([.\d]+);([.\d]+)/
and push @s, [ 'temp',
[ 'temperature', GAUGE, $1 ],
[ 'warn', GAUGE, $2 ],
[ 'crit', GAUGE, $3 ] ];
# Service type: unix uptime
# output:OK - uptime is 36 Days, 2 Hours, 42 Minutes
# perfdata:
/output:.*uptime is.*?([.\d]+)\sDays/
and push @s, [ 'data',
[ 'days', GAUGE, $1 ] ]
or (/output:.*uptime is.*?([.\d]+)\sHours/
and push @s, [ 'data',
[ 'days', GAUGE, $1/24 ] ])
or (/output:.*uptime is.*?([.\d]+)\sMinutes/
and push @s, [ 'data',
[ 'days', GAUGE, $1/1440 ] ]);
# Service type: macosx-ntp
# output:NTP OK: Offset 0.001083 secs
/output:NTP.*Offset ([-.0-9]+)/
and push @s, [ 'ntp',
[ 'offset', GAUGE, $1 ] ];
# Service type: unix-ntp-client
# output:NTP OK: Offset 0.001083 secs
# perfdata:offset=1032.98;60.00000; 120.00000;
/perfdata: offset=([-.0-9]+)s;(.\d+);(.\d+);/
and push @s, [ 'data',
[ 'offset', GAUGE, $1 ],
[ 'warn', GAUGE, $2 ],
[ 'crit', GAUGE, $3 ] ];
# Service type: unix total processes
# output:OK: Total: 90, Zombie: 0, RSDT: 23
# perfdata:total=90 zombie=0 rsdt=23
/perfdata:total=(\d+) zombie=(\d+) rsdt=(\d+)/
and push @s, [ 'data',
[ 'total', GAUGE, $1 ],
[ 'zombie', GAUGE, $2 ],
[ 'rsdt', GAUGE, $3 ] ];
# Service type: unix cpu
# output: User: 14%, Nice: 0%, System: 1%, Idle: 83%
# perfdata: user=14.17 nice=0 sys=1.9488 idle=83.87
/perfdata:user=([.\d]+) nice=([.\d]+) sys=([.\d]+) idle=([.\d]+)/
and push @s, [ 'cpu',
[ 'user', GAUGE, $1 ],
[ 'nice', GAUGE, $2 ],
[ 'system', GAUGE, $3 ],
[ 'idle', GAUGE, $4 ]];
# Service type: unix memory
# output: Real Free: 25924 kB, Swap Free: 1505472 kb
# perfdata: total=514560 free=25924 swaptot=1506172 swapfree=1505472
/perfdata:total=([\d]+) free=([\d]+) swaptot=([\d]+) swapfree=([\d]+)/
and push @s, [ 'data',
[ 'real_total', GAUGE, $1 ],
[ 'real_free', GAUGE, $2 ],
[ 'swap_total', GAUGE, $3 ],
[ 'swap_free', GAUGE, $4 ]];
# Service type: unix network
# output: Received 3956221475, Transmitted = 571374458
# perfdata: rbyte=3956221475 rpacket=36097353 rerr=0 rdrop=0 rmult=0 tbyte=571374458 tpacket=62062295 terr=6 tdrop=0 tmult=0
/perfdata:rbyte=([\d]+) rpacket=([\d]+) rerr=([\d]+) rdrop=([\d]+) rmult=([\d]+) tbyte=([\d]+) tpacket=([\d]+) terr=([\d]+) tdrop=([\d]+) tmult=([\d]+)/
and push @s, [ 'data',
[ 'byte_received', COUNTER, $1 ],
[ 'byte_transmitted', COUNTER, $6 ],
[ 'packet_received', COUNTER, $2 ],
[ 'packet_transmitted', COUNTER, $7 ],
[ 'error_received', COUNTER, $3 ],
[ 'error_transmitted', COUNTER, $8 ],
[ 'drop_received', COUNTER, $4 ],
[ 'drop_transmitted', COUNTER, $9 ],
[ 'multi_received', COUNTER, $5 ],
[ 'multi_transmitted', COUNTER, $10 ]];
# Example for handling variable number of input items in one entry (from a
# request from Mathias Waack to handle tracking Oracle tablespace usage):
#/output:.*tbs.*usage is/ and do {
# my @order = /tbs ([A-Z0-9]+) usage/g;
# my %data = /tbs ([A-Z0-9]+) usage is ([0-9.]+)%/g;
# my @rval;
# foreach my $key (@order) {
# push @rval, [$key, 'GAUGE', $data{$key}];
# }
# push @s, ['tablespaces', @rval];
#};