2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
10 # | Copyright Mathias Kettner 2014 mk@mathias-kettner.de |
11 # +------------------------------------------------------------------+
13 # This file is part of Check_MK.
14 # The official homepage is at http://mathias-kettner.de/check_mk.
16 # check_mk is free software; you can redistribute it and/or modify it
17 # under the terms of the GNU General Public License as published by
18 # the Free Software Foundation in version 2. check_mk is distributed
19 # in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
20 # out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
21 # PARTICULAR PURPOSE. See the GNU General Public License for more de-
22 # tails. You should have received a copy of the GNU General Public
23 # License along with GNU Make; see the file COPYING. If not, write
24 # to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
25 # Boston, MA 02110-1301 USA.
27 # <<<haproxy:sep(44)>>>
28 # # pxname,svname,qcur,qmax,scur,smax,slim,stot,bin,bout,dreq,dresp,ereq,econ,eresp,wretr,wredis,status,weight,act,bck,chkfail,chkdown,lastchg,downtime,qlimit,pid,iid,sid,throttle,lbtot,tracked,type,rate,rate_lim,rate_max,check_status,check_code,check_duration,hrsp_1xx,hrsp_2xx,hrsp_3xx,hrsp_4xx,hrsp_5xx,hrsp_other,hanafail,req_rate,req_rate_max,req_tot,cli_abrt,srv_abrt,comp_in,comp_out,comp_byp,comp_rsp,lastsess,last_chk,last_agt,qtime,ctime,rtime,ttime,
29 # https_t3test.tgic.de,FRONTEND,,,0,0,2000,0,0,0,0,0,0,,,,,OPEN,,,,,,,,,1,2,0,,,,0,0,0,0,,,,0,0,0,0,0,0,,0,0,0,,,0,0,0,0,,,,,,,,
30 # https_t3test.tgic.de,BACKEND,0,0,0,0,200,0,0,0,0,0,,0,0,0,0,UP,0,0,0,,0,363417,0,,1,2,0,,0,,1,0,,0,,,,0,0,0,0,0,0,,,,,0,0,0,0,0,0,-1,,,0,0,0,0,
31 # t3test,t3test,0,0,0,0,,0,0,0,,0,,0,0,0,0,UP,1,1,0,0,0,363417,0,,1,3,1,,0,,2,0,,0,L4OK,,0,0,0,0,0,0,0,0,,,,0,0,,,,,-1,,,0,0,0,0,
33 # <<<haproxy:sep(44)>>>
34 # BLABLABFO,ELEADC05,0,0,0,5,,841,483793,1386127,,0,,0,751,0,0,UP,1,1,0,0,0,38624,0,,1,5,2,,841,,2,0,,4,L4OK,,0,,,,,,,0,,,,90,751,,,,,169,,,0,0,0,3073,
35 # BLABLABLABLA,FRONTEND,,,0,0,2000,0,0,0,0,0,0,,,,,OPEN,,,,,,,,,1,2,0,,,,0,0,0,0,,,,0,0,0,0,0,0,,0,0,0,,,0,0,0,0,,,,,,,,
36 # LDAP,IP.IP.IP.IP,,,0,32,250,5892,3365040,9470591,0,0,0,,,,,OPEN,,,,,,,,,1,3,1,,,,3,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
38 # from http://www.haproxy.org/download/1.7/doc/management.txt
39 # 0=frontend, 1=backend, 2=server, 3=socket/listener
42 def inventory_haproxy_frontend(info
):
48 def check_haproxy_frontend(item
, _no_params
, info
):
54 session_rate
= get_rate("sessions.%s" % item
, now
, stot
)
56 infotext
= "%s, Session Rate: %.2f/s" % (status
, session_rate
)
57 perfdata
= [("session_rate", session_rate
)]
64 return state
, infotext
, perfdata
67 check_info
["haproxy.frontend"] = {
68 'check_function': check_haproxy_frontend
,
69 'inventory_function': inventory_haproxy_frontend
,
70 'service_description': 'HAProxy Frontend %s',
75 def inventory_haproxy_server(info
):
78 yield "%s/%s" % (line
[0], line
[1]), None
81 def check_haproxy_server(item
, _no_params
, info
):
83 if "%s/%s" % (line
[0], line
[1]) == item
:
86 layer_check
= line
[36]
87 active
= int(line
[19])
88 backup
= int(line
[20])
90 infotext
= "Status: %s" % status
92 infotext
+= " since %s" % get_age_human_readable(int(uptime_str
))
94 if status
== "UP" and (active
or backup
):
99 infotext
+= ", Layer Check: %s" % layer_check
101 infotext
+= ", active"
103 infotext
+= ", backup"
105 infotext
+= ", neither active nor backup (!!)"
107 return state
, infotext
110 check_info
["haproxy.server"] = {
111 'check_function': check_haproxy_server
,
112 'inventory_function': inventory_haproxy_server
,
113 'service_description': 'HAProxy Server %s',