Module: check_mk
Branch: master
Commit: 5c64b547174eba483e408c7fbb0f684f532574ea
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=5c64b547174eba…
Author: Jukka Aro <ja(a)mathias-kettner.de>
Date: Fri Apr 6 14:17:04 2018 +0200
Win-agent: use std::cerr instead of fprintf
---
agents/windows/SectionManager.cc | 8 ++++----
agents/windows/build_version | 2 +-
agents/windows/check_mk_agent.cc | 40 +++++++++++++++++++++-------------------
agents/windows/stringutil.cc | 9 +++++----
agents/windows/types.cc | 4 ++--
5 files changed, 33 insertions(+), 30 deletions(-)
diff --git a/agents/windows/SectionManager.cc b/agents/windows/SectionManager.cc
index 0ebebfa..e215eb6 100644
--- a/agents/windows/SectionManager.cc
+++ b/agents/windows/SectionManager.cc
@@ -63,10 +63,10 @@ winperf_counter from_string<winperf_counter>(const
WinApiInterface &winapi,
const std::string &value) {
size_t colonIdx = value.find_last_of(":");
if (colonIdx == std::string::npos) {
- fprintf(stderr,
- "Invalid counter '%s' in section [winperf]: need number(or
"
- "text) and colon, e.g. 238:processor.\n",
- value.c_str());
+ std::cerr << "Invalid counter '" << value
+ << "' in section [winperf]: need number(or "
+ "text) and colon, e.g. 238:processor."
+ << std::endl;
exit(1);
}
diff --git a/agents/windows/build_version b/agents/windows/build_version
index 5ccbba2..4daa189 100644
--- a/agents/windows/build_version
+++ b/agents/windows/build_version
@@ -1 +1 @@
-3226
+3228
diff --git a/agents/windows/check_mk_agent.cc b/agents/windows/check_mk_agent.cc
index 5c5608b..92ac9fa 100644
--- a/agents/windows/check_mk_agent.cc
+++ b/agents/windows/check_mk_agent.cc
@@ -467,7 +467,7 @@ void do_remove() { UninstallService(); }
void wsa_startup() {
WSADATA wsa;
if (0 != s_winapi.WSAStartup(MAKEWORD(2, 0), &wsa)) {
- fprintf(stderr, "Cannot initialize winsock.\n");
+ std::cerr << "Cannot initialize winsock." << std::endl;
exit(1);
}
}
@@ -497,23 +497,24 @@ void stop_threads() {
// '----------------------------------------------------------------------'
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 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_agent showconfig -- shows the effective "
- "configuration used (currently incomplete)\n",
- CHECK_MK_VERSION, *s_config->port);
+ std::cerr
+ << "Usage: \n"
+ << "check_mk_agent version -- show version " <<
CHECK_MK_VERSION
+ << " 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 " <<
*s_config->port
+ << " 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_agent showconfig -- shows the effective "
+ << "configuration used (currently incomplete)" <<
std::endl;
exit(1);
}
@@ -1008,7 +1009,8 @@ void RunImmediate(const char *mode, int argc, char **argv) {
do_test(env);
else if (!strcmp(mode, "file")) {
if (argc < 1) {
- fprintf(stderr, "Please specify the name of an output file.\n");
+ std::cerr << "Please specify the name of an output file."
+ << std::endl;
exit(1);
}
do_file(env, argv[0]);
diff --git a/agents/windows/stringutil.cc b/agents/windows/stringutil.cc
index 615404e..8b7f9cf 100644
--- a/agents/windows/stringutil.cc
+++ b/agents/windows/stringutil.cc
@@ -31,8 +31,8 @@ int parse_boolean(const char *value) {
else if (!strcmp(value, "no"))
return 0;
else
- fprintf(stderr,
- "Invalid boolean value. Only yes and no are allowed.\r\n");
+ std::cerr << "Invalid boolean value. Only yes and no are
allowed."
+ << std::endl;
return -1;
}
@@ -115,7 +115,7 @@ void stringToIPv6(const char *value, uint16_t *address,
unsigned long segment = strtoul(pos, &endpos, 16);
if (segment > 0xFFFFu) {
- fprintf(stderr, "Invalid ipv6 address %s\n", value);
+ std::cerr << "Invalid ipv6 address " << value <<
std::endl;
exit(1);
} else if (endpos == pos) {
skip_offset = segments.size();
@@ -149,7 +149,8 @@ void stringToIPv6(const char *value, uint16_t *address,
void stringToIPv4(const char *value, uint32_t &address) {
unsigned a, b, c, d;
if (4 != sscanf(value, "%u.%u.%u.%u", &a, &b, &c, &d)) {
- fprintf(stderr, "Invalid value %s for only_hosts\n", value);
+ std::cerr << "Invalid value " << value << " for
only_hosts"
+ << std::endl;
exit(1);
}
diff --git a/agents/windows/types.cc b/agents/windows/types.cc
index ab5c78c..27babc8 100644
--- a/agents/windows/types.cc
+++ b/agents/windows/types.cc
@@ -61,8 +61,8 @@ ipspec from_string<ipspec>(const WinApiInterface &winapi,
if ((result.ip.v4.address & result.ip.v4.netmask) !=
result.ip.v4.address) {
- fprintf(stderr, "Invalid only_hosts entry: host part not 0: %s",
- value.c_str());
+ std::cerr << "Invalid only_hosts entry: host part not 0: "
<< value
+ << std::endl;
exit(1);
}
}