zabbix-agent2/src/zabbix_server/server.c
/******************************************************************************
 *                                                                            *
 * Function: zbx_validate_config                                              *
 *                                                                            *
 * Purpose: validate configuration parameters                                 *
 *                                                                            *
 * Author: Vladimir Levijev                                                   *
 *                                                                            *
 ******************************************************************************/
zbx_validate_config

Purpose: validate configuration parameters

Author: Vladimir Levijev
zbx_validate_config Purpose : validate configuration parameters Author : Vladimir Levijev
static void	zbx_validate_config(ZBX_TASK_EX *task)
{
	char		*ch_error, *address = NULL;
	int		err = 0;
	unsigned short	port;
	if (0 == CONFIG_UNREACHABLE_POLLER_FORKS && 0 != CONFIG_POLLER_FORKS + CONFIG_JAVAPOLLER_FORKS)
	{
		zabbix_log(LOG_LEVEL_CRIT, "\"StartPollersUnreachable\" configuration parameter must not be 0"
				" if regular or Java pollers are started");
		err = 1;
	}
	if ((NULL == CONFIG_JAVA_GATEWAY || '\0' == *CONFIG_JAVA_GATEWAY) && 0 < CONFIG_JAVAPOLLER_FORKS)
	{
		zabbix_log(LOG_LEVEL_CRIT, "\"JavaGateway\" configuration parameter is not specified or empty");
		err = 1;
	}
	if (0 != CONFIG_VALUE_CACHE_SIZE && 128 * ZBX_KIBIBYTE > CONFIG_VALUE_CACHE_SIZE)
	{
		zabbix_log(LOG_LEVEL_CRIT, "\"ValueCacheSize\" configuration parameter must be either 0"
				" or greater than 128KB");
		err = 1;
	}
	if (0 != CONFIG_TREND_FUNC_CACHE_SIZE && 128 * ZBX_KIBIBYTE > CONFIG_TREND_FUNC_CACHE_SIZE)
	{
		zabbix_log(LOG_LEVEL_CRIT, "\"TrendFunctionCacheSize\" configuration parameter must be either 0"
				" or greater than 128KB");
		err = 1;
	}
	if (NULL != CONFIG_SOURCE_IP && SUCCEED != is_supported_ip(CONFIG_SOURCE_IP))
	{
		zabbix_log(LOG_LEVEL_CRIT, "invalid \"SourceIP\" configuration parameter: '%s'", CONFIG_SOURCE_IP);
		err = 1;
	}
	if (NULL != CONFIG_STATS_ALLOWED_IP && FAIL == zbx_validate_peer_list(CONFIG_STATS_ALLOWED_IP, &ch_error))
	{
		zabbix_log(LOG_LEVEL_CRIT, "invalid entry in \"StatsAllowedIP\" configuration parameter: %s", ch_error);
		zbx_free(ch_error);
		err = 1;
	}
	if (SUCCEED != zbx_validate_export_type(CONFIG_EXPORT_TYPE, NULL))
	{
		zabbix_log(LOG_LEVEL_CRIT, "invalid \"ExportType\" configuration parameter: %s", CONFIG_EXPORT_TYPE);
		err = 1;
	}
	if (FAIL == parse_serveractive_element(CONFIG_NODE_ADDRESS, &address, &port, 10051) ||
			(FAIL == is_supported_ip(address) && FAIL == zbx_validate_hostname(address)))
	{
		zabbix_log(LOG_LEVEL_CRIT, "invalid \"NodeAddress\" configuration parameter: address \"%s\""
				" is invalid", CONFIG_NODE_ADDRESS);
		err = 1;
	}
	zbx_free(address);
#if !defined(HAVE_IPV6)
	err |= (FAIL == check_cfg_feature_str("Fping6Location", CONFIG_FPING6_LOCATION, "IPv6 support"));
#endif
#if !defined(HAVE_LIBCURL)
	err |= (FAIL == check_cfg_feature_str("SSLCALocation", CONFIG_SSL_CA_LOCATION, "cURL library"));
	err |= (FAIL == check_cfg_feature_str("SSLCertLocation", CONFIG_SSL_CERT_LOCATION, "cURL library"));
	err |= (FAIL == check_cfg_feature_str("SSLKeyLocation", CONFIG_SSL_KEY_LOCATION, "cURL library"));
	err |= (FAIL == check_cfg_feature_str("HistoryStorageURL", CONFIG_HISTORY_STORAGE_URL, "cURL library"));
	err |= (FAIL == check_cfg_feature_str("HistoryStorageTypes", CONFIG_HISTORY_STORAGE_OPTS, "cURL library"));
	err |= (FAIL == check_cfg_feature_int("HistoryStorageDateIndex", CONFIG_HISTORY_STORAGE_PIPELINES,
			"cURL library"));
	err |= (FAIL == check_cfg_feature_str("VaultToken", CONFIG_VAULTTOKEN, "cURL library"));
	err |= (FAIL == check_cfg_feature_str("VaultDBPath", CONFIG_VAULTDBPATH, "cURL library"));
	err |= (FAIL == check_cfg_feature_int("StartReportWriters", CONFIG_REPORTWRITER_FORKS, "cURL library"));
#endif
#if !defined(HAVE_LIBXML2) || !defined(HAVE_LIBCURL)
	err |= (FAIL == check_cfg_feature_int("StartVMwareCollectors", CONFIG_VMWARE_FORKS, "VMware support"));
#endif
	if (SUCCEED != zbx_validate_log_parameters(task))
		err = 1;
#if !(defined(HAVE_GNUTLS) || defined(HAVE_OPENSSL))
	err |= (FAIL == check_cfg_feature_str("TLSCAFile", CONFIG_TLS_CA_FILE, "TLS support"));
	err |= (FAIL == check_cfg_feature_str("TLSCRLFile", CONFIG_TLS_CRL_FILE, "TLS support"));
	err |= (FAIL == check_cfg_feature_str("TLSCertFile", CONFIG_TLS_CERT_FILE, "TLS support"));
	err |= (FAIL == check_cfg_feature_str("TLSKeyFile", CONFIG_TLS_KEY_FILE, "TLS support"));
#endif
#if !(defined(HAVE_GNUTLS) || defined(HAVE_OPENSSL))
	err |= (FAIL == check_cfg_feature_str("TLSCipherCert", CONFIG_TLS_CIPHER_CERT, "GnuTLS or OpenSSL"));
	err |= (FAIL == check_cfg_feature_str("TLSCipherPSK", CONFIG_TLS_CIPHER_PSK, "GnuTLS or OpenSSL"));
	err |= (FAIL == check_cfg_feature_str("TLSCipherAll", CONFIG_TLS_CIPHER_ALL, "GnuTLS or OpenSSL"));
#endif
#if !defined(HAVE_OPENSSL)
	err |= (FAIL == check_cfg_feature_str("TLSCipherCert13", CONFIG_TLS_CIPHER_CERT13, "OpenSSL 1.1.1 or newer"));
	err |= (FAIL == check_cfg_feature_str("TLSCipherPSK13", CONFIG_TLS_CIPHER_PSK13, "OpenSSL 1.1.1 or newer"));
	err |= (FAIL == check_cfg_feature_str("TLSCipherAll13", CONFIG_TLS_CIPHER_ALL13, "OpenSSL 1.1.1 or newer"));
#endif
#if !defined(HAVE_OPENIPMI)
	err |= (FAIL == check_cfg_feature_int("StartIPMIPollers", CONFIG_IPMIPOLLER_FORKS, "IPMI support"));
#endif
	err |= (FAIL == zbx_db_validate_config_features());
	if (0 != CONFIG_REPORTWRITER_FORKS && NULL == CONFIG_WEBSERVICE_URL)
	{
		zabbix_log(LOG_LEVEL_CRIT, "\"WebServiceURL\" configuration parameter must be set when "
				" setting \"StartReportWriters\" configuration parameter");
	}
	if (0 != err)
		exit(EXIT_FAILURE);
}
static void zbx_validate_config ( ZBX_TASK_EX * task ) { char * ch_error , * address = NULL ; int err = 0 ; unsigned short port ; if ( 0 == CONFIG_UNREACHABLE_POLLER_FORKS && 0 != CONFIG_POLLER_FORKS + CONFIG_JAVAPOLLER_FORKS ) { zabbix_log ( LOG_LEVEL_CRIT , " \" \" " " " ) ; err = 1 ; } if ( ( NULL == CONFIG_JAVA_GATEWAY || ' \0 ' == * CONFIG_JAVA_GATEWAY ) && 0 < CONFIG_JAVAPOLLER_FORKS ) { zabbix_log ( LOG_LEVEL_CRIT , " \" \" " ) ; err = 1 ; } if ( 0 != CONFIG_VALUE_CACHE_SIZE && 128 * ZBX_KIBIBYTE > CONFIG_VALUE_CACHE_SIZE ) { zabbix_log ( LOG_LEVEL_CRIT , " \" \" " " " ) ; err = 1 ; } if ( 0 != CONFIG_TREND_FUNC_CACHE_SIZE && 128 * ZBX_KIBIBYTE > CONFIG_TREND_FUNC_CACHE_SIZE ) { zabbix_log ( LOG_LEVEL_CRIT , " \" \" " " " ) ; err = 1 ; } if ( NULL != CONFIG_SOURCE_IP && SUCCEED != is_supported_ip ( CONFIG_SOURCE_IP ) ) { zabbix_log ( LOG_LEVEL_CRIT , " \" \" " , CONFIG_SOURCE_IP ) ; err = 1 ; } if ( NULL != CONFIG_STATS_ALLOWED_IP && FAIL == zbx_validate_peer_list ( CONFIG_STATS_ALLOWED_IP , & ch_error ) ) { zabbix_log ( LOG_LEVEL_CRIT , " \" \" " , ch_error ) ; zbx_free ( ch_error ) ; err = 1 ; } if ( SUCCEED != zbx_validate_export_type ( CONFIG_EXPORT_TYPE , NULL ) ) { zabbix_log ( LOG_LEVEL_CRIT , " \" \" " , CONFIG_EXPORT_TYPE ) ; err = 1 ; } if ( FAIL == parse_serveractive_element ( CONFIG_NODE_ADDRESS , & address , & port , 10051 ) || ( FAIL == is_supported_ip ( address ) && FAIL == zbx_validate_hostname ( address ) ) ) { zabbix_log ( LOG_LEVEL_CRIT , " \" \" \" \" " " " , CONFIG_NODE_ADDRESS ) ; err = 1 ; } zbx_free ( address ) ; #if ! defined ( HAVE_IPV6 ) err |= ( FAIL == check_cfg_feature_str ( " " , CONFIG_FPING6_LOCATION , " " ) ) ; #endif #if ! defined ( HAVE_LIBCURL ) err |= ( FAIL == check_cfg_feature_str ( " " , CONFIG_SSL_CA_LOCATION , " " ) ) ; err |= ( FAIL == check_cfg_feature_str ( " " , CONFIG_SSL_CERT_LOCATION , " " ) ) ; err |= ( FAIL == check_cfg_feature_str ( " " , CONFIG_SSL_KEY_LOCATION , " " ) ) ; err |= ( FAIL == check_cfg_feature_str ( " " , CONFIG_HISTORY_STORAGE_URL , " " ) ) ; err |= ( FAIL == check_cfg_feature_str ( " " , CONFIG_HISTORY_STORAGE_OPTS , " " ) ) ; err |= ( FAIL == check_cfg_feature_int ( " " , CONFIG_HISTORY_STORAGE_PIPELINES , " " ) ) ; err |= ( FAIL == check_cfg_feature_str ( " " , CONFIG_VAULTTOKEN , " " ) ) ; err |= ( FAIL == check_cfg_feature_str ( " " , CONFIG_VAULTDBPATH , " " ) ) ; err |= ( FAIL == check_cfg_feature_int ( " " , CONFIG_REPORTWRITER_FORKS , " " ) ) ; #endif #if ! defined ( HAVE_LIBXML2 ) || ! defined ( HAVE_LIBCURL ) err |= ( FAIL == check_cfg_feature_int ( " " , CONFIG_VMWARE_FORKS , " " ) ) ; #endif if ( SUCCEED != zbx_validate_log_parameters ( task ) ) err = 1 ; #if ! ( defined ( HAVE_GNUTLS ) || defined ( HAVE_OPENSSL ) ) err |= ( FAIL == check_cfg_feature_str ( " " , CONFIG_TLS_CA_FILE , " " ) ) ; err |= ( FAIL == check_cfg_feature_str ( " " , CONFIG_TLS_CRL_FILE , " " ) ) ; err |= ( FAIL == check_cfg_feature_str ( " " , CONFIG_TLS_CERT_FILE , " " ) ) ; err |= ( FAIL == check_cfg_feature_str ( " " , CONFIG_TLS_KEY_FILE , " " ) ) ; #endif #if ! ( defined ( HAVE_GNUTLS ) || defined ( HAVE_OPENSSL ) ) err |= ( FAIL == check_cfg_feature_str ( " " , CONFIG_TLS_CIPHER_CERT , " " ) ) ; err |= ( FAIL == check_cfg_feature_str ( " " , CONFIG_TLS_CIPHER_PSK , " " ) ) ; err |= ( FAIL == check_cfg_feature_str ( " " , CONFIG_TLS_CIPHER_ALL , " " ) ) ; #endif #if ! defined ( HAVE_OPENSSL ) err |= ( FAIL == check_cfg_feature_str ( " " , CONFIG_TLS_CIPHER_CERT13 , " " ) ) ; err |= ( FAIL == check_cfg_feature_str ( " " , CONFIG_TLS_CIPHER_PSK13 , " " ) ) ; err |= ( FAIL == check_cfg_feature_str ( " " , CONFIG_TLS_CIPHER_ALL13 , " " ) ) ; #endif #if ! defined ( HAVE_OPENIPMI ) err |= ( FAIL == check_cfg_feature_int ( " " , CONFIG_IPMIPOLLER_FORKS , " " ) ) ; #endif err |= ( FAIL == zbx_db_validate_config_features ( ) ) ; if ( 0 != CONFIG_REPORTWRITER_FORKS && NULL == CONFIG_WEBSERVICE_URL ) { zabbix_log ( LOG_LEVEL_CRIT , " \" \" " " \" \" " ) ; } if ( 0 != err ) exit ( EXIT_FAILURE ) ; }
Function: zbx_validate_config                                              
                                                                            
 Purpose: validate configuration parameters                                 
                                                                            
 Author: Vladimir Levijev
Function : zbx_validate_config Purpose : validate configuration parameters Author : Vladimir Levijev
/* parameters VMwareFrequency, VMwarePerfFrequency, VMwareCacheSize, VMwareTimeout are not checked here */ /* because they have non-zero default values */