| 1 |
#compdef systemd-analyze |
| 2 |
# SPDX-License-Identifier: LGPL-2.1-or-later |
| 3 |
|
| 4 |
(( $+functions[_systemd-analyze_verify] )) || |
| 5 |
_systemd-analyze_verify() { |
| 6 |
_sd_unit_files |
| 7 |
} |
| 8 |
|
| 9 |
(( $+functions[_systemd-analyze_cat-config] )) || |
| 10 |
_systemd-analyze_cat-config() { |
| 11 |
_files -W '(/run/systemd/ /etc/systemd/ /usr/lib/systemd/)' -P 'systemd/' |
| 12 |
} |
| 13 |
|
| 14 |
(( $+functions[_systemd-analyze_inspect-elf] )) || |
| 15 |
_systemd-analyze_inspect-elf() { |
| 16 |
_files |
| 17 |
} |
| 18 |
|
| 19 |
(( $+functions[_systemd-analyze_critical-chain] )) || |
| 20 |
_systemd-analyze_critical-chain() { |
| 21 |
local -a _units |
| 22 |
systemctl list-units --no-legend --no-pager --plain --all 2>/dev/null | |
| 23 |
while read -r a b c; do |
| 24 |
_units+=($a) |
| 25 |
done |
| 26 |
compadd -a _units |
| 27 |
} |
| 28 |
|
| 29 |
(( $+functions[_systemd-analyze_security] )) || |
| 30 |
_systemd-analyze_security() { |
| 31 |
_sd_unit_files |
| 32 |
} |
| 33 |
|
| 34 |
(( $+functions[_systemd-analyze_syscall-filter] )) || |
| 35 |
_systemd-analyze_syscall-filter() { |
| 36 |
local -a _groups |
| 37 |
_groups=( $(systemd-analyze --quiet --no-pager syscall-filter 2>/dev/null | grep '^@') ) |
| 38 |
_describe -t groups 'syscall groups' _groups || compadd "$@" |
| 39 |
} |
| 40 |
|
| 41 |
(( $+functions[_systemd-analyze_filesystems] )) || |
| 42 |
_systemd-analyze_filesystems() { |
| 43 |
local -a _groups |
| 44 |
_groups=( $(systemd-analyze --quiet --no-pager filesystems 2>/dev/null | grep '^@') ) |
| 45 |
_describe -t groups 'file system groups' _groups || compadd "$@" |
| 46 |
} |
| 47 |
|
| 48 |
(( $+functions[_systemd-analyze_architectures] )) || |
| 49 |
_systemd-analyze_architectures() { |
| 50 |
local -a _architectures |
| 51 |
_architectures=( $(systemd-analyze --quiet --no-pager --no-legend architectures | { while read -r a b; do echo " $a"; done; } 2>/dev/null) ) |
| 52 |
_describe -t architectures 'architectures' _architectures || compadd "$@" |
| 53 |
} |
| 54 |
|
| 55 |
(( $+functions[_systemd-analyze_plot] )) || |
| 56 |
_systemd-analyze_plot() { |
| 57 |
local -a _options |
| 58 |
_options=( '--json=off' '--json=pretty' '--json=short' '--table' '--no-legend' ) |
| 59 |
_describe 'plot options' _options |
| 60 |
} |
| 61 |
|
| 62 |
(( $+functions[_systemd-analyze_transient-settings] )) || |
| 63 |
_systemd-analyze_transient-settings() { |
| 64 |
local -a _types |
| 65 |
_types=( $(systemctl --no-pager --no-legend -t help 2>/dev/null) ) |
| 66 |
_describe -t types 'unit types' _types |
| 67 |
} |
| 68 |
|
| 69 |
(( $+functions[_systemd-analyze_commands] )) || |
| 70 |
_systemd-analyze_commands(){ |
| 71 |
local -a _systemd_analyze_cmds |
| 72 |
# Descriptions taken from systemd-analyze --help. |
| 73 |
_systemd_analyze_cmds=( |
| 74 |
'time:Print time spent in the kernel before reaching userspace' |
| 75 |
'blame:Print list of running units ordered by time to init' |
| 76 |
'critical-chain:Print a tree of the time critical chain of units' |
| 77 |
'plot:Output SVG graphic showing service initialization, or raw time data in JSON or table format' |
| 78 |
'dot:Dump dependency graph (in dot(1) format)' |
| 79 |
'dump:Dump server status' |
| 80 |
'cat-config:Cat systemd config files' |
| 81 |
'unit-files:List files and symlinks for units' |
| 82 |
'unit-paths:List unit load paths' |
| 83 |
'exit-status:List known exit statuses' |
| 84 |
'capability:List capability definitions' |
| 85 |
'syscall-filter:List syscalls in seccomp filters' |
| 86 |
'filesystems:List known filesystems' |
| 87 |
'condition:Evaluate Condition*= and Assert*= assignments' |
| 88 |
'verify:Check unit files for correctness' |
| 89 |
'calendar:Validate repetitive calendar time events' |
| 90 |
'timestamp:Parse a systemd syntax timestamp' |
| 91 |
'timespan:Parse a systemd syntax timespan' |
| 92 |
'security:Analyze security settings of a service' |
| 93 |
'inspect-elf:Parse and print ELF package metadata' |
| 94 |
'dlopen-metadata:Parse and print ELF dlopen metadata' |
| 95 |
'has-tpm2:Report whether TPM2 support is available' |
| 96 |
'transient-settings:List transient settings for unit types' |
| 97 |
'architectures:List known architectures' |
| 98 |
'smbios11:List strings passed via SMBIOS Type #11' |
| 99 |
'chid:List local CHIDs' |
| 100 |
'compare-versions:Compare two version strings' |
| 101 |
'image-policy:Analyze image policy string' |
| 102 |
'pcrs:Show TPM2 PCRs and their names' |
| 103 |
'srk:Write TPM2 SRK (to FILE)' |
| 104 |
# log-level, log-target, service-watchdogs have been deprecated |
| 105 |
) |
| 106 |
|
| 107 |
if (( CURRENT == 1 )); then |
| 108 |
_describe "options" _systemd_analyze_cmds |
| 109 |
else |
| 110 |
local curcontext="$curcontext" |
| 111 |
cmd="${${_systemd_analyze_cmds[(r)$words[1]:*]%%:*}}" |
| 112 |
if (( $#cmd )); then |
| 113 |
if (( $+functions[_systemd-analyze_$cmd] )) && (( CURRENT == 2 )); then |
| 114 |
_systemd-analyze_$cmd |
| 115 |
else |
| 116 |
_message "no more options" |
| 117 |
fi |
| 118 |
else |
| 119 |
_message "unknown systemd-analyze command: $words[1]" |
| 120 |
fi |
| 121 |
fi |
| 122 |
} |
| 123 |
|
| 124 |
_arguments \ |
| 125 |
'(- *)'{-h,--help}'[Show help text]' \ |
| 126 |
'(- *)--version[Show package version]' \ |
| 127 |
'--system[Operate on system systemd instance]' \ |
| 128 |
'--user[Operate on user systemd instance]' \ |
| 129 |
'--global[Show global user instance config]' \ |
| 130 |
'--root=[Add support for root argument]:PATH' \ |
| 131 |
'--image=[Add support for discrete images]:PATH' \ |
| 132 |
'--recursive-errors=[When verifying a unit, control dependency verification]:MODE' \ |
| 133 |
'--offline=[Perform a security review of the specified unit files]:BOOL:(yes no)' \ |
| 134 |
'--threshold=[Set a value to compare the overall security exposure level with]: NUMBER' \ |
| 135 |
'--security-policy=[Use customized requirements to compare unit files against]: PATH' \ |
| 136 |
"--json=[Generate a JSON output of the security analysis table or plot's raw time data]:MODE:(pretty short off)" \ |
| 137 |
"--table=[Generate a table of plot's raw time data]" \ |
| 138 |
'--profile=[Include the specified profile in the security review of units]: PATH' \ |
| 139 |
'--no-pager[Do not pipe output into a pager]' \ |
| 140 |
"--no-legend[Do not show the headers and footers for plot's raw time data formats]" \ |
| 141 |
'--man=[Do (not) check for existence of man pages]:BOOL:(yes no)' \ |
| 142 |
'--generators=[Do (not) run unit generators]:BOOL:(yes no)' \ |
| 143 |
'--order[When generating graph for dot, show only order]' \ |
| 144 |
'--require[When generating graph for dot, show only requirement]' \ |
| 145 |
'--fuzz=[When printing the tree of the critical chain, print also services, which finished TIMESPAN earlier, than the latest in the branch]:TIMESPAN' \ |
| 146 |
'--from-pattern=[When generating a dependency graph, filter only origins]:GLOB' \ |
| 147 |
'--to-pattern=[When generating a dependency graph, filter only destinations]:GLOB' \ |
| 148 |
'(-H --host)'{-H+,--host=}'[Operate on remote host]:userathost:_sd_hosts_or_user_at_host' \ |
| 149 |
'(-M --machine)'{-M+,--machine=}'[Operate on local container]:machine:_sd_machines' \ |
| 150 |
'--quiet[Do not show hints]' \ |
| 151 |
'*::systemd-analyze commands:_systemd-analyze_commands' |