Exemplo n.º 1
0
func validateScriptsConf(scripts *ScriptsConf, meta toml.MetaData) error {
	if scripts == nil {
		return nil
	}
	if !meta.IsDefined("scripts", "path") {
		return errors.New("scripts section provided without path.")
	}
	if !meta.IsDefined("scripts", "run_interval_ms") {
		return errors.New("scripts section provided without run_interval_ms.")
	}
	if scripts.RunIntervalMS <= 0 {
		return errors.New("scripts.run_interval_ms must be positive")
	}
	return nil
}
Exemplo n.º 2
0
func validateOSStatsConf(osStats *OSStatsConf, meta toml.MetaData) error {
	if osStats == nil {
		return nil
	}
	if meta.IsDefined("os_stats", "check_interval_ms") {
		if osStats.CheckIntervalMS <= 0 {
			return errors.New("check_interval_ms must be positive")
		}
	}
	if err := validateMemConf(osStats.Mem); err != nil {
		return err
	}
	if err := validateCPUConf(osStats.CPU); err != nil {
		return err
	}
	// For now, any parseable NetConf is valid.
	for _, diskConf := range osStats.Disk {
		if err := validateDiskConf(diskConf); err != nil {
			return err
		}
	}
	return nil
}