iexample-full.lisp - 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 iexample-full.lisp (3461B) Err bitreich.org 70 i--- Err bitreich.org 70 i 1 (alert dont-use-it "REMINDER %state% %function% %params% %date% %hostname% %desc% %level% %os% %newline% _ %space% %result%") Err bitreich.org 70 i 2 (alert empty "") Err bitreich.org 70 i 3 (alert mail "") Err bitreich.org 70 i 4 (alert peroket "echo '%state% problem at %date% with %function% %params% : %result%'") Err bitreich.org 70 i 5 (alert sms "echo -n '%date% %function% CRITICAL on %hostname%' | curl http://somewebservice") Err bitreich.org 70 i 6 ;(alert mail "echo -n '%date% %hostname% had problem on %function% %newline% %params% values %result% %newline% Err bitreich.org 70 i 7 ; %desc%' | mail -s '[Error] %function% - %hostname%' foo@bar.com") Err bitreich.org 70 i 8 Err bitreich.org 70 i 9 Err bitreich.org 70 i 10 ;; check if used percent :path partition is more than :limit Err bitreich.org 70 i 11 (=> peroket disk-usage :path "/" :limit 90) Err bitreich.org 70 i 12 (=> peroket disk-usage :path "/usr" :limit 85) Err bitreich.org 70 i 13 (=> peroket disk-usage :path "/tmp" :limit 0) ;; failure Err bitreich.org 70 i 14 Err bitreich.org 70 i 15 ;; check if :path file exists Err bitreich.org 70 i 16 (=> mail check-file-exists :path "/bsd.rd" :desc "OpenBSD kernel /bsd.rd") Err bitreich.org 70 i 17 (=> empty check-file-exists :path "/non-existant-file" :try 3) ;; failure file not found Err bitreich.org 70 i 18 Err bitreich.org 70 i 19 ;; check if :path file exists and has been updated since :limit minutes Err bitreich.org 70 i 20 (=> empty file-updated :path "/var/log/messages" :limit 400) Err bitreich.org 70 i 21 (=> mail file-updated :path "/bsd.rd" :limit 1 :desc "OpenBSD kernel") ;; failure Err bitreich.org 70 i 22 (=> mail file-updated :path "/tmp/reed-alert.txt" :limit 10) Err bitreich.org 70 i 23 Err bitreich.org 70 i 24 ;; check if :path pid file process is running Err bitreich.org 70 i 25 (=> mail pid-running :path "/var/run/xdm.pid" :desc "XDM pid") Err bitreich.org 70 i 26 (=> mail pid-running :path "/home/user/test.pid") ;; failure Err bitreich.org 70 i 27 Err bitreich.org 70 i 28 ;; check if number of processes on the system is more than :limit Err bitreich.org 70 i 29 (=> mail number-of-processes :limit 200) Err bitreich.org 70 i 30 (=> mail number-of-processes :limit 1) ;; failure Err bitreich.org 70 i 31 Err bitreich.org 70 i 32 ;; check if service is running Err bitreich.org 70 i 33 (=> mail service :name "httpd" :reminder 2) ;; reminds every 2 check when it's failing Err bitreich.org 70 i 34 (=> mail service :name "ospfd") ;; failure : not started Err bitreich.org 70 i 35 (=> mail service :name "unknown") ;; failure : not known Err bitreich.org 70 i 36 Err bitreich.org 70 i 37 ;; check if load average on (1/5/15) minutes is more than :limit Err bitreich.org 70 i 38 (=> mail load-average-1 :limit 4) Err bitreich.org 70 i 39 ;;(=> mail load-average-5 :limit 2) Err bitreich.org 70 i 40 ;;(=> mail load-average-15 :limit 1) Err bitreich.org 70 i 41 (=> mail load-average-1 :limit 0.2) ;; should trigger error Err bitreich.org 70 i 42 Err bitreich.org 70 i 43 ;; check if :host host is reachable Err bitreich.org 70 i 44 ;;(=> mail ping :host "8.8.8.8" :desc "Google DNS") Err bitreich.org 70 i 45 ;;(=> empty ping :host "127.40.30.21" :desc "Certainly not used address") ;; fail time out Err bitreich.org 70 i 46 (loop for host in (list "8.8.8.8" "8.8.4.4" "127.0.0.1") Err bitreich.org 70 i 47 do Err bitreich.org 70 i 48 (=> empty ping :host host)) Err bitreich.org 70 i 49 Err bitreich.org 70 i 50 ;; check if :command command return 0 (success) or something else (error) Err bitreich.org 70 i 51 (=> empty command :command "echo hello") ;; success Err bitreich.org 70 i 52 (=> empty command :command "ls /non-existent-file") ;; fail Err bitreich.org 70 i 53 Err bitreich.org 70 i 54 ;; check if web page :url answer under :limit Err bitreich.org 70 i 55 (=> empty command :command "curl -m 10 http://google.fr/") Err bitreich.org 70 i 56 Err bitreich.org 70 i 57 ;; check if a certificate is still valid within a time range Err bitreich.org 70 i 58 (=> mail ssl-expiration :host "google.fr" :seconds 1296000) Err bitreich.org 70 i 59 (=> mail ssl-expiration :host "freenode.net" :seconds (* 7 24 60 60)) Err bitreich.org 70 i 60 (=> mail ssl-expiration :host "freenode.net" :seconds 1296000 :port 6697) Err bitreich.org 70 i 61 Err bitreich.org 70 i 62 ;; update a file modification time Err bitreich.org 70 i 63 (=> mail write-to-file :path "/tmp/reed-alert.txt") Err bitreich.org 70 i 64 Err bitreich.org 70 i 65 ;; we declare a new probe here Err bitreich.org 70 i 66 (create-probe Err bitreich.org 70 i 67 check-http-pattern Err bitreich.org 70 i 68 (command-return-code (format nil "curl ~a | grep -i ~a" Err bitreich.org 70 i 69 (getf params :url) (getf params :pattern)))) Err bitreich.org 70 i 70 Err bitreich.org 70 i 71 ;; check if the web page :url contains the text regex :pattern Err bitreich.org 70 i 72 (=> empty check-http-pattern :url "http://google.fr/" :pattern "html") Err bitreich.org 70 i 73 (=> empty check-http-pattern :url "http://127.0.0.1/" :pattern "HTML") Err bitreich.org 70 i 74 (=> empty check-http-pattern :url "http://google.fr/" :pattern "hello") ;; error Err bitreich.org 70 i 75 Err bitreich.org 70 .