概述
监控是一种监视当前系统状态的方式。在 SequoiaDB 中,用户可以使用快照(SNAPSHOT)与列表(LIST)命令进行系统监控。
快照视图
快照是一种得到系统当前状态的命令,主要分为以下类型:
列表视图
列表是一种轻量级的得到系统当前状态的命令,主要分为以下类型:
SQL到SequoiaDB映射表
下表列出了 SQL 快照查询语句的操作在 API 中对应的快照操作:
SQL 语句 | API 语句 |
---|
select <sel> from $<snapshot> where <cond> order by <sort> | db.snapshot( , [cond], [sel], [sort] ) |
db.exec( "select from $SNAPSHOT_CONTEXT where SessionID = 20" ) | 过滤指定条件的记录。db.snapshot(SDB_SNAP_CONTEXTS, { SessionID: 20 } ) |
db.exec( " select NodeName from $SNAPSHOT_CONTEXT " ) | 只显示记录的指定字段。db.snapshot(SDB_SNAP_CONTEXTS, {}, { NodeName:""} ) |
db.exec( " select from $SNAPSHOT_CONTEXT order by SessionID" ) | 根据指定字段进行排序。db.snapshot(SDB_SNAP_CONTEXTS, {}, {}, { "SessionID": 1 } ) |
下面列出了 SQL 快照查询语句的操作在 API 中使用指定快照查询参数的对应快照操作:
- select <sel> from $<snapshot>
- where <cond>
- order by <sort>
- limit <limit>
- offset <skip> /*+use_option(<options>)*/
对应
- SdbSnapshotOption[.cond(<cond>)]
- [.sel(<sel>)]
- [.sort(<sort>)]
- [.options(<options>)]
- [.skip(<skip>)]
- [.limit(<limit>)]
cond(<cond>)
SQL 语句 | API 语句 |
---|
db.exec( "select * from $SNAPSHOT_CONTEXT where SessionID = 22" ) | db.snapshot( SDB_SNAP_CONTEXTS, new SdbSnapshotOption().cond( { SessionID: 22 } ) ) |
sel(<sel>)
SQL 语句 | API 语句 |
---|
db.exec( "select SessionID from $SNAPSHOT_CONTEXT" ) | db.snapshot( SDB_SNAP_CONTEXTS, new SdbSnapshotOption().cond( {} ).sel( { SessionID: "" } ) ) |
sort(<sort>)
SQL 语句 | API 语句 |
---|
db.exec( " select * from $SNAPSHOT_CONTEXT order by SessionID" ) | db.snapshot( SDB_SNAP_CONTEXTS, new SdbSnapshotOption().cond( {} ).sort( { SessionID: 1 } ) ) |
options(<options>)
SQL 语句 | API 语句 |
---|
db.exec('select from $SNAPSHOT_CONFIGS where GroupName = "db1" and ServiceName = "20000" /+use_option(Mode, local) use_option(Expand, false)*/') | db.snapshot( SDB_SNAP_CONFIGS, new SdbSnapshotOption().cond( { GroupName:'db1', ServiceName:'20000' } ).options( { "Mode": "local", "Expand": false } ) ) |
skip(<skip>)
SQL 语句 | API 语句 |
---|
db.exec( " select * from $SNAPSHOT_CONTEXT offset 2" ) | db.snapshot( SDB_SNAP_CONTEXTS, new SdbSnapshotOption().cond( {} ).skip( 2 ) ) |
limit(<limit>)
SQL 语句 | API 语句 |
---|
db.exec( "select * from $SNAPSHOT_CONTEXT limit 1" ) | db.snapshot( SDB_SNAP_CONTEXTS, new SdbSnapshotOption().cond( {} ).limit( 1 ) ) |
SQL使用命令位置参数
命令位置参数 是用于控制命令执行的位置信息。SQL 可以用 where 语句来使用命令位置参数。
示例
- > db.exec("select * from $SNAPSHOT_CONTEXT where Role = 'catalog'")
- {
- "NodeName": "hostname:30000",
- "SessionID": 21,
- "Contexts": [
- {
- "ContextID": 7764,
- "Type": "DUMP",
- "Description": "IsOpened:1,IsTrans:0,HitEnd:0,BufferSize:0",
- "DataRead": 0,
- "IndexRead": 0,
- "QueryTimeSpent": 0,
- "StartTimestamp": "2019-06-26-17.55.42.355666"
- }
- ]
- }
- ...
- > db.exec("select * from $SNAPSHOT_CONTEXT where Global = false")
- {
- "NodeName": "hostname:50000",
- "SessionID": 10,
- "Contexts": [
- {
- "ContextID": 70,
- "Type": "DUMP",
- "Description": "IsOpened:1,IsTrans:0,HitEnd:0,BufferSize:0",
- "DataRead": 0,
- "IndexRead": 0,
- "QueryTimeSpent": 0,
- "StartTimestamp": "2019-06-26-17.56.55.916040"
- }
- ]
- }