diff options
author | Oscar Najera <hi@oscarnajera.com> | 2025-01-17 10:16:02 +0100 |
---|---|---|
committer | Oscar Najera <hi@oscarnajera.com> | 2025-01-17 10:16:02 +0100 |
commit | 84b0f73739386ebaa9ec986f025a51815a1204cb (patch) | |
tree | f7cc87fb0f9fef51a744970c6b84430b6073e6fa /elisp/cmk.el | |
parent | 5285a701450cbf05dd9719d4573a0cf660a1c4d3 (diff) | |
download | dotfiles-84b0f73739386ebaa9ec986f025a51815a1204cb.tar.gz dotfiles-84b0f73739386ebaa9ec986f025a51815a1204cb.tar.bz2 dotfiles-84b0f73739386ebaa9ec986f025a51815a1204cb.zip |
[cmk] merge problems view
Diffstat (limited to 'elisp/cmk.el')
-rw-r--r-- | elisp/cmk.el | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/elisp/cmk.el b/elisp/cmk.el index c31b2b9..ebe1b55 100644 --- a/elisp/cmk.el +++ b/elisp/cmk.el @@ -179,36 +179,39 @@ Default is \"%Y-%m-%d %H:%M\"." (vtable-revert-command))))) (switch-to-buffer edit-buffer))) -(defun cmk-view (table spec filters) +(defun cmk-vtable (table spec filters) "Render a tabular view for livestatus TABLE with SPEC columns using FILTERS." - (with-current-buffer (get-buffer-create "*CMK View*") - (fundamental-mode) - (erase-buffer) - (setq-local cmk-livestatus-query - (format "GET %s\n%s\n%s\n%s\n\n" - table - (cmk-colums-from-spec spec) - filters - "OutputFormat: json")) + (let ((livestatus-query + (format "GET %s\n%s\n%s\n%s\n\n" + table + (cmk-colums-from-spec spec) + filters + "OutputFormat: json"))) (make-vtable :columns (mapcar (lambda (li) (map-delete (map-copy li) :column)) spec) :use-header-line nil :objects-function (lambda () - (let ((cmks (cmk-livestatus-query cmk-livestatus-query))) + (let ((cmks (cmk-livestatus-query livestatus-query))) (accept-process-output cmks 0.1) (with-current-buffer (process-buffer cmks) (goto-char (point-min)) (json-parse-buffer :array-type 'list)))) :keymap (define-keymap - "Q" #'cmk-edit-lq)) - (switch-to-buffer (current-buffer)))) + "Q" #'cmk-edit-lq + "q" #'kill-buffer-and-window + "v" (lambda () + (interactive) + (message "loc %S" livestatus-query)))))) (defun cmk-problems () "Render default problems view." (interactive) - (cmk-view "services" cmk-problem-col-spec - "Filter: service_state = 0 + (with-current-buffer (get-buffer-create "*CMK View*") + (fundamental-mode) + (erase-buffer) + (cmk-vtable "services" cmk-problem-col-spec + "Filter: service_state = 0 Filter: service_has_been_checked = 1 And: 2 Negate: @@ -224,24 +227,21 @@ Negate: Filter: host_state = 2 Filter: host_has_been_checked = 1 And: 2 -Negate:")) - - -(defun cmk-log-prob () - "Render default event log view." - (interactive) - (cmk-view "log" cmk-log-col-spec - (format - "Filter: log_time >= %d +Negate:") + (goto-char (point-max)) + (insert "\n") + (cmk-vtable "log" cmk-log-col-spec + (format + "Filter: log_time >= %d Filter: class = 1 Filter: class = 3 Filter: class = 8 Or: 3 Filter: log_state_type = HARD" - (floor - (- (time-to-seconds (current-time)) - (* 24 3600)))))) - + (floor + (- (time-to-seconds (current-time)) + (* 24 3600))))) + (switch-to-buffer (current-buffer)))) ;;; Get a different csv ;; (let* ((cmks (cmk-oneshot t))) |