Module: check_mk
Branch: master
Commit: 07c8c5f0f9d4d7f49b0bee500ab2d8149ff8e98a
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=07c8c5f0f9d4d7…
Author: Bastian Kuhn <bk(a)mathias-kettner.de>
Date: Thu May 21 20:50:19 2015 +0200
Corrected path
---
acme_sbc => checks/acme_sbc | 35 ++++++++++++++++++++++++++++++++++-
1 file changed, 34 insertions(+), 1 deletion(-)
diff --git a/acme_sbc b/checks/acme_sbc
similarity index 63%
rename from acme_sbc
rename to checks/acme_sbc
index 261a3a9..6566f0c 100644
--- a/acme_sbc
+++ b/checks/acme_sbc
@@ -24,8 +24,41 @@
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA.
+# <<<acme_sbc>>>
+# show health
+# Media Synchronized true
+# SIP Synchronized true
+# BGF Synchronized disabled
+# MGCP Synchronized disabled
+# H248 Synchronized disabled
+# Config Synchronized true
+# Collect Synchronized disabled
+# Radius CDR Synchronized disabled
+# Rotated CDRs Synchronized disabled
+# IPSEC Synchronized disabled
+# Iked Synchronized disabled
+# Active Peer Address 179.253.2.2
+#
+# Redundancy Protocol Process (v3):
+# State Standby
+# Health 100
+# Lowest Local Address 189.253.3.1:9090
+# 1 peer(s) on 2 socket(s):
+# BERTZSBC02: v3, Active, health=100, max silence=1050
+# last received from 142.224.2.3 on wancom1:0
+#
+# Switchover log:
+# Apr 24 10:14:09.235: Standby to BecomingActive, active peer xxx has timed out, no arp reply from active in 250ms
+# Oct 17 10:07:44.567: Active to RelinquishingActive
+# Oct 20 18:41:11.855: Standby to BecomingActive, active peer xxx has unacceptable health (70)
+# Oct 29 11:46:04.294: Active to RelinquishingActive
+# Oct 29 11:47:05.452: Standby to BecomingActive, active peer xxx has unacceptable health (70)
+# Dec 8 11:37:36.445: Active to RelinquishingActive
+# Dec 8 11:43:00.227: Standby to BecomingActive, active peer xxx has timed out, no arp reply from active in 250ms
+# Mar 16 10:13:33.248: Active to RelinquishingActive
+
def acme_sbc_parse_function(info):
- states = {}
+ states = {}
settings = {}
for line in info:
if len(line) == 2:
Module: check_mk
Branch: master
Commit: 069a5bc29eec36728f868437941ae29f7aba4173
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=069a5bc29eec36…
Author: Bastian Kuhn <bk(a)mathias-kettner.de>
Date: Thu May 21 13:55:18 2015 +0200
#1248 acme_sbc, acme_sbc.settings: New Checks to monitor an ACME Session Border Controller
In order to work, that check needs excpect installed on the monitoring server. Also it's needed to add a public SSH keys from your OMD Site to the device.
---
.werks/1248 | 10 +++++
ChangeLog | 1 +
acme_sbc | 73 +++++++++++++++++++++++++++++++
agents/special/agent_acme_sbc | 12 +++++
checkman/acme_sbc | 12 +++++
checkman/acme_sbc.settings | 11 +++++
checks/agent_acme_sbc | 30 +++++++++++++
web/plugins/wato/datasource_programs.py | 14 ++++++
8 files changed, 163 insertions(+)
diff --git a/.werks/1248 b/.werks/1248
new file mode 100644
index 0000000..445f194
--- /dev/null
+++ b/.werks/1248
@@ -0,0 +1,10 @@
+Title: acme_sbc, acme_sbc.settings: New Checks to monitor an ACME Session Border Controller
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.2.7i1
+Date: 1432209154
+Class: feature
+
+In order to work, that check needs excpect installed on the monitoring server. Also it's needed to add a public SSH keys from your OMD Site to the device.
+
diff --git a/ChangeLog b/ChangeLog
index c66bdfe..5897a46 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -190,6 +190,7 @@
* 2294 if, if64: Move global option for padding port numbers with zeroes into rule...
* 2296 win_dhcp_pools: Convert global option for discovery empty pools into rule set...
* 1247 alcatel_timetra_chassis: New Check for Slots, Power Supplies, MDAs, cf cards and Fans of Alcatel Switches Supporting the TIMETRA-CHASSIS-MIB
+ * 1248 acme_sbc, acme_sbc.settings: New Checks to monitor an ACME Session Border Controller...
* 1457 FIX: logins: new check renamed from "users" check...
NOTE: Please refer to the migration notes!
* 1762 FIX: lnx_thermal: Now ignoring trip points with level 0...
diff --git a/acme_sbc b/acme_sbc
new file mode 100644
index 0000000..261a3a9
--- /dev/null
+++ b/acme_sbc
@@ -0,0 +1,73 @@
+#!/usr/bin/python
+# -*- encoding: utf-8; py-indent-offset: 4 -*-
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | Copyright Mathias Kettner 2013 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.
+
+def acme_sbc_parse_function(info):
+ states = {}
+ settings = {}
+ for line in info:
+ if len(line) == 2:
+ for what in [ "Health", "State" ]:
+ if line[0] == what:
+ states[what] = line[1]
+ elif len(line) == 3 and line[1] == "Synchronized":
+ settings[line[0]] = line[2]
+ return states, settings
+
+def inventory_acme_sbc(parsed):
+ return [(None, None)]
+
+def check_acme_sbc(_no_item, _no_params, parsed):
+ health = int(parsed[0]["Health"])
+ dev_state = parsed[0]["State"]
+ if health == 100:
+ state = 0
+ else:
+ state = 2
+ return state, "Health at %d %% (State: %s)" % (health, dev_state)
+
+check_info["acme_sbc"] = {
+ "check_function" : check_acme_sbc,
+ "inventory_function" : inventory_acme_sbc,
+ "service_description" : "Status",
+ "parse_function" : acme_sbc_parse_function,
+}
+
+def inventory_acme_sbc_settings(parsed):
+ return [(None, parsed[1])]
+
+def check_acme_sbc_settings(_no_item, params, parsed):
+ current_settings = parsed[1]
+ saved_settings = params
+ yield 0, "Checking %d settings" % len(saved_settings)
+ for setting, value in saved_settings.items():
+ if current_settings[setting] != value:
+ yield 2, "%s changed from %s to %s" % (setting, value, current_settings[setting])
+
+check_info["acme_sbc.settings"] = {
+ "check_function" : check_acme_sbc_settings,
+ "inventory_function" : inventory_acme_sbc_settings,
+ "service_description" : "Settings",
+}
diff --git a/agents/special/agent_acme_sbc b/agents/special/agent_acme_sbc
new file mode 100644
index 0000000..93d6ace
--- /dev/null
+++ b/agents/special/agent_acme_sbc
@@ -0,0 +1,12 @@
+#!/usr/bin/expect -f
+send_user "<<<acme_sbc>>>\n"
+log_user 0
+set host [lindex $argv 0]
+spawn ssh -l user $host
+
+expect "*>"
+log_user 1
+send "show health\r"
+expect "*>"
+log_user 0
+send "exit\r"
diff --git a/checkman/acme_sbc b/checkman/acme_sbc
new file mode 100644
index 0000000..0cbe5f9
--- /dev/null
+++ b/checkman/acme_sbc
@@ -0,0 +1,12 @@
+title: ACME SBC: Health
+agents: special
+catalog: hw/network/acme
+license: GPL
+distribution: check_mk
+description:
+ This is a simple check which checks the health status in percent.
+ The percent value is reported by the devices and reflects the status of cluster
+ and harware. If the status not is at 100 %, a {CRIT} is raised.
+
+inventory:
+ One check will be created.
diff --git a/checkman/acme_sbc.settings b/checkman/acme_sbc.settings
new file mode 100644
index 0000000..92d3a26
--- /dev/null
+++ b/checkman/acme_sbc.settings
@@ -0,0 +1,11 @@
+title: ACME SBC: Health Settings
+agents: special
+catalog: hw/network/acme
+license: GPL
+distribution: check_mk
+description:
+ This Checks monitors changes of health releated options on the device.
+ If e.g. Media Synchronized changes from true to disabled/ false, a {CRIT} is raised.
+
+inventory:
+ One check will be created.
diff --git a/checks/agent_acme_sbc b/checks/agent_acme_sbc
new file mode 100644
index 0000000..65a11b6
--- /dev/null
+++ b/checks/agent_acme_sbc
@@ -0,0 +1,30 @@
+#!/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.
+
+def agent_acme_sbc(params, hostname, ipaddress):
+ return hostname
+
+special_agent_info['acme_sbc'] = agent_acme_sbc
diff --git a/web/plugins/wato/datasource_programs.py b/web/plugins/wato/datasource_programs.py
index d816bb4..b918974 100644
--- a/web/plugins/wato/datasource_programs.py
+++ b/web/plugins/wato/datasource_programs.py
@@ -360,6 +360,20 @@ register_rule(group,
match = 'first')
register_rule(group,
+ "special_agents:acme_sbc",
+ FixedValue(
+ {},
+ title = _("Check ACME Session Border Controller"),
+ help = _("This rule activates an expect based agent who connects"
+ "to an ACME Session Border Controller (SBC). This agent uses SSH, this"
+ "means that you have to exchange a SSH key to make a password less"
+ "connect possible"),
+ totext = _("Connect to ACME SBC"),
+ ),
+ factory_default = FACTORY_DEFAULT_UNUSED, # No default, do not use setting if no rule matches
+ match = 'first')
+
+register_rule(group,
"special_agents:fritzbox",
Dictionary(
title = _("Check state of Fritz!Box Devices"),
Module: check_mk
Branch: master
Commit: c427b6c9d97f89a4aadef129186af33eb80dcd98
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=c427b6c9d97f89…
Author: Bastian Kuhn <bk(a)mathias-kettner.de>
Date: Thu May 21 13:29:13 2015 +0200
#1247 alcatel_timetra_chassis: New Check for Slots, Power Supplies, MDAs, cf cards and Fans of Alcatel Switches Supporting the TIMETRA-CHASSIS-MIB
---
.werks/1247 | 9 ++++
ChangeLog | 1 +
checkman/alcatel_timetra_chassis | 20 +++++++
checks/alcatel_timetra_chassis | 106 ++++++++++++++++++++++++++++++++++++++
4 files changed, 136 insertions(+)
diff --git a/.werks/1247 b/.werks/1247
new file mode 100644
index 0000000..d505927
--- /dev/null
+++ b/.werks/1247
@@ -0,0 +1,9 @@
+Title: alcatel_timetra_chassis: New Check for Slots, Power Supplies, MDAs, cf cards and Fans of Alcatel Switches Supporting the TIMETRA-CHASSIS-MIB
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.2.7i1
+Date: 1432207625
+Class: feature
+
+
diff --git a/ChangeLog b/ChangeLog
index 55cfb0a..c66bdfe 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -189,6 +189,7 @@
* 2293 logwatch: Remove global setting logwatch_service_output from WATO...
* 2294 if, if64: Move global option for padding port numbers with zeroes into rule...
* 2296 win_dhcp_pools: Convert global option for discovery empty pools into rule set...
+ * 1247 alcatel_timetra_chassis: New Check for Slots, Power Supplies, MDAs, cf cards and Fans of Alcatel Switches Supporting the TIMETRA-CHASSIS-MIB
* 1457 FIX: logins: new check renamed from "users" check...
NOTE: Please refer to the migration notes!
* 1762 FIX: lnx_thermal: Now ignoring trip points with level 0...
diff --git a/checkman/alcatel_timetra_chassis b/checkman/alcatel_timetra_chassis
new file mode 100644
index 0000000..e577701
--- /dev/null
+++ b/checkman/alcatel_timetra_chassis
@@ -0,0 +1,20 @@
+title: Alcatel switches: Chassis components
+agents: snmp
+catalog: hw/network/alcatel
+license: GPL
+distribution: check_mk
+description:
+ This Checks Monitors the oper, alarm and admin states in Alcatel switchtes supporting the
+ TIMETRA-CHASSIS-MIB. It rasises {CRIT} if the component enters an Alarm state.
+ There is also {CRIT} if the Operstate changes to "failed" or "out of serrvices", or the Adminstate
+ changes to "diagnose" or "operate switch".
+ There is a {WARN} in case of "booting", "diagnosing" "upgrade", "downgrade".
+
+ No Configuration is needed.
+
+item:
+ The name of the device.
+
+inventory:
+ One check is created for each device.
+
diff --git a/checks/alcatel_timetra_chassis b/checks/alcatel_timetra_chassis
new file mode 100644
index 0000000..825b883
--- /dev/null
+++ b/checks/alcatel_timetra_chassis
@@ -0,0 +1,106 @@
+#!/usr/bin/python
+# -*- encoding: utf-8; py-indent-offset: 4 -*-
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | Copyright Mathias Kettner 2013 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.
+
+def inventory_alcatel_timetra_chassis(info):
+ for name, adminstate, operstate, alarmstate in info:
+ # Only add active devices
+ if operstate in [ '2','8' ]:
+ yield name, None
+
+def check_alcatel_timetra_chassis(item, _no_params, info):
+ admin_states = {
+ 1 : "noop",
+ 2 : "inService",
+ 3 : "outOfService",
+ 4 : "diagnose",
+ 5 : "operateSwitch",
+ }
+
+ oper_states = {
+ 1 : "unknown",
+ 2 : "inService",
+ 3 : "outOfService",
+ 4 : "diagnosing",
+ 5 : "failed",
+ 6 : "booting",
+ 7 : "empty",
+ 8 : "provisioned",
+ 9 : "unprovisioned",
+ 10 : "upgrade",
+ 11 : "downgrade",
+ 12 : "inServiceUpgrade",
+ 13 : "inServiceDowngrade",
+ 14 : "resetPending",
+ }
+
+ alarm_states = {
+ 0 : "unknown",
+ 1 : "alarmActive",
+ 2 : "alarmCleared",
+
+ }
+ for line in info:
+ if line[0] == item:
+ adminstate, operstate, alarmstate = map(int, line[1:])
+ state = 0
+ if operstate != adminstate:
+ if adminstate in [4, 5]:
+ state = 2
+ elif adminstate in [3, 1]:
+ state = 1
+ yield state, "Admin State: %s" % admin_states[adminstate]
+
+ state = 0
+ if operstate in [5, 3]:
+ state = 2
+ elif operstate in [4, 6, 10, 11, 12, 13, 14]:
+ state = 1
+ elif operstate not in [2, 8]:
+ state = 3
+ yield state, "Oper State: %s" % oper_states[operstate]
+
+ if alarmstate not in [0,2]:
+ state = 0
+ if alarmstate == 1:
+ state = 2
+ yield state, "Alarms State: %s" % alarm_states[alarmstate]
+ return
+
+
+check_info["alcatel_timetra_chassis"] = {
+ "check_function" : check_alcatel_timetra_chassis,
+ "inventory_function" : inventory_alcatel_timetra_chassis,
+ "service_description" : "Device %s",
+ "has_perfdata" : False,
+ "snmp_scan_function" : lambda oid: "TiMOS" in oid(".1.3.6.1.2.1.1.1.0"),
+ "snmp_info" : (".1.3.6.1.4.1.6527.3.1.2.2.1.8.1", [
+ 8, # tmnxHwName
+ 15, # tmnxHwAdminState
+ 16, # tmnxHwOperState
+ 24, # tmnxHwAlarmState
+ ]),
+}
+
Module: check_mk
Branch: master
Commit: a1265a6ced3fb0688094966c28b2af6c77d78d74
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=a1265a6ced3fb0…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu May 21 16:35:19 2015 +0200
#2256 mk_mysql: MySQL monitoring is now available for windows
The mk_mysql plugin which already existed for some time has been
ported to Windows. It is now available as windows agent plugin.
You can use the exact same checks as on linux hosts. To make the
agent plugin working, you need to configure the credentials
to access the database just like on linux systems with the
difference that the configuration file needs to be placed in
the directory of the <tt>check_mk_agent.exe</tt> and named
<tt>mysql.ini</tt>. In case you have multiple instances running
on a single host and need different credentials, you can create
multiple files named <tt>mysql_<instance>.ini</tt> while you need
to replace instance with the ident of the mysql process.
For further details take a look at the
<a href="http://mathias-kettner.de/checkmk_mysql.html">documentation</a>.
---
.werks/2256 | 22 ++++++
ChangeLog | 1 +
agents/windows/plugins/mk_mysql.vbs | 130 +++++++++++++++++++++++++++++++++++
3 files changed, 153 insertions(+)
diff --git a/.werks/2256 b/.werks/2256
new file mode 100644
index 0000000..61978cc
--- /dev/null
+++ b/.werks/2256
@@ -0,0 +1,22 @@
+Title: mk_mysql: MySQL monitoring is now available for windows
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.2.7i1
+Date: 1432218553
+Class: feature
+
+The mk_mysql plugin which already existed for some time has been
+ported to Windows. It is now available as windows agent plugin.
+You can use the exact same checks as on linux hosts. To make the
+agent plugin working, you need to configure the credentials
+to access the database just like on linux systems with the
+difference that the configuration file needs to be placed in
+the directory of the <tt>check_mk_agent.exe</tt> and named
+<tt>mysql.ini</tt>. In case you have multiple instances running
+on a single host and need different credentials, you can create
+multiple files named <tt>mysql_<instance>.ini</tt> while you need
+to replace instance with the ident of the mysql process.
+
+For further details take a look at the
+<a href="http://mathias-kettner.de/checkmk_mysql.html">documentation</a>.
diff --git a/ChangeLog b/ChangeLog
index fbc5677..433d721 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -189,6 +189,7 @@
* 2293 logwatch: Remove global setting logwatch_service_output from WATO...
* 2294 if, if64: Move global option for padding port numbers with zeroes into rule...
* 2296 win_dhcp_pools: Convert global option for discovery empty pools into rule set...
+ * 2256 mk_mysql: MySQL monitoring is now available for windows...
* 1457 FIX: logins: new check renamed from "users" check...
NOTE: Please refer to the migration notes!
* 1762 FIX: lnx_thermal: Now ignoring trip points with level 0...
diff --git a/agents/windows/plugins/mk_mysql.vbs b/agents/windows/plugins/mk_mysql.vbs
new file mode 100644
index 0000000..b479205
--- /dev/null
+++ b/agents/windows/plugins/mk_mysql.vbs
@@ -0,0 +1,130 @@
+' +------------------------------------------------------------------+
+' | ____ _ _ __ __ _ __ |
+' | / ___| |__ ___ ___| | __ | \/ | |/ / |
+' | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+' | | |___| | | | __/ (__| < | | | | . \ |
+' | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+' | |
+' | 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.
+
+' This agent plugin is meant to be used on a windows server which
+' is running one or multiple MySQL server instances locally.
+
+Option Explicit
+
+Dim SHO, FSO, WMI, PROC
+Dim cfg_dir, cfg_file, service_list, service, instances, instance, cmd
+Dim output, pos, conn_args
+
+Set instances = CreateObject("Scripting.Dictionary")
+Set FSO = CreateObject("Scripting.FileSystemObject")
+Set SHO = CreateObject("WScript.Shell")
+
+cfg_dir = FSO.GetParentFolderName(FSO.GetParentFolderName(WScript.ScriptFullName))
+
+'
+' First detect all local instances. We only add services of instances
+' which service is currently reported as running
+'
+
+Set WMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
+Set service_list = WMI.ExecQuery("SELECT * FROM Win32_Service WHERE Name LIKE '%MySQL%' and State = 'Running'")
+For Each service in service_list
+ ' add the internal service name as key and the launch command line as value
+ instances.add service.Name, service.PathName
+Next
+
+Set WMI = Nothing
+
+'
+' Now query these instances
+'
+
+' don't blame me for the stupid tempfile. I am aware of SHO.Exec, but in context of
+' the agent this lead into strang hanging process problems. Propably because of some
+' filled buffer or whatever. Could not get this working. But SHO.Run works fine.
+Sub Run(cmd)
+ Dim FILE, tmp_file
+ tmp_file = "mk_mysql.out"
+ SHO.Run "cmd.exe /s /c "" " & cmd & " 1>>" & tmp_file & " 2>&1 """, 0, 1
+ Set FILE = FSO.GetFile(tmp_file)
+ If FILE.size <> 0 Then
+ wscript.echo FSO.OpenTextFile(tmp_file, 1).ReadAll()
+ End If
+ FILE.Delete()
+ Set FILE = Nothing
+End Sub
+
+For Each instance In instances.Keys
+ ' Use either an instance specific config file named mysql_<instance-id>.ini
+ ' or the default mysql.ini file.
+ cfg_file = cfg_dir & "\mysql_" & instance & ".ini"
+ If Not fso.FileExists(cfg_file) Then
+ cfg_file = cfg_dir & "\mysql.ini"
+ If Not fso.FileExists(cfg_file) Then
+ cfg_file = ""
+ End If
+ End If
+
+ ' Now detect the correct socket / port to connect to this instance. This can be done by executing
+ ' mysql.exe with the --defaults-file found in the command line of the windows process together
+ ' with the option --print-defaults
+ cmd = instances.Item(instance)
+ cmd = Replace(cmd, "mysqld.exe", "mysql.exe")
+ cmd = Left(cmd, InStrRev(cmd, " ")) & " --print-defaults"
+ Set PROC = SHO.Exec(cmd)
+ PROC.StdIn.Close()
+ PROC.StdErr.Close()
+ output = PROC.StdOut.ReadAll()
+ pos = InStrRev(output, vbCrLf, Len(output)-1)
+ conn_args = Mid(output, pos+2, Len(output)-pos-4)
+
+ ' Now we try to construct a mysql.exe client command which is able to connect to this database
+ ' based on the command uses by the database service.
+ ' In our development setup, where MySQL 5.6 has been used, the server command is:
+ ' "C:\Programme\MySQL\MySQL Server 5.6\bin\mysqld.exe" --defaults-file="C:\Dokumente und Einstellungen\All Users\Anwendungsdaten\MySQL\MySQL Server 5.6\my.ini" MySQL56
+ ' To get the client command we simply need to replace mysqld.exe with mysql.exe, remove the
+ ' my.ini and instance name from the end of the command and add our config as --defaults-extra-file.
+ cmd = instances.Item(instance)
+ cmd = Replace(cmd, "mysqld.exe", "mysql.exe")
+ cmd = Left(cmd, InStr(cmd, "mysql.exe""")+9)
+ If cfg_file <> "" Then
+ cmd = cmd & " --defaults-extra-file=""" & cfg_file & """"
+ End If
+ cmd = cmd & " " & conn_args
+
+ wscript.echo "<<<mysql_ping>>>"
+ wscript.echo "[[" & instance & "]]"
+ Run Replace(cmd, "mysql.exe", "mysqladmin.exe") & " ping"
+
+ wscript.echo "<<<mysql>>>"
+ wscript.echo "[[" & instance & "]]"
+ Run cmd & " -B -sN -e ""show global status ; show global variables ;"""
+
+ wscript.echo "<<<mysql_capacity>>>"
+ wscript.echo "[[" & instance & "]]"
+ Run cmd & " -B -sN -e ""SELECT table_schema, sum(data_length + index_length), sum(data_free)" & _
+ "FROM information_schema.TABLES GROUP BY table_schema"""
+
+ wscript.echo "<<<mysql_slave>>>"
+ wscript.echo "[[" & instance & "]]"
+ Run cmd & " -B -s -e ""show slave status\G"""
+Next
+
+Set SHO = Nothing
+Set FSO = Nothing