Module: check_mk
Branch: master
Commit: 8fb7d9583cf9d8ea7a589772307e3654996386c9
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=8fb7d9583cf9d8…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Fri Aug 22 16:05:55 2014 +0200
windows agent, winperf counter: try to find counter name in english registry
if it does not exist in the CurrentLanguage key
---
agents/windows/build_version | 2 +-
agents/windows/check_mk_agent-64.exe | Bin 208896 -> 208896 bytes
agents/windows/check_mk_agent-64.unversioned.exe | Bin 208896 -> 208896 bytes
agents/windows/check_mk_agent.cc | 48 ++++++++++------------
agents/windows/check_mk_agent.exe | Bin 178176 -> 177664 bytes
agents/windows/check_mk_agent.unversioned.exe | Bin 178176 -> 177664 bytes
agents/windows/install_agent-64.exe | Bin 159961 -> 159952 bytes
agents/windows/install_agent.exe | Bin 156821 -> 156803 bytes
8 files changed, 23 insertions(+), 27 deletions(-)
diff --git a/agents/windows/build_version b/agents/windows/build_version
index e1617e8..dd47563 100644
--- a/agents/windows/build_version
+++ b/agents/windows/build_version
@@ -1 +1 @@
-57
+76
diff --git a/agents/windows/check_mk_agent-64.exe b/agents/windows/check_mk_agent-64.exe
index b1933ac..5b050b7 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 349cabb..5e9778e 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 e69808e..b49d335 100755
--- a/agents/windows/check_mk_agent.cc
+++ b/agents/windows/check_mk_agent.cc
@@ -4651,17 +4651,15 @@ void determine_directories()
snprintf(g_logwatch_statefile, sizeof(g_logwatch_statefile),
"%s\\logstate.txt", g_agent_directory);
}
-int get_perf_counter_id(const char *counter_name) {
-
+int get_counter_id_from_lang(const char *language, const char *counter_name)
+{
HKEY hKey;
LONG result;
TCHAR szValueName[300000];
DWORD dwcbData = sizeof(szValueName);
-
- // Determine the correct perflib key..
- // CurrentLanguage first
- result = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
- "SOFTWARE\\Microsoft\\Windows
NT\\CurrentVersion\\Perflib\\CurrentLanguage", REG_MULTI_SZ, KEY_READ, &hKey);
+ char regkey[512];
+ snprintf(regkey, sizeof(regkey), "SOFTWARE\\Microsoft\\Windows
NT\\CurrentVersion\\Perflib\\%s", language);
+ result = RegOpenKeyEx(HKEY_LOCAL_MACHINE, regkey, REG_MULTI_SZ, KEY_READ,
&hKey);
RegQueryValueEx(
hKey,
"Counter",
@@ -4672,27 +4670,10 @@ int get_perf_counter_id(const char *counter_name) {
);
RegCloseKey (hKey);
- if (result != ERROR_SUCCESS) // nothing found, try english (009) as fallback
- {
- result = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
- "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Perflib\\009",
REG_MULTI_SZ, KEY_READ, &hKey);
- RegQueryValueEx(
- hKey,
- "Counter",
- NULL,
- NULL,
- (LPBYTE) szValueName,
- &dwcbData
- );
- RegCloseKey (hKey);
- if (result != ERROR_SUCCESS)
- {
- // Unable to open any perflib registry
- return -1;
- }
+ if (result != ERROR_SUCCESS) {
+ return -1;
}
-
int length = 0;
int last_ctr_id = 0;
bool is_name = false;
@@ -4716,6 +4697,21 @@ int get_perf_counter_id(const char *counter_name) {
ptr_perf = szValueName + offset;
is_name = !is_name;
}
+
+ return -1;
+}
+
+int get_perf_counter_id(const char *counter_name)
+{
+ int counter_id;
+ // Try to find it in current language
+ if ((counter_id = get_counter_id_from_lang("CurrentLanguage",
counter_name)) != -1)
+ return counter_id;
+
+ // Try to find it in english
+ if ((counter_id = get_counter_id_from_lang("009", counter_name)) != -1)
+ return counter_id;
+
return -1;
}
diff --git a/agents/windows/check_mk_agent.exe b/agents/windows/check_mk_agent.exe
index e529788..4ac96e9 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.unversioned.exe
b/agents/windows/check_mk_agent.unversioned.exe
index e622182..f2dd030 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 b002fa9..1e95b33 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 24c616e..778fd5a 100755
Binary files a/agents/windows/install_agent.exe and b/agents/windows/install_agent.exe
differ