diff options
Diffstat (limited to 'elisp/cmk.el')
-rw-r--r-- | elisp/cmk.el | 40 |
1 files changed, 5 insertions, 35 deletions
diff --git a/elisp/cmk.el b/elisp/cmk.el index 790aa8b..c31b2b9 100644 --- a/elisp/cmk.el +++ b/elisp/cmk.el @@ -73,15 +73,11 @@ Default is \"%Y-%m-%d %H:%M\"." " "))) (defconst cmk-problem-col-spec - `(("STATE" 5 t :column "service_state" :parser cmk-state-coloring ) - ("Host" 9 t :column "host_name") - ("Service" 20 t :column "service_description") - ("Since" 16 ,(lambda (a b) - (time-less-p - (encode-time (parse-time-string (elt (cadr a) 3))) - (encode-time (parse-time-string (elt (cadr b) 3))))) - :column "service_last_state_change" :parser cmk-timestamp-to-date) - ("Check output" 18 t :column "service_plugin_output" :parser cmk-purge-bangs))) + `((:name "STATE" :column "service_state" :formatter cmk-state-coloring :min-width 6) + (:name "Host" :column "host_name") + (:name "Service" :column "service_description") + (:name "Since" :column "service_last_state_change" :formatter cmk-timestamp-to-date :min-width 18) + (:name "Check output" :column "service_plugin_output" :formatter cmk-purge-bangs))) (defconst cmk-log-col-spec '(;("host_state" :column "host_state" :parser cmk-state-coloring) @@ -98,25 +94,6 @@ Default is \"%Y-%m-%d %H:%M\"." ;; ("host_has_been_checked" :column "host_has_been_checked") (:name "log_plugin_output" :column "log_plugin_output"))) -(defun cmk-parse-rows (buffer column-spec) - "Return tabulated entries from BUFFER according to COLUMN-SPEC." - (with-current-buffer buffer - (goto-char (point-min)) - (let (rows - (parsers (mapcar (lambda (spec) - (or (plist-get (cdddr spec) :parser) #'identity)) - column-spec))) - (while (not (eobp)) - (thread-first - (list (count-lines 1 (point)) - (cl-map 'vector - (lambda (parser entry) (funcall parser entry)) - parsers - (split-string (thing-at-point 'line t) ";" nil "\n"))) - (push rows)) - (forward-line)) - (nreverse rows)))) - (defun cmk-livestatus-query (query) "One shot livestatus QUERY, return network process." (let ((cmks (cmk-oneshot 'keep))) @@ -127,13 +104,6 @@ Default is \"%Y-%m-%d %H:%M\"." (defvar-local cmk-livestatus-query "" "Livestatus query in buffer.") -(defun cmk-table--refresh () - "Query and reprint the Livestatus query result table." - (let ((cmks (cmk-livestatus-query cmk-livestatus-query))) - (accept-process-output cmks 0.1) - (setq tabulated-list-entries (cmk-parse-rows (process-buffer cmks) tabulated-list-format)) - (tabulated-list-print 'remember))) - (defun cmk-timestamp-eldoc-documentation () (when-let ((number (thing-at-point 'number))) (format-time-string "%Y-%m-%d %H:%M" (seconds-to-time number)))) |