SMOLNET PORTAL home about changes
iFix check function return value - reed-alert - Lightweight agentless alerting system for server	Err	bitreich.org	70
hgit clone git://bitreich.org/reed-alert/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/reed-alert/	URL:git://bitreich.org/reed-alert/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/reed-alert/	bitreich.org	70
1Log	/scm/reed-alert/log.gph	bitreich.org	70
1Files	/scm/reed-alert/files.gph	bitreich.org	70
1Refs	/scm/reed-alert/refs.gph	bitreich.org	70
1Tags	/scm/reed-alert/tag	bitreich.org	70
1README	/scm/reed-alert/file/README.gph	bitreich.org	70
1LICENSE	/scm/reed-alert/file/LICENSE.gph	bitreich.org	70
i---	Err	bitreich.org	70
1commit 9698c24926a46f573d376851a397799f4f0fc41d	/scm/reed-alert/commit/9698c24926a46f573d376851a397799f4f0fc41d.gph	bitreich.org	70
1parent b890363bf7bc8dbae4ac17dd0e65396969e09f2d	/scm/reed-alert/commit/b890363bf7bc8dbae4ac17dd0e65396969e09f2d.gph	bitreich.org	70
hAuthor: Solene Rapenne <solene@perso.pw>	URL:mailto:solene@perso.pw	bitreich.org	70
iDate:   Tue,  9 Jul 2019 16:55:01 +0200	Err	bitreich.org	70
i	Err	bitreich.org	70
iFix check function return value	Err	bitreich.org	70
i	Err	bitreich.org	70
iDiffstat:	Err	bitreich.org	70
i  M functions.lisp                      |      21 +++++++++++++--------	Err	bitreich.org	70
i  M test/test.lisp                      |      10 ++++++++++	Err	bitreich.org	70
i	Err	bitreich.org	70
i2 files changed, 23 insertions(+), 8 deletions(-)	Err	bitreich.org	70
i---	Err	bitreich.org	70
1diff --git a/functions.lisp b/functions.lisp	/scm/reed-alert/file/functions.lisp.gph	bitreich.org	70
i@@ -94,8 +94,8 @@	Err	bitreich.org	70
i          (result (funcall fonction params))	Err	bitreich.org	70
i          (filename (format nil "~a-~a-~a" level fonction hash))	Err	bitreich.org	70
i          (filepath (format nil "~a/~a" *states-dir* filename))	Err	bitreich.org	70
i-         (current-state 'failure) ;; default state is a failure	Err	bitreich.org	70
i-         (previous-state 'success)	Err	bitreich.org	70
i+         (current-state nil) ;; default state is a failure	Err	bitreich.org	70
i+         (previous-state nil)	Err	bitreich.org	70
i          (trigger-state 'no))	Err	bitreich.org	70
i 	Err	bitreich.org	70
i     ;; we open the file to read the number of tries	Err	bitreich.org	70
i@@ -109,10 +109,12 @@	Err	bitreich.org	70
i       ;; if result is a list then the check had fail a return both nil and the error value	Err	bitreich.org	70
i       ;; if result is not a list, then it was successful	Err	bitreich.org	70
i       (if (not (listp result))	Err	bitreich.org	70
i+	Err	bitreich.org	70
i+          ;; SUCCESS HANDLING	Err	bitreich.org	70
i           (progn	Err	bitreich.org	70
i 	Err	bitreich.org	70
i             ;; mark state as success	Err	bitreich.org	70
i-            (setf current-state 'success)	Err	bitreich.org	70
i+            (setf current-state t)	Err	bitreich.org	70
i 	Err	bitreich.org	70
i             ;; we delete the file with previous states	Err	bitreich.org	70
i             (when (probe-file filepath)	Err	bitreich.org	70
i@@ -121,11 +123,11 @@	Err	bitreich.org	70
i             ;; it was a failure and then it's back to normal state	Err	bitreich.org	70
i             (when triggered-before?	Err	bitreich.org	70
i               (uiop:run-program (trigger-alert level fonction params t 'success) :output t)	Err	bitreich.org	70
i-              (setf previous-state 'failure))	Err	bitreich.org	70
i+              (setf previous-state nil))	Err	bitreich.org	70
i             ;; in any case we return t because it's ok	Err	bitreich.org	70
i             t)	Err	bitreich.org	70
i 	Err	bitreich.org	70
i-          ;; failure handling	Err	bitreich.org	70
i+          ;; FAILURE HANDLING	Err	bitreich.org	70
i           (let ((trigger-now? (or	Err	bitreich.org	70
i                                ;; we add +1 to tries because it's failing right now	Err	bitreich.org	70
i                                (and (= (+ 1 tries) (getf params :try *tries*))	Err	bitreich.org	70
i@@ -138,7 +140,7 @@	Err	bitreich.org	70
i 	Err	bitreich.org	70
i             ;; more error than limit, send alert once	Err	bitreich.org	70
i             (when trigger-now?	Err	bitreich.org	70
i-              (setf trigger-state 'notified)	Err	bitreich.org	70
i+              (setf trigger-state 'YES)	Err	bitreich.org	70
i               (uiop:run-program (trigger-alert level fonction params (cadr result) trigger-now?)))	Err	bitreich.org	70
i             ;; increment the number of tries by 1	Err	bitreich.org	70
i             (with-open-file (stream-out filepath :direction :output	Err	bitreich.org	70
i@@ -146,9 +148,12 @@	Err	bitreich.org	70
i               (format stream-out "~a~%~a~%" (+ 1 tries) params))	Err	bitreich.org	70
i             nil))	Err	bitreich.org	70
i 	Err	bitreich.org	70
i-      (format t "~a        ~A        ~A        ~A        ~A        ~A~%"	Err	bitreich.org	70
i+      (format t "~a        ~A        ~A        ~A        ~A        ~A        ~A~%"	Err	bitreich.org	70
i               level fonction (format nil "~{~A ~}" params)	Err	bitreich.org	70
i-              previous-state current-state trigger-state))))	Err	bitreich.org	70
i+              (if previous-state "SUCCESS" "ERROR")	Err	bitreich.org	70
i+              (if current-state "SUCCESS" "ERROR")	Err	bitreich.org	70
i+              trigger-state (+ 1 tries)))	Err	bitreich.org	70
i+    current-state))	Err	bitreich.org	70
i 	Err	bitreich.org	70
i ;; abort when using ctrl+c instead of dropping to debugger	Err	bitreich.org	70
i #+ecl	Err	bitreich.org	70
1diff --git a/test/test.lisp b/test/test.lisp	/scm/reed-alert/file/test/test.lisp.gph	bitreich.org	70
i@@ -12,3 +12,13 @@	Err	bitreich.org	70
i (=> notification disk-usage :path "/"    :limit 1 :reminder 2)	Err	bitreich.org	70
i (=> notification disk-usage :path "/"    :limit 1 :reminder 2)	Err	bitreich.org	70
i (=> notification disk-usage :path "/"    :limit 1 :reminder 2)	Err	bitreich.org	70
i+	Err	bitreich.org	70
i+(and	Err	bitreich.org	70
i+ (=> notification disk-usage :path "/"    :limit 99 :reminder 2 :desc "always OK")	Err	bitreich.org	70
i+ (=> notification disk-usage :path "/"    :limit 1 :reminder 2 :desc "always error")	Err	bitreich.org	70
i+ (=> notification disk-usage :path "/"    :limit 1 :reminder 2 :desc "always error, should not be displayed"))	Err	bitreich.org	70
i+	Err	bitreich.org	70
i+	Err	bitreich.org	70
i+(or	Err	bitreich.org	70
i+ (=> notification disk-usage :path "/"    :limit 1 :reminder 2 :desc "always error, should be followed by always ok")	Err	bitreich.org	70
i+ (=> notification disk-usage :path "/"    :limit 99 :reminder 2 :desc "always OK"))	Err	bitreich.org	70
.
Response: text/plain
Original URLgopher://bitreich.org/0/scm/reed-alert/commit/9698c24926a...
Content-Typetext/plain; charset=utf-8