Beispiel #1
0
func editAlert(data interface{}, cmd string, args ...string) string {
	cs := data.(*ABChans)
	if cmd != "editalert" {
		return ""
	}
	if len(args) < 1 {
		return "No alert kvplist provided"
	}
	row := new(alertbaseutil.ROW)
	row.SetFromKVL(strings.Join(args, " "))
	cs.addModRowChan <- *row
	return "done"
}
Beispiel #2
0
func editAlert(w http.ResponseWriter, r *http.Request, usr string) {
	editkvplist := r.FormValue("editkvplist")
	if editkvplist == "" {
		return
	}
	editkvplist, _ = url.QueryUnescape(editkvplist)
	log.Println("Got editalert req from", usr, "editkvplist =", editkvplist)
	conn, err := cim.NewCimConnection(alertBaseHost, "alertbase01", fmt.Sprintf("alertbase01-%d", time.Now().UnixNano()))
	if err != nil {
		http.Error(w, "Monim cannot connect to alertbase", 500)
		return
	}
	defer conn.Close()
	res, err := conn.RunCommand("editalert " + editkvplist)
	if err != nil || res != "done" {
		http.Error(w, "Error running cim command in alertbase", 500)
		return
	}
	alert := new(alertbaseutil.ROW)
	alert.SetFromKVL(editkvplist)
	if alert.Status == "owned" || alert.Status == "closed" {
		owner := usr
		if alert.Owner != "" {
			owner = alert.Owner
		}
		closed := ""
		if alert.Status == "closed" {
			closed = "closed"
		}
		kk := alert.GetKey()
		if openat2sent2[kk] {

			mailer(openat2esc[kk], fmt.Sprintf("Alert %s @%s '%s'", closed, owner, alert.Subject))
		} else if openat2sent1[kk] {

			mailer(email[currentOperator], fmt.Sprintf("Alert %s @%s '%s'", closed, owner, alert.Subject))
		}
	}
}