diff options
author | osmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2006-07-12 12:24:51 +0000 |
---|---|---|
committer | osmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2006-07-12 12:24:51 +0000 |
commit | a62b9e10b87ee280ae3c72f75acbc6777dd92009 (patch) | |
tree | 1be9fe96eb20da2e3a13382241400c6b639c1b86 | |
parent | 8a9f232945f6ec241470513933baf6d72d256a06 (diff) | |
download | zabbix-a62b9e10b87ee280ae3c72f75acbc6777dd92009.tar.gz zabbix-a62b9e10b87ee280ae3c72f75acbc6777dd92009.tar.xz zabbix-a62b9e10b87ee280ae3c72f75acbc6777dd92009.zip |
minor fixes
git-svn-id: svn://svn.zabbix.com/trunk@3039 97f52cf1-0a1b-0410-bd0e-c28be96e8082
-rw-r--r-- | src/alphacode/poller/poller.c | 34 | ||||
-rwxr-xr-x | src/alphacode/poller/snmp.c | 18 | ||||
-rwxr-xr-x | src/alphacode/poller/snmp_orig.c | 4 | ||||
-rwxr-xr-x | src/libs/zbxcommon/alias.c | 18 | ||||
-rw-r--r-- | src/libs/zbxcommon/base64.c | 10 | ||||
-rw-r--r-- | src/libs/zbxconf/cfg.c | 2 | ||||
-rw-r--r-- | src/libs/zbxlog/log.c | 82 | ||||
-rwxr-xr-x | src/libs/zbxnix/daemon.c | 2 | ||||
-rw-r--r-- | src/libs/zbxsysinfo/common/common.c | 36 | ||||
-rw-r--r-- | src/libs/zbxsysinfo/solaris/swap.c | 8 | ||||
-rwxr-xr-x | src/libs/zbxsysinfo/win32/system_w32.c | 2 | ||||
-rwxr-xr-x | src/libs/zbxwin32/perfmon.c | 6 | ||||
-rwxr-xr-x | src/libs/zbxwin32/service.c | 76 | ||||
-rw-r--r-- | src/zabbix_agent/active.c | 16 | ||||
-rw-r--r-- | src/zabbix_agent/active.h | 1 | ||||
-rw-r--r-- | src/zabbix_agent/cpustat.c | 10 | ||||
-rw-r--r-- | src/zabbix_agent/logfiles.c | 4 | ||||
-rw-r--r-- | src/zabbix_agent/zabbix_agent.c | 2 | ||||
-rw-r--r-- | src/zabbix_agent/zabbix_agentd.c | 18 | ||||
-rw-r--r-- | src/zabbix_server/Makefile.am | 2 | ||||
-rw-r--r-- | src/zabbix_server/actions.c | 2 | ||||
-rw-r--r-- | src/zabbix_server/trapper/trapper.c | 4 |
22 files changed, 184 insertions, 173 deletions
diff --git a/src/alphacode/poller/poller.c b/src/alphacode/poller/poller.c index 570cee64..f39e9518 100644 --- a/src/alphacode/poller/poller.c +++ b/src/alphacode/poller/poller.c @@ -35,7 +35,7 @@ ZBXPOOL char ip[128]; int port; int socket; - int status; // 0 - not connected, 1 - connected, 2 - wrote data + int status; /* 0 - not connected, 1 - connected, 2 - wrote data */ }; ZBXPOOL pool[NUM]; @@ -67,13 +67,14 @@ void wait_connect() for(;;) { -// printf("To process [%d]\n", NUM-READ); -// printf("-----------------------\n"); -// for(j=0;j<NUM-READ;j++) -// { -// printf("[%d] fd [%d] revents [%X]\n",j,poll_cli[j].fd,poll_cli[j].revents); -// } -// printf("-----------------------\n"); +/* printf("To process [%d]\n", NUM-READ); + printf("-----------------------\n"); + for(j=0;j<NUM-READ;j++) + { + printf("[%d] fd [%d] revents [%X]\n",j,poll_cli[j].fd,poll_cli[j].revents); + } + printf("-----------------------\n"); +*/ if(NUM-READ<=0) break; retval = poll(poll_cli,NUM-READ,-1); @@ -90,7 +91,7 @@ void wait_connect() for(i=0;i<NUM-READ;i++) { -// printf("[%d] remote socket [%X]\n",i,poll_cli[i].revents); +/* printf("[%d] remote socket [%X]\n",i,poll_cli[i].revents); */ if ((poll_cli[i].revents&POLLHUP)==POLLHUP) { printf("[%d] remote socket has closed\n",i); @@ -100,13 +101,14 @@ void wait_connect() { memmove(&poll_cli[i], &poll_cli[i+1],(NUM-READ-i-1)*sizeof(struct pollfd)); READ++; -// for(j=i;j<NUM-READ;j++) -// { -// memmove(&poll_cli[j], &poll_cli[j+1],sizeof(struct pollfd)); -// poll_cli[j].fd=poll_cli[j+1].fd; -// poll_cli[j].events=poll_cli[j+1].events; -// poll_cli[j].revents=poll_cli[j+1].revents; -// } +/* for(j=i;j<NUM-READ;j++) + { + memmove(&poll_cli[j], &poll_cli[j+1],sizeof(struct pollfd)); + poll_cli[j].fd=poll_cli[j+1].fd; + poll_cli[j].events=poll_cli[j+1].events; + poll_cli[j].revents=poll_cli[j+1].revents; + } +*/ break; } if ((poll_cli[i].revents&POLLERR)==POLLERR) diff --git a/src/alphacode/poller/snmp.c b/src/alphacode/poller/snmp.c index 9f2bc583..1a85d3df 100755 --- a/src/alphacode/poller/snmp.c +++ b/src/alphacode/poller/snmp.c @@ -34,7 +34,7 @@ struct host { char *hostname; char *community; } hosts[10000] = { -// { "192.168.1.60", "public" }, +/* { "192.168.1.60", "public" }, */ { NULL } }; @@ -47,7 +47,7 @@ struct oid { oid Oid[MAX_OID_LEN]; int OidLen; } oids[10000] = { -// { "192.168.1.5", ".1.3.6.1.2.1.1.6.5" }, +/* { "192.168.1.5", ".1.3.6.1.2.1.1.6.5" }, */ { NULL } }; @@ -127,7 +127,7 @@ void load_oids(void) for(i=0;i<DBnum_rows(result);i++) { -// printf("[%s] [%s] [%s]\n",DBget_field(result,i,0),DBget_field(result,i,1),DBget_field(result,i,2)); +/* printf("[%s] [%s] [%s]\n",DBget_field(result,i,0),DBget_field(result,i,1),DBget_field(result,i,2)); */ hostname = DBget_field(result,i,0); community = DBget_field(result,i,1); @@ -191,7 +191,7 @@ void initialize (void) /* parse the oids */ op = oids; while (op->hostname) { -// printf("[%s]\n",op->hostname); +/* printf("[%s]\n",op->hostname); */ op->OidLen = sizeof(op->Oid)/sizeof(op->Oid[0]); if (!read_objid(op->Name, op->Oid, &op->OidLen)) { snmp_perror("read_objid"); @@ -272,12 +272,12 @@ int asynch_response(int operation, struct snmp_session *sp, int reqid, if (operation == NETSNMP_CALLBACK_OP_RECEIVED_MESSAGE) { if (print_result(STAT_SUCCESS, host->sess, pdu)) { -// host->current_oid++; /* send next GET (if any) */ +/* host->current_oid++; */ /* send next GET (if any) */ op = host->current_oid; op++; while(op->hostname) { -// printf("[%s] [%s]\n",op->hostname, host->current_oid->hostname); +/* printf("[%s] [%s]\n",op->hostname, host->current_oid->hostname); */ if(strcmp(op->hostname,host->current_oid->hostname)==0) { host->current_oid = op; break; @@ -297,7 +297,7 @@ int asynch_response(int operation, struct snmp_session *sp, int reqid, } else { -// printf("No more OIDs for [%s]\n", host->current_oid->hostname); +/* printf("No more OIDs for [%s]\n", host->current_oid->hostname); */ } } } @@ -324,7 +324,7 @@ void asynchronous(void) struct snmp_session sess; snmp_sess_init(&sess); /* initialize session */ sess.version = SNMP_VERSION_1; - // sess.version = SNMP_VERSION_2c; + /* sess.version = SNMP_VERSION_2c; */ sess.peername = strdup(hp->hostname); sess.community = strdup(hp->community); sess.community_len = strlen(sess.community); @@ -347,7 +347,7 @@ void asynchronous(void) printf("No OIDs for [%s]\n", hp->hostname); continue; } -// printf("Sending request [%s] [%s]\n",hp->hostname, hs->current_oid->Name); +/* printf("Sending request [%s] [%s]\n",hp->hostname, hs->current_oid->Name); */ req = snmp_pdu_create(SNMP_MSG_GET); /* send the first GET */ snmp_add_null_var(req, hs->current_oid->Oid, hs->current_oid->OidLen); if (snmp_send(hs->sess, req)) diff --git a/src/alphacode/poller/snmp_orig.c b/src/alphacode/poller/snmp_orig.c index dfd8f5a9..37e82e5f 100755 --- a/src/alphacode/poller/snmp_orig.c +++ b/src/alphacode/poller/snmp_orig.c @@ -210,7 +210,7 @@ void synchronous (void) snmp_sess_init(&ss); /* initialize session */ ss.version = SNMP_VERSION_1; -// ss.version = SNMP_VERSION_2c; +/* ss.version = SNMP_VERSION_2c; */ ss.peername = strdup(hp->name); ss.community = strdup(hp->community); ss.community_len = strlen(ss.community); @@ -289,7 +289,7 @@ void asynchronous(void) struct snmp_session sess; snmp_sess_init(&sess); /* initialize session */ sess.version = SNMP_VERSION_1; -// sess.version = SNMP_VERSION_2c; +/* sess.version = SNMP_VERSION_2c; */ sess.peername = strdup(hp->name); sess.community = strdup(hp->community); sess.community_len = strlen(sess.community); diff --git a/src/libs/zbxcommon/alias.c b/src/libs/zbxcommon/alias.c index bd7de8b0..1b4ea33a 100755 --- a/src/libs/zbxcommon/alias.c +++ b/src/libs/zbxcommon/alias.c @@ -20,17 +20,15 @@ #include "common.h" #include "alias.h" -// -// Static data -// +/* Static data */ static ALIAS *aliasList=NULL; -// -// Add alias to the list -// Returns 1 on success or 0 if alias with that name already exist -// +/* + * Add alias to the list + * Returns 1 on success or 0 if alias with that name already exist +*/ int add_alias_from_config(char *line) { char *name = NULL, @@ -108,9 +106,9 @@ void alias_list_free(void) } } -// -// Checks parameter and expands it if aliased -// +/* + * Checks parameter and expands it if aliased + */ void alias_expand(const char *orig, char *expanded, int exp_buf_len) { diff --git a/src/libs/zbxcommon/base64.c b/src/libs/zbxcommon/base64.c index e7b28dcd..526a4cae 100644 --- a/src/libs/zbxcommon/base64.c +++ b/src/libs/zbxcommon/base64.c @@ -1,6 +1,6 @@ -#include <string.h> +#include "common.h" -#define ZBX_MAX_B64_LEN 16*1024 +#define MAX_B64_LEN ZBX_MAX_B64_LEN static char base64_set [] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; @@ -189,7 +189,7 @@ void str_base64_decode(char *p_b64str, char *p_str, int *p_out_size) int in_size; char from1='A',from2='A',from3='A',from4='A'; unsigned char to1=0,to2=0,to3=0,to4=0; - char str_clean[ZBX_MAX_B64_LEN];/* str_clean is the string + char str_clean[MAX_B64_LEN];/* str_clean is the string * after removing the non-base64 * characters */ @@ -286,8 +286,8 @@ int main() "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" "0000000000000000000000000000000000000000000000000000000000000000" "11111111111111111111111111111111111111111111111111111111111111"; - char b64[ZBX_MAX_B64_LEN]; - char b64_rev[ZBX_MAX_B64_LEN]; + char b64[MAX_B64_LEN]; + char b64_rev[MAX_B64_LEN]; int i; memset(b64,0,sizeof(b64)); diff --git a/src/libs/zbxconf/cfg.c b/src/libs/zbxconf/cfg.c index c7d7628c..78cb3556 100644 --- a/src/libs/zbxconf/cfg.c +++ b/src/libs/zbxconf/cfg.c @@ -97,7 +97,7 @@ int parse_cfg_file(char *cfg_file,struct cfg_line *cfg) if(strcmp(cfg[i].parameter, parameter)) continue; - zbx_error("Accepted configuration parameter: '%s' = '%s'",parameter, value); + /* zbx_error("Accepted configuration parameter: '%s' = '%s'",parameter, value); */ if(cfg[i].function != 0) { diff --git a/src/libs/zbxlog/log.c b/src/libs/zbxlog/log.c index a5c3d7df..7c671160 100644 --- a/src/libs/zbxlog/log.c +++ b/src/libs/zbxlog/log.c @@ -151,7 +151,7 @@ void zabbix_log(int level, const char *fmt, ...) { FILE *log_file = NULL; - char message[MAX_STRING_LEN]; + char message[MAX_BUF_LEN]; time_t t; struct tm *tm; @@ -173,37 +173,7 @@ void zabbix_log(int level, const char *fmt, ...) return; } - va_start(args, fmt); - vsnprintf(message, MAX_STRING_LEN-2, fmt, args); - va_end(args); - strncat(message,"\0",MAX_STRING_LEN); - - if(LOG_TYPE_SYSLOG == log_type) - { -#if defined(WIN32) - switch(level) - { - case LOG_LEVEL_CRIT: - case LOG_LEVEL_ERR: - wType = EVENTLOG_ERROR_TYPE; - break; - case LOG_LEVEL_WARNING: - wType = EVENTLOG_WARNING_TYPE; - break; - default: - wType = EVENTLOG_INFORMATION_TYPE; - break; - } - - ReportEvent(system_log_handle, wType, 0, MSG_ZABBIX_MESSAGE, NULL, 1, 0, strings, NULL); - -#else /* not WIN32 */ - - syslog(LOG_DEBUG,message); - -#endif /* WIN32 */ - } - else if(log_type == LOG_TYPE_FILE) + if(LOG_TYPE_FILE == log_type) { zbx_mutex_lock(&log_file_access); @@ -251,6 +221,39 @@ void zabbix_log(int level, const char *fmt, ...) } zbx_mutex_unlock(&log_file_access); + + return; + } + + va_start(args, fmt); + vsnprintf(message, sizeof(message)-2, fmt, args); + va_end(args); + strncat(message,"\0",sizeof(message)); + + if(LOG_TYPE_SYSLOG == log_type) + { +#if defined(WIN32) + switch(level) + { + case LOG_LEVEL_CRIT: + case LOG_LEVEL_ERR: + wType = EVENTLOG_ERROR_TYPE; + break; + case LOG_LEVEL_WARNING: + wType = EVENTLOG_WARNING_TYPE; + break; + default: + wType = EVENTLOG_INFORMATION_TYPE; + break; + } + + ReportEvent(system_log_handle, wType, 0, MSG_ZABBIX_MESSAGE, NULL, 1, 0, strings, NULL); + +#else /* not WIN32 */ + + syslog(LOG_DEBUG,message); + +#endif /* WIN32 */ } else { @@ -277,12 +280,11 @@ void zabbix_log(int level, const char *fmt, ...) zbx_mutex_unlock(&log_file_access); } - return; } -// -// Get system error string by call to FormatMessage -// +/* + * Get system error string by call to FormatMessage + */ #define ZBX_MESSAGE_BUF_SIZE 1024 char *strerror_from_system(unsigned long error) @@ -314,9 +316,9 @@ char *strerror_from_system(unsigned long error) #endif /* WIN32 */ } -// -// Get system error string by call to FormatMessage -// +/* + * Get system error string by call to FormatMessage + */ char *strerror_from_module(unsigned long error, const char *module) { @@ -332,7 +334,7 @@ char *strerror_from_module(unsigned long error, const char *module) FORMAT_MESSAGE_FROM_HMODULE, GetModuleHandle(module), error, - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), /* Default language */ buffer, 1024, NULL) == 0) diff --git a/src/libs/zbxnix/daemon.c b/src/libs/zbxnix/daemon.c index c5137e68..7290be20 100755 --- a/src/libs/zbxnix/daemon.c +++ b/src/libs/zbxnix/daemon.c @@ -131,7 +131,7 @@ int daemon_start(int allow_root) } chdir("/"); - umask(002 /* 022 */); + umask(0002); for(i=0; i<MAXFD; i++) { diff --git a/src/libs/zbxsysinfo/common/common.c b/src/libs/zbxsysinfo/common/common.c index a8edb0a2..a9b61b1e 100644 --- a/src/libs/zbxsysinfo/common/common.c +++ b/src/libs/zbxsysinfo/common/common.c @@ -1157,7 +1157,7 @@ int EXECUTE_STR(const char *cmd, const char *param, unsigned flags, AGENT_RESULT #if defined(WIN32) - // Create temporary file to hold process output + /* Create temporary file to hold process output */ GetTempPath( MAX_PATH-1, szTempPath); GetTempFileName( szTempPath, "zbx", 0, szTempFile); @@ -1178,7 +1178,7 @@ int EXECUTE_STR(const char *cmd, const char *param, unsigned flags, AGENT_RESULT return SYSINFO_RET_FAIL; } - // Fill in process startup info structure + /* Fill in process startup info structure */ memset(&si,0,sizeof(STARTUPINFO)); si.cb = sizeof(STARTUPINFO); si.dwFlags = STARTF_USESTDHANDLES; @@ -1186,22 +1186,22 @@ int EXECUTE_STR(const char *cmd, const char *param, unsigned flags, AGENT_RESULT si.hStdOutput = hOutput; si.hStdError = GetStdHandle(STD_ERROR_HANDLE); - // Create new process + /* Create new process */ if (!CreateProcess(NULL,command,NULL,NULL,TRUE,0,NULL,NULL,&si,&pi)) { zabbix_log(LOG_LEVEL_DEBUG, "Unable to create process: '%s' [%s]", command, strerror_from_system(GetLastError())); return SYSINFO_RET_FAIL; } - // Wait for process termination and close all handles + /* Wait for process termination and close all handles */ WaitForSingleObject(pi.hProcess,INFINITE); CloseHandle(pi.hThread); CloseHandle(pi.hProcess); - // Rewind temporary file for reading + /* Rewind temporary file for reading */ SetFilePointer(hOutput,0,NULL,FILE_BEGIN); - // Read process output + /* Read process output */ ReadFile(hOutput, cmd_result, MAX_STRING_LEN-1, &len, NULL); cmd_result[len] = '\0'; @@ -1330,7 +1330,7 @@ int RUN_COMMAND(const char *cmd, const char *param, unsigned flags, AGENT_RESULT return SYSINFO_RET_FAIL; } - zabbix_log(LOG_LEVEL_WARNING, "Run command '%s'",command); + zabbix_log(LOG_LEVEL_DEBUG, "Run command '%s'",command); if(get_param(param, 2, flag, sizeof(flag)) != 0) { @@ -1360,19 +1360,19 @@ int RUN_COMMAND(const char *cmd, const char *param, unsigned flags, AGENT_RESULT GetStartupInfo(&si); - zabbix_log(LOG_LEVEL_WARNING, "Execute command '%s'",full_command); + zabbix_log(LOG_LEVEL_DEBUG, "Execute command '%s'",full_command); if(!CreateProcess( - NULL, // No module name (use command line) - full_command,// Name of app to launch - NULL, // Default process security attributes - NULL, // Default thread security attributes - FALSE, // Don't inherit handles from the parent - 0, // Normal priority - NULL, // Use the same environment as the parent - NULL, // Launch in the current directory - &si, // Startup Information - &pi)) // Process information stored upon return + NULL, /* No module name (use command line) */ + full_command,/* Name of app to launch */ + NULL, /* Default process security attributes */ + NULL, /* Default thread security attributes */ + FALSE, /* Don't inherit handles from the parent */ + 0, /* Normal priority */ + NULL, /* Use the same environment as the parent */ + NULL, /* Launch in the current directory */ + &si, /* Startup Information */ + &pi)) /* Process information stored upon return */ { return SYSINFO_RET_FAIL; } diff --git a/src/libs/zbxsysinfo/solaris/swap.c b/src/libs/zbxsysinfo/solaris/swap.c index 6085507f..a1045e40 100644 --- a/src/libs/zbxsysinfo/solaris/swap.c +++ b/src/libs/zbxsysinfo/solaris/swap.c @@ -243,22 +243,22 @@ int get_swap_io(double *swapin, double *pgswapin, double *swapout, double *pgswa cpu = (cpu_stat_t*) k->ks_data; if(swapin) { - /* uint_t swapin; // swapins */ + /* uint_t swapin; */ /* swapins */ (*swapin) += (double) cpu->cpu_vminfo.swapin; } if(pgswapin) { - /* uint_t pgswapin; // pages swapped in */ + /* uint_t pgswapin; */ /* pages swapped in */ (*pgswapin) += (double) cpu->cpu_vminfo.pgswapin; } if(swapout) { - /* uint_t swapout; // swapout */ + /* uint_t swapout; */ /* swapout */ (*swapout) += (double) cpu->cpu_vminfo.swapout; } if(pgswapout) { - /* uint_t pgswapout; // pages swapped out */ + /* uint_t pgswapout; */ /* pages swapped out */ (*pgswapout) += (double) cpu->cpu_vminfo.pgswapout; } cpu_count += 1; diff --git a/src/libs/zbxsysinfo/win32/system_w32.c b/src/libs/zbxsysinfo/win32/system_w32.c index 8d5fdb02..d2b9aa06 100755 --- a/src/libs/zbxsysinfo/win32/system_w32.c +++ b/src/libs/zbxsysinfo/win32/system_w32.c @@ -77,7 +77,7 @@ int SYSTEM_UNAME(const char *cmd, const char *param, unsigned flags, AGENT_R versionInfo.szCSDVersion ); } - else // Windows 2000, Windows XP or Windows Server 2003 + else /* Windows 2000, Windows XP or Windows Server 2003 */ { zbx_snprintf( osVersion, diff --git a/src/libs/zbxwin32/perfmon.c b/src/libs/zbxwin32/perfmon.c index 0a4e4636..63c066bb 100755 --- a/src/libs/zbxwin32/perfmon.c +++ b/src/libs/zbxwin32/perfmon.c @@ -27,9 +27,9 @@ PERFCOUNTER *PerfCounterList = NULL; -// -// Get performance counter name by index -// +/* + * Get performance counter name by index + */ char *GetCounterName(DWORD index) { diff --git a/src/libs/zbxwin32/service.c b/src/libs/zbxwin32/service.c index 6097c4b7..887c8922 100755 --- a/src/libs/zbxwin32/service.c +++ b/src/libs/zbxwin32/service.c @@ -32,18 +32,18 @@ static int ZabbixRemoveEventSource(void); static int ZabbixInstallEventSource(char *path); -// -// Static data -// +/* + * Static data + */ static SERVICE_STATUS serviceStatus; static SERVICE_STATUS_HANDLE serviceHandle; int application_is_runned = ZBX_APP_RUNNED; -// -// ZABBIX service control handler -// +/* + * ZABBIX service control handler + */ static VOID WINAPI ServiceCtrlHandler(DWORD ctrlCode) { @@ -82,9 +82,9 @@ static VOID WINAPI ServiceCtrlHandler(DWORD ctrlCode) SetServiceStatus(serviceHandle, &serviceStatus); } -// -// The entry point for a ZABBIX service. -// +/* + * The entry point for a ZABBIX service. + */ static VOID WINAPI ServiceEntry(DWORD argc,LPTSTR *argv) { @@ -93,7 +93,7 @@ static VOID WINAPI ServiceEntry(DWORD argc,LPTSTR *argv) serviceHandle = RegisterServiceCtrlHandler(ZABBIX_SERVICE_NAME, ServiceCtrlHandler); - // Now we start service initialization + /* Now we start service initialization */ serviceStatus.dwServiceType = SERVICE_WIN32_OWN_PROCESS; serviceStatus.dwCurrentState = SERVICE_START_PENDING; serviceStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN; @@ -104,14 +104,14 @@ static VOID WINAPI ServiceEntry(DWORD argc,LPTSTR *argv) SetServiceStatus(serviceHandle, &serviceStatus); - // Initialize Windows Sockets API + /* Initialize Windows Sockets API */ WSAStartup(0x0002,&sockInfo); - // Internal command aliases + /* Internal command aliases */ zbx_snprintf(counterPath, sizeof(counterPath), "perf_counter[\\%s\\%s]",GetCounterName(PCI_SYSTEM),GetCounterName(PCI_SYSTEM_UP_TIME)); add_alias("system.uptime",counterPath); - // Now service is running + /* Now service is running */ serviceStatus.dwCurrentState = SERVICE_RUNNING; serviceStatus.dwWaitHint = 0; SetServiceStatus(serviceHandle, &serviceStatus); @@ -120,9 +120,9 @@ static VOID WINAPI ServiceEntry(DWORD argc,LPTSTR *argv) } -// -// Initialize service -// +/* + * Initialize service + */ void service_start(void) { @@ -134,7 +134,7 @@ void service_start(void) WSADATA sockInfo; - // Initialize Windows Sockets API + /* Initialize Windows Sockets APIa */ switch(WSAStartup(0x0002,&sockInfo)) { case WSASYSNOTREADY: @@ -154,8 +154,8 @@ void service_start(void) return; } - // Create synchronization stuff -// eventShutdown = CreateEvent(NULL,TRUE,FALSE,NULL); + /* Create synchronization stuff */ +/* eventShutdown = CreateEvent(NULL,TRUE,FALSE,NULL); */ if (!StartServiceCtrlDispatcher(serviceTable)) { @@ -171,13 +171,13 @@ void service_start(void) } -// CloseHandle(eventShutdown); +/* CloseHandle(eventShutdown); */ } -// -// Create service -// +/* + * Create service + */ int ZabbixCreateService(char *path) { @@ -248,9 +248,9 @@ int ZabbixCreateService(char *path) } -// -// Remove service -// +/* + * Remove service + */ int ZabbixRemoveService(void) { @@ -296,9 +296,9 @@ int ZabbixRemoveService(void) } -// -// Start service -// +/* + * Start service + */ int ZabbixStartService(void) { @@ -340,9 +340,9 @@ int ZabbixStartService(void) } -// -// Stop service -// +/* + * Stop service + */ int ZabbixStopService(void) { @@ -384,9 +384,9 @@ int ZabbixStopService(void) } -// -// Install event source -// +/* + * Install event source + */ static int ZabbixInstallEventSource(char *path) { HKEY hKey; @@ -419,9 +419,9 @@ static int ZabbixInstallEventSource(char *path) } -// -// Remove event source -// +/* + * Remove event source + */ static int ZabbixRemoveEventSource(void) { diff --git a/src/zabbix_agent/active.c b/src/zabbix_agent/active.c index 02b0334c..e838e41f 100644 --- a/src/zabbix_agent/active.c +++ b/src/zabbix_agent/active.c @@ -112,11 +112,11 @@ static int get_min_nextcheck() return min; } -static void add_check(char *key, int refresh, int lastlogsize) +static void add_check(char *key, int refresh, long lastlogsize) { int i; - zabbix_log( LOG_LEVEL_DEBUG, "In add_check('%s', %i, %i)", key, refresh, lastlogsize); + zabbix_log( LOG_LEVEL_DEBUG, "In add_check('%s', %i, %li)", key, refresh, lastlogsize); for(i=0; NULL != active_metrics[i].key; i++) { @@ -315,11 +315,11 @@ static int get_active_checks(char *server, unsigned short port, char *error, int zabbix_log(LOG_LEVEL_DEBUG, "Before read"); amount_read = 0; - memset(buf, 0, MAX_BUF_LEN); + memset(buf, 0, sizeof(buf)); do { - len = zbx_sock_read(s, buf + amount_read, (MAX_BUF_LEN-1) - amount_read, CONFIG_TIMEOUT); + len = zbx_sock_read(s, buf + amount_read, (sizeof(buf)-1) - amount_read, CONFIG_TIMEOUT); if(SOCKET_ERROR == len) { @@ -357,7 +357,7 @@ static int send_value(char *server,unsigned short port,char *host, char *key,cha ZBX_SOCKADDR myaddr_in; ZBX_SOCKADDR servaddr_in; - char buf[MAX_STRING_LEN]; + char buf[MAX_BUF_LEN]; int len; struct hostent *hp; @@ -409,9 +409,9 @@ static int send_value(char *server,unsigned short port,char *host, char *key,cha return FAIL; } - memset(buf, 0, MAX_STRING_LEN); + memset(buf, 0, sizeof(buf)); - if(SOCKET_ERROR == (len = zbx_sock_read(s, buf, MAX_STRING_LEN-1, CONFIG_TIMEOUT))) + if(SOCKET_ERROR == (len = zbx_sock_read(s, buf, sizeof(buf)-1, CONFIG_TIMEOUT))) { zabbix_log( LOG_LEVEL_WARNING, "Error in recvfrom() [%s:%u] [%s]",server, port, strerror(errno)); zbx_sock_close(s); @@ -468,7 +468,7 @@ static int process_active_checks(char *server, unsigned short port) count = 0; while(process_log(filename,&active_metrics[i].lastlogsize,value) == 0) { - zbx_snprintf(lastlogsize, sizeof(lastlogsize), "%d", active_metrics[i].lastlogsize); + zbx_snprintf(lastlogsize, sizeof(lastlogsize), "%li", active_metrics[i].lastlogsize); if(send_value(server,port,CONFIG_HOSTNAME,active_metrics[i].key,value,lastlogsize) == FAIL) { diff --git a/src/zabbix_agent/active.h b/src/zabbix_agent/active.h index 669c6bc5..ab4dfe63 100644 --- a/src/zabbix_agent/active.h +++ b/src/zabbix_agent/active.h @@ -34,7 +34,6 @@ typedef struct zbx_active_metric_type int nextcheck; int status; /* Must be long for fseek() */ -/* int lastlogsize;*/ long lastlogsize; } ZBX_ACTIVE_METRIC; diff --git a/src/zabbix_agent/cpustat.c b/src/zabbix_agent/cpustat.c index d27b7281..02ea93c2 100644 --- a/src/zabbix_agent/cpustat.c +++ b/src/zabbix_agent/cpustat.c @@ -128,7 +128,7 @@ int init_cpu_collector(ZBX_CPUS_STAT_DATA *pcpus) zbx_snprintf(counter_path, sizeof(counter_path), "\\%s\\%s", GetCounterName(PCI_SYSTEM), GetCounterName(PCI_PROCESSOR_QUEUE_LENGTH)); - // Prepare for CPU execution queue usage collection + /* Prepare for CPU execution queue usage collection */ if (ERROR_SUCCESS != (status = PdhAddCounter(pcpus->pdh_query, counter_path, 0, &pcpus->queue_counter))) { zabbix_log( LOG_LEVEL_ERR, "Unable to add performance counter \"%s\" to query: %s", strerror_from_module(status,"PDH.DLL")); @@ -214,7 +214,7 @@ void collect_cpustat(ZBX_CPUS_STAT_DATA *pcpus) return; } - // Process CPU utilization data + /* Process CPU utilization data */ for(i=0; i <= pcpus->count; i++) { if(!pcpus->cpu[i].usage_couter) @@ -235,7 +235,7 @@ void collect_cpustat(ZBX_CPUS_STAT_DATA *pcpus) pcpus->cpu[i].h_usage[pcpus->cpu[i].h_usage_index] = value.longValue; pcpus->cpu[i].usage_old = pcpus->cpu[i].usage; - // Calculate average cpu usage + /* Calculate average cpu usage */ for(n = pcpus->cpu[i].h_usage_index, j = 0, sum = 0; j < MAX_CPU_HISTORY; j++, n--) { if(n < 0) n = MAX_CPU_HISTORY - 1; @@ -263,7 +263,7 @@ void collect_cpustat(ZBX_CPUS_STAT_DATA *pcpus) if(pcpus->queue_counter) { - // Process CPU queue length data + /* Process CPU queue length data */ PdhGetRawCounterValue( pcpus->queue_counter, NULL, @@ -278,7 +278,7 @@ void collect_cpustat(ZBX_CPUS_STAT_DATA *pcpus) pcpus->h_queue[pcpus->h_queue_index] = value.longValue; - // Calculate average cpu usage + /* Calculate average cpu usage */ for(n = pcpus->h_queue_index, j = 0, sum = 0; j < MAX_CPU_HISTORY; j++, n--) { if(n < 0) n = MAX_CPU_HISTORY - 1; diff --git a/src/zabbix_agent/logfiles.c b/src/zabbix_agent/logfiles.c index bc248300..df777344 100644 --- a/src/zabbix_agent/logfiles.c +++ b/src/zabbix_agent/logfiles.c @@ -31,7 +31,7 @@ int process_log(char *filename,long *lastlogsize, char *value) assert(lastlogsize); assert(value); - zabbix_log( LOG_LEVEL_DEBUG, "In process log (%s,%d)", filename, *lastlogsize); + zabbix_log( LOG_LEVEL_DEBUG, "In process log (%s,%li)", filename, *lastlogsize); /* Handling of file shrinking */ if(stat(filename,&buf) == 0) @@ -57,7 +57,7 @@ int process_log(char *filename,long *lastlogsize, char *value) if(-1 == fseek(f,*lastlogsize,SEEK_SET)) { - zabbix_log( LOG_LEVEL_WARNING, "Cannot set postition to [%d] for [%s] [%s]", *lastlogsize, filename, strerror(errno)); + zabbix_log( LOG_LEVEL_WARNING, "Cannot set postition to [%li] for [%s] [%s]", *lastlogsize, filename, strerror(errno)); zbx_snprintf(value,sizeof(value),"%s","ZBX_NOTSUPPORTED\n"); zbx_fclose(f); return 1; diff --git a/src/zabbix_agent/zabbix_agent.c b/src/zabbix_agent/zabbix_agent.c index 642ae2a9..88434ed0 100644 --- a/src/zabbix_agent/zabbix_agent.c +++ b/src/zabbix_agent/zabbix_agent.c @@ -159,7 +159,7 @@ int main(int argc, char **argv) break; } - init_metrics(); // Must be before init_config() + init_metrics(); /* Must be before init_config() */ load_config(1); diff --git a/src/zabbix_agent/zabbix_agentd.c b/src/zabbix_agent/zabbix_agentd.c index 1367127c..9ac50379 100644 --- a/src/zabbix_agent/zabbix_agentd.c +++ b/src/zabbix_agent/zabbix_agentd.c @@ -204,21 +204,31 @@ static ZBX_SOCKET connect_to_server(void) { ZBX_SOCKET sock; ZBX_SOCKADDR serv_addr; + int on; if ((sock = socket(AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET) { zabbix_log( LOG_LEVEL_CRIT, "Unable to create socket. [%s]", strerror_from_system(zbx_sock_last_error())); exit(1); } + + /* Enable address reuse */ + /* This is to immediately use the address even if it is in TIME_WAIT state */ + /* http://www-128.ibm.com/developerworks/linux/library/l-sockpit/index.html */ + on = 1; + if( -1 == setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on) )) + { + zabbix_log(LOG_LEVEL_WARNING, "Cannot setsockopt SO_REUSEADDR [%s]", strerror(errno)); + } - // Create socket // Fill in local address structure + /* Create socket Fill in local address structure */ memset(&serv_addr, 0, sizeof(ZBX_SOCKADDR)); serv_addr.sin_family = AF_INET; serv_addr.sin_addr.s_addr = CONFIG_LISTEN_IP ? inet_addr(CONFIG_LISTEN_IP) : htonl(INADDR_ANY); serv_addr.sin_port = htons((unsigned short)CONFIG_LISTEN_PORT); - // Bind socket + /* Bind socket */ if (bind(sock,(struct sockaddr *)&serv_addr,sizeof(ZBX_SOCKADDR)) == SOCKET_ERROR) { zabbix_log(LOG_LEVEL_CRIT, "Cannot bind to port %u for server %s. Error [%s]. Another zabbix_agentd already running ?", @@ -369,7 +379,7 @@ int main(int argc, char **argv) task = parse_commandline(argc, argv); - init_metrics(); // Must be before load_config(). load_config - use metrics!!! + init_metrics(); /* Must be before load_config(). load_config - use metrics!!! */ load_config(task == 0); @@ -441,7 +451,7 @@ int main() printf("Pattern:\t %s\n", p); printf("Result: \t [%s] [%d]\n", zbx_regexp_match(s, p, &len), len); /* -#elif 1 // 0 - off; 1 - on; +#elif 1 /* 0 - off; 1 - on; */ Place your test code HERE!!! diff --git a/src/zabbix_server/Makefile.am b/src/zabbix_server/Makefile.am index 8c168160..0399322e 100644 --- a/src/zabbix_server/Makefile.am +++ b/src/zabbix_server/Makefile.am @@ -10,4 +10,4 @@ zabbix_server_LDADD = ../libs/zbxsysinfo/libzbxsysinfo.a ../libs/zbxsysinfo/@ARC alerter/libzbxalerter.a timer/libzbxtimer.a trapper/libzbxtrapper.a ../libs/zbxemail/libzbxemail.a \ ../libs/zbxsms/libzbxsms.a ../libs/zbxdbhigh/libzbxdbhigh.a ../libs/zbxcommon/libzbxcommon.a \ ../libs/zbxcrypto/libzbxcrypto.a @MYSQL_LIBS@ @PGSQL_LIBS@ @ORACLE_LIBS@ @LDAP_LIBS@ @SNMP_LIBS@ -zabbix_server_LDFLAGS=@MYSQL_LFLAGS@ @PGSQL_LFLAGS@ @ORACLE_LFLAGS@ @LDAP_LFLAGS@ @SNMP_LFLAGS@ -DZABBIX_DEAMON +zabbix_server_LDFLAGS=@MYSQL_LFLAGS@ @PGSQL_LFLAGS@ @ORACLE_LFLAGS@ @LDAP_LFLAGS@ @SNMP_LFLAGS@ diff --git a/src/zabbix_server/actions.c b/src/zabbix_server/actions.c index 5f1be76e..4cfbb3d9 100644 --- a/src/zabbix_server/actions.c +++ b/src/zabbix_server/actions.c @@ -401,7 +401,7 @@ static int get_next_command(char** command_list, char** alias, int* is_group, ch { run_remote_command(alias, command); } -// DBadd_alert(action->actionid,trigger->triggerid, userid, media.mediatypeid,media.sendto,action->subject,action->scripts, action->maxrepeats, action->repeatdelay); // TODO !!! Add alert for remote commands !!! +/* DBadd_alert(action->actionid,trigger->triggerid, userid, media.mediatypeid,media.sendto,action->subject,action->scripts, action->maxrepeats, action->repeatdelay); */ /* TODO !!! Add alert for remote commands !!! */ } zabbix_log( LOG_LEVEL_DEBUG, "Run remote commands END"); } diff --git a/src/zabbix_server/trapper/trapper.c b/src/zabbix_server/trapper/trapper.c index d0755c61..dd695ecf 100644 --- a/src/zabbix_server/trapper/trapper.c +++ b/src/zabbix_server/trapper/trapper.c @@ -182,7 +182,7 @@ void process_trapper_child(int sockfd) zabbix_log( LOG_LEVEL_DEBUG, "Before read(%d)", MAX_BUF_LEN); /* if( (nbytes = read(sockfd, line, MAX_BUF_LEN)) < 0)*/ - memset(buffer,0,MAX_BUF_LEN); + memset(buffer,0,sizeof(buffer)); bufptr = buffer; while ((nbytes = read(sockfd, bufptr, buffer + sizeof(buffer) - bufptr - 1)) != -1 && nbytes != 0) { @@ -213,7 +213,7 @@ void process_trapper_child(int sockfd) zabbix_log( LOG_LEVEL_DEBUG, "Got data:%s", buffer); - process_trap(sockfd,buffer, MAX_BUF_LEN); + process_trap(sockfd,buffer, sizeof(buffer)); alarm(0); } |