summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xsrc/zabbix_agent_win32/Debug/ZabbixW32.exebin331849 -> 331849 bytes
-rwxr-xr-xsrc/zabbix_agent_win32/Release/ZabbixW32.exebin102400 -> 106496 bytes
-rwxr-xr-xsrc/zabbix_agent_win32/active.cpp32
-rwxr-xr-xsrc/zabbix_agent_win32/eventlog.cpp51
-rw-r--r--src/zabbix_agent_win32/log.cpp1
5 files changed, 82 insertions, 2 deletions
diff --git a/src/zabbix_agent_win32/Debug/ZabbixW32.exe b/src/zabbix_agent_win32/Debug/ZabbixW32.exe
index 2bf3f8c2..8e78f239 100755
--- a/src/zabbix_agent_win32/Debug/ZabbixW32.exe
+++ b/src/zabbix_agent_win32/Debug/ZabbixW32.exe
Binary files differ
diff --git a/src/zabbix_agent_win32/Release/ZabbixW32.exe b/src/zabbix_agent_win32/Release/ZabbixW32.exe
index b71be538..40327380 100755
--- a/src/zabbix_agent_win32/Release/ZabbixW32.exe
+++ b/src/zabbix_agent_win32/Release/ZabbixW32.exe
Binary files differ
diff --git a/src/zabbix_agent_win32/active.cpp b/src/zabbix_agent_win32/active.cpp
index b924dcd2..f2a62ad8 100755
--- a/src/zabbix_agent_win32/active.cpp
+++ b/src/zabbix_agent_win32/active.cpp
@@ -93,12 +93,14 @@ void disable_all_metrics()
{
int i;
+ WriteLog(MSG_ACTIVE_CHECKS,EVENTLOG_ERROR_TYPE,"s","disable_all_metrics: start");
for(i=0;;i++)
{
if(metrics[i].key == NULL) break;
metrics[i].status = ITEM_STATUS_NOTSUPPORTED;
}
+ WriteLog(MSG_ACTIVE_CHECKS,EVENTLOG_ERROR_TYPE,"s","disable_all_metrics: end");
}
int get_min_nextcheck()
@@ -107,6 +109,8 @@ int get_min_nextcheck()
int min=-1;
int nodata=0;
+ WriteLog(MSG_ACTIVE_CHECKS,EVENTLOG_ERROR_TYPE,"s","get_min_nextcheck: start");
+
for(i=0;;i++)
{
if(metrics[i].key == NULL) break;
@@ -121,8 +125,11 @@ int get_min_nextcheck()
if(nodata==0)
{
+ WriteLog(MSG_ACTIVE_CHECKS,EVENTLOG_ERROR_TYPE,"s","get_min_nextcheck: end: FAIL");
return FAIL;
}
+ WriteLog(MSG_ACTIVE_CHECKS,EVENTLOG_ERROR_TYPE,"s","get_min_nextcheck: end");
+
return min;
}
@@ -130,6 +137,8 @@ void add_check(char *key, int refresh, int lastlogsize)
{
int i;
+ WriteLog(MSG_ACTIVE_CHECKS,EVENTLOG_ERROR_TYPE,"s","add_check: start");
+
for(i=0;;i++)
{
if(metrics[i].key == NULL)
@@ -156,6 +165,7 @@ void add_check(char *key, int refresh, int lastlogsize)
break;
}
}
+ WriteLog(MSG_ACTIVE_CHECKS,EVENTLOG_ERROR_TYPE,"s","add_check: end");
}
// Return position of Nth delimiter from right size, 0 - otherwise
@@ -164,12 +174,14 @@ int strnrchr(char *str, int num, char delim)
int i=0;
int n=0;
+ WriteLog(MSG_ACTIVE_CHECKS,EVENTLOG_ERROR_TYPE,"s","strnrchr: start");
for(i=strlen(str)-1;i>=0;i--)
{
if(str[i]==delim) n++;
if(n==num) break;
}
if(i==-1) i=0;
+ WriteLog(MSG_ACTIVE_CHECKS,EVENTLOG_ERROR_TYPE,"s","strnrchr: end");
return i;
}
@@ -186,6 +198,7 @@ int parse_list_of_checks(char *str)
char *str_copy;
int p1,p2;
+ WriteLog(MSG_ACTIVE_CHECKS,EVENTLOG_ERROR_TYPE,"s","parse_list_of_checks: start");
disable_all_metrics();
str_copy=str;
@@ -230,6 +243,7 @@ int parse_list_of_checks(char *str)
pos=strchr(str_copy,'\n');
}
+ WriteLog(MSG_ACTIVE_CHECKS,EVENTLOG_ERROR_TYPE,"s","parse_list_of_checks: end");
return SUCCEED;
}
@@ -245,6 +259,7 @@ int get_active_checks(char *server, int port, char *error, int max_error_len)
struct sockaddr_in servaddr_in;
// zabbix_log( LOG_LEVEL_DEBUG, "get_active_checks: host[%s] port[%d]", server, port);
+ WriteLog(MSG_ACTIVE_CHECKS,EVENTLOG_ERROR_TYPE,"s","get_active_checks: start");
servaddr_in.sin_family=AF_INET;
hp=gethostbyname(server);
@@ -389,6 +404,7 @@ int get_active_checks(char *server, int port, char *error, int max_error_len)
// zabbix_log(LOG_LEVEL_WARNING, "Problem with close [%s]", strerror(errno));
}
+ WriteLog(MSG_ACTIVE_CHECKS,EVENTLOG_ERROR_TYPE,"s","get_active_checks: end");
return SUCCEED;
}
@@ -405,6 +421,7 @@ int send_value(char *server,int port,char *host, char *key,char *value,char *las
struct sockaddr_in servaddr_in;
// zabbix_log( LOG_LEVEL_DEBUG, "In send_value()");
+ WriteLog(MSG_ACTIVE_CHECKS,EVENTLOG_ERROR_TYPE,"s","send_value: start");
servaddr_in.sin_family=AF_INET;
hp=gethostbyname(server);
@@ -493,6 +510,7 @@ sprintf(tmp,"Error in recvfrom()");
// zabbix_log( LOG_LEVEL_WARNING, "Error in close() [%s] [%s]",server, strerror(errno));
}
+ WriteLog(MSG_ACTIVE_CHECKS,EVENTLOG_ERROR_TYPE,"s","send_value: end");
return SUCCEED;
}
@@ -515,6 +533,7 @@ int process_active_checks(char *server, int port)
char c[MAX_STRING_LEN];
char *filename;
+ WriteLog(MSG_ACTIVE_CHECKS,EVENTLOG_ERROR_TYPE,"s","process_active_checks: start");
now=time(NULL);
for(i=0;;i++)
@@ -561,9 +580,12 @@ int process_active_checks(char *server, int port)
/* Special processing for log files */
else if(strncmp(metrics[i].key,"eventlog[",9) == 0)
{
+ WriteLog(MSG_ACTIVE_CHECKS,EVENTLOG_ERROR_TYPE,"s","process_active_checks: 1");
+
strscpy(c,metrics[i].key);
filename=strtok(c,"[]");
filename=strtok(NULL,"[]");
+ WriteLog(MSG_ACTIVE_CHECKS,EVENTLOG_ERROR_TYPE,"s","process_active_checks: 2");
count=0;
while(process_eventlog_new(filename,&metrics[i].lastlogsize, timestamp, source, severity, value) == 0)
@@ -574,6 +596,7 @@ int process_active_checks(char *server, int port)
// WriteLog(MSG_ACTIVE_CHECKS,EVENTLOG_ERROR_TYPE,"s","In loop()");
// WriteLog(MSG_ACTIVE_CHECKS,EVENTLOG_ERROR_TYPE,"s",value);
+ WriteLog(MSG_ACTIVE_CHECKS,EVENTLOG_ERROR_TYPE,"s","process_active_checks: 3");
sprintf(lastlogsize,"%d",metrics[i].lastlogsize);
if(send_value(server,port,confHostname,metrics[i].key,value,lastlogsize,timestamp,source,severity) == FAIL)
{
@@ -590,6 +613,7 @@ int process_active_checks(char *server, int port)
// WriteLog(MSG_ACTIVE_CHECKS,EVENTLOG_ERROR_TYPE,"s","End of loop()");
/* Do not flood ZABBIX server if file grows too fast */
if(count >= MAX_LINES_PER_SECOND*metrics[i].refresh) break;
+ WriteLog(MSG_ACTIVE_CHECKS,EVENTLOG_ERROR_TYPE,"s","process_active_checks: 4");
}
}
else
@@ -630,11 +654,13 @@ int process_active_checks(char *server, int port)
metrics[i].nextcheck=time(NULL)+metrics[i].refresh;
}
+ WriteLog(MSG_ACTIVE_CHECKS,EVENTLOG_ERROR_TYPE,"s","process_active_checks: end");
return ret;
}
void refresh_metrics(char *server, int port, char *error, int max_error_len)
{
+ WriteLog(MSG_ACTIVE_CHECKS,EVENTLOG_ERROR_TYPE,"s","refresh_metrics: start");
// zabbix_log( LOG_LEVEL_DEBUG, "In refresh_metrics()");
while(get_active_checks(server, port, error, sizeof(error)) != SUCCEED)
{
@@ -644,6 +670,7 @@ void refresh_metrics(char *server, int port, char *error, int max_error_len)
#endif
Sleep(60*1000);
}
+ WriteLog(MSG_ACTIVE_CHECKS,EVENTLOG_ERROR_TYPE,"s","refresh_metrics: end");
}
void ActiveChecksThread(void *)
@@ -656,6 +683,8 @@ void ActiveChecksThread(void *)
// WriteLog(MSG_ACTIVE_CHECKS,EVENTLOG_ERROR_TYPE,"d",confServerPort);
+
+ WriteLog(MSG_ACTIVE_CHECKS,EVENTLOG_ERROR_TYPE,"s","ActiveChecksThread: start");
init_list();
refresh_metrics(confServer, confServerPort, error, sizeof(error));
@@ -663,6 +692,7 @@ void ActiveChecksThread(void *)
for(;;)
{
+ WriteLog(MSG_ACTIVE_CHECKS,EVENTLOG_ERROR_TYPE,"s","ActiveChecksThread: loop 1");
if(process_active_checks(confServer, confServerPort) == FAIL)
{
Sleep(60*1000);
@@ -702,5 +732,7 @@ void ActiveChecksThread(void *)
refresh_metrics(confServer, confServerPort, error, sizeof(error));
nextrefresh=time(NULL)+300;
}
+ WriteLog(MSG_ACTIVE_CHECKS,EVENTLOG_ERROR_TYPE,"s","ActiveChecksThread: loop 2");
}
+ WriteLog(MSG_ACTIVE_CHECKS,EVENTLOG_ERROR_TYPE,"s","ActiveChecksThread: end");
}
diff --git a/src/zabbix_agent_win32/eventlog.cpp b/src/zabbix_agent_win32/eventlog.cpp
index e6898916..367e0c54 100755
--- a/src/zabbix_agent_win32/eventlog.cpp
+++ b/src/zabbix_agent_win32/eventlog.cpp
@@ -24,13 +24,16 @@ int process_eventlog_new(char *source,int *lastlogsize, char *timestamp, char *s
// open up event log
// if (!MyOpenEventLog("Application",&hAppLog,&nRecords,&Latest))
+ WriteLog(MSG_ACTIVE_CHECKS,EVENTLOG_ERROR_TYPE,"s","process_eventlog_new: start");
if (!MyOpenEventLog(source,&hAppLog,&nRecords,&Latest))
{
+ WriteLog(MSG_ACTIVE_CHECKS,EVENTLOG_ERROR_TYPE,"s","process_eventlog_new: if 1");
// for (i = nRecords + 1;--i;++Latest)
for (i = 0; i<nRecords;i++)
{
+ WriteLog(MSG_ACTIVE_CHECKS,EVENTLOG_ERROR_TYPE,"s","process_eventlog_new: for 1");
// if (Latest > nRecords) // need totreat as circular que
// Latest = 1;
// WriteLog(MSG_ACTIVE_CHECKS,EVENTLOG_ERROR_TYPE,"s","i");
@@ -39,8 +42,10 @@ int process_eventlog_new(char *source,int *lastlogsize, char *timestamp, char *s
{
// MyGetAEventLog("Application",hAppLog,Latest,&time,src,msg,&type,&category);
+ WriteLog(MSG_ACTIVE_CHECKS,EVENTLOG_ERROR_TYPE,"s","process_eventlog_new: if 2");
if(0 == MyGetAEventLog(source,hAppLog,Latest,&time,src,message,&type,&category,&t))
{
+ WriteLog(MSG_ACTIVE_CHECKS,EVENTLOG_ERROR_TYPE,"s","process_eventlog_new: if 3");
sprintf(timestamp,"%ld",t);
// WriteLog(MSG_ACTIVE_CHECKS,EVENTLOG_ERROR_TYPE,"s","YO");
// WriteLog(MSG_ACTIVE_CHECKS,EVENTLOG_ERROR_TYPE,"d",type);
@@ -55,15 +60,21 @@ int process_eventlog_new(char *source,int *lastlogsize, char *timestamp, char *s
// WriteLog(MSG_ACTIVE_CHECKS,EVENTLOG_ERROR_TYPE,"d",Latest);
// WriteLog(MSG_ACTIVE_CHECKS,EVENTLOG_ERROR_TYPE,"s",severity);
*lastlogsize = Latest;
+ WriteLog(MSG_ACTIVE_CHECKS,EVENTLOG_ERROR_TYPE,"s","process_eventlog_new: if 4");
MyCloseEventLog(hAppLog);
+ WriteLog(MSG_ACTIVE_CHECKS,EVENTLOG_ERROR_TYPE,"s","process_eventlog_new: if 5");
return 0;
}
+ WriteLog(MSG_ACTIVE_CHECKS,EVENTLOG_ERROR_TYPE,"s","process_eventlog_new: if 6");
}
Latest++;
+ WriteLog(MSG_ACTIVE_CHECKS,EVENTLOG_ERROR_TYPE,"s","process_eventlog_new: for 8");
}
+ WriteLog(MSG_ACTIVE_CHECKS,EVENTLOG_ERROR_TYPE,"s","process_eventlog_new: 6");
MyCloseEventLog(hAppLog);
+ WriteLog(MSG_ACTIVE_CHECKS,EVENTLOG_ERROR_TYPE,"s","process_eventlog_new: 7");
}
-
+WriteLog(MSG_ACTIVE_CHECKS,EVENTLOG_ERROR_TYPE,"s","process_eventlog_new: end");
return 1;
}
@@ -74,14 +85,19 @@ DllExport long MyOpenEventLog(char *pAppName,HANDLE
HANDLE hAppLog; /* handle to the
application log */
+ WriteLog(MSG_ACTIVE_CHECKS,EVENTLOG_ERROR_TYPE,"s","MyOpenEventLog: start");
*pEventHandle = 0;
*pNumRecords = 0;
hAppLog = OpenEventLog(NULL,pAppName); // open log file
if (!hAppLog)
+ {
+ WriteLog(MSG_ACTIVE_CHECKS,EVENTLOG_ERROR_TYPE,"s","MyOpenEventLog: 1");
return(GetLastError());
+ }
GetNumberOfEventLogRecords(hAppLog,(unsigned long*)pNumRecords);// get number of records
GetOldestEventLogRecord(hAppLog,(unsigned long*)pLatestRecord);
*pEventHandle = hAppLog;
+ WriteLog(MSG_ACTIVE_CHECKS,EVENTLOG_ERROR_TYPE,"s","MyOpenEventLog: end");
return(0);
}
@@ -89,8 +105,10 @@ application log */
// close event logger
DllExport long MyCloseEventLog(HANDLE hAppLog)
{
+ WriteLog(MSG_ACTIVE_CHECKS,EVENTLOG_ERROR_TYPE,"s","MyCloseEventLog: start");
if (hAppLog)
CloseEventLog(hAppLog);
+ WriteLog(MSG_ACTIVE_CHECKS,EVENTLOG_ERROR_TYPE,"s","MyCloseEventLog: end");
return(0);
}
@@ -98,8 +116,13 @@ DllExport long MyCloseEventLog(HANDLE hAppLog)
// clear event log
DllExport long MyClearEventLog(HANDLE hAppLog)
{
+ WriteLog(MSG_ACTIVE_CHECKS,EVENTLOG_ERROR_TYPE,"s","MyClearEventLog: start");
if (!(ClearEventLog(hAppLog,0)))
+ {
+ WriteLog(MSG_ACTIVE_CHECKS,EVENTLOG_ERROR_TYPE,"s","MyClearEventLog: end1");
return(GetLastError());
+ }
+ WriteLog(MSG_ACTIVE_CHECKS,EVENTLOG_ERROR_TYPE,"s","MyClearEventLog: end2");
return(0);
}
@@ -127,8 +150,12 @@ messagetable DLL */
LPTSTR msgBuf; // hold text of the error message that we
long err;
+ WriteLog(MSG_ACTIVE_CHECKS,EVENTLOG_ERROR_TYPE,"s","MyGetAEventLog: start");
if (!hAppLog)
+ {
+ WriteLog(MSG_ACTIVE_CHECKS,EVENTLOG_ERROR_TYPE,"s","MyGetAEventLog: 1");
return(0);
+ }
bSuccess = ReadEventLog(hAppLog, /* event-log handle */
EVENTLOG_SEEK_READ | /* read forward */
EVENTLOG_FORWARDS_READ, /* sequential read */
@@ -141,7 +168,10 @@ read */
&dwNeeded); /* bytes in next
record */
if (!bSuccess)
+ {
+ WriteLog(MSG_ACTIVE_CHECKS,EVENTLOG_ERROR_TYPE,"s","MyGetAEventLog: 2");
return(GetLastError());
+ }
pELR = (EVENTLOGRECORD*)bBuffer; // point to data
strcpy(pSource,((char*)pELR + sizeof(EVENTLOGRECORD)));// copy source name
@@ -151,7 +181,10 @@ record */
strcat(temp,"\\");
strcat(temp,((char*)pELR + sizeof(EVENTLOGRECORD)));
if (RegOpenKey(HKEY_LOCAL_MACHINE, temp, &hk))
+ {
+ WriteLog(MSG_ACTIVE_CHECKS,EVENTLOG_ERROR_TYPE,"s","MyGetAEventLog: 3");
return(GetLastError());
+ }
Data = MAX_PATH;
if (RegQueryValueEx(hk, /* handle of key
to query */
@@ -165,18 +198,28 @@ value */
value data */
&Data)) /* length of value
data */
+ {
+ WriteLog(MSG_ACTIVE_CHECKS,EVENTLOG_ERROR_TYPE,"s","MyGetAEventLog: 4");
return(GetLastError());
+ }
pFile = temp;
err = 1;
for (;;)
{
+ WriteLog(MSG_ACTIVE_CHECKS,EVENTLOG_ERROR_TYPE,"s","MyGetAEventLog: for 1");
if ((pNextFile = strchr(pFile,';')))
*pNextFile = 0;
if (!ExpandEnvironmentStrings(pFile, MsgDll, MAX_PATH))
+ {
+ WriteLog(MSG_ACTIVE_CHECKS,EVENTLOG_ERROR_TYPE,"s","MyGetAEventLog: for 2");
return(GetLastError());
+ }
if (!(hLib = LoadLibraryEx(MsgDll, NULL, LOAD_LIBRARY_AS_DATAFILE)))
+ {
+ WriteLog(MSG_ACTIVE_CHECKS,EVENTLOG_ERROR_TYPE,"s","MyGetAEventLog: for 3");
return(1);
+ }
/* prepare the array of insert strings for FormatMessage - the
insert strings are in the log entry. */
@@ -214,6 +257,7 @@ insert strings for the message */
{
RegCloseKey(hk);
i = GetLastError();
+ WriteLog(MSG_ACTIVE_CHECKS,EVENTLOG_ERROR_TYPE,"s","MyGetAEventLog: for 4");
return(i);
}
pFile = ++pNextFile;
@@ -230,15 +274,18 @@ insert strings for the message */
/* Free the buffer that FormatMessage allocated for us. */
+WriteLog(MSG_ACTIVE_CHECKS,EVENTLOG_ERROR_TYPE,"s","MyGetAEventLog: 10");
LocalFree((HLOCAL) msgBuf);
/* free the message DLL since we don't know if we'll need it again */
+ WriteLog(MSG_ACTIVE_CHECKS,EVENTLOG_ERROR_TYPE,"s","MyGetAEventLog: 11");
FreeLibrary(hLib);
+ WriteLog(MSG_ACTIVE_CHECKS,EVENTLOG_ERROR_TYPE,"s","MyGetAEventLog: 12");
RegCloseKey(hk);
//WriteLog(MSG_ACTIVE_CHECKS,EVENTLOG_ERROR_TYPE,"s","Y");
//WriteLog(MSG_ACTIVE_CHECKS,EVENTLOG_ERROR_TYPE,"d",*pType);
-
+WriteLog(MSG_ACTIVE_CHECKS,EVENTLOG_ERROR_TYPE,"s","MyGetAEventLog: end");
return(0);
} \ No newline at end of file
diff --git a/src/zabbix_agent_win32/log.cpp b/src/zabbix_agent_win32/log.cpp
index cc0e3f93..b5a35b65 100644
--- a/src/zabbix_agent_win32/log.cpp
+++ b/src/zabbix_agent_win32/log.cpp
@@ -60,6 +60,7 @@ void InitLog(void)
strftime(tbuf,32,"%d-%b-%Y %H:%M:%S",loc);
sprintf(buffer,"**************************************************************\r\n[%s] Log file opened\r\n",tbuf);
WriteFile(hLog,buffer,strlen(buffer),&size,NULL);
+ FlushFileBuffers(hLog);
mutexLogAccess=CreateMutex(NULL,FALSE,NULL);
}