質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
systemd

systemdは、Linuxの起動処理及びシステム管理を行う技術です。他にも多くのサービス管理機能を備えており、ユーザープロセスを並列に起動しシステムの起動処理に要する時間を短縮できるなどの特徴があります。

Linux

Linuxは、Unixをベースにして開発されたオペレーティングシステムです。日本では「リナックス」と呼ばれています。 主にWebサーバやDNSサーバ、イントラネットなどのサーバ用OSとして利用されています。 上位500のスーパーコンピュータの90%以上はLinuxを使用しています。 携帯端末用のプラットフォームAndroidは、Linuxカーネル上に構築されています。

Q&A

解決済

1回答

2825閲覧

systemctl status で Unit, 起動状態 のみ表示するオプション

teityura

総合スコア84

systemd

systemdは、Linuxの起動処理及びシステム管理を行う技術です。他にも多くのサービス管理機能を備えており、ユーザープロセスを並列に起動しシステムの起動処理に要する時間を短縮できるなどの特徴があります。

Linux

Linuxは、Unixをベースにして開発されたオペレーティングシステムです。日本では「リナックス」と呼ばれています。 主にWebサーバやDNSサーバ、イントラネットなどのサーバ用OSとして利用されています。 上位500のスーパーコンピュータの90%以上はLinuxを使用しています。 携帯端末用のプラットフォームAndroidは、Linuxカーネル上に構築されています。

0グッド

0クリップ

投稿2020/09/21 12:29

前提・実現したいこと

systemd でワイルドカードを使って、ceph*.{target,service} の
Unitと起動状態だけ を取り出すオプションを知りたいです。

試したこと1

起動状態のみ表示するオプションがありそうで、
man systemctl 見たところ、is-active を見つけましたが、
ワイルドカードで表示しているため、サービス名が表示されず、
何のUnitがどういう状態なのか分からない結果となりました。

grepで絞るなら、下記のイメージです。

# なんのUnitか分からない systemctl is-active ceph*.service ceph*.target -a inactive inactive inactive failed inactive # grep ならこのように絞れるが、もっと楽な確認方法はないでしょうか systemctl status ceph*.service ceph*.target -a | grep -e '(target\|service) - ' -e 'Active: ' ● ceph-mon@ceph1.service - Ceph cluster monitor daemon Active: inactive (dead) since Mon 2020-09-21 02:23:48 EDT; 5h 26min ago ● ceph-mon.target - ceph target allowing to start/stop all ceph-mon@.service instances at once Active: inactive (dead) since Mon 2020-09-21 02:23:48 EDT; 5h 26min ago ● ceph-osd.target - ceph target allowing to start/stop all ceph-osd@.service instances at once Active: inactive (dead) since Mon 2020-09-21 02:23:48 EDT; 5h 26min ago ● ceph-radosgw@rgw.ceph1.service - Ceph rados gateway Active: failed (Result: timeout) since Mon 2020-09-21 02:25:18 EDT; 5h 25min ago ● ceph-mgr.target - ceph target allowing to start/stop all ceph-mgr@.service instances at once Active: inactive (dead) since Mon 2020-09-21 02:23:48 EDT; 5h 26min ago ● ceph-radosgw.target - ceph target allowing to start/stop all ceph-radosgw@.service instances at once Active: inactive (dead) since Mon 2020-09-21 02:23:48 EDT; 5h 26min ago ● ceph-crash.service - Ceph crash dump collector Active: inactive (dead) since Mon 2020-09-21 02:23:48 EDT; 5h 26min ago ● ceph-mgr@ceph1.service - Ceph cluster manager daemon Active: inactive (dead) since Mon 2020-09-21 02:23:48 EDT; 5h 26min ago ● ceph.target - ceph target allowing to start/stop all ceph*@.service instances at once Active: inactive (dead) since Mon 2020-09-21 02:23:48 EDT; 5h 26min ago ● ceph-volume@lvm-0-24d9456d-f020-4ce3-8f88-541b3a499370.service - Ceph Volume activation: lvm-0-24d9456d-f020-4ce3-8f88-541b3a499370 Active: inactive (dead) ● ceph-osd@0.service - Ceph object storage daemon osd.0 Active: inactive (dead) since Mon 2020-09-21 02:23:48 EDT; 5h 26min ago ● ceph-mds@ceph1.service - Ceph metadata server daemon Active: inactive (dead) since Mon 2020-09-21 02:23:51 EDT; 5h 26min ago ● ceph-mds.target - ceph target allowing to start/stop all ceph-mds@.service instances at once Active: inactive (dead) since Mon 2020-09-21 02:23:48 EDT; 5h 26min ago

試したこと2

list-dependencies で ceph.target の依存関係のある service を表示できたが、
-type=service に対して status を実行するような サブコマンド, オプション等が見つからなかった

systemctl list-dependencies ceph.target ceph.target ● ├─ceph-crash.service ● ├─ceph-mds.target ● │ └─ceph-mds@ceph1.service ● ├─ceph-mgr.target ● │ └─ceph-mgr@ceph1.service ● ├─ceph-mon.target ● │ └─ceph-mon@ceph1.service ● ├─ceph-osd.target ● │ └─ceph-osd@0.service ● └─ceph-radosgw.target ● └─ceph-radosgw@rgw.ceph1.service

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

ベストアンサー

systemctl --all list-units サービス名で得られたリスト(と余分な情報)から、awkで必要な部分だけを取得する。

terminal

1$ systemctl --all list-units ssh*service | gawk 'NR == 2,/^$/ {if (NF>0) printf("%s\t%s\n",$1,$3)}' 2sshd-keygen.service inactive 3sshd.service active

投稿2020/09/21 13:25

Daregada

総合スコア11990

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

teityura

2020/10/09 10:52

awk等で欲しい部分を取得するしかないですよね。 ありがとうございます!
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問