Compare commits

...

4 Commits

Author SHA1 Message Date
Solène Rapenne b9d5e56837
display date in test 2023-06-28 10:55:17 +02:00
Solène Rapenne 3872389e3a
use leading zeros for date and ISO date format 2023-06-28 10:54:58 +02:00
Solène Rapenne 46c03914d4
rename file-exists into check-file-exists 2023-06-28 10:54:37 +02:00
Solène Rapenne 93bc94cbac
fix local tests 2023-06-28 10:54:06 +02:00
6 changed files with 15 additions and 11 deletions

View File

@ -7,13 +7,17 @@ all: reed-alert
reed-alert: reed-alert.in
sed 's,REEDDIR=,&${LISPDIR},' reed-alert.in > reed-alert
reed-alert-test: reed-alert.in
sed 's,REEDDIR=,&../,' reed-alert.in > reed-alert
install: reed-alert
mkdir -p ${LISPDIR}
mkdir -p ${PREFIX}/bin
install -o root -g bin -m 755 reed-alert ${PREFIX}/bin/reed-alert
install -o root -g wheel -m 644 probes.lisp functions.lisp ${LISPDIR}/
test: reed-alert
test: reed-alert-test
cd test && sh ../reed-alert test.lisp
clean:

10
README
View File

@ -195,7 +195,7 @@ As of this commit, reed-alert ships with the following probes:
(1) number-of-processes
(2) pid-running
(3) disk-usage
(4) file-exists
(4) check-file-exists
(5) file-updated
(6) load-average-1
(7) load-average-5
@ -239,14 +239,14 @@ Check if the disk-usage of a chosen partition does exceed a specific limit.
Example: `(=> alert disk-usage :path "/tmp" :limit 50)`
file-exists
check-file-exists
-----------
Check if a file exists.
> Set the path of the file to check.
:path "STRING"
Example: `(=> alert file-exists :path "/var/postgresql/standby")`
Example: `(=> alert check-file-exists :path "/var/postgresql/standby")`
file-updated
@ -521,10 +521,10 @@ but one may want to do it in LISP, allowing to use full features of
the language and even some libraries to check values in a database for
example. I recommend to read the "probes.lisp" file, it's the best way
to learn how to write a new probe. But as an example, we will learn
from the easiest probe included : file-exists
from the easiest probe included : check-file-exists
(create-probe
file-exists
check-file-exists
(let ((result (probe-file (getf params :path))))
(if result
t

View File

@ -13,8 +13,8 @@
(=> peroket disk-usage :path "/tmp" :limit 0) ;; failure
;; check if :path file exists
(=> mail file-exists :path "/bsd.rd" :desc "OpenBSD kernel /bsd.rd")
(=> empty file-exists :path "/non-existant-file" :try 3) ;; failure file not found
(=> mail check-file-exists :path "/bsd.rd" :desc "OpenBSD kernel /bsd.rd")
(=> empty check-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)

View File

@ -78,7 +78,7 @@
(multiple-value-bind
(second minute hour day month year)
(get-decoded-time)
(format nil "~a/~a/~a ~a:~a:~a" year month day hour minute second))))
(format nil "~d-~2,'0d-~2,'0d ~2,'0d:~2,'0d:~2,'0d" year month day hour minute second))))
command-string))
(defmacro stop-if-error(&body body)

View File

@ -1,5 +1,5 @@
(create-probe
file-exists
check-file-exists
(let ((result (probe-file (getf params :path))))
(if result
t

View File

@ -1,7 +1,7 @@
(setf *tries* 2)
(setf *reminder* 5)
(alert notification "echo '%state% %function% %params% %result%'")
(alert notification "echo '%state% %function% %params% %result% %date%'")
;; check for /tmp/ disk usage
;; create a big file to increase size