Module: check_mk
Branch: master
Commit: 8256dd260e90cae06d72bdf135a0884af15b71e9
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=8256dd260e90ca…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Fri Dec 5 09:02:54 2014 +0100
#1698 FIX Fix specifying explicit path to unix socket for check_mkeventd
---
.werks/1698 | 9 +++++++++
ChangeLog | 1 +
checks/.f12 | 2 +-
mkeventd/checks/check_mkevents | 5 +++--
mkeventd/lib/check_mkevents.cc | 34 ++++++++++++++++++++-------------
mkeventd/web/plugins/wato/mkeventd.py | 6 ++++++
6 files changed, 41 insertions(+), 16 deletions(-)
diff --git a/.werks/1698 b/.werks/1698
new file mode 100644
index 0000000..4692e7e
--- /dev/null
+++ b/.werks/1698
@@ -0,0 +1,9 @@
+Title: Fix specifying explicit path to unix socket for check_mkeventd
+Level: 1
+Component: ec
+Compatible: compat
+Version: 1.2.5i7
+Date: 1417766546
+Class: fix
+
+
diff --git a/ChangeLog b/ChangeLog
index efde51f..2ad9ef1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -221,6 +221,7 @@
* 1610 FIX: Hostname translation now also works for incoming SNMP traps
* 1643 FIX: Improved error handling of exceptions when processing log lines
* 1644 FIX: Fixed matching dynamic number of regex match groups...
+ * 1698 FIX: Fix specifying explicit path to unix socket for check_mkeventd
Livestatus:
* 1613 FIX: Fixed invalid json format in Stats query with requested heaeders...
diff --git a/checks/.f12 b/checks/.f12
index 6e3cc8c..7d65f22 100644
--- a/checks/.f12
+++ b/checks/.f12
@@ -2,5 +2,5 @@
SITE=${SITE:-$(cat ../.site 2>/dev/null || true)}
SITE=${SITE:-$(omd sites --bare | head -n 1)}
echo "TARGET: /omd/sites/$SITE/share/check_mk/checks"
-sudo rsync -ar --delete-after ./ /omd/sites/$SITE/share/check_mk/checks/
+sudo rsync --exclude=check_mkevents -ar --delete-after ./
/omd/sites/$SITE/share/check_mk/checks/
diff --git a/mkeventd/checks/check_mkevents b/mkeventd/checks/check_mkevents
index b8575b2..baf8cd3 100644
--- a/mkeventd/checks/check_mkevents
+++ b/mkeventd/checks/check_mkevents
@@ -7,8 +7,9 @@ def check_mkevents_arguments(params):
remote = params["remote"]
if type(remote) == tuple:
args += "-H %s:%d " % (quote_shell_string(remote[0]), remote[1])
- else:
- args += "-H %s " % quote_shell_string(remote)
+ elif remote:
+ args += "-s %s " % quote_shell_string(remote)
+
if params.get("ignore_acknowledged"):
args += "-a "
diff --git a/mkeventd/lib/check_mkevents.cc b/mkeventd/lib/check_mkevents.cc
index db280bf..4d54be5 100644
--- a/mkeventd/lib/check_mkevents.cc
+++ b/mkeventd/lib/check_mkevents.cc
@@ -45,7 +45,7 @@ using namespace std;
void usage()
{
- printf("Usage: check_mkevents_c [-H REMOTE:PORT] [-a] HOST
[APPLICATION]");
+ printf("Usage: check_mkevents [-s SOCKETPATH] [-H REMOTE:PORT] [-a] HOST
[APPLICATION]");
printf("\n -a do not take into account acknowledged events.\n");
}
@@ -60,6 +60,8 @@ int main(int argc, char** argv)
int remote_port = 6558;
char *application = NULL;
bool ignore_acknowledged = false;
+ char unixsocket_path[1024];
+ unixsocket_path[0] = 0;
int argc_count = argc;
for (int i = 1; i < argc ; i++) {
@@ -68,17 +70,22 @@ int main(int argc, char** argv)
i++;
argc_count -= 2;
}
+ else if (!strcmp("-s", argv[i]) && i < argc + 1) {
+ strcpy(unixsocket_path, argv[i+1]);
+ i++;
+ argc_count -= 2;
+ }
else if (!strcmp("-a", argv[i])) {
ignore_acknowledged = true;
argc_count--;
}
else if (argc_count > 2) {
- host = argv[i];
+ host = argv[i];
application = argv[i+1];
break;
}
else if (argc_count > 1) {
- host = argv[i];
+ host = argv[i];
break;
}
}
@@ -89,13 +96,14 @@ int main(int argc, char** argv)
}
// Get omd environment
- char *omd_path = getenv("OMD_ROOT");
- char unixsocket_path[1024];
- if (omd_path)
- snprintf(unixsocket_path, sizeof(unixsocket_path),
"%s/tmp/run/mkeventd/status", omd_path);
- else {
- printf("UNKNOWN - OMD_ROOT is not set, no socket path is defined.\n");
- exit(3);
+ if (!unixsocket_path[0] && !remote_host) {
+ char *omd_path = getenv("OMD_ROOT");
+ if (omd_path)
+ snprintf(unixsocket_path, sizeof(unixsocket_path),
"%s/tmp/run/mkeventd/status", omd_path);
+ else {
+ printf("UNKNOWN - OMD_ROOT is not set, no socket path is
defined.\n");
+ exit(3);
+ }
}
if (remote_host) {
@@ -103,7 +111,7 @@ int main(int argc, char** argv)
struct in_addr **addr_list;
remote_hostaddress = strtok(remote_host, ":");
- if ( (he = gethostbyname( remote_hostaddress ) ) == NULL)
+ if ( (he = gethostbyname(remote_hostaddress) ) == NULL)
{
printf("UNKNOWN - Unable to resolve remote host address: %s\n",
remote_hostaddress);
return 3;
@@ -114,9 +122,9 @@ int main(int argc, char** argv)
strcpy(remote_hostipaddress, inet_ntoa(*addr_list[i]) );
}
- char *port_str = strtok(NULL, ":");
+ char *port_str = strtok(NULL, ":");
if (port_str)
- remote_port = atoi(port_str);
+ remote_port = atoi(port_str);
}
//Create socket and setup connection
diff --git a/mkeventd/web/plugins/wato/mkeventd.py
b/mkeventd/web/plugins/wato/mkeventd.py
index de161ca..298146f 100644
--- a/mkeventd/web/plugins/wato/mkeventd.py
+++ b/mkeventd/web/plugins/wato/mkeventd.py
@@ -2003,7 +2003,13 @@ register_rule(
( "remote",
Alternative(
title = _("Access to the Event Console"),
+ style = "dropdown",
elements = [
+ FixedValue(
+ None,
+ title = _("Connect to the local Event Console"),
+ totext = _("local connect"),
+ ),
Tuple(
elements = [
TextAscii(