iExample of writing a new probe - 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 05af8b622cc297dac094cfd6ffcb7a39987a26a9 /scm/reed-alert/commit/05af8b622cc297dac094cfd6ffcb7a39987a26a9.gph bitreich.org 70 1parent 9469c17e98862282e7e6e810f17d8a1ae6af2922 /scm/reed-alert/commit/9469c17e98862282e7e6e810f17d8a1ae6af2922.gph bitreich.org 70 hAuthor: Solene Rapenne URL:mailto:solene@perso.pw bitreich.org 70 iDate: Mon, 22 Jan 2018 08:09:53 +0100 Err bitreich.org 70 i Err bitreich.org 70 iExample of writing a new probe Err bitreich.org 70 i Err bitreich.org 70 iDiffstat: Err bitreich.org 70 i M example.lisp | 13 ++++++++++--- Err bitreich.org 70 i Err bitreich.org 70 i1 file changed, 10 insertions(+), 3 deletions(-) Err bitreich.org 70 i--- Err bitreich.org 70 1diff --git a/example.lisp b/example.lisp /scm/reed-alert/file/example.lisp.gph bitreich.org 70 i@@ -16,7 +16,7 @@ Err bitreich.org 70 i Err bitreich.org 70 i ;; check if :path file exists Err bitreich.org 70 i (=> mail file-exists :path "/bsd.rd" :desc "OpenBSD kernel /bsd.rd") Err bitreich.org 70 i-(=> empty file-exists :path "/non-existant-file" :try 1) ;; failure file not found Err bitreich.org 70 i+(=> empty file-exists :path "/non-existant-file" :try 3) ;; failure file not found Err bitreich.org 70 i Err bitreich.org 70 i ;; check if :path file exists and has been updated since :limit minutes Err bitreich.org 70 i (=> empty file-updated :path "/var/log/messages" :limit 400) Err bitreich.org 70 i@@ -55,8 +55,15 @@ Err bitreich.org 70 i ;; check if web page :url answer under :limit Err bitreich.org 70 i (=> empty command :command "curl -m 10 http://google.fr/") Err bitreich.org 70 i Err bitreich.org 70 i+;; we declare a new probe here Err bitreich.org 70 i+(create-probe Err bitreich.org 70 i+ check-http-pattern Err bitreich.org 70 i+ (command-return-code (format nil "curl ~a | grep -i ~a" Err bitreich.org 70 i+ (getf params :url) (getf params :pattern)))) Err bitreich.org 70 i+ Err bitreich.org 70 i ;; check if the web page :url contains the text regex :pattern Err bitreich.org 70 i-(=> empty command :command "curl http://google.fr/ | grep html") Err bitreich.org 70 i-(=> empty command :command "curl http://google.fr/ | grep hello") ;; error Err bitreich.org 70 i+(=> empty check-http-pattern :url "http://google.fr/" :pattern "html") Err bitreich.org 70 i+(=> empty check-http-pattern :url "http://127.0.0.1/" :pattern "HTML") Err bitreich.org 70 i+(=> empty check-http-pattern :url "http://google.fr/" :pattern "hello") ;; error Err bitreich.org 70 i Err bitreich.org 70 i (quit) Err bitreich.org 70 .