feat: display panel or nodes host

This commit is contained in:
hirzidevs
2024-09-13 21:20:35 +07:00
parent 5cacb4c9c4
commit f7f1ba850f
3 changed files with 9 additions and 3 deletions
+3 -1
View File
@@ -75,14 +75,16 @@ nodes_settings:
details: true # Show node details such as memory and disk usage (true/false).
servers: false # Show server details (true/false).
allocations_as_max_servers: false # Show allocations as max servers (true/false).
host: false # Show node host (true/false).
unit: "byte" # Unit for node usage, Available types: "byte" or "percentage".
uptime: true # Enable or disable node uptime (true/false).
limit: 100 # Node limit for usage statistics display.
# Panel Users and Servers Settings
panel_settings:
status: true # Display panel stats above node stats (true/false).
host: false # Show panel host (true/false).
uptime: true # Enable or disable node uptime (true/false).
status: true # Display panel stats under node stats (true/false).
servers: true # Display servers count (true/false).
users: true # Display users count (true/false).
+5 -2
View File
@@ -23,7 +23,8 @@ module.exports = function App() {
servers: results.servers,
users: results.users,
});
} catch {
} catch (error) {
if (config.log_error) console.error(error)
console.log(cliColor.cyanBright("[PteroStats] ") + cliColor.redBright("Panel is currently offline."));
fs.readFile(require('node:path').join(__dirname, "../cache.json"), (err, data) => {
@@ -113,6 +114,7 @@ module.exports = function App() {
name: `${node.attributes.name} - ${node.status ? config.status.online : config.status.offline}`,
value:
"```\n" +
(config.nodes_settings.host ? `Host : ${node.attributes.fqdn}\n` : "") +
`Memory : ${convertUnits(node.attributes.allocated_resources.memory, node.attributes.memory, config.nodes_settings.unit)}\n` +
`Disk : ${convertUnits(node.attributes.allocated_resources.disk, node.attributes.disk, config.nodes_settings.unit)}` +
(node.attributes?.allocated_resources?.cpu ? `\nCPU : ${node.attributes?.allocated_resources?.cpu || 0}%` : "") +
@@ -151,6 +153,7 @@ module.exports = function App() {
name: `Panel - ${panel ? config.status.online : config.status.offline}`,
value:
"```\n" +
(config.panel_settings.host ? `Host : ${new URL(process.env.PanelURL).host}\n` : "") +
`Nodes : ${nodes.length}\n` +
(config.panel_settings.servers ? `Servers: ${servers || "Unknown"}\n` : "") +
(config.panel_settings.users ? `Users : ${users || "Unknown"}\n` : "") +
@@ -230,7 +233,7 @@ module.exports = function App() {
}
process.exit();
} catch (err) {
console.log(error)
console.error(error)
process.exit();
}
}
+1
View File
@@ -39,6 +39,7 @@ module.exports = async function getStats() {
memory: node.attributes.memory,
disk: node.attributes.disk,
cpu: node.attributes.cpu,
fqdn: node.attributes.fqdn,
allocated_resources: node.attributes.allocated_resources,
relationships: {
allocations: node.attributes.relationships.allocations.data.length,