feat(daemon): Add UPSD (NUT) protocol support, Proxmox VM shutdown action, pause/resume monitoring, and network-loss/unreachable handling; bump config version to 4.2
This commit is contained in:
41
ts/cli.ts
41
ts/cli.ts
@@ -26,8 +26,9 @@ export class NupstCli {
|
||||
const debugOptions = this.extractDebugOptions(args);
|
||||
if (debugOptions.debugMode) {
|
||||
logger.log('Debug mode enabled');
|
||||
// Enable debug mode in the SNMP client
|
||||
// Enable debug mode in both protocol clients
|
||||
this.nupst.getSnmp().enableDebug();
|
||||
this.nupst.getUpsd().enableDebug();
|
||||
}
|
||||
|
||||
// Check for version flag
|
||||
@@ -259,6 +260,12 @@ export class NupstCli {
|
||||
|
||||
// Handle top-level commands
|
||||
switch (command) {
|
||||
case 'pause':
|
||||
await serviceHandler.pause(commandArgs);
|
||||
break;
|
||||
case 'resume':
|
||||
await serviceHandler.resume();
|
||||
break;
|
||||
case 'update':
|
||||
await serviceHandler.update();
|
||||
break;
|
||||
@@ -351,18 +358,32 @@ export class NupstCli {
|
||||
|
||||
// UPS Devices Table
|
||||
if (config.upsDevices.length > 0) {
|
||||
const upsRows = config.upsDevices.map((ups) => ({
|
||||
name: ups.name,
|
||||
id: theme.dim(ups.id),
|
||||
host: `${ups.snmp.host}:${ups.snmp.port}`,
|
||||
model: ups.snmp.upsModel || 'cyberpower',
|
||||
actions: `${(ups.actions || []).length} configured`,
|
||||
groups: ups.groups.length > 0 ? ups.groups.join(', ') : theme.dim('None'),
|
||||
}));
|
||||
const upsRows = config.upsDevices.map((ups) => {
|
||||
const protocol = ups.protocol || 'snmp';
|
||||
let host = 'N/A';
|
||||
let model = '';
|
||||
if (protocol === 'upsd' && ups.upsd) {
|
||||
host = `${ups.upsd.host}:${ups.upsd.port}`;
|
||||
model = `NUT:${ups.upsd.upsName}`;
|
||||
} else if (ups.snmp) {
|
||||
host = `${ups.snmp.host}:${ups.snmp.port}`;
|
||||
model = ups.snmp.upsModel || 'cyberpower';
|
||||
}
|
||||
return {
|
||||
name: ups.name,
|
||||
id: theme.dim(ups.id),
|
||||
protocol: protocol.toUpperCase(),
|
||||
host,
|
||||
model,
|
||||
actions: `${(ups.actions || []).length} configured`,
|
||||
groups: ups.groups.length > 0 ? ups.groups.join(', ') : theme.dim('None'),
|
||||
};
|
||||
});
|
||||
|
||||
const upsColumns: ITableColumn[] = [
|
||||
{ header: 'Name', key: 'name', align: 'left', color: theme.highlight },
|
||||
{ header: 'ID', key: 'id', align: 'left' },
|
||||
{ header: 'Protocol', key: 'protocol', align: 'left' },
|
||||
{ header: 'Host:Port', key: 'host', align: 'left', color: theme.info },
|
||||
{ header: 'Model', key: 'model', align: 'left' },
|
||||
{ header: 'Actions', key: 'actions', align: 'left' },
|
||||
@@ -534,6 +555,8 @@ export class NupstCli {
|
||||
this.printCommand('action <subcommand>', 'Manage UPS actions');
|
||||
this.printCommand('feature <subcommand>', 'Manage optional features');
|
||||
this.printCommand('config [show]', 'Display current configuration');
|
||||
this.printCommand('pause [--duration <time>]', 'Pause action monitoring');
|
||||
this.printCommand('resume', 'Resume action monitoring');
|
||||
this.printCommand('update', 'Update NUPST from repository', theme.dim('(requires root)'));
|
||||
this.printCommand('uninstall', 'Completely remove NUPST', theme.dim('(requires root)'));
|
||||
this.printCommand('help, --help, -h', 'Show this help message');
|
||||
|
||||
Reference in New Issue
Block a user