Example of writing a new probe

This commit is contained in:
Solene Rapenne 2018-01-22 08:09:53 +01:00
parent 9469c17e98
commit 05af8b622c
1 changed files with 10 additions and 3 deletions

View File

@ -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)