Exemplo n.º 1
0
 private static AgentConfig SetDefaultTaskValues(AgentConfig ac)
 {
     if (!ac.Tasks.ContainsKey("persistResults"))
     {
         ac.Tasks.Add("persistResults", new AgentConfigTask()
         {
             Enabled = true,
             Interval = new TimeSpan(0, 10, 0),
             Startup = false
         });
     }
     if (!ac.Tasks.ContainsKey("uploadResults"))
     {
         ac.Tasks.Add("uploadResults", new AgentConfigTask()
         {
             Enabled = true,
             Interval = new TimeSpan(0, 30, 0),
             Startup = false
         });
     }
     if (!ac.Tasks.ContainsKey("sendHeartbeat"))
     {
         ac.Tasks.Add("sendHeartbeat", new AgentConfigTask()
         {
             Enabled = true,
             Interval = new TimeSpan(0, 10, 0),
             Startup = true
         });
     }
     return ac;
 }
Exemplo n.º 2
0
 private static AgentConfig LoadSerializedCheck(AgentConfig ac)
 {
     foreach (var _check in ac._checks)
     {
         var checkProperties = GetProperties(_check.Value);
         var checkSettings = new CheckSettings(checkProperties);
         checkSettings.TargetSettings = new Dictionary<string, Dictionary<string, string>>();
         checkSettings.Actions = GetActions(_check.Value);
         checkSettings.Thresholds = GetThresholds(_check.Value);
         var targetSettings = new Dictionary<string, string>();
         foreach (var target in GetTargets(_check.Value))
             checkSettings.TargetSettings.Add(target.Key, targetSettings);
         checkSettings.ParseRaw();
         ac.Checks.Add(_check.Key, checkSettings);
     }
     return ac;
 }
Exemplo n.º 3
0
        private static AgentConfig LoadSerializedInfo(AgentConfig ac)
        {
            foreach (var _info in ac._info)
            {
                var infoProperties = GetProperties(_info.Value);
                var infoSettings = new InfoSettings(infoProperties);
                infoSettings.TargetSettings = new Dictionary<string, Dictionary<string, string>>();
                var targetSettings = new Dictionary<string, string>();
                foreach (var target in GetTargets(_info.Value))
                    infoSettings.TargetSettings.Add(target.Key, targetSettings);
                infoSettings.ParseRaw();
                ac.Info.Add(_info.Key, infoSettings);
            }

            return ac;
        }
Exemplo n.º 4
0
        private static AgentConfig LoadSerializedActions(AgentConfig ac)
        {
            foreach (var _action in ac._actions)
            {
                var actionProperties = GetProperties(_action.Value);
                var actionSettings = new ActionSettings(actionProperties);
                actionSettings.TargetSettings = new Dictionary<string, Dictionary<string, string>>();
                var targetSettings = new Dictionary<string, string>();
                foreach (var target in GetTargets(_action.Value))
                    actionSettings.TargetSettings.Add(target.Key, targetSettings);
                actionSettings.ParseRaw();
                ac.Actions.Add(_action.Key, actionSettings);
            }

            return ac;
        }
Exemplo n.º 5
0
        private static AgentConfig InitializeAgentConfigLists(AgentConfig ac)
        {
            ac.Checks = new Dictionary<string, CheckSettings>();
            ac.Info = new Dictionary<string, InfoSettings>();
            ac.Actions = new Dictionary<string, ActionSettings>();

            return ac;
        }
Exemplo n.º 6
0
 private static void CheckAgentConfigForNull(AgentConfig ac)
 {
     if (ac == null)
     {
         throw new Exception("Could not deserialize config.yaml. Make sure the syntax is correct.");
     }
 }
Exemplo n.º 7
0
 private void ProcessInternalTasks(AgentConfig config)
 {
     foreach (InternalTaskType itt in Enum.GetValues(typeof(InternalTaskType)))
     {
         var key = itt.ToString();
         key = key.Substring(0, 1).ToLower() + key.Substring(1); // Convert to dict key
         if (!config.Tasks[key].Enabled)
             continue;
         ScheduleTask(new InternalTask(itt),
             config.Tasks[key].Interval);
         if (config.Tasks[key].Startup)
             EnqueueTask(new InternalTask(itt));
     }
 }
        private void LoadConfiguration()
        {
            _log.Debug("Loading configuration...");
            env.ConfigFile = Path.Combine(env.DataPath, "config.yaml");
            if(!File.Exists(env.ConfigFile))
            {
                _log.Warn("No configuration file has been fetched.");
                return;
            }
            config = Config.AgentConfig.LoadFromFile(env.ConfigFile);
            ServiceProvider.SetService(config);

            _log.Debug("Configuration successfully loaded, found {0} checks.", config.Checks.Count);
        }