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_critical-chain] )) || 15 _systemd-analyze_critical-chain() { 16 local -a _units 17 systemctl list-units --no-legend --no-pager --plain --all | 18 while read -r a b c; do 19 _units+=($a) 20 done 21 compadd -a _units 22 } 23 24(( $+functions[_systemd-analyze_security] )) || 25 _systemd-analyze_security() { 26 _sd_unit_files 27 } 28 29(( $+functions[_systemd-analyze_syscall-filter] )) || 30 _systemd-analyze_syscall-filter() { 31 local -a _groups 32 _groups=( $(systemd-analyze --quiet --no-pager syscall-filter | grep '^@') ) 33 _describe -t groups 'syscall groups' _groups || compadd "$@" 34 } 35 36(( $+functions[_systemd-analyze_filesystems] )) || 37 _systemd-analyze_filesystems() { 38 local -a _groups 39 _groups=( $(systemd-analyze --quiet --no-pager filesystems | grep '^@') ) 40 _describe -t groups 'file system groups' _groups || compadd "$@" 41 } 42 43(( $+functions[_systemd-analyze_commands] )) || 44 _systemd-analyze_commands(){ 45 local -a _systemd_analyze_cmds 46 # Descriptions taken from systemd-analyze --help. 47 _systemd_analyze_cmds=( 48 'time:Print time spent in the kernel before reaching userspace' 49 'blame:Print list of running units ordered by time to init' 50 'critical-chain:Print a tree of the time critical chain of units' 51 'plot:Output SVG graphic showing service initialization' 52 'dot:Dump dependency graph (in dot(1) format)' 53 'dump:Dump server status' 54 'cat-config:Cat systemd config files' 55 'unit-files:List files and symlinks for units' 56 'unit-paths:List unit load paths' 57 'exit-status:List known exit statuses' 58 'capability:List capability definitions' 59 'syscall-filter:List syscalls in seccomp filters' 60 'filesystems:List known filesystems' 61 'condition:Evaluate Condition*= and Assert*= assignments' 62 'verify:Check unit files for correctness' 63 'calendar:Validate repetitive calendar time events' 64 'timestamp:Parse a systemd syntax timestamp' 65 'timespan:Parse a systemd syntax timespan' 66 'security:Analyze security settings of a service' 67 'inspect-elf:Parse and print ELF package metadata' 68 # log-level, log-target, service-watchdogs have been deprecated 69 ) 70 71 if (( CURRENT == 1 )); then 72 _describe "options" _systemd_analyze_cmds 73 else 74 local curcontext="$curcontext" 75 cmd="${${_systemd_analyze_cmds[(r)$words[1]:*]%%:*}}" 76 if (( $#cmd )); then 77 if (( $+functions[_systemd-analyze_$cmd] )) && (( CURRENT == 2 )); then 78 _systemd-analyze_$cmd 79 else 80 _message "no more options" 81 fi 82 else 83 _message "unknown systemd-analyze command: $words[1]" 84 fi 85 fi 86 } 87 88_arguments \ 89 {-h,--help}'[Show help text]' \ 90 '--version[Show package version]' \ 91 '--system[Operate on system systemd instance]' \ 92 '--user[Operate on user systemd instance]' \ 93 '--global[Show global user instance config]' \ 94 '--root=[Add support for root argument]:PATH' \ 95 '--image=[Add support for discrete images]:PATH' \ 96 '--recursive-errors=[When verifying a unit, control dependency verification]:MODE' \ 97 '--offline=[Perform a security review of the specified unit files]:BOOL:(yes no)' \ 98 '--threshold=[Set a value to compare the overall security exposure level with]: NUMBER' \ 99 '--security-policy=[Allow user to use customized requirements to compare unit file(s) against]: PATH' \ 100 '--json=[Generate a JSON output of the security analysis table]:MODE:(pretty short off)' \ 101 '--profile=[Include the specified profile in the security review of the unit(s)]: PATH' \ 102 '--no-pager[Do not pipe output into a pager]' \ 103 '--man=[Do (not) check for existence of man pages]:BOOL:(yes no)' \ 104 '--generators=[Do (not) run unit generators]:BOOL:(yes no)' \ 105 '--order[When generating graph for dot, show only order]' \ 106 '--require[When generating graph for dot, show only requirement]' \ 107 '--fuzz=[When printing the tree of the critical chain, print also services, which finished TIMESPAN earlier, than the latest in the branch]:TIMESPAN' \ 108 '--from-pattern=[When generating a dependency graph, filter only origins]:GLOB' \ 109 '--to-pattern=[When generating a dependency graph, filter only destinations]:GLOB' \ 110 {-H+,--host=}'[Operate on remote host]:userathost:_sd_hosts_or_user_at_host' \ 111 {-M+,--machine=}'[Operate on local container]:machine:_sd_machines' \ 112 '--quiet[Do not show hints]' \ 113 '*::systemd-analyze commands:_systemd-analyze_commands' 114