1
0
mirror of git://bitreich.org/reed-alert synced 2024-06-18 15:17:04 +00:00

[FIX] Return value of disk-used was a disk-used string instead of the variable

This commit is contained in:
solene rapenne 2016-10-10 20:35:49 +02:00
parent c3f594da02
commit 9b5e9bd4a8

View File

@ -1,6 +1,10 @@
(defmacro create-probe(name &body code) (defmacro create-probe(name &body code)
`(progn (defun ,name(params) ,@code))) `(progn (defun ,name(params) ,@code)))
(defun get-file-size(path)
(with-open-file (stream path)
(and stream (file-length path))))
(defun command-return-code(command) (defun command-return-code(command)
(let ((code (nth-value 2 (uiop:run-program command :ignore-error-status t)))) (let ((code (nth-value 2 (uiop:run-program command :ignore-error-status t))))
(if (= 0 code) (if (= 0 code)
@ -44,7 +48,7 @@
percent-character-pos)))) percent-character-pos))))
(if (< used-disk (getf params :limit)) (if (< used-disk (getf params :limit))
t t
(list nil "used-disk")))))) (list nil used-disk))))))
(defun system-load(time) (defun system-load(time)
(read-from-string (read-from-string
@ -75,6 +79,24 @@
t t
(list nil load)))) (list nil load))))
(create-probe
file-more-than
(if (probe-file (getf params :path))
(let ((result (get-file-size (getf params :path))))
(if (< result (getf params :limit))
t
(list nil result)))
"file not found"))
(create-probe
file-less-than
(if (probe-file (getf params :path))
(let ((result (get-file-size (getf params :path))))
(if (> result (getf params :limit))
t
(list nil result)))
"file not found"))
(create-probe (create-probe
command command
(command-return-code (getf params :command))) (command-return-code (getf params :command)))