fix(tooling): better oids and more power metrics. Also new json httpServer feature support.
This commit is contained in:
59
ts/cli.ts
59
ts/cli.ts
@@ -223,6 +223,24 @@ export class NupstCli {
|
||||
return;
|
||||
}
|
||||
|
||||
// Handle feature subcommands
|
||||
if (command === 'feature') {
|
||||
const subcommand = commandArgs[0];
|
||||
const featureHandler = this.nupst.getFeatureHandler();
|
||||
|
||||
switch (subcommand) {
|
||||
case 'httpServer':
|
||||
case 'http-server':
|
||||
case 'http':
|
||||
await featureHandler.configureHttpServer();
|
||||
break;
|
||||
default:
|
||||
this.showFeatureHelp();
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Handle config subcommand
|
||||
if (command === 'config') {
|
||||
const subcommand = commandArgs[0] || 'show';
|
||||
@@ -294,6 +312,26 @@ export class NupstCli {
|
||||
` ${theme.path('/etc/nupst/config.json')}`,
|
||||
], 60, 'info');
|
||||
|
||||
// HTTP Server Status (if configured)
|
||||
if (config.httpServer) {
|
||||
const serverStatus = config.httpServer.enabled
|
||||
? theme.success('Enabled')
|
||||
: theme.dim('Disabled');
|
||||
|
||||
logger.log('');
|
||||
logger.logBox('HTTP Server', [
|
||||
`Status: ${serverStatus}`,
|
||||
...(config.httpServer.enabled ? [
|
||||
`Port: ${theme.highlight(String(config.httpServer.port))}`,
|
||||
`Path: ${theme.highlight(config.httpServer.path)}`,
|
||||
`Auth Token: ${theme.dim('***' + config.httpServer.authToken.slice(-4))}`,
|
||||
'',
|
||||
theme.dim('Usage:'),
|
||||
` curl -H "Authorization: Bearer TOKEN" http://localhost:${config.httpServer.port}${config.httpServer.path}`,
|
||||
] : []),
|
||||
], 70, config.httpServer.enabled ? 'success' : 'default');
|
||||
}
|
||||
|
||||
// UPS Devices Table
|
||||
if (config.upsDevices.length > 0) {
|
||||
const upsRows = config.upsDevices.map((ups) => ({
|
||||
@@ -466,6 +504,7 @@ export class NupstCli {
|
||||
this.printCommand('ups <subcommand>', 'Manage UPS devices');
|
||||
this.printCommand('group <subcommand>', 'Manage UPS groups');
|
||||
this.printCommand('action <subcommand>', 'Manage UPS actions');
|
||||
this.printCommand('feature <subcommand>', 'Manage optional features');
|
||||
this.printCommand('config [show]', 'Display current configuration');
|
||||
this.printCommand('update', 'Update NUPST from repository', theme.dim('(requires root)'));
|
||||
this.printCommand('uninstall', 'Completely remove NUPST', theme.dim('(requires root)'));
|
||||
@@ -509,6 +548,11 @@ export class NupstCli {
|
||||
this.printCommand('nupst action list [target-id]', 'List all actions (optionally for specific target)');
|
||||
console.log('');
|
||||
|
||||
// Feature subcommands
|
||||
logger.log(theme.info('Feature Subcommands:'));
|
||||
this.printCommand('nupst feature httpServer', 'Configure HTTP server for JSON status export');
|
||||
console.log('');
|
||||
|
||||
// Options
|
||||
logger.log(theme.info('Options:'));
|
||||
this.printCommand('--debug, -d', 'Enable debug mode for detailed SNMP logging');
|
||||
@@ -632,6 +676,21 @@ Examples:
|
||||
nupst action add default - Add a new action to UPS or group 'default'
|
||||
nupst action remove default 0 - Remove action at index 0 from UPS or group 'default'
|
||||
nupst action add dc-rack-1 - Add a new action to group 'dc-rack-1'
|
||||
`);
|
||||
}
|
||||
|
||||
private showFeatureHelp(): void {
|
||||
logger.log(`
|
||||
NUPST - Feature Management Commands
|
||||
|
||||
Usage:
|
||||
nupst feature <subcommand>
|
||||
|
||||
Subcommands:
|
||||
httpServer - Configure HTTP server for JSON status export
|
||||
|
||||
Examples:
|
||||
nupst feature httpServer - Enable/disable HTTP server with interactive setup
|
||||
`);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user