Example #1
0
func verifyProject(projectObj project.Project, err error, context appengine.Context) (int, error) {
	if err != nil {
		log.Warnf(context, "Error polling graphite %v ", err.Error())
		return http.StatusInternalServerError, err
	} else if projectObj.GetConfig()["graphite.baseurl"] == "" {
		log.Warnf(context, "Error polling graphite, property graphite.base missing for project ")
		return http.StatusInternalServerError, errors.New("Property graphite.base missing for project")
	} else if projectObj.GetConfig()["graphite.lookback"] == "" {
		log.Warnf(context, "Error polling graphite, property graphite.lookback missing for project ")
		return http.StatusInternalServerError, errors.New("Property graphite.lookback missing for project")
	} else {
		return 0, nil
	}
}
Example #2
0
func processAlerts(projectObj project.Project, alerts []alert.Alert,
	subscriptions []subscription.Subscription, context appengine.Context) (int, []byte) {

	graphiteReader, _ := graphite.MakeGraphiteReader(projectObj.GetConfig()["graphite.baseurl"],
		projectObj.GetConfig()["graphite.lookback"], context)

	alertChecks := make([]alert.Check, 0)

	for _, projectAlert := range alerts {
		//TODO Make this in to a go routine
		alertCheck := processAlert(projectAlert, context, graphiteReader, subscriptions, alertChecks)
		alertChecks = append(alertChecks, alertCheck)
	}

	alertBytes, err := json.MarshalIndent(alertChecks, "", "	")

	if err != nil {
		log.Errorf(context, "Error marshalling response %v", err)
		return http.StatusInternalServerError, []byte(err.Error())
	} else {
		return http.StatusOK, alertBytes
	}

}