Beispiel #1
0
func (r *Skydns2Adapter) Ping() error {
	rr := etcd.NewRawRequest("GET", "version", nil, nil)
	_, err := r.client.SendRequest(rr)
	if err != nil {
		return err
	}
	return nil
}
Beispiel #2
0
func (a *AgentCommand) dashboardIndexHandler(w http.ResponseWriter, r *http.Request) {
	w.Header().Set("Content-Type", "text/html")

	tmpl := template.Must(template.New("dashboard.html.tmpl").ParseFiles(
		"templates/dashboard.html.tmpl", "templates/index.html.tmpl", "templates/status.html.tmpl"))

	rr := etcdc.NewRawRequest("GET", "../version", nil, nil)
	res, err := a.etcd.Client.SendRequest(rr)
	if err != nil {
		log.Error(err)
	}
	var version struct {
		Etcdserver  string `json:"etcdserver"`
		Etcdcluster string `json:"etcdcluster"`
	}
	json.Unmarshal(res.Body, &version)

	var ss *EtcdServerStats
	rr = etcdc.NewRawRequest("GET", "stats/self", nil, nil)
	res, err = a.etcd.Client.SendRequest(rr)
	if err != nil {
		log.Error(err)
	}
	json.Unmarshal(res.Body, &ss)

	l, _ := a.leaderMember()
	data := struct {
		Version     string
		LeaderName  string
		EtcdVersion string
		Stats       *EtcdServerStats
		StartTime   string
	}{
		Version:     a.Version,
		LeaderName:  l.Name,
		EtcdVersion: version.Etcdserver,
		Stats:       ss,
		StartTime:   ss.LeaderInfo.StartTime.Format("2/Jan/2006 15:05:05"),
	}

	if err := tmpl.Execute(w, data); err != nil {
		log.Error(err)
	}
}
Beispiel #3
0
func (s *EtcdBackend) addChildDir(key string, ttl uint) (*etcd.Response, error) {
	p := path.Join("keys", key)
	vals := url.Values{}
	vals.Set("dir", "true")
	req := etcd.NewRawRequest("POST", p, vals, nil)
	raw, err := s.client.SendRequest(req)
	if err != nil {
		return nil, err
	}
	return raw.Unmarshal()
}
Beispiel #4
0
func (r *EtcdAdapter) Ping() error {
	var err error
	if r.client != nil {
		rr := etcd.NewRawRequest("GET", "version", nil, nil)
		_, err = r.client.SendRequest(rr)
	} else {
		rr := etcd2.NewRawRequest("GET", "version", nil, nil)
		_, err = r.client2.SendRequest(rr)
	}

	if err != nil {
		return err
	}
	return nil
}
Beispiel #5
0
// Check if we can talk to etcd
func (b *Backend) Ping() error {
	rr := etcd.NewRawRequest("GET", "version", nil, nil)
	_, err := b.client.SendRequest(rr)
	return err
}