Beispiel #1
0
func NagiosReset(w http.ResponseWriter, req *http.Request) *webapp.Error {
	if nagios.Status() == nagios.OkStatus {
		fmt.Fprintln(w, "OK")
		return nil
	}

	ns := req.FormValue("nagios-secret")
	if ns != "" {
		if ns != config.AnaLog.NagiosSecret {
			http.Error(w, "Invalid secret", http.StatusUnauthorized)
			return nil
		} else {
			nagios.SetOK()
			fmt.Fprintln(w, "OK")
			return nil
		}
	}

	fmt.Fprintln(w, `
		<!DOCTYPE html>
		<html>
			<body>
				<form method="POST">
					<input type="text" name="nagios-secret">
					<input type="submit">
				</form>
			</body>
		</html>
	`)

	return nil
}
Beispiel #2
0
func NagiosStatus(w http.ResponseWriter, req *http.Request) *webapp.Error {
	fmt.Fprintln(w, nagios.Status())
	return nil
}