Module: check_mk
Branch: master
Commit: e75a46f49bbae9015dbff3404b4cbea1f5975535
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=e75a46f49bbae9…
Author: Sebastian Herbord <sh(a)mathias-kettner.de>
Date: Fri Feb 12 10:44:03 2016 +0100
resolved gitbug #2405
---
.bugs/2405 | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/.bugs/2405 b/.bugs/2405
index 4904846..536ce16 100644
--- a/.bugs/2405
+++ b/.bugs/2405
@@ -1,10 +1,13 @@
Title: Windows inventory plugin seems to crash with cyrillic symbols in sofware list
Component: checks
-State: open
+Class: bug
+State: done
Date: 2016-01-22 10:11:05
Targetversion: 1.2.8
-Class: bug
With cyrillic symbols in the software list (manufacturer field) the inventory
plugin crashs and doesn't report remaining sections. The same probably
applies to other symbols not present in the current code page.
+
+2016-02-12 10:43:36: changed state open -> done
+This was a more fundamental problem in how output is piped from scripts to the agent, which failed for all symbols that couldn't be encoded in the current ansi codepage. With commit 091316c the agent can now handle utf16 output (if it contains a BOM) and the inventory plugin now uses that.
Module: check_mk
Branch: master
Commit: a5f4430a065498891e80f0bd12f8a5957e27b0f7
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=a5f4430a065498…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Fri Feb 12 10:33:29 2016 +0100
#2982 solaris_services.summary: new check which gives a summary of services provided by SMF on Solaris
---
.werks/2982 | 9 ++++
ChangeLog | 1 +
agents/check_mk_agent.solaris | 9 ++++
checkman/solaris_services.summary | 22 +++++++++
checks/solaris_services | 83 ++++++++++++++++++++++++++++++++++
web/plugins/wato/check_parameters.py | 18 ++++++++
6 files changed, 142 insertions(+)
diff --git a/.werks/2982 b/.werks/2982
new file mode 100644
index 0000000..9ecfa45
--- /dev/null
+++ b/.werks/2982
@@ -0,0 +1,9 @@
+Title: solaris_services.summary: new check which gives a summary of services provided by SMF on Solaris
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.2.7i4
+Date: 1455269547
+Class: feature
+
+
diff --git a/ChangeLog b/ChangeLog
index c306b1b..fcf5832 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -117,6 +117,7 @@
* 2979 aruba_wlc_aps: new inventory plugin for Aruba Networks WLAN Controller which displays name, group name, model, serial number and system location of all access points of this WLC
* 2980 agent_ipmi_sensors: new special agent to monitor IPMI data via ipmi-sensors (of freeipmi)...
* 2981 isc_dhcpd: added leases path /var/lib/dhcpd/dhcpd.leases for CentOS
+ * 2982 solaris_services.summary: new check which gives a summary of services provided by SMF on Solaris
* 2660 FIX: fixed windows agent using the wrong working directory...
* 2664 FIX: ps: Speedup in situation with many matching processes...
* 2661 FIX: windows agent: fixed incomplete process list...
diff --git a/agents/check_mk_agent.solaris b/agents/check_mk_agent.solaris
index d3e674b..d226755 100755
--- a/agents/check_mk_agent.solaris
+++ b/agents/check_mk_agent.solaris
@@ -327,6 +327,15 @@ then
fmadm faulty
fi
+# Getting Information About Services Running on Solaris
+# We can get a list of all service instances, including disabled
+# or incomplete ones by 'svcs -a'
+if type svcs > /dev/null 2>&1
+then
+ echo '<<<solaris_services>>>'
+ svcs -a
+fi
+
# MK's Remote Plugin Executor
if test -f "$MK_CONFDIR/mrpe.cfg"
then
diff --git a/checkman/solaris_services.summary b/checkman/solaris_services.summary
new file mode 100644
index 0000000..77bc68c
--- /dev/null
+++ b/checkman/solaris_services.summary
@@ -0,0 +1,22 @@
+title: SMF Solaris: Services Summary
+agents: solaris
+catalog: os/services
+license: GPL
+distribution: check_mk
+description:
+ This check gives a summary of the solaris services provided by
+ the Service Management Facility command 'svcs -a'.
+ The check reports the number of all services and for each service
+ type, i.e. 'online', 'disabled', 'legacy_run', 'maintenance' and
+ other ones.
+ You can configure the status of the services of type
+ 'maintenance'.
+
+item:
+ No item.
+
+perfdata:
+ No performance data.
+
+Inventory:
+ One service is created
diff --git a/checks/solaris_services b/checks/solaris_services
new file mode 100644
index 0000000..766f0fc
--- /dev/null
+++ b/checks/solaris_services
@@ -0,0 +1,83 @@
+#!/usr/bin/python
+# -*- encoding: utf-8; py-indent-offset: 4 -*-
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | Copyright Mathias Kettner 2016 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-
+# tails. 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.
+
+
+# <<<solaris_services>>>
+# STATE STIME FMRI
+# legacy_run Jun_14 lrc:/etc/rcS_d/S99openconnect-clean
+# legacy_run Jun_14 lrc:/etc/rc2_d/S47pppd
+# legacy_run Jun_14 lrc:/etc/rc2_d/S81dodatadm_udaplt
+# legacy_run Jun_14 lrc:/etc/rc2_d/S89PRESERVE
+# disabled Jun_14 svc:/system/device/mpxio-upgrade:default
+# disabled Jun_14 svc:/network/install:default
+# disabled Jun_14 svc:/network/ipfilter:default
+# disabled Jun_14 svc:/network/ipsec/ike:default
+# disabled Jun_14 svc:/network/ipsec/manual-key:default
+# disabled Jun_14 svc:/system/name-service-cache:default
+# disabled Jun_14 svc:/network/ldap/client:default
+# disabled Jun_14 svc:/network/nis/client:default
+# disabled Jun_14 svc:/network/ibd-post-upgrade:default
+# disabled Jun_14 svc:/network/inetd-upgrade:default
+# disabled Jun_14 svc:/network/nfs/status:default
+# disabled Jun_14 svc:/network/nfs/nlockmgr:default
+# online Jun_14 svc:/system/zones:default
+# online Jun_14 svc:/system/power:default
+# online Jun_14 svc:/system/hal:default
+# online Jun_14 svc:/application/texinfo-update:default
+# online Jun_14 svc:/application/pkg/update:default
+# maintenance Jul_09 svc:/network/smtp:sendmail
+
+
+def inventory_solaris_services_summary(info):
+ return [ (None, {}) ]
+
+
+def check_solaris_services_summary(_no_item, params, info):
+ collected_services = {}
+ if len(info) >= 1:
+ for line in info[1:]:
+ collected_services.setdefault(line[0], [])
+ collected_services[line[0]].append(line[2])
+
+ yield 0, "%d services" % (len(info) - 1)
+
+ for srv_type, srv_names in collected_services.items():
+ state = 0
+ extra_info = ""
+ if srv_type == "maintenance":
+ if params.get("maintenance_state", 0):
+ extra_info += " (%s)" % ", ".join(srv_names)
+ state = params["maintenance_state"]
+
+ yield state, "%d %s%s" % (len(srv_names), srv_type.replace("_", " "), extra_info)
+
+
+check_info['solaris_services.summary'] = {
+ 'inventory_function' : inventory_solaris_services_summary,
+ 'check_function' : check_solaris_services_summary,
+ 'service_description' : 'SMF Services Summary', # Service Management Facility
+ 'group' : 'solaris_services_summary',
+}
diff --git a/web/plugins/wato/check_parameters.py b/web/plugins/wato/check_parameters.py
index 42942a4..5126988 100644
--- a/web/plugins/wato/check_parameters.py
+++ b/web/plugins/wato/check_parameters.py
@@ -4692,6 +4692,24 @@ register_check_parameters(
register_check_parameters(
subgroup_applications,
+ "solaris_services_summary",
+ _("Solaris Services Summary"),
+ Dictionary(
+ title = _('SMF Services'),
+ elements = [
+ ('maintenance_state',
+ MonitoringState(
+ title = _("State if 'maintenance' services are found"),
+ default_value = 0,
+ )),
+ ],
+ ),
+ None,
+ "dict"
+)
+
+register_check_parameters(
+ subgroup_applications,
"esx_vsphere_objects",
_("State of ESX hosts and virtual machines"),
Dictionary(
Module: check_mk
Branch: master
Commit: 091316cf59c22e518738b7eadcd58a1ae708827c
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=091316cf59c22e…
Author: Sebastian Herbord <sh(a)mathias-kettner.de>
Date: Fri Feb 12 10:18:13 2016 +0100
windows agent: mk_inventory now uses utf16 output
this was actually in the last commit, in this commit the code was only cleaned up slightly
---
agents/windows/plugins/mk_inventory.vbs | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/agents/windows/plugins/mk_inventory.vbs b/agents/windows/plugins/mk_inventory.vbs
index 929bded..d11163c 100644
--- a/agents/windows/plugins/mk_inventory.vbs
+++ b/agents/windows/plugins/mk_inventory.vbs
@@ -10,8 +10,9 @@ exePaths = Array("")
regPaths = Array("Software\Microsoft\Windows\CurrentVersion\Uninstall","Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall")
Set fso = CreateObject("Scripting.FileSystemObject")
-' request unicode stdout
-Set objStdout = fso.GetStandardStream(1, True)
+' request unicode stdout and add a bom so the agent knows we send utf-16
+Set objStdout = fso.GetStandardStream(1, True)
+objStdout.Write(chrW(&HFEFF))
Set objClass = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
Set wshShell = WScript.CreateObject( "WScript.Shell" )
remote_host = wshShell.ExpandEnvironmentStrings( "%REMOTE_HOST%" )
@@ -48,8 +49,6 @@ End If
' handle error message ourselves so this script can also be run directly, for testing
On Error Resume Next
-'need a bom so the agent knows we send utf-16
-outPut(chrW(&HFEFF))
' create new timestamp file
' only allowed when script runs as administrator user
Module: check_mk
Branch: master
Commit: e9e095f48d4f7f6c6995c4d3b175691936949130
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=e9e095f48d4f7f…
Author: Sebastian Herbord <sh(a)mathias-kettner.de>
Date: Fri Feb 12 10:15:13 2016 +0100
#3072 FIX windows agent: agent can now handle utf-16 encoded output from plugins
utf-16 is the default unicode encoding used on windows and appears to be the only one supported as
an output encoding for vbs scripts.
Previously the agent would print an empty string instead of the utf-16 encoded output.
For this to work the plugin/local check has to use a unicode-enabled stdout and print a utf-16 BOM,
i.e.:
Set objStdout = fso.GetStandardStream(1, True)
objStdout.Write(chrW(&HFEFF))
---
.werks/3072 | 15 ++++++++
ChangeLog | 1 +
agents/windows/build_version | 2 +-
agents/windows/check_mk_agent-64.exe | Bin 907776 -> 908288 bytes
agents/windows/check_mk_agent-64.unversioned.exe | Bin 907776 -> 908288 bytes
agents/windows/check_mk_agent.cc | 42 +++++++++++++---------
agents/windows/check_mk_agent.exe | Bin 832000 -> 832000 bytes
agents/windows/check_mk_agent.msi | Bin 2000384 -> 2000896 bytes
agents/windows/check_mk_agent.unversioned.exe | Bin 832000 -> 832000 bytes
agents/windows/install_agent-64.exe | Bin 416904 -> 417015 bytes
agents/windows/install_agent.exe | Bin 407353 -> 407477 bytes
agents/windows/plugins/mk_inventory.vbs | 8 +++--
12 files changed, 48 insertions(+), 20 deletions(-)
diff --git a/.werks/3072 b/.werks/3072
new file mode 100644
index 0000000..ba4f312
--- /dev/null
+++ b/.werks/3072
@@ -0,0 +1,15 @@
+Title: windows agent: agent can now handle utf-16 encoded output from plugins
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.2.7i4
+Date: 1455267933
+Class: fix
+
+utf-16 is the default unicode encoding used on windows and appears to be the only one supported as
+an output encoding for vbs scripts.
+Previously the agent would print an empty string instead of the utf-16 encoded output.
+For this to work the plugin/local check has to use a unicode-enabled stdout and print a utf-16 BOM,
+i.e.:
+Set objStdout = fso.GetStandardStream(1, True)
+objStdout.Write(chrW(&HFEFF))
diff --git a/ChangeLog b/ChangeLog
index 02ac762..c306b1b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -272,6 +272,7 @@
* 3054 FIX: ups_modulys_battery: Fixed wrong remaining minutes in some cases
* 3055 FIX: ibm_svc_mdiskgrp: Fixed exception in case of configured thresholds...
* 3056 FIX: vms_cpu: Fixed exception when having thresholds configured
+ * 3072 FIX: windows agent: agent can now handle utf-16 encoded output from plugins...
Multisite:
* 2684 Added icons for downloading agent data / walks of hosts...
diff --git a/agents/windows/build_version b/agents/windows/build_version
index 939b0cb..837dd96 100644
--- a/agents/windows/build_version
+++ b/agents/windows/build_version
@@ -1 +1 @@
-1233
+1258
diff --git a/agents/windows/check_mk_agent-64.exe b/agents/windows/check_mk_agent-64.exe
index 5ffab7b..4037e7a 100755
Binary files a/agents/windows/check_mk_agent-64.exe and b/agents/windows/check_mk_agent-64.exe differ
diff --git a/agents/windows/check_mk_agent-64.unversioned.exe b/agents/windows/check_mk_agent-64.unversioned.exe
index 4e864d9..a8dbb2c 100755
Binary files a/agents/windows/check_mk_agent-64.unversioned.exe and b/agents/windows/check_mk_agent-64.unversioned.exe differ
diff --git a/agents/windows/check_mk_agent.cc b/agents/windows/check_mk_agent.cc
index 082538a..e7522c3 100644
--- a/agents/windows/check_mk_agent.cc
+++ b/agents/windows/check_mk_agent.cc
@@ -2047,17 +2047,16 @@ char *add_interpreter(char *path, char *newpath) {
// -> Get-ExecutionPolicy / Set-ExecutionPolicy
//
// actually, microsoft always installs the powershell interpreter to the
- // same
- // directory (independent of the version) so even if it's not in the
- // path,
- // we have a good chance with this fallback.
+ // same directory (independent of the version) so even if it's not in
+ // the path, we have a good chance with this fallback.
+ const char *fallback =
+ "C:\\Windows\\System32\\WindowsPowershell\\v1.0\\powershell.exe";
+
char dummy;
::SearchPathA(NULL, "powershell.exe", NULL, 1, &dummy, NULL);
const char *interpreter = ::GetLastError() != ERROR_FILE_NOT_FOUND
? "powershell.exe"
- : "C:"
- "\\Windows\\System32\\WindowsPowershell"
- "\\v1.0\\powershell.exe";
+ : fallback;
snprintf(newpath, 256,
"%s -NoLogo -ExecutionPolicy RemoteSigned \"& \'%s\'\"",
interpreter, path);
@@ -2230,6 +2229,18 @@ int launch_program(script_container *cont) {
CloseHandle(pi.hThread);
CloseHandle(pi.hProcess);
+ // if the output has a utf-16 bom, we need to convert it now, as the remaining
+ // code doesn't handle wide characters
+ unsigned char *buf_u = reinterpret_cast<unsigned char *>(cont->buffer_work);
+ if ((buf_u[0] == 0xFF) && (buf_u[1] == 0xFE)) {
+ wchar_t *buffer_u16 = reinterpret_cast<wchar_t *>(cont->buffer_work);
+ std::string buffer_u8 = to_utf8(buffer_u16);
+ HeapFree(GetProcessHeap(), 0, buffer_u16);
+ cont->buffer_work =
+ (char *)HeapAlloc(GetProcessHeap(), 0, buffer_u8.size() + 1);
+ memcpy(cont->buffer_work, buffer_u8.c_str(), buffer_u8.size() + 1);
+ }
+
return exit_code;
}
@@ -2341,16 +2352,13 @@ void output_external_programs(OutputProxy &out, script_type type) {
cont->buffer = NULL;
}
- // Replace BOM for UTF-16 LE and UTF-8 with newlines
- if ((strlen(cont->buffer_work)) >= 2 &&
- ((unsigned char)cont->buffer_work[0] == 0xFF &&
- (unsigned char)cont->buffer_work[1] == 0xFE)) {
- cont->buffer_work[0] = '\n';
- cont->buffer_work[1] = '\n';
- } else if (strlen(cont->buffer_work) >= 3 &&
- (unsigned char)cont->buffer_work[0] == 0xEF &&
- (unsigned char)cont->buffer_work[1] == 0xBB &&
- (unsigned char)cont->buffer_work[2] == 0xBF) {
+ // Replace BOM with newlines.
+ // At this point the buffer must not contain a wide character
+ // encoding as the code can't handle it!
+ if (strlen(cont->buffer_work) >= 3 &&
+ (unsigned char)cont->buffer_work[0] == 0xEF &&
+ (unsigned char)cont->buffer_work[1] == 0xBB &&
+ (unsigned char)cont->buffer_work[2] == 0xBF) {
cont->buffer_work[0] = '\n';
cont->buffer_work[1] = '\n';
cont->buffer_work[2] = '\n';
diff --git a/agents/windows/check_mk_agent.exe b/agents/windows/check_mk_agent.exe
index 2b81fa5..54559eb 100755
Binary files a/agents/windows/check_mk_agent.exe and b/agents/windows/check_mk_agent.exe differ
diff --git a/agents/windows/check_mk_agent.msi b/agents/windows/check_mk_agent.msi
index 95d0461..428f210 100755
Binary files a/agents/windows/check_mk_agent.msi and b/agents/windows/check_mk_agent.msi differ
diff --git a/agents/windows/check_mk_agent.unversioned.exe b/agents/windows/check_mk_agent.unversioned.exe
index 22c2986..ab45e69 100755
Binary files a/agents/windows/check_mk_agent.unversioned.exe and b/agents/windows/check_mk_agent.unversioned.exe differ
diff --git a/agents/windows/install_agent-64.exe b/agents/windows/install_agent-64.exe
index 8b18ba5..b2931d7 100755
Binary files a/agents/windows/install_agent-64.exe and b/agents/windows/install_agent-64.exe differ
diff --git a/agents/windows/install_agent.exe b/agents/windows/install_agent.exe
index 9ad7b41..6c0da5e 100755
Binary files a/agents/windows/install_agent.exe and b/agents/windows/install_agent.exe differ
diff --git a/agents/windows/plugins/mk_inventory.vbs b/agents/windows/plugins/mk_inventory.vbs
index 190118a..929bded 100644
--- a/agents/windows/plugins/mk_inventory.vbs
+++ b/agents/windows/plugins/mk_inventory.vbs
@@ -10,7 +10,8 @@ exePaths = Array("")
regPaths = Array("Software\Microsoft\Windows\CurrentVersion\Uninstall","Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall")
Set fso = CreateObject("Scripting.FileSystemObject")
-Set objStdout = WScript.Stdout
+' request unicode stdout
+Set objStdout = fso.GetStandardStream(1, True)
Set objClass = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
Set wshShell = WScript.CreateObject( "WScript.Shell" )
remote_host = wshShell.ExpandEnvironmentStrings( "%REMOTE_HOST%" )
@@ -47,12 +48,15 @@ End If
' handle error message ourselves so this script can also be run directly, for testing
On Error Resume Next
+'need a bom so the agent knows we send utf-16
+outPut(chrW(&HFEFF))
+
' create new timestamp file
' only allowed when script runs as administrator user
Set stampo = fso.CreateTextFile(timestamp)
If Err.Number <> 0 Then
- outPut "Failed to create time stamp: " & Err.Description & " (" & Err.Number & ")"
+ outPut "Failed to create time stamp: " & Err.Description & " (" & Err.Number & ")"
Err.Clear
End If