Example #1
0
func startCollector() {
	interval := cfg.GetAgentAutonomic().LoopTimeInterval + c_AUTO_LOOP_EPSILON
	ticker := time.NewTicker(time.Duration(interval) * time.Second)

	for {
		select {
		case <-ticker.C:
			collectMetrics()
		}
	}
}
Example #2
0
func initiailizeMonitoring() {
	defer log.Infoln("Initializing autonomic monitoring")
	ch_aut_err := chn.GetAutonomicErrChannel()
	enableLogReading = cfg.GetAgentAutonomic().EnableLogReading
	mtr.Initialize(srv.List())

	// Start log reader if needed
	if enableLogReading {
		lgr.StartLogReader()
		log.WithField("logreader", enableLogReading).Debugln("Log reading is enabled")
	}

	// Get the list of containers (running or not) to monitor
	containers, err := container.Docker().Client.ListContainers(true, false, "")
	if err != nil {
		log.WithField("err", err).Debugln("Error monitoring containers")
		ch_aut_err <- err
	}

	// Start the monitor for each configured service
	for _, c := range containers {
		info, _ := container.Docker().Client.InspectContainer(c.Id)
		status := getContainerStatus(info)
		service, err := srv.GetServiceByImage(c.Image)
		if err != nil {
			log.WithFields(log.Fields{
				"err":   err,
				"image": c.Image,
			}).Warningln("Error monitoring service")
		} else {
			e := evt.Event{
				Service:  service.Name,
				Image:    c.Image,
				Instance: c.Id,
				Status:   status,
			}

			evt.HandleCreateEvent(e)
			evt.HanldeStartEvent(e)
			mtr.AddInstance(c.Id)
			if _, ok := instBuffer[c.Id]; !ok {
				instBuffer[c.Id] = instanceMetricBuffer{
					cpuInst: utils.BuildBuffer(c_B_SIZE),
					cpuSys:  utils.BuildBuffer(c_B_SIZE),
				}
			}
			container.Docker().Client.StartMonitorStats(c.Id, statCallBack, ch_mnt_stats_err)
			if status == enum.PENDING && enableLogReading {
				startMonitorLog(c.Id)
			}
		}
	}
}
Example #3
0
func startAutonomicManager() {
	autonomic.RunLoop(cfg.GetAgentAutonomic().LoopTimeInterval)
}
Example #4
0
func Initialize() {
	autonomic.UpdatePlannerStrategy(cfg.GetAgentAutonomic().PlannerStrategy)
}
Example #5
0
func UpdateStrategy() {
	autonomic.UpdatePlannerStrategy(cfg.GetAgentAutonomic().PlannerStrategy)
}