gpt4 book ai didi

sqlite - 如何将从 Osquery 触发的 SQL 查询的输出保存到文件

转载 作者:行者123 更新时间:2023-12-03 18:42:33 25 4
gpt4 key购买 nike

我已经在我的机器上安装了 Osquery 实用程序。当我启动 SQL 命令时,它会将输出提供给 STDOUT。有什么方法可以将该输出重定向到文件吗?

$ sudo osqueryi 
I0314 10:57:51.644351 3958 database.cpp:563] Checking database version for migration
I0314 10:57:51.644912 3958 database.cpp:587] Performing migration: 0 -> 1
I0314 10:57:51.645279 3958 database.cpp:619] Migration 0 -> 1 successfully completed!
I0314 10:57:51.645627 3958 database.cpp:587] Performing migration: 1 -> 2
I0314 10:57:51.646088 3958 database.cpp:619] Migration 1 -> 2 successfully completed!
Using a virtual database. Need help, type '.help'
osquery>
osquery>
osquery> SELECT * from memory_info;
+--------------+-------------+----------+----------+-------------+-----------+----------+------------+-----------+
| memory_total | memory_free | buffers | cached | swap_cached | active | inactive | swap_total | swap_free |
+--------------+-------------+----------+----------+-------------+-----------+----------+------------+-----------+
| 513617920 | 270921728 | 15110144 | 99860480 | 0 | 145080320 | 59494400 | 0 | 0 |
+--------------+-------------+----------+----------+-------------+-----------+----------+------------+-----------+
osquery>

我想把这个输出放在一个文件中。我检查了 Osquery 官方文档。但它对解决这个特定问题没有帮助。 https://osquery.readthedocs.io/en/stable/introduction/sql/#sql-as-understood-by-osquery

最佳答案

您可以使用 shell 的重定向功能:

$ osqueryi --json 'select * from osquery_info' > res.json
$ cat res.json
[
{"build_distro":"10.12","build_platform":"darwin","config_hash":"e7c68185a7252c23585d53d04ecefb77b3ebf99c","config_valid":"1","extensions":"inactive","instance_id":"38201952-9a75-41dc-b2f8-188c2119cda1","pid":"26255","start_time":"1552676034","uuid":"4740D59F-699E-5B29-960B-979AAF9BBEEB","version":"3.3.0","watcher":"-1"}
]

请注意,在此示例中,我们使用 JSON 输出。还有其他可用选项:--csv--line--list

正如 seph 在 https://stackoverflow.com/a/55164199/491710 中解释的那样,在 osqueryd 中安排查询并将结果推送到日志记录管道是一个常见的用例。

关于sqlite - 如何将从 Osquery 触发的 SQL 查询的输出保存到文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55160888/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com