Module: check_mk
Branch: master
Commit: b3196b156e5866c94da5439fafa1cd93d0b4de56
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=b3196b156e5866…
Author: Sebastian Herbord <sh(a)mathias-kettner.de>
Date: Thu Dec 17 08:42:39 2015 +0100
windows agent: made realtime port configurable
---
agents/windows/Configuration.cc | 6 ++++++
agents/windows/Configuration.h | 2 ++
agents/windows/check_mk_agent.cc | 9 +++++----
3 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/agents/windows/Configuration.cc b/agents/windows/Configuration.cc
index 9065f9c..0ecf790 100644
--- a/agents/windows/Configuration.cc
+++ b/agents/windows/Configuration.cc
@@ -36,12 +36,14 @@
static const int CHECK_MK_AGENT_PORT = 6556;
+static const int REALTIME_DEFAULT_PORT = 6559;
Configuration::Configuration(const Environment &env)
: _enabled_sections(0xffffffff)
, _realtime_sections(0x0)
, _port(CHECK_MK_AGENT_PORT)
+ , _realtime_port(REALTIME_DEFAULT_PORT)
, _default_script_execution_mode(SYNC)
, _default_script_async_execution(SEQUENTIAL)
, _passphrase()
@@ -118,6 +120,10 @@ bool Configuration::handleGlobalConfigVariable(char *var, char
*value)
_port = atoi(value);
return true;
}
+ else if (!strcmp(var, "realtime_port")) {
+ _realtime_port = atoi(value);
+ return true;
+ }
else if (!strcmp(var, "ipv6")) {
int s = parse_boolean(value);
_support_ipv6 = s != 0;
diff --git a/agents/windows/Configuration.h b/agents/windows/Configuration.h
index 474e22b..171b041 100644
--- a/agents/windows/Configuration.h
+++ b/agents/windows/Configuration.h
@@ -70,6 +70,7 @@ public:
unsigned long realtimeSections();
int port() const { return _port; }
+ int realtimePort() const { return _realtime_port; }
bool crashDebug() const { return _crash_debug; }
bool logwatchSendInitialEntries() const { return _logwatch_send_initial_entries; }
@@ -169,6 +170,7 @@ private:
unsigned long _realtime_sections;
int _port;
+ int _realtime_port;
script_execution_mode _default_script_execution_mode;
script_async_execution _default_script_async_execution;
diff --git a/agents/windows/check_mk_agent.cc b/agents/windows/check_mk_agent.cc
index 948c560..d600bbe 100644
--- a/agents/windows/check_mk_agent.cc
+++ b/agents/windows/check_mk_agent.cc
@@ -3143,6 +3143,7 @@ struct ThreadData {
Mutex mutex;
};
+
DWORD WINAPI realtime_check_func(void *data_in)
{
ThreadData *data = (ThreadData*)data_in;
@@ -3175,14 +3176,14 @@ DWORD WINAPI realtime_check_func(void *data_in)
if (current_address.ss_family != 0) {
current_socket = socket(current_address.ss_family, SOCK_DGRAM,
IPPROTO_UDP);
if (current_socket == INVALID_SOCKET) {
- printf("failed to establish socket: %d\n",
(int)::WSAGetLastError());
+ crash_log("failed to establish socket: %d",
(int)::WSAGetLastError());
return 1;
}
int sockaddr_size = 0;
if (current_address.ss_family == AF_INET) {
sockaddr_in *addrv4 = (sockaddr_in*)¤t_address;
- addrv4->sin_port = htons(6558);
+ addrv4->sin_port = htons(g_config->realtimePort());
sockaddr_size = sizeof(sockaddr_in);
} else {
sockaddr_in6 *addrv6 = (sockaddr_in6*)¤t_address;
@@ -3195,14 +3196,14 @@ DWORD WINAPI realtime_check_func(void *data_in)
addrv6->sin6_addr.u.Byte[i + 1] = temp;
}
- addrv6->sin6_port = htons(6558);
+ addrv6->sin6_port = htons(g_config->realtimePort());
sockaddr_size = sizeof(sockaddr_in6);
}
current_ip = ListenSocket::readableIP(¤t_address);
if (connect(current_socket, (const
sockaddr*)¤t_address,
sockaddr_size) == SOCKET_ERROR) {
- crash_log("failed to connect: %d\n",
(int)::WSAGetLastError());
+ crash_log("failed to connect: %d",
(int)::WSAGetLastError());
closesocket(current_socket);
current_socket = INVALID_SOCKET;
}