@intflow/sentinelctl 0.8.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +48 -6
- package/bin/sentinelctl.mjs +2 -2
- package/package.json +7 -3
- package/src/commands.mjs +456 -3
- package/src/main.mjs +23 -4
- package/src/update-core.mjs +223 -0
- package/src/update-runtime.mjs +152 -0
- package/src/update-store.mjs +205 -0
- package/src/updates.mjs +28 -0
package/README.md
CHANGED
|
@@ -150,9 +150,49 @@ sentinelctl admin operations -r 7d
|
|
|
150
150
|
|
|
151
151
|
Any other endpoint: `sentinelctl api "/api/devices?status=offline"`.
|
|
152
152
|
|
|
153
|
+
## Event sources and the event specification
|
|
154
|
+
|
|
155
|
+
Monitors, applications and infrastructure that send `intflow.event.v1` events are registered as sources. Reading is open to every role; changes need `admin` (and a `full` key when you use an access key).
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
sentinelctl events schema -o json # JSON Schema, reason codes and example events
|
|
159
|
+
sentinelctl sources list # stage, expected reporting and key state per source
|
|
160
|
+
sentinelctl sources show nas-super-monitor -o json # key expiry state, never the key itself
|
|
161
|
+
sentinelctl sources register nas-super-monitor --nature monitor --name "NAS SUPER" --category incident \
|
|
162
|
+
--subject nas:nas-super --every 60 --legacy-room mon --critical availability_lost
|
|
163
|
+
sentinelctl sources update app-backup --cron "1 3 * * *" --grace 3600
|
|
164
|
+
sentinelctl sources update db-monitor --clear runbook
|
|
165
|
+
sentinelctl sources stage nas-super-monitor shadow --reason "parallel run starts"
|
|
166
|
+
sentinelctl sources retire edgefarm-efc-stale-mail --reason "merged"
|
|
167
|
+
sentinelctl sources keys issue nas-super-monitor # sfauto_ key, events:write, 365 days, shown once
|
|
168
|
+
sentinelctl sources keys issue nas-super-monitor --replace
|
|
169
|
+
sentinelctl sources keys revoke nas-super-monitor
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
- A new source starts at stage `store`. `sources stage` moves one step at a time along `store → shadow → live → cut_over`, or one step back.
|
|
173
|
+
- `--every` (seconds) or `--cron` with `--grace` (five cron fields in KST, seconds of grace) set the expected reporting. `--critical` replaces the list of critical checks.
|
|
174
|
+
- One valid write key per source. It writes events for that source only, expires after 365 days and shows `expiring` in `sources list` and `sources show` from 30 days before. `sources retire` revokes it at once.
|
|
175
|
+
- `sources keys issue` is not offered as an MCP tool so that a key is never shown inside an AI conversation; use the CLI.
|
|
176
|
+
|
|
177
|
+
Received events (server v1.15.0 or newer, with event ingest switched on) can be searched and checked per source:
|
|
178
|
+
|
|
179
|
+
```bash
|
|
180
|
+
sentinelctl events search --source nas-super-monitor --range 7d # newest received first, default 24h, up to 200
|
|
181
|
+
sentinelctl events search --kind incident --state firing --severity critical -o json
|
|
182
|
+
sentinelctl events search --subject nas-super --check availability_lost --from 2026-11-01T00:00:00+09:00 --to 2026-11-02T00:00:00+09:00
|
|
183
|
+
sentinelctl events freshness # age of the last accepted event per source and kind
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
- Search covers the events tenant only and stays inside the VictoriaLogs retention (about 3 months); a wider window is refused with `range_beyond_retention`. Time filters use the time Sentinel received the event.
|
|
187
|
+
- Each result is `{receivedAt, event}` with the event exactly as sent; select fields with `--select receivedAt,event.summary`.
|
|
188
|
+
|
|
153
189
|
## Updates
|
|
154
190
|
|
|
155
|
-
|
|
191
|
+
Each ordinary launch makes a bounded registry check and selects a verified exact stable release in a private per-user cache. Global, local and npx installations are left intact. TTY, pipes and JSON use the same policy; the original command runs once. A failed lookup or preparation keeps the verified runtime. Releases need update protocol 1, compatible Node engines, a load probe and matching version before activation.
|
|
192
|
+
|
|
193
|
+
`update --check` (the default) checks without installing; `--apply` explicitly prepares the selected release; `--status` reports selection without a registry request. `--auto on|off` persists the policy. `--pin VERSION` verifies and prepares that exact version before changing the pin and selection together; a failed pin leaves both unchanged. A pin takes precedence, and `--unpin` only removes it. Update actions cannot be combined. These controls, help, version and `--runtime-probe` never install automatically.
|
|
194
|
+
|
|
195
|
+
`INTFLOW_CLI_AUTO_UPDATE=0` or `SENTINELCTL_AUTO_UPDATE=0` freezes the selected runtime. `SENTINELCTL_UPDATE_CHECK=0` bypasses the cache and runs the base installation. An explicit `update --apply` remains available while automatic selection is off. Old installations need one manual upgrade to this bootstrap-capable CLI. The server's separate minimum-version check still returns exit code 3; API update notices can be silenced with `SENTINELCTL_NO_UPDATE_NOTICE=1`.
|
|
156
196
|
|
|
157
197
|
## Output and exit codes
|
|
158
198
|
|
|
@@ -163,10 +203,12 @@ The server tells the CLI the latest version; when a newer one exists the CLI pri
|
|
|
163
203
|
|
|
164
204
|
## Publishing
|
|
165
205
|
|
|
166
|
-
|
|
206
|
+
Keep both package versions, the alias dependency and `config/dashboard.json`'s `cliLatestVersion` equal; `node scripts/check-cli-release.mjs` checks them.
|
|
207
|
+
|
|
208
|
+
1. Run `gh workflow run publish-cli.yml --repo yeon3724/intflow-sentinel --ref main -f publish=false`. The self-hosted runner checks versions, tests and both pack contents without publishing.
|
|
209
|
+
2. From that clean, verified commit, run `npm pack --pack-destination <absolute-output-directory>` in `cli/` and `cli/unscoped/`. Keep the commit and tarball checksums with the artifacts. A maintainer signs in with `npm login --auth-type=web` and publishes the scoped tarball with `npm publish <tarball> --access public`, completing npm's 2FA approval. Confirm its exact version with `npm view @intflow/sentinelctl@0.10.0 version`, then publish and confirm the alias tarball the same way.
|
|
210
|
+
3. After both exact versions are public, create the immutable annotated tag on that verified commit: `git tag -a cli-v0.10.0 <verified-commit> -m 'Sentinel CLI 0.10.0'`, then `git push origin cli-v0.10.0`.
|
|
167
211
|
|
|
168
|
-
|
|
169
|
-
2. Commit, then push a tag: `git tag cli-v0.8.0 && git push origin cli-v0.8.0`.
|
|
170
|
-
3. The workflow runs the CLI checks and tests, publishes `@intflow/sentinelctl`, waits for the registry, then publishes the `sentinelctl` alias. Versions already on npm are skipped. Run it manually (Actions → publish-cli) to verify and pack without publishing.
|
|
212
|
+
A tag always runs the self-hosted checks. If both exact package versions are public, the hosted publisher is skipped. A missing version or uncertain registry lookup keeps the existing trusted-publishing path: scoped package, registry confirmation, then alias; versions already present are skipped. This path needs a GitHub-hosted runner. For each package, npm Settings → Trusted Publisher must use `yeon3724`, repository `intflow-sentinel`, workflow `publish-cli.yml`, environment `npm`; verify the settings after a repository rename.
|
|
171
213
|
|
|
172
|
-
|
|
214
|
+
Updating the NAS Compose `DASHBOARD_CLI_LATEST_VERSION` pin is a separate deployment step, after both packages are public.
|
package/bin/sentinelctl.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intflow/sentinelctl",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "Sentinel Fleet Console CLI: search device logs, inspect status and metrics, edit metadata, manage roles and create access keys for MCP",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
7
|
"sentinelctl": "bin/sentinelctl.mjs"
|
|
8
8
|
},
|
|
9
9
|
"exports": {
|
|
10
|
-
".": "./src/main.mjs"
|
|
10
|
+
".": "./src/main.mjs",
|
|
11
|
+
"./update-runtime": "./src/updates.mjs"
|
|
11
12
|
},
|
|
12
13
|
"files": [
|
|
13
14
|
"bin",
|
|
@@ -17,9 +18,12 @@
|
|
|
17
18
|
"engines": {
|
|
18
19
|
"node": ">=20"
|
|
19
20
|
},
|
|
21
|
+
"intflow": {
|
|
22
|
+
"cliUpdateProtocol": 1
|
|
23
|
+
},
|
|
20
24
|
"scripts": {
|
|
21
25
|
"test": "node --test test/*.test.mjs",
|
|
22
|
-
"check": "node --check bin/sentinelctl.mjs && node --check src/main.mjs && node --check src/args.mjs && node --check src/credentials.mjs && node --check src/client.mjs && node --check src/login.mjs && node --check src/format.mjs && node --check src/commands.mjs"
|
|
26
|
+
"check": "node --check bin/sentinelctl.mjs && node --check src/main.mjs && node --check src/args.mjs && node --check src/credentials.mjs && node --check src/client.mjs && node --check src/login.mjs && node --check src/format.mjs && node --check src/commands.mjs && node --check src/updates.mjs && node --check src/update-core.mjs && node --check src/update-store.mjs && node --check src/update-runtime.mjs"
|
|
23
27
|
},
|
|
24
28
|
"license": "UNLICENSED",
|
|
25
29
|
"publishConfig": {
|
package/src/commands.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { readFile, writeFile } from 'node:fs/promises';
|
|
2
2
|
import { closest, keyValue, UsageError } from './args.mjs';
|
|
3
3
|
import { ageText, localTime, percentText, renderKeyValues, renderTable, singleLine } from './format.mjs';
|
|
4
|
+
import { update } from './updates.mjs';
|
|
4
5
|
|
|
5
6
|
export const roleLabels = { viewer: 'viewer (read-only)', editor: 'editor', admin: 'admin' };
|
|
6
7
|
export const outputChoices = ['table', 'json', 'ndjson'];
|
|
@@ -57,7 +58,7 @@ function logCriteria(options, positionals) {
|
|
|
57
58
|
};
|
|
58
59
|
}
|
|
59
60
|
|
|
60
|
-
const listKeys = ['devices', 'logs', 'groups', 'buckets', 'sources', 'sessions', 'users', 'history', 'results', 'attention'];
|
|
61
|
+
const listKeys = ['devices', 'logs', 'groups', 'buckets', 'sources', 'sessions', 'users', 'history', 'results', 'attention', 'events'];
|
|
61
62
|
|
|
62
63
|
function pick(item, paths) {
|
|
63
64
|
if (!item || typeof item !== 'object') return item;
|
|
@@ -602,7 +603,8 @@ async function health(context) {
|
|
|
602
603
|
const body = await context.client.get('/api/health');
|
|
603
604
|
emit(context, body, () => [
|
|
604
605
|
renderKeyValues([['Overall', body.status], ['Version', `${body.application?.version} (${body.application?.commit})`],
|
|
605
|
-
['Observer', body.observer?.status ?? body.observer?.state]
|
|
606
|
+
['Observer', body.observer?.status ?? body.observer?.state],
|
|
607
|
+
['Events', body.events ? `ingest ${body.events.ingest}, ${body.events.status}${body.events.settings?.length ? ` (${body.events.settings.join(', ')})` : ''}${body.events.lastFailureCode && body.events.status === 'error' ? ` (${body.events.lastFailureCode})` : ''}` : undefined]]),
|
|
606
608
|
'',
|
|
607
609
|
renderTable(Object.entries(body.components ?? {}), [
|
|
608
610
|
{ header: 'COMPONENT', value: ([name]) => name },
|
|
@@ -612,6 +614,9 @@ async function health(context) {
|
|
|
612
614
|
], { width: context.width }),
|
|
613
615
|
].join('\n'));
|
|
614
616
|
if (body.status !== 'ok') context.hint('Some backends are unhealthy; results may be stale or empty.');
|
|
617
|
+
if (body.events?.status === 'misconfigured') {
|
|
618
|
+
context.hint(`Event ingest is forced off by invalid settings${body.events.settings?.length ? `: ${body.events.settings.join(', ')}` : ''}. Device monitoring is not affected.`);
|
|
619
|
+
}
|
|
615
620
|
}
|
|
616
621
|
|
|
617
622
|
async function metadataGet(context, { positionals }) {
|
|
@@ -902,7 +907,305 @@ async function rawApi(context, { options, positionals }) {
|
|
|
902
907
|
context.out(JSON.stringify(project(result.body, context.select), null, 2));
|
|
903
908
|
}
|
|
904
909
|
|
|
910
|
+
const sourceNatures = ['monitor', 'application', 'infrastructure'];
|
|
911
|
+
const sourceCategories = ['incident', 'report', 'both'];
|
|
912
|
+
const sourceStages = ['store', 'shadow', 'live', 'cut_over'];
|
|
913
|
+
const legacyRooms = ['svc', 'db', 'mon', 'efc', 'haenuri', 'proto'];
|
|
914
|
+
const sourceTextFields = { nature: 'nature', name: 'name', category: 'category', subject: 'subjectRef', owner: 'ownerRef', 'legacy-room': 'legacyRoom', runbook: 'runbook' };
|
|
915
|
+
const sourceClearFields = { subject: 'subjectRef', owner: 'ownerRef', expected: 'expected', 'legacy-room': 'legacyRoom', runbook: 'runbook', critical: 'criticalChecks' };
|
|
916
|
+
const sourceFieldOptions = {
|
|
917
|
+
nature: { type: 'string', choices: sourceNatures, description: 'What kind of sender this is.' },
|
|
918
|
+
name: { type: 'string', placeholder: 'text', description: 'Display name, 1-120 characters (Korean is fine).' },
|
|
919
|
+
category: { type: 'string', choices: sourceCategories, description: 'incident, report or both.' },
|
|
920
|
+
subject: { type: 'string', placeholder: 'kind:id', description: 'What it watches, e.g. nas:nas-super (kind as in event subject.kind).' },
|
|
921
|
+
owner: { type: 'string', placeholder: 'role', description: 'Owner role reference from the INFRA portal; never a person.' },
|
|
922
|
+
every: { type: 'integer', placeholder: 'seconds', description: 'Expected reporting interval, 10-86400 seconds.' },
|
|
923
|
+
cron: { type: 'string', placeholder: 'cron', description: 'Expected schedule as five cron fields in KST, with --grace.' },
|
|
924
|
+
grace: { type: 'integer', placeholder: 'seconds', description: 'Allowed delay after each --cron run, 60-86400 seconds.' },
|
|
925
|
+
'legacy-room': { type: 'string', choices: legacyRooms, description: 'Current Slack room code until cut-over.' },
|
|
926
|
+
runbook: { type: 'string', placeholder: 'url', description: 'Runbook URL (http or https).' },
|
|
927
|
+
critical: { type: 'string', multiple: true, placeholder: 'check', description: 'Critical check name; the given list replaces the old one.' },
|
|
928
|
+
};
|
|
929
|
+
|
|
930
|
+
function requireSourceId(positionals) {
|
|
931
|
+
if (!positionals[0]) throw new UsageError('A source ID is required.', { hint: 'List them with `sentinelctl sources list`.' });
|
|
932
|
+
return positionals[0];
|
|
933
|
+
}
|
|
934
|
+
|
|
935
|
+
function sourcePath(id, suffix = '') {
|
|
936
|
+
return `/api/sources/${encodeURIComponent(id)}${suffix}`;
|
|
937
|
+
}
|
|
938
|
+
|
|
939
|
+
function sourceBody(options) {
|
|
940
|
+
const body = {};
|
|
941
|
+
for (const [option, field] of Object.entries(sourceTextFields)) if (options[option] !== undefined) body[field] = options[option];
|
|
942
|
+
if (options.critical !== undefined) body.criticalChecks = options.critical;
|
|
943
|
+
if (options.every !== undefined && (options.cron !== undefined || options.grace !== undefined)) {
|
|
944
|
+
throw new UsageError('Give either --every or --cron with --grace, not both.');
|
|
945
|
+
}
|
|
946
|
+
if ((options.cron === undefined) !== (options.grace === undefined)) throw new UsageError('--cron and --grace go together.');
|
|
947
|
+
if (options.every !== undefined) body.expected = { everySeconds: options.every };
|
|
948
|
+
if (options.cron !== undefined) body.expected = { cron: options.cron, graceSeconds: options.grace };
|
|
949
|
+
for (const option of options.clear ?? []) {
|
|
950
|
+
if (body[sourceClearFields[option]] !== undefined) throw new UsageError(`--clear ${option} cannot be combined with a new value for it.`);
|
|
951
|
+
body[sourceClearFields[option]] = option === 'critical' ? [] : null;
|
|
952
|
+
}
|
|
953
|
+
return body;
|
|
954
|
+
}
|
|
955
|
+
|
|
956
|
+
function expectedText(expected) {
|
|
957
|
+
if (!expected) return '-';
|
|
958
|
+
return expected.everySeconds !== undefined ? `every ${expected.everySeconds}s` : `${expected.cron} +${expected.graceSeconds}s`;
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
function keyText(key) {
|
|
962
|
+
if (!key || key.state === 'none') return 'none';
|
|
963
|
+
return key.state === 'active' || key.state === 'expiring' ? `${key.state} (${key.daysLeft}d left)` : key.state;
|
|
964
|
+
}
|
|
965
|
+
|
|
966
|
+
const sourceColumns = [
|
|
967
|
+
{ header: 'ID', value: (source) => source.id, max: 32 },
|
|
968
|
+
{ header: 'NATURE', value: (source) => source.nature },
|
|
969
|
+
{ header: 'STAGE', value: (source) => (source.retired ? 'retired' : source.stage) },
|
|
970
|
+
{ header: 'CATEGORY', value: (source) => source.category },
|
|
971
|
+
{ header: 'ROOM', value: (source) => source.legacyRoom ?? '-' },
|
|
972
|
+
{ header: 'EXPECTED', value: (source) => expectedText(source.expected), max: 28 },
|
|
973
|
+
{ header: 'KEY', value: (source) => keyText(source.key) },
|
|
974
|
+
{ header: 'NAME', value: (source) => source.name },
|
|
975
|
+
];
|
|
976
|
+
|
|
977
|
+
function sourceDetails(source) {
|
|
978
|
+
return renderKeyValues([
|
|
979
|
+
['ID', source.id], ['Name', source.name], ['Nature', source.nature], ['Category', source.category],
|
|
980
|
+
['Stage', `${source.retired ? 'retired, was ' : ''}${source.stage} (since ${localTime(source.stageChangedAt)})`],
|
|
981
|
+
['Subject', source.subjectRef], ['Owner', source.ownerRef], ['Expected', expectedText(source.expected)],
|
|
982
|
+
['Legacy room', source.legacyRoom], ['Runbook', source.runbook], ['Critical checks', source.criticalChecks.join(', ')],
|
|
983
|
+
['Key', `${keyText(source.key)}${source.key?.expiresAt ? `, expires ${localTime(source.key.expiresAt)}` : ''}`],
|
|
984
|
+
['Revision', source.revision], ['Updated', source.updatedAt],
|
|
985
|
+
...(source.portal ? portalSourceRows(source.portal) : []),
|
|
986
|
+
]);
|
|
987
|
+
}
|
|
988
|
+
|
|
989
|
+
function routeText(route) {
|
|
990
|
+
if (!route) return '-';
|
|
991
|
+
return `${route.id} (${route.critical ? 'critical' : route.defaultDecision}, owner ${route.ownerRole}${route.sms ? `, SMS ${route.smsRoles.join('+')}` : ''})`;
|
|
992
|
+
}
|
|
993
|
+
|
|
994
|
+
function portalSourceRows(portal) {
|
|
995
|
+
return [
|
|
996
|
+
['Portal copy', localTime(portal.copiedAt)], ['Portal asset', portal.asset ? `${portal.asset.ref} (${portal.asset.kind ?? '-'})` : '-'],
|
|
997
|
+
['Portal owner', portal.owner ? `${portal.owner.role} ${portal.owner.label}` : '-'], ['Portal route', routeText(portal.route)],
|
|
998
|
+
...portal.critical.map((item) => [`Route ${item.check}`, routeText(item.route)]),
|
|
999
|
+
...(portal.mismatches.length ? [['Mismatches', portal.mismatches.map((item) => `${item.kind} ${item.check ?? ''}`.trim()).join(', ')]] : []),
|
|
1000
|
+
];
|
|
1001
|
+
}
|
|
1002
|
+
|
|
1003
|
+
function statusText(part) {
|
|
1004
|
+
return `${part.status}${part.reasons ? ` (${part.reasons.join(', ')})` : ''}`;
|
|
1005
|
+
}
|
|
1006
|
+
|
|
1007
|
+
async function portalStatus(context) {
|
|
1008
|
+
const body = await context.client.get('/api/portal');
|
|
1009
|
+
const mismatches = body.comparison?.mismatches ?? [];
|
|
1010
|
+
emit(context, body, () => [
|
|
1011
|
+
renderKeyValues([
|
|
1012
|
+
['Copy', statusText(body.sync)], ['Copied', localTime(body.sync.copiedAt)], ['Checked', localTime(body.sync.checkedAt)],
|
|
1013
|
+
['Assets', body.sync.assets ?? '-'], ['Routes', body.sync.routes ?? '-'], ['Portal SMS switch', body.sync.smsSending ?? '-'],
|
|
1014
|
+
]),
|
|
1015
|
+
...(mismatches.length ? ['', 'Critical checks vs portal routes:', renderTable(mismatches, [
|
|
1016
|
+
{ header: 'KIND', value: (item) => item.kind }, { header: 'SOURCE', value: (item) => item.source ?? '-' },
|
|
1017
|
+
{ header: 'CHECK', value: (item) => item.check ?? '-' }, { header: 'ROUTE', value: (item) => item.route ?? '-' },
|
|
1018
|
+
], { width: context.width })] : []),
|
|
1019
|
+
].join('\n'));
|
|
1020
|
+
if (body.sync.state === 'off') context.hint('The portal copy is off on this server (PORTAL_SYNC_ENABLED).');
|
|
1021
|
+
}
|
|
1022
|
+
|
|
1023
|
+
async function portalSync(context, { options }) {
|
|
1024
|
+
if (!options.now) throw new UsageError('Add --now to fetch the portal copy immediately.', { hint: 'The copy is otherwise refreshed every 5 minutes.' });
|
|
1025
|
+
const body = await context.client.post('/api/portal/sync', {});
|
|
1026
|
+
emit(context, body, () => renderKeyValues([
|
|
1027
|
+
['Copy', statusText(body.sync)], ['Copied', localTime(body.sync.copiedAt)], ['Checked', localTime(body.sync.checkedAt)],
|
|
1028
|
+
['Assets', body.sync.assets ?? '-'], ['Routes', body.sync.routes ?? '-'],
|
|
1029
|
+
]));
|
|
1030
|
+
}
|
|
1031
|
+
|
|
1032
|
+
async function assetsShow(context, { positionals }) {
|
|
1033
|
+
if (!positionals[0]) throw new UsageError('An asset name is required.', { hint: 'Find it in `sentinelctl sources show <id>` (Portal asset).' });
|
|
1034
|
+
const body = await context.client.get(`/api/assets/${encodeURIComponent(positionals[0])}`);
|
|
1035
|
+
emit(context, body, () => renderKeyValues([
|
|
1036
|
+
['Asset', body.ref], ['Kind', body.kind], ['Category', body.category], ['Group', body.group], ['Purpose', body.purpose], ['Parent', body.parent],
|
|
1037
|
+
['Children', body.children.join(', ') || '-'], ['Addresses', body.addresses.map((address) => `${address.kind} ${address.value}`).join(', ') || '-'],
|
|
1038
|
+
['Sources', body.sources.map((source) => source.id).join(', ') || '-'], ['Portal copy', localTime(body.copiedAt)],
|
|
1039
|
+
]));
|
|
1040
|
+
}
|
|
1041
|
+
|
|
1042
|
+
async function sourcesList(context, { options }) {
|
|
1043
|
+
const body = await context.client.get('/api/sources', { nature: options.nature, stage: options.stage, category: options.category, all: options.all ? 1 : undefined });
|
|
1044
|
+
emit(context, context.global.output === 'ndjson' ? body.sources : body, () => (body.sources.length
|
|
1045
|
+
? renderTable(body.sources, sourceColumns, { width: context.width })
|
|
1046
|
+
: 'No sources registered.'));
|
|
1047
|
+
const expiring = body.sources.filter((source) => ['expiring', 'expired'].includes(source.key?.state)).length;
|
|
1048
|
+
if (expiring) context.hint(`${expiring} source key(s) expire within 30 days or have expired; issue a new one with \`sentinelctl sources keys issue <id> --replace\`.`);
|
|
1049
|
+
}
|
|
1050
|
+
|
|
1051
|
+
async function sourcesShow(context, { positionals }) {
|
|
1052
|
+
const body = await context.client.get(sourcePath(requireSourceId(positionals)));
|
|
1053
|
+
emit(context, body, () => sourceDetails(body));
|
|
1054
|
+
}
|
|
1055
|
+
|
|
1056
|
+
async function sourcesRegister(context, { options, positionals }) {
|
|
1057
|
+
const id = requireSourceId(positionals);
|
|
1058
|
+
for (const option of ['nature', 'name', 'category']) {
|
|
1059
|
+
if (options[option] === undefined) throw new UsageError(`--${option} is required.`, { hint: 'Example: sentinelctl sources register nas-super-monitor --nature monitor --name "NAS SUPER" --category incident --every 60' });
|
|
1060
|
+
}
|
|
1061
|
+
const body = await context.client.post('/api/sources', { id, ...sourceBody(options) });
|
|
1062
|
+
emit(context, body, () => `Registered ${body.id} at stage ${body.stage}.`);
|
|
1063
|
+
context.hint(`Issue its write key with \`sentinelctl sources keys issue ${body.id}\`.`);
|
|
1064
|
+
}
|
|
1065
|
+
|
|
1066
|
+
async function sourcesUpdate(context, { options, positionals }) {
|
|
1067
|
+
const id = requireSourceId(positionals);
|
|
1068
|
+
const changes = sourceBody(options);
|
|
1069
|
+
if (!Object.keys(changes).length) throw new UsageError('Nothing to change. Give at least one field option.', { hint: 'All fields: sentinelctl sources update --help' });
|
|
1070
|
+
const current = await context.client.get(sourcePath(id));
|
|
1071
|
+
const body = await context.client.patch(sourcePath(id), { revision: current.revision, ...changes });
|
|
1072
|
+
emit(context, body, () => `Saved ${body.id} as revision ${body.revision}.`);
|
|
1073
|
+
}
|
|
1074
|
+
|
|
1075
|
+
async function sourcesStage(context, { options, positionals }) {
|
|
1076
|
+
const id = requireSourceId(positionals);
|
|
1077
|
+
const stage = positionals[1];
|
|
1078
|
+
if (!sourceStages.includes(stage)) throw new UsageError(`The stage must be one of ${sourceStages.join(', ')}.`, { hint: 'Stages move one step at a time: store → shadow → live → cut_over.' });
|
|
1079
|
+
const current = await context.client.get(sourcePath(id));
|
|
1080
|
+
const body = await context.client.post(sourcePath(id, '/stage'), { stage, revision: current.revision, ...(options.reason ? { reason: options.reason } : {}) });
|
|
1081
|
+
emit(context, body, () => `${body.id}: ${current.stage} → ${body.stage}.`);
|
|
1082
|
+
}
|
|
1083
|
+
|
|
1084
|
+
async function sourcesRetire(context, { options, positionals }) {
|
|
1085
|
+
const id = requireSourceId(positionals);
|
|
1086
|
+
if (!options.reason) throw new UsageError('--reason is required.');
|
|
1087
|
+
const current = await context.client.get(sourcePath(id));
|
|
1088
|
+
const body = await context.client.post(sourcePath(id, '/retire'), { revision: current.revision, reason: options.reason });
|
|
1089
|
+
emit(context, body, () => `Retired ${body.id}; its write key, if any, is revoked.`);
|
|
1090
|
+
}
|
|
1091
|
+
|
|
1092
|
+
async function sourcesKeysIssue(context, { options, positionals }) {
|
|
1093
|
+
const id = requireSourceId(positionals);
|
|
1094
|
+
const body = await context.client.post(sourcePath(id, '/key'), { replace: Boolean(options.replace) });
|
|
1095
|
+
emit(context, body, () => [
|
|
1096
|
+
renderKeyValues([['Source', body.sourceId], ['Key ID', body.key.id], ['Scope', body.key.scope], ['Expires', localTime(body.key.expiresAt)]]),
|
|
1097
|
+
'',
|
|
1098
|
+
body.token,
|
|
1099
|
+
].join('\n'));
|
|
1100
|
+
context.hint('Shown once; put it in the source\'s key file now. It writes events for this source only and expires in 365 days.');
|
|
1101
|
+
}
|
|
1102
|
+
|
|
1103
|
+
async function sourcesKeysRevoke(context, { positionals }) {
|
|
1104
|
+
const id = requireSourceId(positionals);
|
|
1105
|
+
const body = (await context.client.request('DELETE', sourcePath(id, '/key'))).body;
|
|
1106
|
+
emit(context, body, () => `Revoked the write key ${body.key.id} of ${body.sourceId}.`);
|
|
1107
|
+
}
|
|
1108
|
+
|
|
1109
|
+
async function eventsSchema(context) {
|
|
1110
|
+
const body = await context.client.get('/api/events/v1/schema');
|
|
1111
|
+
emit(context, body, () => JSON.stringify(body, null, 2));
|
|
1112
|
+
}
|
|
1113
|
+
|
|
1114
|
+
const eventKinds = ['incident', 'report', 'heartbeat', 'change'];
|
|
1115
|
+
const eventSeverities = ['critical', 'warning', 'info'];
|
|
1116
|
+
const eventStates = ['firing', 'resolved'];
|
|
1117
|
+
const eventRanges = ['15m', '1h', '6h', '24h', '7d', '30d', '90d'];
|
|
1118
|
+
const eventLimit = 200;
|
|
1119
|
+
|
|
1120
|
+
const eventColumns = [
|
|
1121
|
+
{ header: 'RECEIVED', value: (item) => localTime(item.receivedAt), max: 19 },
|
|
1122
|
+
{ header: 'KIND', value: (item) => item.event.kind, max: 9 },
|
|
1123
|
+
{ header: 'SEVERITY', value: (item) => item.event.severity, max: 8 },
|
|
1124
|
+
{ header: 'SOURCE', value: (item) => item.event.source?.id, max: 28 },
|
|
1125
|
+
{ header: 'SUBJECT', value: (item) => item.event.subject?.id ?? '-', max: 24 },
|
|
1126
|
+
{ header: 'STATE', value: (item) => item.event.state ?? '-', max: 8 },
|
|
1127
|
+
{ header: 'SUMMARY', value: (item) => `${item.event.test ? '[test] ' : ''}${item.event.summary}` },
|
|
1128
|
+
];
|
|
1129
|
+
|
|
1130
|
+
const freshnessColumns = [
|
|
1131
|
+
{ header: 'SOURCE', value: (source) => source.id, max: 32 },
|
|
1132
|
+
{ header: 'STAGE', value: (source) => source.stage },
|
|
1133
|
+
{ header: 'EXPECTED', value: (source) => expectedText(source.expected), max: 28 },
|
|
1134
|
+
{ header: 'LAST', value: (source) => source.last?.kind ?? '-' },
|
|
1135
|
+
{ header: 'AGE', value: (source) => (source.last ? ageText(source.last.ageSeconds) : 'never') },
|
|
1136
|
+
{ header: 'RECEIVED', value: (source) => localTime(source.last?.receivedAt) },
|
|
1137
|
+
];
|
|
1138
|
+
|
|
1139
|
+
async function eventsSearch(context, { options }) {
|
|
1140
|
+
if ((options.from && !options.to) || (!options.from && options.to)) {
|
|
1141
|
+
throw new UsageError('--from and --to must be given together.', { hint: 'For a recent window use --range, e.g. --range 24h.' });
|
|
1142
|
+
}
|
|
1143
|
+
if (options.from && options.range) throw new UsageError('--range cannot be combined with --from/--to.');
|
|
1144
|
+
for (const [name, value] of [['from', options.from], ['to', options.to]]) {
|
|
1145
|
+
if (value && !Number.isFinite(Date.parse(value))) {
|
|
1146
|
+
throw new UsageError(`Cannot parse --${name}: ${value}`, { hint: 'Use ISO 8601 with a zone, e.g. 2026-11-13T09:00:00+09:00.' });
|
|
1147
|
+
}
|
|
1148
|
+
}
|
|
1149
|
+
if (options.limit !== undefined && (options.limit < 1 || options.limit > eventLimit)) throw new UsageError(`--limit must be between 1 and ${eventLimit}.`);
|
|
1150
|
+
const body = await context.client.get('/api/events/v1/search', {
|
|
1151
|
+
source: options.source, kind: options.kind, subject: options.subject, check: options.check, state: options.state, severity: options.severity,
|
|
1152
|
+
range: options.range,
|
|
1153
|
+
from: options.from ? new Date(options.from).toISOString() : undefined,
|
|
1154
|
+
to: options.to ? new Date(options.to).toISOString() : undefined,
|
|
1155
|
+
limit: options.limit,
|
|
1156
|
+
});
|
|
1157
|
+
emit(context, context.global.output === 'ndjson' ? body.events : body, () => (body.events.length
|
|
1158
|
+
? renderTable(body.events, eventColumns, { width: context.width, wide: options.wide })
|
|
1159
|
+
: 'No events matched.'));
|
|
1160
|
+
if (body.events.length) context.note(`${body.count} events · ${localTime(body.window.start)} → ${localTime(body.window.end)}`);
|
|
1161
|
+
if (body.hasMore) context.hint(`More events match. Narrow the filters or raise --limit (up to ${eventLimit}).`);
|
|
1162
|
+
}
|
|
1163
|
+
|
|
1164
|
+
async function eventsFreshness(context) {
|
|
1165
|
+
const body = await context.client.get('/api/events/v1/freshness');
|
|
1166
|
+
emit(context, context.global.output === 'ndjson' ? body.sources : body, () => (body.sources.length
|
|
1167
|
+
? renderTable(body.sources, freshnessColumns, { width: context.width })
|
|
1168
|
+
: 'No sources registered.'));
|
|
1169
|
+
if (!body.ingest.enabled) context.hint('Event ingest is off on this server; sources keep their events in the spool until it is turned on.');
|
|
1170
|
+
}
|
|
1171
|
+
|
|
1172
|
+
const changeColumns = [
|
|
1173
|
+
{ header: 'RECEIVED', value: (item) => localTime(item.receivedAt), max: 19 },
|
|
1174
|
+
{ header: 'SOURCE', value: (item) => item.event.source?.id, max: 28 },
|
|
1175
|
+
{ header: 'SUBJECT', value: (item) => item.event.subject?.id ?? '', max: 24 },
|
|
1176
|
+
{ header: 'TYPE', value: (item) => item.event.change?.type ?? '', max: 12 },
|
|
1177
|
+
{ header: 'RESULT', value: (item) => item.event.change?.result ?? '', max: 10 },
|
|
1178
|
+
{ header: 'SUMMARY', value: (item) => item.event.summary },
|
|
1179
|
+
];
|
|
1180
|
+
|
|
1181
|
+
async function changesRecent(context, { options }) {
|
|
1182
|
+
if (options.limit !== undefined && (options.limit < 1 || options.limit > eventLimit)) throw new UsageError(`--limit must be between 1 and ${eventLimit}.`);
|
|
1183
|
+
const body = await context.client.get('/api/changes/recent', {
|
|
1184
|
+
source: options.source, subject: options.subject, agent: options.agent, range: options.range, limit: options.limit,
|
|
1185
|
+
});
|
|
1186
|
+
emit(context, body, () => [
|
|
1187
|
+
body.events.length ? renderTable(body.events, changeColumns, { width: context.width, wide: options.wide }) : 'No change events matched.',
|
|
1188
|
+
...(body.metadata ? ['', `Metadata history of ${body.metadata.agentId}: ${body.metadata.history.length} entries (-o json shows them).`] : []),
|
|
1189
|
+
].join('\n'));
|
|
1190
|
+
if (body.hasMore) context.hint(`More change events match. Narrow the filters or raise --limit (up to ${eventLimit}).`);
|
|
1191
|
+
}
|
|
1192
|
+
|
|
905
1193
|
const commands = [
|
|
1194
|
+
{
|
|
1195
|
+
group: null, name: 'update', role: 'viewer', mutates: false, mcp: false, local: true,
|
|
1196
|
+
run: async (context, { options }) => context.out(JSON.stringify(await update(options))),
|
|
1197
|
+
summary: 'Check, prepare or freeze the per-user CLI runtime',
|
|
1198
|
+
options: {
|
|
1199
|
+
check: { type: 'boolean', description: 'Check the release without installing (default).' },
|
|
1200
|
+
apply: { type: 'boolean', description: 'Prepare and activate the selected exact release.' },
|
|
1201
|
+
status: { type: 'boolean', description: 'Show runtime selection and policy without a registry request.' },
|
|
1202
|
+
auto: { type: 'string', choices: ['on', 'off'], description: 'Persist automatic selection on or off.' },
|
|
1203
|
+
pin: { type: 'string', placeholder: 'VERSION', description: 'Validate, prepare and select one exact stable version.' },
|
|
1204
|
+
unpin: { type: 'boolean', description: 'Remove the pin without installing.' },
|
|
1205
|
+
},
|
|
1206
|
+
examples: ['sentinelctl update --status', 'sentinelctl update --pin 0.10.0', 'sentinelctl update --auto off'],
|
|
1207
|
+
output: '{current,installed,active,previous,automatic,pin,protocol,last_check,last_error}.',
|
|
1208
|
+
},
|
|
906
1209
|
{
|
|
907
1210
|
group: 'logs', name: 'search', run: logsSearch, role: 'viewer', mutates: false,
|
|
908
1211
|
summary: 'Raw log lines, newest first',
|
|
@@ -1067,10 +1370,11 @@ const commands = [
|
|
|
1067
1370
|
{
|
|
1068
1371
|
group: 'devices', name: 'overview', run: devicesOverview, role: 'viewer', mutates: false,
|
|
1069
1372
|
summary: 'Reception state, outage counts and durations, and attention reasons for one device',
|
|
1373
|
+
description: 'The answer includes the device metadata: lifecycle (active, maintenance, retired), maintenanceUntil and maintenanceReason. A maintenance whose maintenanceUntil has passed counts as active.',
|
|
1070
1374
|
args: [{ name: 'agent-id' }],
|
|
1071
1375
|
options: { range: { alias: 'r', type: 'string', default: '24h', placeholder: 'window', description: 'History window, e.g. 24h or 7d.' } },
|
|
1072
1376
|
examples: ['sentinelctl devices overview <agent-id> -r 7d -o json'],
|
|
1073
|
-
output: '{summary{metrics, logs}: {state, outages, delays, missingMinutes, longestOutageMinutes, normalRatio}, agentId, device, products, attentionReasons[], history, related{parent, children[], expectedParent}}.',
|
|
1377
|
+
output: '{summary{metrics, logs}: {state, outages, delays, missingMinutes, longestOutageMinutes, normalRatio}, agentId, metadata{displayName, role, lifecycle, maintenanceUntil, maintenanceReason, ...}, device, products, attentionReasons[], history, related{parent, children[], expectedParent}}.',
|
|
1074
1378
|
},
|
|
1075
1379
|
{
|
|
1076
1380
|
group: 'metrics', name: 'top', run: metricsTop, role: 'viewer', mutates: false,
|
|
@@ -1291,6 +1595,150 @@ const commands = [
|
|
|
1291
1595
|
},
|
|
1292
1596
|
examples: ['sentinelctl api "/api/devices?status=offline&pageSize=5"'], output: 'The server response JSON as is.',
|
|
1293
1597
|
},
|
|
1598
|
+
{
|
|
1599
|
+
group: 'sources', name: 'list', run: sourcesList, role: 'viewer', mutates: false,
|
|
1600
|
+
summary: 'Registered event sources with stage, expected reporting and key state',
|
|
1601
|
+
options: {
|
|
1602
|
+
nature: { type: 'string', choices: sourceNatures, description: 'Only this nature.' },
|
|
1603
|
+
stage: { type: 'string', choices: sourceStages, description: 'Only this stage.' },
|
|
1604
|
+
category: { type: 'string', choices: sourceCategories, description: 'Only this category.' },
|
|
1605
|
+
all: { type: 'boolean', description: 'Include retired sources.' },
|
|
1606
|
+
},
|
|
1607
|
+
examples: ['sentinelctl sources list', 'sentinelctl sources list --stage live -o json'],
|
|
1608
|
+
output: '{sources[]: {id, nature, name, subjectRef, ownerRef, expected, category, legacyRoom, stage, runbook, criticalChecks, retired, revision, key{state, expiresAt, daysLeft}}}.',
|
|
1609
|
+
},
|
|
1610
|
+
{
|
|
1611
|
+
group: 'sources', name: 'show', run: sourcesShow, role: 'viewer', mutates: false,
|
|
1612
|
+
summary: 'One event source: owner, runbook, expected reporting, stage and key expiry',
|
|
1613
|
+
description: 'Key state is none, active, expiring (30 days or less left), expired or revoked; key material is never shown.',
|
|
1614
|
+
args: [{ name: 'source-id' }], options: {},
|
|
1615
|
+
examples: ['sentinelctl sources show nas-super-monitor -o json'],
|
|
1616
|
+
output: '{id, nature, name, subjectRef, ownerRef, expected{everySeconds | cron, graceSeconds}, category, legacyRoom, stage, stageChangedAt, runbook, criticalChecks[], retired, retiredAt, revision, createdAt, updatedAt, key{id, state, scope, createdAt, expiresAt, daysLeft, revokedAt}, portal?{copiedAt, asset, owner, route, critical[]: {check, route}, mismatches[]} (only while the portal copy is on)}.',
|
|
1617
|
+
},
|
|
1618
|
+
{
|
|
1619
|
+
group: 'sources', name: 'register', run: sourcesRegister, role: 'admin', mutates: true,
|
|
1620
|
+
summary: 'Register an event source at stage store',
|
|
1621
|
+
args: [{ name: 'source-id', description: 'Lowercase letters, digits and hyphens, 2-64 characters; used as source.id in events.' }],
|
|
1622
|
+
options: sourceFieldOptions,
|
|
1623
|
+
examples: ['sentinelctl sources register nas-super-monitor --nature monitor --name "NAS SUPER" --category incident --subject nas:nas-super --every 60 --legacy-room mon --critical availability_lost'],
|
|
1624
|
+
output: 'The registered source (same shape as sources show).',
|
|
1625
|
+
},
|
|
1626
|
+
{
|
|
1627
|
+
group: 'sources', name: 'update', run: sourcesUpdate, role: 'admin', mutates: true,
|
|
1628
|
+
summary: 'Change registry fields of an event source (reads the latest revision first)',
|
|
1629
|
+
args: [{ name: 'source-id' }],
|
|
1630
|
+
options: { ...sourceFieldOptions, clear: { type: 'string', multiple: true, choices: Object.keys(sourceClearFields), description: 'Clear a field.' } },
|
|
1631
|
+
examples: ['sentinelctl sources update db-monitor --owner role:db-operators --runbook https://runbook.example/db', 'sentinelctl sources update app-backup --cron "1 3 * * *" --grace 3600'],
|
|
1632
|
+
output: 'The saved source (same shape as sources show).',
|
|
1633
|
+
},
|
|
1634
|
+
{
|
|
1635
|
+
group: 'sources', name: 'stage', run: sourcesStage, role: 'admin', mutates: true,
|
|
1636
|
+
summary: 'Move a source one step: store → shadow → live → cut_over, or one step back',
|
|
1637
|
+
args: [{ name: 'source-id' }, { name: 'stage', description: 'store, shadow, live or cut_over.' }],
|
|
1638
|
+
options: { reason: { type: 'string', placeholder: 'text', description: 'Why, kept in the audit record (max 200 chars).' } },
|
|
1639
|
+
examples: ['sentinelctl sources stage nas-super-monitor shadow --reason "parallel run starts"'],
|
|
1640
|
+
output: 'The saved source (same shape as sources show).',
|
|
1641
|
+
},
|
|
1642
|
+
{
|
|
1643
|
+
group: 'sources', name: 'retire', run: sourcesRetire, role: 'admin', mutates: true,
|
|
1644
|
+
summary: 'Retire an event source and revoke its write key',
|
|
1645
|
+
args: [{ name: 'source-id' }],
|
|
1646
|
+
options: { reason: { type: 'string', placeholder: 'text', description: 'Why (required, max 200 chars).' } },
|
|
1647
|
+
examples: ['sentinelctl sources retire edgefarm-efc-stale-mail --reason "merged into edgefarm-device-monitor"'],
|
|
1648
|
+
output: 'The retired source (same shape as sources show).',
|
|
1649
|
+
},
|
|
1650
|
+
{
|
|
1651
|
+
group: 'sources', name: 'keys issue', run: sourcesKeysIssue, role: 'admin', mutates: true, mcp: false,
|
|
1652
|
+
summary: 'Issue the write key of a source (events:write, 365 days, shown once)',
|
|
1653
|
+
description: 'One valid key per source. With --replace the current key is revoked at once and a new one is issued.',
|
|
1654
|
+
args: [{ name: 'source-id' }],
|
|
1655
|
+
options: { replace: { type: 'boolean', description: 'Revoke the current valid key and issue a new one.' } },
|
|
1656
|
+
examples: ['sentinelctl sources keys issue nas-super-monitor', 'sentinelctl sources keys issue nas-super-monitor --replace -o json --select token'],
|
|
1657
|
+
output: '{sourceId, key{id, state, scope, createdAt, expiresAt, daysLeft}, token}. The token is never shown again.',
|
|
1658
|
+
},
|
|
1659
|
+
{
|
|
1660
|
+
group: 'sources', name: 'keys revoke', run: sourcesKeysRevoke, role: 'admin', mutates: true,
|
|
1661
|
+
summary: 'Revoke the write key of a source now',
|
|
1662
|
+
args: [{ name: 'source-id' }], options: {},
|
|
1663
|
+
examples: ['sentinelctl sources keys revoke nas-super-monitor'],
|
|
1664
|
+
output: '{sourceId, key{id, state: revoked, revokedAt}}.',
|
|
1665
|
+
},
|
|
1666
|
+
{
|
|
1667
|
+
group: 'events', name: 'schema', run: eventsSchema, role: 'viewer', mutates: false,
|
|
1668
|
+
summary: 'The intflow.event.v1 specification: JSON Schema, reason codes and example events',
|
|
1669
|
+
options: {},
|
|
1670
|
+
examples: ['sentinelctl events schema -o json --select reasonCodes', 'sentinelctl events schema -o json'],
|
|
1671
|
+
output: '{name, maxBytes, reasonCodes[], schema (JSON Schema 2020-12), examples[]}.',
|
|
1672
|
+
},
|
|
1673
|
+
{
|
|
1674
|
+
group: 'events', name: 'search', run: eventsSearch, role: 'viewer', mutates: false,
|
|
1675
|
+
summary: 'Raw monitoring events (incident, report, heartbeat, change), newest received first',
|
|
1676
|
+
description: 'Searches the events tenant only, within the VictoriaLogs retention (about 3 months). Time filters use the time Sentinel received the event. An event_id stored twice shows once.',
|
|
1677
|
+
options: {
|
|
1678
|
+
source: { type: 'string', placeholder: 'source-id', description: 'Registry source ID (see sources list).' },
|
|
1679
|
+
kind: { type: 'string', choices: eventKinds, description: 'Event kind.' },
|
|
1680
|
+
subject: { type: 'string', placeholder: 'id', description: 'subject.id, e.g. nas-super.' },
|
|
1681
|
+
check: { type: 'string', placeholder: 'name', description: 'Incident check name, e.g. availability_lost.' },
|
|
1682
|
+
state: { type: 'string', choices: eventStates, description: 'Incident state.' },
|
|
1683
|
+
severity: { type: 'string', choices: eventSeverities, description: 'Severity reported by the source.' },
|
|
1684
|
+
range: { type: 'string', choices: eventRanges, description: 'Relative window by receive time (default 24h).' },
|
|
1685
|
+
from: { type: 'string', placeholder: 'ISO', description: 'Start, e.g. 2026-11-13T09:00:00+09:00 (with --to).' },
|
|
1686
|
+
to: { type: 'string', placeholder: 'ISO', description: 'End.' },
|
|
1687
|
+
limit: { alias: 'n', type: 'integer', placeholder: 'N', description: `Events to return (1-${eventLimit}, default 50).` },
|
|
1688
|
+
wide: { alias: 'w', type: 'boolean', description: 'Do not truncate.' },
|
|
1689
|
+
},
|
|
1690
|
+
examples: [
|
|
1691
|
+
'sentinelctl events search --source nas-super-monitor --range 7d',
|
|
1692
|
+
'sentinelctl events search --kind incident --state firing --severity critical -o json',
|
|
1693
|
+
'sentinelctl events search --subject nas-super --check availability_lost --range 30d -o json --select receivedAt,event.summary',
|
|
1694
|
+
],
|
|
1695
|
+
output: '{criteria, window{start, end}, retentionDays, count, hasMore, events[]: {receivedAt, event (as sent, intflow.event.v1)}}.',
|
|
1696
|
+
},
|
|
1697
|
+
{
|
|
1698
|
+
group: 'events', name: 'freshness', run: eventsFreshness, role: 'viewer', mutates: false,
|
|
1699
|
+
summary: 'Per source: age of the last accepted event and the expected reporting interval',
|
|
1700
|
+
description: 'Ages count from the time Sentinel accepted the event. Retired sources are left out.',
|
|
1701
|
+
options: {},
|
|
1702
|
+
examples: ['sentinelctl events freshness', 'sentinelctl events freshness -o json --select id,expected,last'],
|
|
1703
|
+
output: '{generatedAt, ingest{enabled}, sources[]: {id, nature, name, category, stage, expected, last{kind, eventId, observedAt, receivedAt, ageSeconds} | null, kinds{<kind>: {eventId, observedAt, receivedAt, ageSeconds}}}}.',
|
|
1704
|
+
},
|
|
1705
|
+
{
|
|
1706
|
+
group: 'changes', name: 'recent', run: changesRecent, role: 'viewer', mutates: false,
|
|
1707
|
+
summary: 'Change events (deploys, settings, approvals) by source or subject, newest first, and the metadata history of one device',
|
|
1708
|
+
description: 'Change events come from the events tenant within its retention (about 3 months). With --agent the existing metadata history of that device is added.',
|
|
1709
|
+
options: {
|
|
1710
|
+
source: { type: 'string', placeholder: 'source-id', description: 'Registry source ID.' },
|
|
1711
|
+
subject: { type: 'string', placeholder: 'id', description: 'subject.id of the change.' },
|
|
1712
|
+
agent: { type: 'string', placeholder: 'agent-id', description: 'Also return the metadata history of this device.' },
|
|
1713
|
+
range: { type: 'string', choices: eventRanges, description: 'Relative window by receive time (default 7d).' },
|
|
1714
|
+
limit: { alias: 'n', type: 'integer', placeholder: 'N', description: `Events to return (1-${eventLimit}, default 50).` },
|
|
1715
|
+
wide: { alias: 'w', type: 'boolean', description: 'Do not truncate.' },
|
|
1716
|
+
},
|
|
1717
|
+
examples: ['sentinelctl changes recent --subject nas-super', 'sentinelctl changes recent --source app-deploy --range 30d -o json'],
|
|
1718
|
+
output: '{criteria, window{start, end}, retentionDays, count, hasMore, events[]: {receivedAt, event}, metadata{agentId, history[]} | null}.',
|
|
1719
|
+
},
|
|
1720
|
+
{
|
|
1721
|
+
group: 'portal', name: 'status', run: portalStatus, role: 'viewer', mutates: false,
|
|
1722
|
+
summary: 'Portal copy (assets, owners, recipient roles, routes, SMS switch) and critical check mismatches',
|
|
1723
|
+
description: 'The copy is pulled from the INFRA portal every 5 minutes; a failed pull keeps the last copy and shows the reason. Mismatches compare every registered critical check with the portal route that wins for it, and every critical portal route with the registered owners of its check.',
|
|
1724
|
+
options: {},
|
|
1725
|
+
examples: ['sentinelctl portal status', 'sentinelctl portal status -o json'],
|
|
1726
|
+
output: '{sync{state, status: off|misconfigured|waiting|ok|stale|error, reasons?, copiedAt, checkedAt, ageSeconds, assets, routes, smsSending, mismatches}, comparison{mismatches[]: {kind: not_critical_in_portal|no_registered_owner|unknown_source, source, check, route}} | null}.',
|
|
1727
|
+
},
|
|
1728
|
+
{
|
|
1729
|
+
group: 'portal', name: 'sync', run: portalSync, role: 'admin', mutates: true,
|
|
1730
|
+
summary: 'Fetch the portal copy now instead of waiting for the 5-minute pull',
|
|
1731
|
+
options: { now: { type: 'boolean', description: 'Fetch now (required).' } },
|
|
1732
|
+
examples: ['sentinelctl portal sync --now'],
|
|
1733
|
+
output: '{sync} (same shape as portal status sync, with admin fields).',
|
|
1734
|
+
},
|
|
1735
|
+
{
|
|
1736
|
+
group: 'assets', name: 'show', run: assetsShow, role: 'viewer', mutates: false,
|
|
1737
|
+
summary: 'One asset of the portal copy: kind, category, parent, children, addresses and the sources that watch it',
|
|
1738
|
+
args: [{ name: 'asset-ref', description: 'Asset name in the portal, e.g. the id part of a source subject.' }], options: {},
|
|
1739
|
+
examples: ['sentinelctl assets show nas-super -o json'],
|
|
1740
|
+
output: '{ref, kind, category, group, purpose, parent, addresses[]: {kind, value}, children[], sources[]: {id, name, stage, retired}, copiedAt}.',
|
|
1741
|
+
},
|
|
1294
1742
|
];
|
|
1295
1743
|
|
|
1296
1744
|
export const catalog = commands;
|
|
@@ -1303,6 +1751,11 @@ export const groups = {
|
|
|
1303
1751
|
sessions: 'Your sessions and CLI tokens',
|
|
1304
1752
|
access: 'Access keys for MCP clients and scripts',
|
|
1305
1753
|
admin: 'Roles, all sessions, audit clean-up, capacity (admin)',
|
|
1754
|
+
sources: 'Event sources: registry, stages and write keys (changes: admin)',
|
|
1755
|
+
events: 'Monitoring events: specification, search and per-source freshness',
|
|
1756
|
+
changes: 'Change events and device metadata history',
|
|
1757
|
+
portal: 'INFRA portal copy and route comparison (sync: admin)',
|
|
1758
|
+
assets: 'Assets of the INFRA portal copy',
|
|
1306
1759
|
};
|
|
1307
1760
|
|
|
1308
1761
|
export function findCommand(group, name) {
|