summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/zabbix_agent_win32/Release/ZabbixW32.exebin102400 -> 102400 bytes
-rwxr-xr-xsrc/zabbix_agent_win32/active.cpp17
-rwxr-xr-xsrc/zabbix_agent_win32/eventlog.cpp14
-rwxr-xr-xsrc/zabbix_agent_win32/logfiles.cpp3
-rwxr-xr-xsrc/zabbix_agent_win32/xml_comms.cpp21
-rw-r--r--src/zabbix_agent_win32/zabbixw32.h4
6 files changed, 41 insertions, 18 deletions
diff --git a/src/zabbix_agent_win32/Release/ZabbixW32.exe b/src/zabbix_agent_win32/Release/ZabbixW32.exe
index 8b168289..56952f8e 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 d8a9b4b7..360524bb 100755
--- a/src/zabbix_agent_win32/active.cpp
+++ b/src/zabbix_agent_win32/active.cpp
@@ -392,7 +392,7 @@ int get_active_checks(char *server, int port, char *error, int max_error_len)
return SUCCEED;
}
-int send_value(char *server,int port,char *host, char *key,char *value,char *lastlogsize)
+int send_value(char *server,int port,char *host, char *key,char *value,char *lastlogsize, char *timestamp)
{
int i,s;
char tosend[1024];
@@ -449,7 +449,7 @@ int send_value(char *server,int port,char *host, char *key,char *value,char *las
return FAIL;
}
- comms_create_request(host,key,value,lastlogsize,tosend,sizeof(tosend)-1);
+ comms_create_request(host,key,value,lastlogsize,timestamp,tosend,sizeof(tosend)-1);
// sprintf(tosend,"%s:%s\n",shortname,value);
WriteLog(MSG_ACTIVE_CHECKS,EVENTLOG_ERROR_TYPE,"s",tosend);
@@ -501,8 +501,11 @@ int process_active_checks(char *server, int port)
HANDLE hThread=NULL;
unsigned int tid;
+
char value[MAX_STRING_LEN];
char lastlogsize[MAX_STRING_LEN];
+ char timestamp[MAX_STRING_LEN];
+
int i, now, count;
int ret = SUCCEED;
@@ -521,6 +524,7 @@ int process_active_checks(char *server, int port)
/* Special processing for log files */
if(strncmp(metrics[i].key,"log[",4) == 0)
{
+ timestamp[0]=0;
strscpy(c,metrics[i].key);
filename=strtok(c,"[]");
filename=strtok(NULL,"[]");
@@ -533,7 +537,7 @@ int process_active_checks(char *server, int port)
// WriteLog(MSG_ACTIVE_CHECKS,EVENTLOG_ERROR_TYPE,"s",shortname);
sprintf(lastlogsize,"%d",metrics[i].lastlogsize);
- if(send_value(server,port,confHostname,metrics[i].key, value, lastlogsize) == FAIL)
+ if(send_value(server,port,confHostname,metrics[i].key, value, lastlogsize,timestamp) == FAIL)
{
ret = FAIL;
break;
@@ -557,7 +561,7 @@ int process_active_checks(char *server, int port)
filename=strtok(NULL,"[]");
count=0;
- while(process_eventlog_new(filename,&metrics[i].lastlogsize,value) == 0)
+ while(process_eventlog_new(filename,&metrics[i].lastlogsize, timestamp, value) == 0)
{
// sprintf(shortname, "%s:%s",confHostname,metrics[i].key);
// zabbix_log( LOG_LEVEL_DEBUG, "%s",shortname);
@@ -566,7 +570,7 @@ int process_active_checks(char *server, int port)
// WriteLog(MSG_ACTIVE_CHECKS,EVENTLOG_ERROR_TYPE,"s",value);
sprintf(lastlogsize,"%d",metrics[i].lastlogsize);
- if(send_value(server,port,confHostname,metrics[i].key,value,lastlogsize) == FAIL)
+ if(send_value(server,port,confHostname,metrics[i].key,value,lastlogsize,timestamp) == FAIL)
{
ret = FAIL;
break;
@@ -585,6 +589,7 @@ int process_active_checks(char *server, int port)
}
else
{
+ timestamp[0]=0;
lastlogsize[0]=0;
strcpy(rq.cmd,metrics[i].key);
@@ -602,7 +607,7 @@ int process_active_checks(char *server, int port)
//sprintf(shortname,"%s:%s",confHostname,metrics[i].key);
// zabbix_log( LOG_LEVEL_DEBUG, "%s",shortname);
- if(send_value(server,port,confHostname,metrics[i].key,rq.result,lastlogsize) == FAIL)
+ if(send_value(server,port,confHostname,metrics[i].key,rq.result,lastlogsize, timestamp) == FAIL)
{
ret = FAIL;
break;
diff --git a/src/zabbix_agent_win32/eventlog.cpp b/src/zabbix_agent_win32/eventlog.cpp
index 988d91a4..0828f70e 100755
--- a/src/zabbix_agent_win32/eventlog.cpp
+++ b/src/zabbix_agent_win32/eventlog.cpp
@@ -10,15 +10,16 @@ DllExport long MyCloseEventLog(HANDLE hAppLog);
DllExport long MyClearEventLog(HANDLE hAppLog);
DllExport long MyGetAEventLog(char *pAppName,HANDLE hAppLog,long
which,double *pTime,char *pSource,char *pMessage,long *pType,long
-*pCategory);
+*pCategory, int *timestamp);
-int process_eventlog_new(char *source,int *lastlogsize, char *value)
+int process_eventlog_new(char *source,int *lastlogsize, char *timestamp, char *value)
{
HANDLE hAppLog;
long nRecords,Latest=1;
long i;
double time;
+ int t;
char src[1024],msg[1024];
long type,category;
@@ -39,7 +40,8 @@ int process_eventlog_new(char *source,int *lastlogsize, char *value)
{
// MyGetAEventLog("Application",hAppLog,Latest,&time,src,msg,&type,&category);
- MyGetAEventLog(source,hAppLog,Latest,&time,src,msg,&type,&category);
+ MyGetAEventLog(source,hAppLog,Latest,&time,src,msg,&type,&category,&t);
+ sprintf(timestamp,"%d",t);
sprintf(value,"Src = %s, Msg = %s, type = %d, Category = %d\n",src,msg,type,category);
WriteLog(MSG_ACTIVE_CHECKS,EVENTLOG_ERROR_TYPE,"d",Latest);
WriteLog(MSG_ACTIVE_CHECKS,EVENTLOG_ERROR_TYPE,"s",value);
@@ -94,8 +96,7 @@ DllExport long MyClearEventLog(HANDLE hAppLog)
// get Nth error from event log. 1 is the first.
DllExport long MyGetAEventLog(char *pAppName,HANDLE hAppLog,long
-which,double *pTime,char *pSource,char *pMessage,long *pType,long
-*pCategory)
+which,double *pTime,char *pSource,char *pMessage,long *pType,long *pCategory, int *timestamp)
{
EVENTLOGRECORD *pELR;
BYTE bBuffer[1024]; /* hold the event
@@ -216,6 +217,9 @@ insert strings for the message */
*pCategory = pELR->EventCategory; // return category
+ *timestamp=pELR->TimeGenerated;
+
+
/* Free the buffer that FormatMessage allocated for us. */
LocalFree((HLOCAL) msgBuf);
diff --git a/src/zabbix_agent_win32/logfiles.cpp b/src/zabbix_agent_win32/logfiles.cpp
index 549cbd07..9e60394e 100755
--- a/src/zabbix_agent_win32/logfiles.cpp
+++ b/src/zabbix_agent_win32/logfiles.cpp
@@ -90,7 +90,7 @@ int process_log(char *filename,int *lastlogsize, char *value)
return 0;
}
-int process_eventlog(char *source,int *lastlogsize, char *value)
+int process_eventlog(char *source,int *lastlogsize, int *timestamp, char *value)
{
HANDLE h;
EVENTLOGRECORD *pevlr;
@@ -147,6 +147,7 @@ int process_eventlog(char *source,int *lastlogsize, char *value)
WriteLog(MSG_ACTIVE_CHECKS,EVENTLOG_ERROR_TYPE,"s",value);
*lastlogsize=dwThisRecord;
+
break;
}
diff --git a/src/zabbix_agent_win32/xml_comms.cpp b/src/zabbix_agent_win32/xml_comms.cpp
index 9a4a551c..2e7c71a4 100755
--- a/src/zabbix_agent_win32/xml_comms.cpp
+++ b/src/zabbix_agent_win32/xml_comms.cpp
@@ -1,31 +1,44 @@
#include "zabbixw32.h"
-int comms_create_request(char *host, char *key, char *data, char *lastlogsize, char *request,int maxlen)
+int comms_create_request(char *host, char *key, char *data, char *lastlogsize, char *timestamp, char *request,int maxlen)
{
int ret = SUCCEED;
char host_b64[MAX_STRING_LEN];
char key_b64[MAX_STRING_LEN];
char data_b64[MAX_STRING_LEN];
char lastlogsize_b64[MAX_STRING_LEN];
+ char timestamp_b64[MAX_STRING_LEN];
memset(host_b64,0,sizeof(host_b64));
memset(key_b64,0,sizeof(key_b64));
memset(data_b64,0,sizeof(data_b64));
memset(lastlogsize_b64,0,sizeof(lastlogsize_b64));
+ memset(timestamp_b64,0,sizeof(timestamp_b64));
str_base64_encode(host, host_b64, strlen(host));
str_base64_encode(key, key_b64, strlen(key));
str_base64_encode(data, data_b64, strlen(data));
str_base64_encode(lastlogsize, lastlogsize_b64, strlen(lastlogsize));
+ str_base64_encode(timestamp, timestamp_b64, strlen(timestamp));
if(lastlogsize[0]==0)
{
- sprintf(request,"<req><host>%s</host><key>%s</key><data>%s</data></req>",host_b64,key_b64,data_b64);
+ sprintf(request,"<req><host>%s</host><key>%s</key><data>%s</data></req>",
+ host_b64,key_b64,data_b64);
}
else
{
- sprintf(request,"<req><host>%s</host><key>%s</key><data>%s</data><lastlogsize>%s</lastlogsize></req>",host_b64,key_b64,data_b64,lastlogsize_b64);
- }
+ if(timestamp[0] == 0)
+ {
+ sprintf(request,"<req><host>%s</host><key>%s</key><data>%s</data><lastlogsize>%s</lastlogsize></req>",
+ host_b64,key_b64,data_b64,lastlogsize_b64);
+ }
+ else
+ {
+ sprintf(request,"<req><host>%s</host><key>%s</key><data>%s</data><lastlogsize>%s</lastlogsize><timestamp>%s</timestamp></req>",
+ host_b64,key_b64,data_b64,lastlogsize_b64,timestamp_b64);
+ }
+ }
return ret;
}
diff --git a/src/zabbix_agent_win32/zabbixw32.h b/src/zabbix_agent_win32/zabbixw32.h
index be09b813..465896b5 100644
--- a/src/zabbix_agent_win32/zabbixw32.h
+++ b/src/zabbix_agent_win32/zabbixw32.h
@@ -213,12 +213,12 @@ void ExpandAlias(char *orig,char *expanded);
unsigned int __stdcall ProcessingThread(void *arg);
int process_log(char *filename,int *lastlogsize, char *value);
//int process_eventlog(char *source,int *lastlogsize, char *value);
-int process_eventlog_new(char *source,int *lastlogsize, char *value);
+int process_eventlog_new(char *source,int *lastlogsize, char *timestamp, char *value);
void str_base64_encode(char *p_str, char *p_b64str, int in_size);
void str_base64_decode(char *p_b64str, char *p_str, int *p_out_size);
-int comms_create_request(char *host, char *key, char *data, char *lastlogsize, char *request,int maxlen);
+int comms_create_request(char *host, char *key, char *data, char *lastlogsize, char *timestamp, char *request,int maxlen);
int xml_get_data(char *xml,char *tag, char *data, int maxlen);