我怎样才能find失败的systemd服务?

当我在一台特定的服务器上运行systemd status时,我得到以下输出:

 ● ⟨host-name⟩ State: degraded Jobs: 0 queued Failed: 1 units Since: Fr 2017-06-09 00:34:27 UTC; 1 weeks 5 days ago CGroup: / … 

如何找出哪些服务是失败的?

我尝试了systemctl is-failed '*' ,但没有产生任何有意义的输出(输出39行active一个failed行,然后一些更多(> 100) active行…)。

这似乎is-failed是错误的子命令…谁会猜到。

这里有一些perl hackery来得到正确的答案:

 $ systemctl list-units | perl -lanE'print if $F[2] !~ /active/' UNIT LOAD ACTIVE SUB DESCRIPTION ● vboxautostart-service.service loaded failed failed vboxautostart-service.service LOAD = Reflects whether the unit definition was properly loaded. ACTIVE = The high-level unit activation state, ie generalization of SUB. SUB = The low-level unit activation state, values depend on unit type. 207 loaded units listed. Pass --all to see loaded but inactive units, too. To show all installed unit files use 'systemctl list-unit-files'. 

而且systemctl也很好地处理信息输出的stderr,只有我们才能得到我们想要的输出。