Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
4af9af0845 | |||
f7e12cdcbb | |||
002498b91b | |||
459911fe5f | |||
9859a02ea2 | |||
65444b6d25 | |||
d049e8741f | |||
1123a99aea |
24
changelog.md
24
changelog.md
@ -1,5 +1,29 @@
|
||||
# Changelog
|
||||
|
||||
## 2025-03-26 - 2.6.12 - fix(systemd)
|
||||
Adjust logging border in systemd service installation output
|
||||
|
||||
- Updated the closing border line for consistent output formatting in ts/systemd.ts
|
||||
|
||||
## 2025-03-26 - 2.6.11 - fix(cli, systemd)
|
||||
Adjust log formatting for consistent output in CLI and systemd commands
|
||||
|
||||
- Fixed spacing issues in service installation and status log messages in the systemd module.
|
||||
- Revised output formatting in the CLI to improve message clarity.
|
||||
|
||||
## 2025-03-26 - 2.6.10 - fix(daemon)
|
||||
Adjust console log box formatting for consistent output in daemon status messages
|
||||
|
||||
- Updated closing box borders to align properly in configuration error, periodic updates, and UPS status logs
|
||||
- Improved visual consistency in log messages
|
||||
|
||||
## 2025-03-26 - 2.6.9 - fix(cli)
|
||||
Improve console output formatting for status banners and logging messages
|
||||
|
||||
- Standardize banner messages in daemon status updates
|
||||
- Refine version information banner in nupst logging
|
||||
- Update UPS connection and status banners in systemd
|
||||
|
||||
## 2025-03-26 - 2.6.8 - fix(cli)
|
||||
Improve CLI formatting, refine debug option filtering, and remove unused dgram import in SNMP manager
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@serve.zone/nupst",
|
||||
"version": "2.6.8",
|
||||
"version": "2.6.12",
|
||||
"description": "Node.js UPS Shutdown Tool for SNMP-enabled UPS devices",
|
||||
"main": "dist/index.js",
|
||||
"bin": {
|
||||
|
@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@serve.zone/nupst',
|
||||
version: '2.6.8',
|
||||
version: '2.6.12',
|
||||
description: 'Node.js UPS Shutdown Tool for SNMP-enabled UPS devices'
|
||||
}
|
||||
|
@ -919,7 +919,7 @@ Options:
|
||||
|
||||
if (isActive) {
|
||||
// Service is running, restart it
|
||||
console.log('┌─ Service Update ─────────────────────────┐');
|
||||
console.log('┌─ Service Update ──────────────────────────┐');
|
||||
console.log('│ Configuration has changed.');
|
||||
console.log('│ Restarting NUPST service to apply changes...');
|
||||
|
||||
@ -939,7 +939,7 @@ Options:
|
||||
console.log('│ sudo systemctl restart nupst.service');
|
||||
}
|
||||
|
||||
console.log('└──────────────────────────────────────────┘');
|
||||
console.log('└───────────────────────────────────────────┘');
|
||||
}
|
||||
} catch (error) {
|
||||
// Ignore errors checking service status
|
||||
|
20
ts/daemon.ts
20
ts/daemon.ts
@ -125,7 +125,7 @@ export class NupstDaemon {
|
||||
console.error('┌─ Configuration Error ─────────────────────┐');
|
||||
console.error(`│ ${message}`);
|
||||
console.error('│ Please run \'nupst setup\' first to create a configuration.');
|
||||
console.error('└──────────────────────────────────────────┘');
|
||||
console.error('└───────────────────────────────────────────┘');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -196,7 +196,7 @@ export class NupstDaemon {
|
||||
console.log(`│ Battery: ${this.config.thresholds.battery}%`);
|
||||
console.log(`│ Runtime: ${this.config.thresholds.runtime} minutes`);
|
||||
console.log(`│ Check Interval: ${this.config.checkInterval / 1000} seconds`);
|
||||
console.log('└──────────────────────────────────────────┘');
|
||||
console.log('└────────────────────────────────────────────┘');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -226,20 +226,20 @@ export class NupstDaemon {
|
||||
|
||||
// Log status changes
|
||||
if (status.powerStatus !== lastStatus) {
|
||||
console.log('┌──────────────────────────────────────────┐');
|
||||
console.log(`│ Power status changed: ${lastStatus} → ${status.powerStatus}`);
|
||||
console.log('└──────────────────────────────────────────┘');
|
||||
console.log('┌─ Power Status Change ─────────────────────┐');
|
||||
console.log(`│ Status changed: ${lastStatus} → ${status.powerStatus}`);
|
||||
console.log('└───────────────────────────────────────────┘');
|
||||
lastStatus = status.powerStatus;
|
||||
lastLogTime = currentTime; // Reset log timer when status changes
|
||||
}
|
||||
// Log status periodically (at least every 5 minutes)
|
||||
else if (shouldLogStatus) {
|
||||
const timestamp = new Date().toISOString();
|
||||
console.log('┌──────────────────────────────────────────┐');
|
||||
console.log(`│ [${timestamp}] Periodic Status Update`);
|
||||
console.log('┌─ Periodic Status Update ──────────────────┐');
|
||||
console.log(`│ Timestamp: ${timestamp}`);
|
||||
console.log(`│ Power Status: ${status.powerStatus}`);
|
||||
console.log(`│ Battery: ${status.batteryCapacity}% | Runtime: ${status.batteryRuntime} min`);
|
||||
console.log('└──────────────────────────────────────────┘');
|
||||
console.log('└───────────────────────────────────────────┘');
|
||||
lastLogTime = currentTime;
|
||||
}
|
||||
|
||||
@ -267,8 +267,8 @@ export class NupstDaemon {
|
||||
batteryCapacity: number,
|
||||
batteryRuntime: number
|
||||
}): Promise<void> {
|
||||
console.log('┌─ UPS Status ───────────────────────────────┐');
|
||||
console.log(`│ Battery: ${status.batteryCapacity}% | Runtime: ${status.batteryRuntime} min │`);
|
||||
console.log('┌─ UPS Status ─────────────────────────────┐');
|
||||
console.log(`│ Battery: ${status.batteryCapacity}% | Runtime: ${status.batteryRuntime} min`);
|
||||
console.log('└──────────────────────────────────────────┘');
|
||||
|
||||
// Check battery threshold
|
||||
|
@ -162,7 +162,7 @@ export class Nupst {
|
||||
*/
|
||||
public logVersionInfo(checkForUpdates: boolean = true): void {
|
||||
const version = this.getVersion();
|
||||
console.log('┌─ NUPST Version ────────────────────────┐');
|
||||
console.log('┌─ NUPST Version ────────────────────────────┐');
|
||||
console.log(`│ Current Version: ${version}`);
|
||||
|
||||
if (this.updateAvailable && this.latestVersion) {
|
||||
|
@ -66,7 +66,7 @@ WantedBy=multi-user.target
|
||||
|
||||
// Write the service file
|
||||
await fs.writeFile(this.serviceFilePath, this.serviceTemplate);
|
||||
console.log('┌─ Service Installation ─────────────────────┐');
|
||||
console.log('┌─ Service Installation ──────────────────────┐');
|
||||
console.log(`│ Service file created at ${this.serviceFilePath}`);
|
||||
|
||||
// Reload systemd daemon
|
||||
@ -76,7 +76,7 @@ WantedBy=multi-user.target
|
||||
// Enable the service
|
||||
execSync('systemctl enable nupst.service');
|
||||
console.log('│ Service enabled to start on boot');
|
||||
console.log('└──────────────────────────────────────────┘');
|
||||
console.log('└────────────────────────────────────────────────┘');
|
||||
} catch (error) {
|
||||
if (error.message === 'Configuration not found') {
|
||||
// Just rethrow the error as the message has already been displayed
|
||||
@ -97,9 +97,9 @@ WantedBy=multi-user.target
|
||||
await this.checkConfigExists();
|
||||
|
||||
execSync('systemctl start nupst.service');
|
||||
console.log('┌─ Service Status ─────────────────────────┐');
|
||||
console.log('┌─ Service Status ───────────────────────────┐');
|
||||
console.log('│ NUPST service started successfully');
|
||||
console.log('└──────────────────────────────────────────┘');
|
||||
console.log('└────────────────────────────────────────────┘');
|
||||
} catch (error) {
|
||||
if (error.message === 'Configuration not found') {
|
||||
// Exit with error code since configuration is required
|
||||
@ -190,20 +190,20 @@ 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('┌─ Connecting to UPS... ─────────────────────┐');
|
||||
console.log(`│ Host: ${config.snmp.host}:${config.snmp.port}`);
|
||||
console.log(`│ UPS Model: ${config.snmp.upsModel || 'cyberpower'}`);
|
||||
console.log('└──────────────────────────────────────────┘');
|
||||
console.log('└────────────────────────────────────────────┘');
|
||||
|
||||
const status = await snmp.getUpsStatus(snmpConfig);
|
||||
|
||||
console.log('┌─ UPS Status ───────────────────────────────┐');
|
||||
console.log('┌─ UPS Status ─────────────────────────────┐');
|
||||
console.log(`│ Power Status: ${status.powerStatus}`);
|
||||
console.log(`│ Battery Capacity: ${status.batteryCapacity}%`);
|
||||
console.log(`│ Runtime Remaining: ${status.batteryRuntime} minutes`);
|
||||
console.log('└──────────────────────────────────────────┘');
|
||||
} catch (error) {
|
||||
console.error('┌─ UPS Status ───────────────────────────────┐');
|
||||
console.error('┌─ UPS Status ─────────────────────────────┐');
|
||||
console.error(`│ Failed to retrieve UPS status: ${error.message}`);
|
||||
console.error('└──────────────────────────────────────────┘');
|
||||
}
|
||||
|
Reference in New Issue
Block a user