zabbix-agent2/src/libs/zbxserver/evalfunc.c
/******************************************************************************
 *                                                                            *
 * Function: add_value_suffix                                                 *
 *                                                                            *
 * Purpose: Add suffix for value                                              *
 *                                                                            *
 * Parameters: value - value for replacing                                    *
 *                                                                            *
 * Return value: SUCCEED - suffix added successfully, value contains new value*
 *               FAIL - adding failed, value contains old value               *
 *                                                                            *
 ******************************************************************************/
add_value_suffix

Purpose: Add suffix for value

Parameters: value - value for replacing

Return value: SUCCEED - suffix added successfully, value contains new value
FAIL - adding failed, value contains old value
add_value_suffix Purpose : Add suffix for value Parameters : value - value for replacing Return value : SUCCEED - suffix added successfully value contains new value FAIL - adding failed value contains old value
static void	add_value_suffix(char *value, size_t max_len, const char *units, unsigned char value_type)
{
	struct tm	*local_time;
	time_t		time;
	zabbix_log(LOG_LEVEL_DEBUG, "In %s() value:'%s' units:'%s' value_type:%d",
			__func__, value, units, (int)value_type);
	switch (value_type)
	{
		case ITEM_VALUE_TYPE_UINT64:
			if (0 == strcmp(units, "unixtime"))
			{
				time = (time_t)atoi(value);
				local_time = localtime(&time);
				strftime(value, max_len, "%Y.%m.%d %H:%M:%S", local_time);
				break;
			}
			ZBX_FALLTHROUGH;
		case ITEM_VALUE_TYPE_FLOAT:
			if (0 == strcmp(units, "s"))
				add_value_suffix_s(value, max_len);
			else if (0 == strcmp(units, "uptime"))
				add_value_suffix_uptime(value, max_len);
			else if ('!' == *units)
				add_value_units_no_kmgt(value, max_len, (const char *)(units + 1));
			else if (SUCCEED == is_blacklisted_unit(units))
				add_value_units_no_kmgt(value, max_len, units);
			else if ('\0' != *units)
				add_value_units_with_kmgt(value, max_len, units);
			break;
		default:
			;
	}
	zabbix_log(LOG_LEVEL_DEBUG, "End of %s() value:'%s'", __func__, value);
}
static void add_value_suffix ( char * value , size_t max_len , const char * units , unsigned char value_type ) { struct tm * local_time ; time_t time ; zabbix_log ( LOG_LEVEL_DEBUG , " " , __func__ , value , units , ( int ) value_type ) ; switch ( value_type ) { case ITEM_VALUE_TYPE_UINT64 : if ( 0 == strcmp ( units , " " ) ) { time = ( time_t ) atoi ( value ) ; local_time = localtime ( & time ) ; strftime ( value , max_len , " " , local_time ) ; break ; } ZBX_FALLTHROUGH ; case ITEM_VALUE_TYPE_FLOAT : if ( 0 == strcmp ( units , " " ) ) add_value_suffix_s ( value , max_len ) ; else if ( 0 == strcmp ( units , " " ) ) add_value_suffix_uptime ( value , max_len ) ; else if ( ' ' == * units ) add_value_units_no_kmgt ( value , max_len , ( const char * ) ( units + 1 ) ) ; else if ( SUCCEED == is_blacklisted_unit ( units ) ) add_value_units_no_kmgt ( value , max_len , units ) ; else if ( ' \0 ' != * units ) add_value_units_with_kmgt ( value , max_len , units ) ; break ; default : ; } zabbix_log ( LOG_LEVEL_DEBUG , " " , __func__ , value ) ; }
Function: add_value_suffix                                                 
                                                                            
 Purpose: Add suffix for value                                              
                                                                            
 Parameters: value - value for replacing                                    
                                                                            
 Return value: SUCCEED - suffix added successfully, value contains new value
               FAIL - adding failed, value contains old value
Function : add_value_suffix Purpose : Add suffix for value Parameters : value - value for replacing Return value : SUCCEED - suffix added successfully value contains new value FAIL - adding failed value contains old value