osquery 実行結果の表示形式を変更する

osquery 実行結果の表示形式を変更する

osqueryで、実行結果の表示形式を変更する手順を記述してます。

環境

  • OS Ubuntu20.04
  • osquery 4.8.0

表示形式を変更

osqueryiを実行して、対話モードでクエリを実行します。

osqueryi

表示形式を変更するに「.mode」を使用します。

デフォルトは以下となります。

osquery> select pid,name,state from processes limit 5;

<出力結果>
+------+-----------------+-------+
| pid  | name            | state |
+------+-----------------+-------+
| 1    | systemd         | S     |
| 10   | ksoftirqd/0     | S     |
| 1000 | goa-identity-se | S     |
| 1001 | goa-identity-se | S     |
| 1004 | gvfs-afc-volume | S     |
+------+-----------------+-------+

「.mode line」

osquery> .mode line
osquery> select pid,name,state from processes limit 5;

<出力結果>
  pid = 1
 name = systemd
state = S

  pid = 10
 name = ksoftirqd/0
state = S

  pid = 1000
 name = goa-identity-se
state = S

  pid = 1001
 name = goa-identity-se
state = S

  pid = 1004
 name = gvfs-afc-volume
state = S

「.mode column」

osquery> .mode column
osquery> select pid,name,state from processes limit 5;

<出力結果>
pid         name        state     
----------  ----------  ----------
1           systemd     S         
10          ksoftirqd/  S         
1000        goa-identi  S         
1001        goa-identi  S         
1004        gvfs-afc-v  S 

「.mode list」

osquery> .mode list
osquery>  select pid,name,state from processes limit 5;

<出力結果>
pid|name|state
1|systemd|S
10|ksoftirqd/0|S
1000|goa-identity-se|S
1001|goa-identity-se|S
1004|gvfs-afc-volume|S

「.mode csv」

osquery> .mode csv
osquery> select pid,name,state from processes limit 5;

<出力結果>
pid,name,state
1,systemd,S
10,ksoftirqd/0,S
1000,goa-identity-se,S
1001,goa-identity-se,S
1004,gvfs-afc-volume,S

デフォルトに戻すには「.mode pretty」を実行します。

osquery> .mode pretty
osquery> select pid,name,state from processes limit 5;

<出力結果>
+------+-----------------+-------+
| pid  | name            | state |
+------+-----------------+-------+
| 1    | systemd         | S     |
| 10   | ksoftirqd/0     | S     |
| 1000 | goa-identity-se | S     |
| 1001 | goa-identity-se | S     |
| 1004 | gvfs-afc-volume | S     |
+------+-----------------+-------+