journalctl-mode
journalctl-mode copied to clipboard
Show failed units when listing units
First of all, thank you very much for creating this package, I've been wanting something like this for a long time.
The reason that I most often have to look at my systemd
units is that one of them has failed (most often because I am experimenting with a new unit). Unfortunately, failed units are not listed on my system when I use journalctl-unit
or journalctl-user-unit
. I believe this is because list-units
by default outputs an initial column with a ●
symbol for failed units, and your parsing removes these lines:
https://github.com/SebastianMeisel/journalctl-mode/blob/c5bca1a5f42d2fe2a00fdf52fe480137ace971d3/journalctl-mode.el#L284
It might have been a deliberate decision to exclude failed units from the list, but I'd ask you to consider changing this as failing units are most often the ones that are interesting to examine.
There is an option for turning off the ●
symbol in list-units
's output (see man systemctl(1)
):
--plain
When used with list-dependencies, list-units or list-machines, the
output is printed as a list instead of a tree, and the bullet
circles are omitted.
The following change seems to do the trick for me:
modified journalctl-mode.el
@@ -275,13 +275,17 @@ If BOOT is provided it is the number of the boot-log to be shown."
(shell-command-to-string "journalctl --list-boots") "[\n]" t " ")) nil t))))))
(journalctl (concat "-b '" boot-log "'"))))
+(defvar journalctl-list-units-format
+ "systemctl list-units --all --quiet --plain %s | awk '{print $1}' | head -n -7 | sed -ne '2,$p'"
+ "Format string for listing units, accepting a single substitution for additional options.")
+
;;;###autoload
(defun journalctl-unit (&optional unit)
"Select and show journal for UNIT."
(interactive)
(let ((unit (or unit (car (split-string
(completing-read "unit: " (split-string
- (shell-command-to-string "systemctl list-units --all --quiet | awk '{print $1}' | head -n -7 | sed -ne '2,$p'| sed -e '/●/d'") "[\n]" t " ") nil t))))))
+ (shell-command-to-string (format journalctl-list-units-format "")) "[\n]" t " ") nil t))))))
(journalctl (concat "--unit='" unit "'"))))
;;;###autoload
@@ -290,7 +294,7 @@ If BOOT is provided it is the number of the boot-log to be shown."
(interactive)
(let ((unit (or unit (car (split-string
(completing-read "unit: " (split-string
- (shell-command-to-string "systemctl list-units --all --user --quiet | awk '{print $1}' | head -n -7 | sed -ne '2,$p'| sed -e '/●/d'") "[\n]" t " ") nil t))))))
+ (shell-command-to-string (format journalctl-list-units-format "--user")) "[\n]" t " ") nil t))))))
(journalctl (concat "--user-unit='" unit "'"))))