osquery —— 来自Facebook的操作系统监控工具
osquery 是 SQL 驱动的分析和监控操作系统的工具,是操作系统分析框架,支持 OS X 和 Linux 系统。osquery 能帮助监控和分析低水平的操作系统,提供更直观的性能监控。
osquery 在操作系统中就像是一个高性能的关系数据库,允许你编写基于 SQL 的查询语句来洞察操作系统的数据。使用 osquery,SQL 表代表如下抽象概念:
SQL 表通过一个简单的可扩展 API 实现,各种表已经存在并且还在不断增加。
为了更好的理解 osquery,看看下面的 SQL 查询:
1
2
3
4
5
6
7
8
9
10
11
12
|
--------------------------------------------------------
-- get the name, pid and attached port of all processes
-- which are listening on all interfaces
--------------------------------------------------------
SELECT DISTINCT
process.name,
listening.port,
process.pid
FROM processes AS process
JOIN listening_ports AS listening
ON process.pid = listening.pid
WHERE listening.address = '0.0.0.0';
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
--------------------------------------------------------
-- find every launchdaemon on an OS X host which
-- * launches an executable when the operating
-- system starts
-- * keeps the executable running
-- return the name of the launchdaemon and the full
-- path (with arguments) of the executable to be ran.
--------------------------------------------------------
SELECT
name,
program || program_arguments AS executable
FROM launchd
WHERE
(run_at_load = 'true' AND keep_alive = 'true')
AND
(program != '' OR program_arguments != '');
|
这些查询可以:
-
在特定条件下探索操作系统状态
-
通过执行调度程序来监控操作系统的主机状态
-
启动使用osquery api的自定义应用程序