summaryrefslogtreecommitdiffstats
path: root/src/zabbix_agent_win32/main.cpp
diff options
context:
space:
mode:
authorsauros <sauros@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2003-06-12 07:28:12 +0000
committersauros <sauros@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2003-06-12 07:28:12 +0000
commitc37d3252f161b0f0ee41bbf286eb7b4cb7b0c88e (patch)
tree8394422243e0f06ba505566cf1a03a7eae7c4b8b /src/zabbix_agent_win32/main.cpp
parent55a6f811f82f8f85a3fa026db1cc54e4d06eb0f4 (diff)
downloadzabbix-c37d3252f161b0f0ee41bbf286eb7b4cb7b0c88e.tar.gz
zabbix-c37d3252f161b0f0ee41bbf286eb7b4cb7b0c88e.tar.xz
zabbix-c37d3252f161b0f0ee41bbf286eb7b4cb7b0c88e.zip
- Applied i18n patch by Harald Holzer (Victor)
git-svn-id: svn://svn.zabbix.com/trunk@815 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'src/zabbix_agent_win32/main.cpp')
-rw-r--r--src/zabbix_agent_win32/main.cpp39
1 files changed, 38 insertions, 1 deletions
diff --git a/src/zabbix_agent_win32/main.cpp b/src/zabbix_agent_win32/main.cpp
index 5cc50960..26860d0d 100644
--- a/src/zabbix_agent_win32/main.cpp
+++ b/src/zabbix_agent_win32/main.cpp
@@ -42,6 +42,7 @@ DWORD confMaxProcTime=100; // 100 milliseconds is default acceptable collector s
SUBAGENT *subagentList; // List of loaded subagents
SUBAGENT_NAME *subagentNameList=NULL;
+PERFCOUNTER *perfCounterList=NULL;
DWORD (__stdcall *imp_GetGuiResources)(HANDLE,DWORD);
BOOL (__stdcall *imp_GetProcessIoCounters)(HANDLE,PIO_COUNTERS);
@@ -148,6 +149,40 @@ static BOOL LoadSubAgent(char *name,char *cmdLine)
return TRUE;
}
+char *GetCounterName(DWORD index)
+{
+ PERFCOUNTER *counterName;
+ DWORD dwSize;
+ char hostname[MAX_COMPUTERNAME_LENGTH+3];
+
+ counterName = perfCounterList;
+ while(counterName!=NULL)
+ {
+ if (counterName->pdhIndex == index) break;
+ counterName = counterName->next;
+ }
+ if (counterName == NULL)
+ {
+ counterName = (PERFCOUNTER *) malloc(sizeof(PERFCOUNTER));
+ memset(counterName,0, sizeof(PERFCOUNTER));
+ counterName->pdhIndex = index;
+ counterName->next = perfCounterList;
+
+ sprintf(hostname, "\\\\");
+ dwSize = MAX_COMPUTERNAME_LENGTH;
+ GetComputerName((char *) &hostname + 2, &dwSize);
+
+ dwSize = MAX_COUNTER_PATH;
+ if (PdhLookupPerfNameByIndex((char *) &hostname, index, (char *) &counterName->name, &dwSize)==ERROR_SUCCESS)
+ {
+ perfCounterList = counterName;
+ } else {
+ free (counterName);
+ return NULL;
+ }
+ }
+ return (char *) &counterName->name;
+}
//
// Initialization routine
@@ -157,6 +192,7 @@ BOOL Initialize(void)
{
WSAData sockInfo;
int i;
+ char counterPath[MAX_COUNTER_PATH * 2 + 50];
// Initialize Windows Sockets API
WSAStartup(0x0002,&sockInfo);
@@ -184,7 +220,8 @@ BOOL Initialize(void)
eventCollectorStarted=CreateEvent(NULL,TRUE,FALSE,NULL);
// Internal command aliases
- AddAlias("system[uptime]","perf_counter[\\System\\System Up Time]");
+ sprintf((char *) &counterPath,"perf_counter[\\%s\\%s]", GetCounterName(PCI_SYSTEM), GetCounterName(PCI_SYSTEM_UP_TIME));
+ AddAlias("system[uptime]",(char *) &counterPath);
// Start TCP/IP listener and collector threads
_beginthread(CollectorThread,0,NULL);