Esempio n. 1
0
func init() {
	var err error
	NodeID, err = server.LocalIP()
	if err != nil {
		log.Fatalf("Failed to determine IP addr: %v", err)
	}
}
Esempio n. 2
0
func LoadConfig() {
	var err error
	c, err = server.NewConfig("logyard_sieve", Config{})
	if err != nil {
		log.Fatalf("Unable to load logyard_sieve config; %v", err)
	}
	log.Info(getConfig().Events)
}
Esempio n. 3
0
func NewProgressiveRetryer(retryLimit time.Duration) Retryer {
	r := new(ProgressiveRetryer)
	r.retryLimit = retryLimit
	if r.hasRetryLimit() && r.retryLimit <= RESET_AFTER {
		log.Fatalf("retryLimit (%v) must be greater than RESET_AFTER (%v)",
			r.retryLimit, RESET_AFTER)
	}
	return r
}
Esempio n. 4
0
func (m *MultiRegexpMatcher) MustAdd(name string, substring string, re string) {
	if oldName, ok := m.substrings[substring]; ok {
		log.Fatalf(
			"substring %s already added under %s; being added again by %s",
			substring, oldName, name)
	}
	if _, ok := m.regexps[name]; ok {
		log.Fatal("already in regexps")
	}
	m.substrings[substring] = name
	m.regexps[name] = regexp.MustCompile(re)
}
Esempio n. 5
0
func getDockerEvents(retries int) *http.Response {
	c := http.Client{}
	for attempt := 0; attempt < retries; attempt++ {
		res, err := c.Get(events_url)
		if err != nil {
			if (attempt + 1) == retries {
				log.Fatalf("Failed to read from docker daemon; giving up retrying: %v", err)
			}
			log.Warnf("Docker connection error (%v); retrying after 1 second.", err)
			time.Sleep(time.Second)
		} else {
			return res
		}
	}
	panic("unreachable")
}
Esempio n. 6
0
func GetLiveDockerContainers(retries int) map[string]bool {
	allDockerIds := make(map[string]bool)
	var httpResByte []byte
	c := http.Client{}
	for attempt := 0; attempt < retries; attempt++ {
		res, err := c.Get(containers_url)
		defer res.Body.Close()
		if err != nil {
			if (attempt + 1) == retries {
				log.Fatalf("Failed to read from docker daemon; giving up retrying: %v", err)
			}
			log.Warnf("Docker connection error (%v); retrying after 1 second.", err)
			time.Sleep(time.Second)
		} else {
			httpResByte, err = ioutil.ReadAll(res.Body)
			if err != nil {
				log.Fatal(err)

			}
			var jsonData []Docker
			err = json.Unmarshal([]byte(httpResByte), &jsonData)

			if err != nil {
				log.Fatal(err)

			}

			for _, element := range jsonData {

				shortenedKey := element.Id[:ID_LENGTH]

				allDockerIds[shortenedKey] = true
			}

		}
	}
	return allDockerIds
}