[DEV] Move functions from probes to funcs - 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 --- DIR commit 8a7e81410bf964feeecd139d551ddd143f730e58 DIR parent 9b5e9bd4a8ff642b8a7408fc0f3e3dec11aa613d HTML Author: solene rapenne <solene@dataswamp.org> Date: Fri, 14 Oct 2016 14:20:36 +0200 [DEV] Move functions from probes to funcs Diffstat: M functions.lisp | 17 ++++++++++++++++- M probes.lisp | 13 ------------- 2 files changed, 16 insertions(+), 14 deletions(-) --- DIR diff --git a/functions.lisp b/functions.lisp @@ -1,5 +1,5 @@ (require 'asdf) -(load "probes.lisp") + (defun color(num1 num2) (format nil "~a[~a;~am" #\Escape num1 num2)) @@ -9,6 +9,19 @@ (defparameter *green* (color 1 32)) (defparameter *yellow* (color 0 33)) +(defmacro create-probe(name &body 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) + (let ((code (nth-value 2 (uiop:run-program command :ignore-error-status t)))) + (if (= 0 code) + t + (list nil (format nil "return code = ~a" code))))) + (defun trigger-alert(level function params result) (format nil "~{~a~}" (mapcar #'(lambda(x) @@ -48,3 +61,5 @@ (format t " => ~aerror~a~%" *red* *white*) (uiop:run-program (trigger-alert ',level ',fonction ',params (cadr result)) :output t) nil))))) + +(load "probes.lisp") DIR diff --git a/probes.lisp b/probes.lisp @@ -1,16 +1,3 @@ -(defmacro create-probe(name &body 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) - (let ((code (nth-value 2 (uiop:run-program command :ignore-error-status t)))) - (if (= 0 code) - t - (list nil (format nil "return code = ~a" code))))) - (create-probe file-exists (let ((result (probe-file (getf params :path))))