mirror of git://bitreich.org/reed-alert
[Fix] Alert triggered one cycle later
This commit is contained in:
parent
0b600b142b
commit
f21b8c0e4e
|
@ -99,7 +99,6 @@
|
|||
0
|
||||
(with-open-file (stream filepath :direction :input)
|
||||
(parse-integer (read-line stream 0 nil)))))
|
||||
(trigger-now? (= tries (getf params :try *tries*)))
|
||||
(triggered-before? (>= tries (getf params :try *tries*))))
|
||||
|
||||
;; if result is a list then the check had fail a return both nil and the error value
|
||||
|
@ -109,7 +108,7 @@
|
|||
|
||||
;; we delete the file with previous states
|
||||
(when (probe-file filepath)
|
||||
(delete-file filepath))
|
||||
(delete-file filepath))
|
||||
|
||||
;; it was a failure and then it's back to normal state
|
||||
(if triggered-before?
|
||||
|
@ -122,18 +121,17 @@
|
|||
;; in any case we return t because it's ok
|
||||
t)
|
||||
|
||||
(progn
|
||||
(format t " => ~aerror (~a failure(s) before)~a~a~%" *red* tries *white* (if trigger-now? " NOTIFIED" ""))
|
||||
;; failure handling
|
||||
(let ((trigger-now? (= (+ 1 tries) (getf params :try *tries*)))) ; we add +1 because it's failing right now
|
||||
(format t " => ~aerror (~a failure(s) before)~a~a~%" *red* tries *white* (if trigger-now? " NOTIFIED" ""))
|
||||
|
||||
;; more error than limit, send alert once
|
||||
(when trigger-now?
|
||||
(uiop:run-program (trigger-alert level fonction params (cadr result) 'error) :output t))
|
||||
|
||||
;; increment the number of tries by 1
|
||||
(with-open-file (stream-out filepath :direction :output
|
||||
:if-exists :supersede)
|
||||
(format stream-out "~a~%~a~%" (+ 1 tries) params))
|
||||
|
||||
nil)))))
|
||||
;; more error than limit, send alert once
|
||||
(when trigger-now?
|
||||
(uiop:run-program (trigger-alert level fonction params (cadr result) 'error) :output t))
|
||||
;; increment the number of tries by 1
|
||||
(with-open-file (stream-out filepath :direction :output
|
||||
:if-exists :supersede)
|
||||
(format stream-out "~a~%~a~%" (+ 1 tries) params))
|
||||
nil)))))
|
||||
|
||||
(load "probes.lisp")
|
||||
|
|
Loading…
Reference in New Issue