New monitors

This commit is contained in:
2025-10-06 00:52:44 -04:00
parent 68f0912843
commit 6806bf5b69
9 changed files with 396 additions and 778 deletions

View File

@@ -20,9 +20,9 @@ const client = new Client({
});
let monitorMessages = {
Gaming: null,
Discord: null,
Web: null
'Web Services': null,
'Infrastructure': null,
'Network': null
};
client.once('ready', async () => {
@@ -56,25 +56,56 @@ async function updateMessages() {
const response = await axios.get(config.backendUrl);
const monitors = response.data;
// Check if the backend returned an error
if (monitors.error) {
console.error('Backend API error:', monitors.message);
return;
}
// Ensure monitors is an array
if (!Array.isArray(monitors)) {
console.error('Backend returned invalid data format:', typeof monitors);
return;
}
console.log(`Fetched ${monitors.length} monitors from backend`);
console.log('Monitor names:', monitors.map(m => m.monitor_name));
const gamingMonitors = monitors.filter(monitor => [
'Lobby', 'Skyblock', 'Survival', 'Creative', 'KitPvP', 'Factions', 'Prison', 'Skywars'
const webServicesMonitors = monitors.filter(monitor => [
'Main Page', 'Pelican', 'Jellyfin', 'Proxmox', 'Jellyseerr',
'CPanel', 'WHMCS', 'Gitea', 'Nextcloud', 'Radarr', 'Sonarr',
'Prowlarr', 'Nginx Proxy Manager', 'Authentik', 'n8n', 'HA Proxy'
].includes(monitor.monitor_name));
const discordMonitors = monitors.filter(monitor => [
'Discord bot', 'Status bot'
const infrastructureMonitors = monitors.filter(monitor => [
'a01.pve.hrs', 'a05.pve.hrs', 'a07.pve.hrs', 'a08.pve.hrs', 'a09.pve.hrs',
'01.bw.hrs', '01.ga.hrs', '01.ha.hrs', '01.lh.hrs', '01.nc.hrs'
].includes(monitor.monitor_name));
const webMonitors = monitors.filter(monitor => [
'web1', 'web2', 'web3'
const networkMonitors = monitors.filter(monitor => [
'01.sh.hrs', '01.rs.hrs', '01.pe.hrs', '01.pt.hrs', '01.rr.hrs',
'01.wn.hrs', '02.pe.hrs', '01.cp.hrs', '02.cp.hrs', 'a06'
].includes(monitor.monitor_name));
await sendMonitorsMessage(channel, 'Gaming', gamingMonitors);
await sendMonitorsMessage(channel, 'Discord', discordMonitors);
await sendMonitorsMessage(channel, 'Web', webMonitors);
console.log(`Web Services: ${webServicesMonitors.length}, Infrastructure: ${infrastructureMonitors.length}, Network: ${networkMonitors.length}`);
await sendMonitorsMessage(channel, 'Web Services', webServicesMonitors);
// await sendMonitorsMessage(channel, 'Infrastructure', infrastructureMonitors);
//await sendMonitorsMessage(channel, 'Network', networkMonitors);
} catch (error) {
console.error('Error:', error);
console.error('Error updating messages:', error);
// If it's an axios error, log more details
if (error.response) {
console.error('Backend API error:', error.response.status, error.response.statusText);
console.error('Response data:', error.response.data);
} else if (error.request) {
console.error('No response from backend API:', error.request);
} else {
console.error('Request setup error:', error.message);
}
}
}
@@ -100,6 +131,11 @@ async function sendMonitorsMessage(channel, category, monitors) {
return `${statusEmoji} | ${monitor.monitor_name}`;
}).join('\n');
// Ensure description is not empty (Discord.js validation requirement)
if (!description || description.trim() === '') {
description = `No ${category.toLowerCase()} monitors found.`;
}
let embed = new EmbedBuilder()
.setTitle(`${category} Monitor`)
.setColor('#0099ff')