Example of writing a new probe - reed-alert - Lightweight agentless alerting system for server
HTML git clone git://bitreich.org/reed-alert/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/reed-alert/
DIR Log
DIR Files
DIR Refs
DIR Tags
DIR README
DIR LICENSE
---
DIR commit 05af8b622cc297dac094cfd6ffcb7a39987a26a9
DIR parent 9469c17e98862282e7e6e810f17d8a1ae6af2922
HTML Author: Solene Rapenne <solene@perso.pw>
Date: Mon, 22 Jan 2018 08:09:53 +0100
Example of writing a new probe
Diffstat:
M example.lisp | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
---
DIR diff --git a/example.lisp b/example.lisp
@@ -16,7 +16,7 @@
;; check if :path file exists
(=> mail file-exists :path "/bsd.rd" :desc "OpenBSD kernel /bsd.rd")
-(=> empty file-exists :path "/non-existant-file" :try 1) ;; failure file not found
+(=> empty file-exists :path "/non-existant-file" :try 3) ;; failure file not found
;; check if :path file exists and has been updated since :limit minutes
(=> empty file-updated :path "/var/log/messages" :limit 400)
@@ -55,8 +55,15 @@
;; check if web page :url answer under :limit
(=> empty command :command "curl -m 10 http://google.fr/")
+;; we declare a new probe here
+(create-probe
+ check-http-pattern
+ (command-return-code (format nil "curl ~a | grep -i ~a"
+ (getf params :url) (getf params :pattern))))
+
;; check if the web page :url contains the text regex :pattern
-(=> empty command :command "curl http://google.fr/ | grep html")
-(=> empty command :command "curl http://google.fr/ | grep hello") ;; error
+(=> empty check-http-pattern :url "http://google.fr/" :pattern "html")
+(=> empty check-http-pattern :url "http://127.0.0.1/" :pattern "HTML")
+(=> empty check-http-pattern :url "http://google.fr/" :pattern "hello") ;; error
(quit)