aboutsummaryrefslogtreecommitdiffstats
path: root/elisp
diff options
context:
space:
mode:
authorOscar Najera <hi@oscarnajera.com>2022-12-20 19:06:45 +0100
committerOscar Najera <hi@oscarnajera.com>2022-12-20 19:06:45 +0100
commita1520c00730416a1414856b8325cc5cd12fede2f (patch)
tree55a899a1834ffd7419c72bdbc885bc4217443690 /elisp
parentff09173d4c8d4fa576fae197869ea2a9d17b626a (diff)
downloaddotfiles-a1520c00730416a1414856b8325cc5cd12fede2f.tar.gz
dotfiles-a1520c00730416a1414856b8325cc5cd12fede2f.tar.bz2
dotfiles-a1520c00730416a1414856b8325cc5cd12fede2f.zip
cmk timesort and line parse
Diffstat (limited to 'elisp')
-rw-r--r--elisp/cmk.el32
1 files changed, 20 insertions, 12 deletions
diff --git a/elisp/cmk.el b/elisp/cmk.el
index 2b6f449..df424ad 100644
--- a/elisp/cmk.el
+++ b/elisp/cmk.el
@@ -67,10 +67,14 @@ Default is \"%Y-%m-%d %H:%M\"."
" ")))
(defconst cmk-problem-col-spec
- '(("STATE" 5 t :column "service_state" :parser cmk-state-coloring )
+ `(("STATE" 5 t :column "service_state" :parser cmk-state-coloring )
("Host" 9 t :column "host_name")
("Service" 20 t :column "service_description")
- ("Since" 16 nil :column "service_last_state_change" :parser cmk-timestamp-to-date)
+ ("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)))
(defconst cmk-log-col-spec
@@ -92,16 +96,20 @@ Default is \"%Y-%m-%d %H:%M\"."
"Return tabulated entries from BUFFER according to COLUMN-SPEC."
(with-current-buffer buffer
(goto-char (point-min))
- (cl-loop until (eobp)
- collect
- (list (count-lines 1 (point))
- (cl-map 'vector
- (lambda (entry spec)
- (let ((parser (or (plist-get (cdddr spec) :parser) #'identity)))
- (funcall parser entry)))
- (split-string (buffer-substring-no-properties (point) (line-end-position)) ";")
- column-spec))
- do (forward-line))))
+ (let (rows
+ (parsers (mapcar (lambda (spec)
+ (or (plist-get (cdddr spec) :parser) #'identity))
+ column-spec)))
+ (while (not (eobp))
+ (push
+ (list (count-lines 1 (point))
+ (cl-map 'vector
+ (lambda (parser entry) (funcall parser entry))
+ parsers
+ (split-string (thing-at-point 'line t) ";" nil "\n")))
+ rows)
+ (forward-line))
+ (nreverse rows))))
(defun cmk-livestatus-query (query)
"One shot livestatus QUERY, return network process."