Skip to content

Commit

Permalink
feat: slightly improve node checker
Browse files Browse the repository at this point in the history
  • Loading branch information
wdhdev committed Sep 18, 2023
1 parent f606d7f commit 187867f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 145 deletions.
33 changes: 6 additions & 27 deletions bot/discord/serverStatus.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
let nstatus = {
Nodes: [
"Free Nodes": [
{
name: "Node 2",
data: "Node2",
Expand Down Expand Up @@ -127,14 +127,14 @@ let parse = async () => {

da =
da.maintenance === true
? `🟣 Maintenance Mode!`
? `🟣 Maintenance`
: da.status === true
? `🟢 Online ${serverUsage}`
: da.is_vm_online == null
? "🔴 **Offline**"
: (da.is_vm_online === true ? "🟠 Wings" : "🔴 **System**") + ` offline ${serverUsage}`;
: (da.is_vm_online === true ? "🟠 **Wings**" : "🔴 **System**") + ` **offline** ${serverUsage}`;

temp.push(`**${d.name}:** ${da}`);
temp.push(`${d.name}: ${da}`);
}

toRetun[title] = temp;
Expand All @@ -147,31 +147,10 @@ let getEmbed = async () => {
let desc = "";

for (let [title, d] of Object.entries(status)) {
desc = `${desc}**__${title}:__**\n${d.join("\n")}\n\n`;
desc = `${desc}***${title}***\n${d.join("\n")}\n\n`;
}

date = new Date();
var hr;
monthNames = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
if (date.getHours() < 10) {
hr = `0${date.getHours()}`;
} else {
hr = date.getHours();
}

var dateString =
"Updated at " +
hr +
":" +
("00" + date.getMinutes()).slice(-2) +
" (GMT) on " +
date.getDate() +
" " +
monthNames[date.getMonth()] +
" " +
date.getFullYear();

let embed = new Discord.MessageEmbed().setTitle("DanBot Hosting Status").setFooter(dateString).setDescription(desc);
let embed = new Discord.MessageEmbed().setTitle("DBH Status").setDescription(desc).setTimestamp();
return embed;
};

Expand Down
104 changes: 0 additions & 104 deletions bot/discord/serverUsage.js

This file was deleted.

21 changes: 7 additions & 14 deletions nodestatsChecker.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
const axios = require("axios");
var ping = require("ping");
const ping2 = require("ping-tcp-js");
const ping = require("ping-tcp-js");

let pingLocals = {
UK: config.Ping.UK,
CA: config.Ping.CA,
};

let stats = {
node1: {
serverID: "7c740e8c",
IP: "176.31.203.22",
ID: "1",
Location: pingLocals.UK,
},
node2: {
serverID: "ca89e5c6",
IP: "176.31.203.21",
Expand Down Expand Up @@ -100,7 +93,7 @@ let stats = {
},
};
if (enabled.nodestatsChecker === true) {
console.log(chalk.magenta("[Nodes Checker] ") + chalk.green("Enabled and Online"));
console.log(chalk.magenta("[Node Checker] ") + chalk.green("Enabled and Online"));
//Node status
setInterval(() => {
//Public nodes
Expand Down Expand Up @@ -148,7 +141,7 @@ if (enabled.nodestatsChecker === true) {
.catch((error) => {
//Node is either offline or wings are offline. Checks if it's maintenance, and then checks for wings.

ping2
ping
.ping(data.IP, 22)
.then(() => {
nodeStatus.set(`${node}.timestamp`, Date.now());
Expand Down Expand Up @@ -188,7 +181,7 @@ if (enabled.nodestatsChecker === true) {
}

// AU 1 VPN Server
ping2
ping
.ping("139.99.171.195", 22)
.then(() =>
nodeStatus.set("au1", {
Expand All @@ -204,7 +197,7 @@ if (enabled.nodestatsChecker === true) {
);

// FR 1 VPN Server
ping2
ping
.ping("176.31.125.135", 22)
.then(() =>
nodeStatus.set("fr1", {
Expand All @@ -220,7 +213,7 @@ if (enabled.nodestatsChecker === true) {
);

// US 1 VPN Server
ping2
ping
.ping("69.197.129.206", 22)
.then(() =>
nodeStatus.set("us1", {
Expand All @@ -236,5 +229,5 @@ if (enabled.nodestatsChecker === true) {
);
}, 10000);
} else {
console.log(chalk.magenta("[Nodes Checker] ") + chalk.red("Disabled"));
console.log(chalk.magenta("[Node Checker] ") + chalk.red("Disabled"));
}

0 comments on commit 187867f

Please sign in to comment.