fix(cli/systemd): Fix status command to pass debug flag and improve systemd status logging output
This commit is contained in:
parent
5eefe8cf40
commit
edce110c8a
@ -1,5 +1,11 @@
|
||||
# Changelog
|
||||
|
||||
## 2025-03-25 - 2.0.1 - fix(cli/systemd)
|
||||
Fix status command to pass debug flag and improve systemd status logging output
|
||||
|
||||
- ts/cli.ts: Now extracts debug options from process arguments and passes debug mode to getStatus.
|
||||
- ts/systemd.ts: Updated getStatus to accept a debugMode parameter, enabling detailed SNMP debug logging, explicitly reloading configuration, and printing connection details.
|
||||
|
||||
## 2025-03-25 - 2.0.0 - BREAKING CHANGE(snmp)
|
||||
refactor: update SNMP type definitions and interface names for consistency
|
||||
|
||||
|
@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@serve.zone/nupst',
|
||||
version: '2.0.0',
|
||||
version: '2.0.1',
|
||||
description: 'Node.js UPS Shutdown Tool for SNMP-enabled UPS devices'
|
||||
}
|
||||
|
@ -182,7 +182,9 @@ export class NupstCli {
|
||||
* Show status of the systemd service and UPS
|
||||
*/
|
||||
private async status(): Promise<void> {
|
||||
await this.nupst.getSystemd().getStatus();
|
||||
// Extract debug options from args array
|
||||
const debugOptions = this.extractDebugOptions(process.argv);
|
||||
await this.nupst.getSystemd().getStatus(debugOptions.debugMode);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -126,9 +126,18 @@ WantedBy=multi-user.target
|
||||
|
||||
/**
|
||||
* Get status of the systemd service and UPS
|
||||
* @param debugMode Whether to enable debug mode for SNMP
|
||||
*/
|
||||
public async getStatus(): Promise<void> {
|
||||
public async getStatus(debugMode: boolean = false): Promise<void> {
|
||||
try {
|
||||
// Enable debug mode if requested
|
||||
if (debugMode) {
|
||||
console.log('┌─ Debug Mode ─────────────────────────────┐');
|
||||
console.log('│ SNMP debugging enabled - detailed logs will be shown');
|
||||
console.log('└──────────────────────────────────────────┘');
|
||||
this.daemon.getNupstSnmp().enableDebug();
|
||||
}
|
||||
|
||||
// Display version information
|
||||
this.daemon.getNupstSnmp().getNupst().logVersionInfo();
|
||||
|
||||
@ -170,6 +179,8 @@ WantedBy=multi-user.target
|
||||
*/
|
||||
private async displayUpsStatus(): Promise<void> {
|
||||
try {
|
||||
// Explicitly load the configuration first to ensure it's up-to-date
|
||||
await this.daemon.loadConfig();
|
||||
const config = this.daemon.getConfig();
|
||||
const snmp = this.daemon.getNupstSnmp();
|
||||
|
||||
@ -179,6 +190,11 @@ WantedBy=multi-user.target
|
||||
timeout: Math.min(config.snmp.timeout, 10000) // Use at most 10 seconds for status check
|
||||
};
|
||||
|
||||
console.log('┌─ Connecting to UPS... ────────────────────┐');
|
||||
console.log(`│ Host: ${config.snmp.host}:${config.snmp.port}`);
|
||||
console.log(`│ UPS Model: ${config.snmp.upsModel || 'cyberpower'}`);
|
||||
console.log('└──────────────────────────────────────────┘');
|
||||
|
||||
const status = await snmp.getUpsStatus(snmpConfig);
|
||||
|
||||
console.log('┌─ UPS Status ───────────────────────────────┐');
|
||||
|
Loading…
x
Reference in New Issue
Block a user