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