XMLWordPrintable

    Details

    • Team:
      Team C
    • Sprint:
      Sprint 6, Sprint 7
    • Story Points:
      0.5

      Description

      Zabbix sender no longer works

      ./bin/zabbix_sender -z 127.0.0.1 -p 10052 -s "test server" -k "trap1" -o 0
      zabbix_sender [13456]: cannot open log: unknown log type
      

      Broken by ZBXNEXT-3687

      Sender opens log like this

      	if (SUCCEED != zabbix_open_log(LOG_TYPE_UNDEFINED, CONFIG_LOG_LEVEL, NULL, &error))
      	{
      		zbx_error("cannot open log: %s", error);
      		zbx_free(error);
      		exit(EXIT_FAILURE);
      	}
      

      But this is no longer allowed. since -r65196:67106

      -int	zabbix_open_log(int type, int level, const char *filename)
      +int	zabbix_open_log(int type, int level, const char *filename, char **error)
       {
      -	FILE	*log_file = NULL;
      -#ifdef _WINDOWS
      -	wchar_t	*wevent_source;
      -#endif
       	log_type = type;
       	log_level = level;
       
      @@ -281,6 +274,8 @@
       	if (LOG_TYPE_SYSTEM == type)
       	{
       #ifdef _WINDOWS
      +		wchar_t	*wevent_source;
      +
       		wevent_source = zbx_utf8_to_unicode(ZABBIX_EVENT_SOURCE);
       		system_log_handle = RegisterEventSource(NULL, wevent_source);
       		zbx_free(wevent_source);
      @@ -290,22 +285,21 @@
       	}
       	else if (LOG_TYPE_FILE == type)
       	{
      +		FILE	*log_file = NULL;
      +
       		if (MAX_STRING_LEN <= strlen(filename))
       		{
      -			zbx_error("too long path for logfile");
      -			exit(EXIT_FAILURE);
      +			*error = zbx_strdup(*error, "too long path for logfile");
      +			return FAIL;
       		}
       
      -		if (FAIL == zbx_mutex_create_force(&log_access, ZBX_MUTEX_LOG))
      -		{
      -			zbx_error("unable to create mutex for log file");
      -			exit(EXIT_FAILURE);
      -		}
      +		if (SUCCEED != zbx_mutex_create(&log_access, ZBX_MUTEX_LOG, error))
      +			return FAIL;
       
       		if (NULL == (log_file = fopen(filename, "a+")))
       		{
      -			zbx_error("unable to open log file [%s]: %s", filename, zbx_strerror(errno));
      -			exit(EXIT_FAILURE);
      +			*error = zbx_dsprintf(*error, "unable to open log file [%s]: %s", filename, zbx_strerror(errno));
      +			return FAIL;
       		}
       
       		strscpy(log_filename, filename);
      @@ -313,10 +307,10 @@
       	}
       	else if (LOG_TYPE_CONSOLE == type)
       	{
      -		if (FAIL == zbx_mutex_create_force(&log_access, ZBX_MUTEX_LOG))
      +		if (SUCCEED != zbx_mutex_create(&log_access, ZBX_MUTEX_LOG, error))
       		{
      -			zbx_error("unable to create mutex for standard output");
      -			exit(EXIT_FAILURE);
      +			*error = zbx_strdup(*error, "unable to create mutex for standard output");
      +			return FAIL;
       		}
       
       		fflush(stderr);
      @@ -323,6 +317,11 @@
       		if (-1 == dup2(STDOUT_FILENO, STDERR_FILENO))
       			zbx_error("cannot redirect stderr to stdout: %s", zbx_strerror(errno));
       	}
      +	else
      +	{
      +		*error = zbx_strdup(*error, "unknown log type");
      +		return FAIL;
      +	}
       
       	return SUCCEED;
       }
      @@ -344,11 +343,6 @@
       	}
       }
      
      

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            vso Vladislavs Sokurenko
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: