source: noc/ng/etc/map @ 338

Last change on this file since 338 was 42, checked in by presbrey, 18 years ago
scripts.mit.edu NOC graphing
File size: 7.4 KB
Line 
1# File:    $Id: map,v 1.9 2005/10/08 05:55:08 sauber Exp $
2# Author:  (c) Soren Dossing, 2005
3# License: OSI Artistic License
4#          http://www.opensource.org/licenses/artistic-license.php
5
6########################################################################
7#
8# INSTRUCTIONS:
9#
10# This file contains several example of service types. Edit this file to
11# add more service types. The data string from Nagios is in $_ . Use
12# regular expressions to identify and extract data like the examples below
13# below.  Match on either output: or perfdata: . The code is pure perl,
14# that will be run inside and eval{}. Results are expected in @s. The
15# general format is:
16#
17# /output|perfdata:<servicetype> <key>=<value> <key2=value2> .../
18# and push @s, [ <databasename>,
19#                [ <key>,  GAUGE|DERIVE, <value>  ],
20#                [ <key2>, GAUGE|DERIVE, <value2> ],
21#                [ .       .              .        ],
22#                [ .       .              .        ] ];
23#
24# But more advanced code is possible, as long as the resulting
25# datastructure is correct.
26#
27########################################################################
28
29# Service type: ping
30#   output:PING OK - Packet loss = 0%, RTA = 0.00 ms
31/output:PING.*?(\d+)%.+?([.\d]+)\sms/
32and push @s, [ "ping",
33               [ "losspct", GAUGE, $1      ],
34               [ "rta",     GAUGE, $2/1000 ] ];
35
36# Service type: single disk
37#  output:DISK OK - free space: /tmp 663 MB (90%):
38/output:DISK.*free space: (\S+) (\d+) MB \((\d+)\%\)/
39and push @s, [ $1,
40               [ "bytesfree", GAUGE, $2*1024**2 ],
41               [ "bytesmax", GAUGE, $3 ? $2*1024**2/$3*100 : 'U' ],
42               [ "pctfree", GAUGE, $3 ] ];
43
44# Service type: all unix-disk
45# Note: nagiosplugin requires the inode patch
46#   ouput:DISK OK - free space: / 12372 mB (77% inode=96%): /raid 882442 mB (88% inode=91%):
47#   perfdata: /=12372mB;14417;15698;96;16019 /raid=882441mB;999780;999780;91;999780
48/output:DISK.*inode=/ and do {
49  my @_pct = /: (\/.*?) .*?(\d+)% inode=(\d+)%/g;
50  while ( my($_d,$_b,$_i) = splice @_pct,0,3 ) {
51    my @_s;
52    /perfdata:.*$_d=(\d+)\w*?;(\d+);(\d+);(\d+);(\d+)/;
53    push @s, [ $_d,
54               [ "free",     GAUGE, $1*1024**2  ],
55               [ "user",     GAUGE, $2*1024**2  ],
56               [ "root",     GAUGE, $3*1024**2  ],
57               [ "max",      GAUGE, $5*1024**2  ],
58               [ "blockpct", GAUGE, $_b ],
59               [ "inodepct", GAUGE, $_i ] ];
60  }
61};
62
63# Service type: unix-dns
64#   output:DNS OK - 0.008 seconds response time (test.test.1M IN A192.169.0.47)
65#   perfdata:time=8260us;;;0
66/output:DNS.*?([.0-9]+) sec/
67and push @s, [ "dns",
68               [ "response",  GAUGE, $1 ] ];
69
70# Service type: unix-imap
71#   output:IMAP OK - 0.009 second response time on port 143
72/output:IMAP.*?([-.0-9]+) sec/
73and push @s, [ "imap",
74               [ "response", GAUGE, $1 ] ];
75
76# Service type: unix-ldap
77#   ouput:LDAP OK - 0.004 seconds response time
78#   perfdata:time=3657us;;;0
79/output:LDAP.*?([.0-9]+) sec/
80and push @s, [ "ldap",
81               [ "response", GAUGE, $1 ] ];
82
83# Service type: unix-load
84#   output: OK - load average: 0.66, 0.70, 0.73
85#   perfdata:load1=0;15;30;0 load5=0;10;25;0 load15=0;5;20;0
86/output:.*load average: ([.0-9]+), ([.0-9]+), ([.0-9]+)/
87and push @s, [ "load",
88               [ "avg1min",  GAUGE, $1 ],
89               [ "avg5min",  GAUGE, $2 ],
90               [ "avg15min", GAUGE, $3 ] ];
91
92# Service type: unix-mailq
93#   output:WARNING: mailq is 5717 (threshold w = 5000)
94#   perfdata:unsent=5717;5000;10000;0
95/perfdata:unsent=(\d+);(\d+);(\d+);(\d+)/
96and push @s, [ "mailq",
97               [ "qsize", GAUGE, $1 ],
98               [ "qwarn", GAUGE, $2 ],
99               [ "qcrit", GAUGE, $3 ] ];
100
101# Service type: unix-netstat
102#   output:OK
103#   perfdata:udpInDatagrams=46517147, udpOutDatagrams=46192507, udpInErrors=0,
104#   tcpActiveOpens=1451583, tcpPassiveOpens=1076181, tcpAttemptFails=1909,
105#   tcpEstabResets=5045, tcpCurrEstab=6, tcpOutDataBytes=3162434373,
106#   tcpInDataBytes=1942718261, tcpRetransBytes=215439
107/perfdata:.*udpInDatagrams=(\d+), udpOutDatagrams=(\d+), udpInErrors=(\d+), tcpActiveOpens=(\d+), tcpPassiveOpens=(\d+), tcpAttemptFails=(\d+), tcpEstabResets=(\d+), tcpCurrEstab=(\d+), tcpOutDataBytes=(\d+), tcpInDataBytes=(\d+), tcpRetransBytes=(\d+)/
108and push @s, [ "udp",
109               [ "InPkts",  DERIVE, int $1/300 ],
110               [ "OutPkts", DERIVE, int $2/300 ],
111               [ "Errors",  DERIVE, int $3/300 ] ],
112             [ "tcp",
113               [ "ActOpens",    DERIVE, int $4/300    ],
114               [ "PsvOpens",    DERIVE, int $5/300    ],
115               [ "AttmptFails", DERIVE, int $6/300    ],
116               [ "OutBytes",    DERIVE, int $9/300*8  ],
117               [ "InBytes",     DERIVE, int $10/300*8 ] ];
118
119# Service type: unix-ntp
120#   output:NTP OK: Offset 0.001083 secs, jitter 14.84 msec, peer is stratum 1
121/output:NTP.*Offset ([-.0-9]+).*jitter ([-.0-9]+).*stratum (\d+)/
122and push @s, [ "ntp",
123               [ "offset",  GAUGE, $1      ],
124               [ "jitter",  GAUGE, $2/1000 ],
125               [ "stratum", GAUGE, $3+1    ] ];
126
127# Service type: unix-pop
128#   output:POP OK - 0.008 second response time on port 110
129/output:POP.*?([.0-9]+) second/
130and push @s, [ "pop3",
131               [ "response", GAUGE, $1 ] ];
132
133# Service type: unix-procs
134#   output:PROCS OK: 43 processes
135/output:PROCS.*?(\d+) processes\n/
136and push @s, [ "procs",
137               [ "procs", GAUGE, $1 ] ];
138
139# Service type: unix-smtp
140#   output:SMTP OK - 0.187 sec. response time
141/output:SMTP.*?([-.0-9]+) sec/
142and push @s, [ "smtp",
143               [ "response", GAUGE, $1 ] ];
144
145# Service type: unix-swap
146#   output:SWAP OK: 96% free (2616 MB out of 2744 MB)
147#   perfdata:swap=2616MB;274;54;0;2744
148/perfdata:swap=(\d+)MB;(\d+);(\d+);\d+;(\d+)/
149and push @s, [ "swap",
150               [ "swapfree", GAUGE, $1*1024**2 ],
151               [ "swapwarn", GAUGE, $2*1024**2 ],
152               [ "swapcrit", GAUGE, $3*1024**2 ],
153               [ "swapmax",  GAUGE, $4*1024**2 ] ];
154
155# Service type: unix-users
156#   output:USERS OK - 4 users currently logged in
157#   perfdata:users=4;5;10;0
158/perfdata:users=(\d+);(\d+);(\d+)/
159and push @s, [ "procs",
160               [ "users", GAUGE, $1 ],
161               [ "uwarn",  GAUGE, $2 ],
162               [ "ucrit",  GAUGE, $3 ] ];
163
164# Service type: unix-zombies
165#   ouput:PROCS OK: 0 processes with STATE = Z
166/output:PROCS.*?(\d+) processes.*Z/
167and push @s, [ "zombie",
168               [ "zombies", GAUGE, $1 ] ];
169
170# Service type: unix-www
171#   ouput:HTTP OK HTTP/1.1 200 OK - 1456 bytes in 0.003 seconds
172/output:HTTP.*?(\d+) byte.*?([.0-9]+) sec/
173and push @s, [ "http",
174               [ "bps", GAUGE, $1/$2 ] ];
175
176# Service type: unix-tcp
177#   output:TCP OK - 0.061 second response time on port 22
178#   perfdata:time=0.060777s;0.000000;0.000000;0.000000;10.000000
179/output:TCP.*?on port (\d+)\s*perfdata:time=(\d+\.\d+).*(\d+\.\d+)\D*(\d+\.\d+)\D*(\d+\.\d+)\D*(\d+\.\d+)/
180and push @s, [ "tcp_$1",
181               [ 'connect_time',   GAUGE, $2 ],
182               [ 'warning_time',   GAUGE, $3 ],
183               [ 'critical_time',  GAUGE, $4 ],
184               [ 'socket_timeout', GAUGE, $6 ],
185             ];
186
187# Service type: mysql
188#   output: Uptime: 1659115  Threads: 1  Questions: 6424617  Slow queries: 0  Opens: 0  Flush tables: 1  Open tables: 512  Queries per second avg: 3.872 Slave IO: Yes Slave SQL: Yes Seconds Behind Master: 0
189/output:Uptime.*Questions: (\d+).*Queries per second avg: (\d+\.?\d+)/
190and push @s, [ "mysql",
191                [ 'qps', DERIVE, $1 ],
192                [ 'avgqps', GAUGE, $2 ]];
Note: See TracBrowser for help on using the repository browser.