Module: check_mk
Branch: master
Commit: f850f78bf51962bb0d29390c664552c1c6af1565
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=f850f78bf51962…
Author: Goetz Golla <gg(a)mathias-kettner.de>
Date: Mon Jul 6 14:39:03 2015 +0200
#2127 haproxy.frontend, haproxy.server: new checks and agent plugin for HAProxy
---
.werks/2127 | 8 +++
ChangeLog | 1 +
agents/plugins/mk_haproxy.freebsd | 5 ++
checkman/haproxy.frontend | 22 ++++++++
checkman/haproxy.server | 19 +++++++
checks/haproxy | 104 +++++++++++++++++++++++++++++++++++++
modules/catalog.py | 1 +
web/plugins/metrics/check_mk.py | 15 +++++-
8 files changed, 174 insertions(+), 1 deletion(-)
diff --git a/.werks/2127 b/.werks/2127
new file mode 100644
index 0000000..0f1ad38
--- /dev/null
+++ b/.werks/2127
@@ -0,0 +1,8 @@
+Title: haproxy.frontend, haproxy.server: new checks and agent plugin for HAProxy
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.2.7i3
+Date: 1436186276
+Class: feature
+
diff --git a/ChangeLog b/ChangeLog
index e754917..c0bf304 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -8,6 +8,7 @@
* 2448 Various Checks for Citrix XenApp 7.x Farms...
* 2399 agent_vsphere/esx_vsphere_counters.if: now also reports interface state,
bandwidth and mac address...
* 1262 check_dns, check_ldap, check_smtp: It is now possible to customize the service
descriptions of this checks....
+ * 2127 haproxy.frontend, haproxy.server: new checks and agent plugin for HAProxy
* 2315 FIX: windows agent: BOM replacement, fixed incorrect byte offset...
* 2316 FIX: windows agent: fix garbled output of cached agent plugins...
* 2358 FIX: check_mk_agent.solaris: more correct computation of zfs used space...
diff --git a/agents/plugins/mk_haproxy.freebsd b/agents/plugins/mk_haproxy.freebsd
new file mode 100755
index 0000000..c56c85a
--- /dev/null
+++ b/agents/plugins/mk_haproxy.freebsd
@@ -0,0 +1,5 @@
+if [ -r /var/run/haproxy.stat ]; then
+ echo "<<<haproxy:sep(44)>>>"
+ echo "show stat" | socat - UNIX-CONNECT:/var/run/haproxy.sock
+fi
+
diff --git a/checkman/haproxy.frontend b/checkman/haproxy.frontend
new file mode 100644
index 0000000..7d39231
--- /dev/null
+++ b/checkman/haproxy.frontend
@@ -0,0 +1,22 @@
+title: HAProxy: Status of the Frontends
+agents: freebsd
+catalog: hw/app/haproxy
+license: GPL
+distribution: check_mk
+description:
+
+ This check monitors the status of the frontends of the HAProxy loadbalancer
+ for TCP and HTTP connections. It requires the mk_haproxy.freebsd agent plugin
+ to be installed on the FreeBSD host to be monitored.
+
+ The check is {OK} if the frontend has the status {OPEN}. It is {CRIT}
+ otherwise.
+
+item:
+ The name of the frontend.
+
+inventory:
+ One service for each frontend is created.
+
+perfdata:
+ The session rate of the frontend.
diff --git a/checkman/haproxy.server b/checkman/haproxy.server
new file mode 100644
index 0000000..2bba86a
--- /dev/null
+++ b/checkman/haproxy.server
@@ -0,0 +1,19 @@
+title: HAProxy: Server Status
+agents: freebsd
+catalog: hw/app/haproxy
+license: GPL
+distribution: check_mk
+description:
+
+ This check monitors the status of the servers of the HAProxy loadbalancer
+ for TCP and HTTP connections. It requires the mk_haproxy.freebsd agent
+ plugin to be installed on the FreeBSD host to be monitored.
+
+ The check is {OK} if the server indicates the status {UP} and either {active}
+ or {backup}. It is {CRIT} otherwise.
+
+item:
+ The name of backend and server, separated by a "/".
+
+inventory:
+ One service for each server is created.
diff --git a/checks/haproxy b/checks/haproxy
new file mode 100644
index 0000000..e761263
--- /dev/null
+++ b/checks/haproxy
@@ -0,0 +1,104 @@
+#!/usr/bin/python
+# -*- encoding: utf-8; py-indent-offset: 4 -*-
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | Copyright Mathias Kettner 2014 mk(a)mathias-kettner.de |
+# +------------------------------------------------------------------+
+#
+# This file is part of Check_MK.
+# The official homepage is at
http://mathias-kettner.de/check_mk.
+#
+# check_mk 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 in version 2. check_mk is distributed
+# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
+# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE. See the GNU General Public License for more de-
+# ails. You should have received a copy of the GNU General Public
+# License along with GNU Make; see the file COPYING. If not, write
+# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+# Boston, MA 02110-1301 USA.
+
+
+# Example output from agent:
+# <<<haproxy:sep(44)>>>
+# #
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,
+#
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,,,,,,,,
+#
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,
+#
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,
+
+
+def inventory_haproxy_frontend(info):
+ for line in info:
+ if line[1] == "FRONTEND":
+ yield line[0], None
+
+def check_haproxy_frontend(item, _no_params, info):
+ for line in info:
+ if line[1] == "FRONTEND" and line[0] == item:
+ now = time.time()
+ status = line[17]
+ stot = int(line[7])
+ session_rate = get_rate("sessions.%s" % item, now, stot)
+
+ infotext = "%s, Session Rate: %.2f/s" % (status, session_rate)
+ perfdata = [ ("session_rate", session_rate) ]
+
+ if status == "OPEN":
+ state = 0
+ else:
+ state = 2
+
+ return state, infotext, perfdata
+
+
+check_info["haproxy.frontend"] = {
+ 'check_function' : check_haproxy_frontend,
+ 'inventory_function' : inventory_haproxy_frontend,
+ 'service_description' : 'HAProxy Frontend %s',
+ 'has_perfdata' : True,
+}
+
+
+def inventory_haproxy_server(info):
+ for line in info:
+ if line[1] != "BACKEND" and line[1] != "FRONTEND" and not
line[0].startswith("#"):
+ item = "%s/%s" % (line[0], line[1])
+ yield item, None
+
+def check_haproxy_server(item, _no_params, info):
+ backend, server = item.split("/")
+ for line in info:
+ if line[0] == backend and line[1] == server:
+ status = line[17]
+ uptime = get_age_human_readable(int(line[23]))
+ layer_check = line[36]
+ active = int(line[19])
+ backup = int(line[20])
+
+ if status == "UP" and (active or backup):
+ state = 0
+ else:
+ state = 2
+
+ infotext = "%s since %s, Layer Check: %s" % \
+ (status, uptime, layer_check)
+ if active:
+ infotext += ", active"
+ elif backup:
+ infotext += ", backup"
+ else:
+ infotext += ", neither active nor backup (!!)"
+ return state, infotext
+
+
+check_info["haproxy.server"] = {
+ 'check_function' : check_haproxy_server,
+ 'inventory_function' : inventory_haproxy_server,
+ 'service_description' : 'HAProxy Server %s',
+}
diff --git a/modules/catalog.py b/modules/catalog.py
index f3d1174..6900d46 100644
--- a/modules/catalog.py
+++ b/modules/catalog.py
@@ -106,6 +106,7 @@ manpage_catalog_titles = {
"citrix" : "Citrix",
"netscaler" : "Citrix Netscaler",
"exchange" : "Microsoft Exchange",
+ "haproxy" : "HAProxy Loadbalancer",
"java" : "Java (Tomcat, Weblogic, JBoss, etc.)",
"libelle" : "Libelle Business Shadow",
"lotusnotes" : "IBM Lotus Domino",
diff --git a/web/plugins/metrics/check_mk.py b/web/plugins/metrics/check_mk.py
index 52184f2..d13d663 100644
--- a/web/plugins/metrics/check_mk.py
+++ b/web/plugins/metrics/check_mk.py
@@ -1136,6 +1136,12 @@ metric_info["inactive_sessions"] = {
"color" : "13/a",
}
+metric_info["session_rate"] = {
+ "title" : _("Session Rate"),
+ "unit" : "1/s",
+ "color" : "#4080a0",
+}
+
metric_info["shared_locks"] = {
"title" : _("Shared locks"),
"unit" : "count",
@@ -3188,6 +3194,13 @@ perfometer_info.append({
perfometer_info.append({
"type" : "logarithmic",
+ "metric" : "session_rate",
+ "half_value" : 50.0,
+ "exponent" : 2,
+})
+
+perfometer_info.append({
+ "type" : "logarithmic",
"metric" : "uptime",
"half_value" : 2592000.0,
"exponent" : 2,
@@ -4874,7 +4887,7 @@ graph_info.append({
"title" : _("Livestatus Requests per Connection"),
"metrics" : [
( "livestatus_request_rate,livestatus_connect_rate,/#88aa33",
"area",
- _("Averate requests per connection")),
+ _("Average requests per connection")),
],
})