コード例 #1
0
// Collect metrics from the '/metrics/snapshot' endpoint on the master.  The '/metrics/snapshot' endpoint returns JSON,
// and all metrics contained in the endpoint use a string as the key, and a double (float64) for the value. For example:
//
//   {
//     "master/cpus_total": 2.0
//   }
//
func GetMetricsSnapshot(host string) (map[string]float64, error) {
	log.Debug("Getting metrics snapshot for host ", host)
	data := map[string]float64{}

	c := client.NewClient(host, "/metrics/snapshot", time.Duration(5))
	if err := c.Fetch(&data); err != nil {
		log.Error(err)
		return nil, err
	}

	return data, nil
}
コード例 #2
0
// Collect metrics from the '/monitor/statistics' endpoint on the agent. This endpoint returns JSON, and all metrics
// contained in the endpoint use a string as the key. Depending on features enabled on the Mesos agent, additional
// metrics might be available under either the "statistics" object, or additional nested objects (e.g. "perf") as
// defined by the Executor structure, and the structures in mesos_pb2.ResourceStatistics.
func GetMonitoringStatistics(host string) ([]Executor, error) {
	log.Debug("Getting monitoring statistics from host ", host)
	var executors []Executor

	c := client.NewClient(host, "/monitor/statistics", time.Duration(30))
	if err := c.Fetch(&executors); err != nil {
		log.Error(err)
		return nil, err
	}

	return executors, nil
}
コード例 #3
0
// Get metrics from the '/master/frameworks' endpoint on the master. This endpoint returns JSON about the overall
// state and resource utilization of the frameworks running on the cluster.
func GetFrameworks(host string) ([]*Framework, error) {
	log.Debug("Getting active frameworks resource utilization from master ", host)
	var frameworks Frameworks

	c := client.NewClient(host, "/master/frameworks", time.Duration(10))
	if err := c.Fetch(&frameworks); err != nil {
		log.Error(err)
		return nil, err
	}

	return frameworks.ActiveFrameworks, nil
}
コード例 #4
0
// Get the configuration flags from the Mesos agent and return them as a map.
func GetFlags(host string) (map[string]string, error) {
	log.Debug("Getting configuration flags from host ", host)
	flags := &Flags{}

	c := client.NewClient(host, "/slave(1)/flags", time.Duration(5))
	if err := c.Fetch(&flags); err != nil {
		log.Error(err)
		return nil, err
	}

	return flags.Flags, nil
}