Пример #1
0
func (this *StatServer) CollectStats() {
	fmt.Println("Collecting data ...")
	metrics := api.Parse(this.source)

	for _, check := range this.config.Checks {
		for _, metricFailed := range metrics.Find(api.NewMetricFilter(check)) {
			fmt.Println(" >> Alert: ", metricFailed.GMetric, " :: ",
				metricFailed.GHost.Name)
		}
	}
}
Пример #2
0
func main() {

	kingpin.Parse()

	filter := &api.MetricFilter{*metric, *node, *cluster, *condition, *threshhold}
	source := &api.DataSource{*localPath, *remoteHost, *remotePort}

	if *deamonMode {
		deamon.NewStatServer(source, filter, *configFile).Start()
	} else {
		s := api.NewGSet()
		for _, metric := range api.Parse(source).Find(filter) {
			if *listClusters {
				s.PrintIfNotInSet(metric.GCluster.Name)
			}
			if *listNodes {
				s.PrintIfNotInSet(metric.GHost.Name)
			}
			if *listMetric {
				s.PrintIfNotInSet(metric.GMetric.Name)
			}
		}
	}
}