Module: check_mk
Branch: master
Commit: 55e36a94e2927c8d884c2eb80508bd83400f5958
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=55e36a94e2927c…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Dec 5 09:20:40 2014 +0100
#1681 FIX cmciii_lcp_fans: Skipping non FAN units now; cleaned up check
---
.werks/1681 | 9 +++++++++
ChangeLog | 1 +
checks/cmciii_lcp_fans | 33 +++++++++++++++++++--------------
3 files changed, 29 insertions(+), 14 deletions(-)
diff --git a/.werks/1681 b/.werks/1681
new file mode 100644
index 0000000..cbe49f1
--- /dev/null
+++ b/.werks/1681
@@ -0,0 +1,9 @@
+Title: cmciii_lcp_fans: Skipping non FAN units now; cleaned up check
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.2.5i7
+Date: 1417767611
+Class: fix
+
+
diff --git a/ChangeLog b/ChangeLog
index efde51f..a5c5977 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -112,6 +112,7 @@
* 1656 FIX: cisco_vpn_tunnel: Refactored complete check, fixed threshold bugs...
* 1677 FIX: f5_bigip_interfaces: Cleaned up check a bit
* 1679 FIX: ups_bat_temp: Now skipping sensors which are reported to have 0 upsBatteryTemperature
+ * 1681 FIX: cmciii_lcp_fans: Skipping non FAN units now; cleaned up check
Multisite:
* 1508 Allow input of plugin output and perfdata when faking check results...
diff --git a/checks/cmciii_lcp_fans b/checks/cmciii_lcp_fans
index 6962c20..136db3a 100644
--- a/checks/cmciii_lcp_fans
+++ b/checks/cmciii_lcp_fans
@@ -25,32 +25,37 @@
# Boston, MA 02110-1301 USA.
def inventory_cmciii_lcp_fans(info):
- if info:
- inventory = []
- for i in range(1,7):
- if info[0][i*4-1].lower() != "off":
- inventory.append((i , None) )
- return inventory
+ inventory = []
+ # FAN infos have 4 elements. Split the single info line we get
+ # into even sized chunks of 4 elements. In some cases there might
+ # be non-fan information in the resulting data like infos about
+ # water cooling. Filter them out.
+ parts = [ info[0][x+1:x+4] for x in range(0, len(info[0]), 4) ]
+ for i, (name, value, status) in enumerate(parts):
+ if status != "off" and 'Water' not in name:
+ # FIXME: Why not use the unique name? Maybe recode
+ inventory.append((i+1 , None))
+ return inventory
def check_cmciii_lcp_fans(item, params, info):
lowlevel = int(re.sub(" .*$", "", info[0][0])) # global low warning
- for i in range(1,7):
+ parts = [ info[0][x+1:x+4] for x in range(0, len(info[0]), 4) ]
+ for i, (name, value, status) in enumerate(parts):
if item == i:
- name = info[0][i*4-3]
- status = info[0][i*4-1].lower()
- rpm = int(info[0][i*4-2].split(" ")[0])
- unit = info[0][i*4-2].split(" ")[1]
+ rpm, unit = value.split(" ", 1)
+ rpm = int(rpm)
sym = ""
- if status == "ok" and rpm >= lowlevel:
+ if status == "OK" and rpm >= lowlevel:
state = 0
- elif ( status == "ok" and rpm < lowlevel ):
+ elif status == "OK" and rpm < lowlevel:
state = 1
sym = "(!)"
else:
state = 2
+ sym = "(!!)"
info_text = "%s RPM: %d%s (limit %d%s)%s, Status %s" \
% (name, rpm, unit, lowlevel, unit, sym, status)
@@ -68,5 +73,5 @@ check_info['cmciii_lcp_fans'] = {
"service_description" : "LCP Fanunit FAN %s",
"snmp_scan_function" : lambda oid: oid(".1.3.6.1.2.1.1.1.0").startswith("Rittal LCP") and \
oid(".1.3.6.1.4.1.2606.7.4.2.2.1.3.2.6").startswith("Air.Temperature.DescName"),
- "snmp_info" : ( '.1.3.6.1.4.1.2606.7.4.2.2.1.10.2', range(34, 59)),
+ "snmp_info" : ( '.1.3.6.1.4.1.2606.7.4.2.2.1.10.2', range(34, 58)),
}
for writing output into a file
Message-ID: <54816a78.U1s2PqoX6So+91lA%mk(a)mathias-kettner.de>
User-Agent: Heirloom mailx 12.5 6/20/10
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Module: check_mk
Branch: master
Commit: d57c9497aa61568f8b90e61259db4d0168d637b8
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=d57c9497aa6156…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Fri Dec 5 09:18:55 2014 +0100
#1699 Windows agent: new option "file" for writing output into a file
The redirection of the output of the agent via <tt>check_mk_agent test > filename</tt>
does not work correctly on Windows and misses some of the outputs of check plugins.
Therefore if you want to get the output into a file the simply call the agent as follows:
C+:
C:\Program Files\Check_MK\> <b>check_mk_agent file output.txt</b>
C-:
The output will then be written to the file <tt>output.txt</tt>.
---
.werks/1699 | 17 +++++++++++++++++
ChangeLog | 1 +
agents/windows/check_mk_agent.cc | 37 +++++++++++++++++++++++++++++--------
3 files changed, 47 insertions(+), 8 deletions(-)
diff --git a/.werks/1699 b/.werks/1699
new file mode 100644
index 0000000..e29bb17
--- /dev/null
+++ b/.werks/1699
@@ -0,0 +1,17 @@
+Title: Windows agent: new option "file" for writing output into a file
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.2.5i7
+Date: 1417767417
+Class: feature
+
+The redirection of the output of the agent via <tt>check_mk_agent test > filename</tt>
+does not work correctly on Windows and misses some of the outputs of check plugins.
+Therefore if you want to get the output into a file the simply call the agent as follows:
+
+C+:
+C:\Program Files\Check_MK\> <b>check_mk_agent file output.txt</b>
+C-:
+
+The output will then be written to the file <tt>output.txt</tt>.
diff --git a/ChangeLog b/ChangeLog
index 2ad9ef1..f9a253e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -56,6 +56,7 @@
* 1645 Added basic kernel section to FreeBSD agent...
* 1597 bluecat_dhcp, bluecat_dns: Checks can now be used in Check_MK Cluster Mode
* 1599 check_mk_agent.aix: Simple run_cached Feature for plugins...
+ * 1699 Windows agent: new option "file" for writing output into a file...
* 1478 FIX: kernel.util, statgrab_cpu: fix computation of utilization...
* 1480 FIX: brocade_vdx_status: disable check on some devices that do not support it...
* 1485 FIX: dell_om_disks, dell_om_esmlog, dell_om_mem, dell_om_processors, dell_om_sensors: detect more devices...
diff --git a/agents/windows/check_mk_agent.cc b/agents/windows/check_mk_agent.cc
index 852fd5b..0abd14c 100755
--- a/agents/windows/check_mk_agent.cc
+++ b/agents/windows/check_mk_agent.cc
@@ -286,6 +286,8 @@ bool verbose_mode = false;
bool g_crash_debug = false;
bool do_tcp = false;
bool force_tcp_output = false; // if true, send socket data immediately
+bool do_file = false;
+static FILE* fileout;
char g_hostname[256];
int g_port = CHECK_MK_AGENT_PORT;
@@ -4375,7 +4377,10 @@ void output(SOCKET &out, const char *format, ...)
}
}
else {
- fwrite(outbuffer, len, 1, stdout);
+ if (do_file)
+ fwrite(outbuffer, len, 1, fileout);
+ else
+ fwrite(outbuffer, len, 1, stdout);
len = 0;
}
}
@@ -4394,12 +4399,13 @@ void output(SOCKET &out, const char *format, ...)
void usage()
{
fprintf(stderr, "Usage: \n"
- "check_mk_agent version -- show version %s and exit\n"
- "check_mk_agent install -- install as Windows NT service Check_Mk_Agent\n"
- "check_mk_agent remove -- remove Windows NT service\n"
- "check_mk_agent adhoc -- open TCP port %d and answer request until killed\n"
- "check_mk_agent test -- test output of plugin, do not open TCP port\n"
- "check_mk_agent debug -- similar to test, but with lots of debug output\n",
+ "check_mk_agent version -- show version %s and exit\n"
+ "check_mk_agent install -- install as Windows NT service Check_Mk_Agent\n"
+ "check_mk_agent remove -- remove Windows NT service\n"
+ "check_mk_agent adhoc -- open TCP port %d and answer request until killed\n"
+ "check_mk_agent test -- test output of plugin, do not open TCP port\n"
+ "check_mk_agent file FILENAME -- write output of plugin into file, do not open TCP port\n"
+ "check_mk_agent debug -- similar to test, but with lots of debug output\n",
check_mk_version, g_port);
exit(1);
}
@@ -4415,6 +4421,7 @@ void do_debug()
output_data(dummy);
}
+
void do_test()
{
do_tcp = false;
@@ -4780,12 +4787,26 @@ int main(int argc, char **argv)
SetConsoleCtrlHandler((PHANDLER_ROUTINE)ctrl_handler, TRUE);
- if (argc > 2)
+ if ( ( argc > 2) and (strcmp(argv[1], "file")) )
usage();
else if (argc <= 1)
RunService();
else if (!strcmp(argv[1], "test"))
do_test();
+ else if (!strcmp(argv[1], "file")) {
+ if (argc < 3) {
+ fprintf(stderr, "Please specify the name of an output file.\n");
+ exit(1);
+ }
+ fileout = fopen(argv[2], "w");
+ if (!fileout) {
+ fprintf(stderr, "Cannot open %s for writing.\n", argv[2]);
+ exit(1);
+ }
+ do_file = true;
+ do_test();
+ fclose(fileout);
+ }
else if (!strcmp(argv[1], "adhoc"))
do_adhoc();
else if (!strcmp(argv[1], "install"))