diff --git a/public/js/app.js b/public/js/app.js
index 051bd43..b1aec11 100644
--- a/public/js/app.js
+++ b/public/js/app.js
@@ -1865,11 +1865,12 @@
if (dom.sourceFilter) {
const current = dom.sourceFilter.value;
let html = '';
- sources.forEach(source => {
+ const displaySources = sources.filter(s => s.type !== 'blackbox');
+ displaySources.forEach(source => {
html += ``;
});
dom.sourceFilter.innerHTML = html;
- if (sources.some(s => s.name === current)) {
+ if (displaySources.some(s => s.name === current)) {
dom.sourceFilter.value = current;
} else {
dom.sourceFilter.value = 'all';
@@ -1889,9 +1890,11 @@
try {
const response = await fetch('/api/sources');
const sources = await response.json();
- if (dom.totalServersLabel) dom.totalServersLabel.textContent = `服务器总数 (${sources.length} 数据源)`;
- updateSourceFilterOptions(sources);
- renderSources(sources);
+ const sourcesArray = Array.isArray(sources) ? sources : [];
+ const promSources = sourcesArray.filter(s => s.type !== 'blackbox');
+ if (dom.totalServersLabel) dom.totalServersLabel.textContent = `服务器总数 (${promSources.length} 数据源)`;
+ updateSourceFilterOptions(sourcesArray);
+ renderSources(sourcesArray);
} catch (err) {
console.error('Error loading sources:', err);
}
@@ -2061,7 +2064,8 @@
const response = await fetch('/api/sources');
const sources = await response.json();
const sourcesArray = Array.isArray(sources) ? sources : [];
- if (dom.totalServersLabel) dom.totalServersLabel.textContent = `服务器总数 (${sourcesArray.length} 数据源)`;
+ const promSources = sourcesArray.filter(s => s.type !== 'blackbox');
+ if (dom.totalServersLabel) dom.totalServersLabel.textContent = `服务器总数 (${promSources.length} 数据源)`;
updateSourceFilterOptions(sourcesArray);
} catch (err) {
// ignore
diff --git a/server/index.js b/server/index.js
index 7aec305..bdf1baf 100644
--- a/server/index.js
+++ b/server/index.js
@@ -610,7 +610,7 @@ app.post('/api/settings', requireAuth, async (req, res) => {
// Reusable function to get overview metrics
async function getOverview() {
- const [sources] = await db.query('SELECT * FROM prometheus_sources WHERE is_server_source = 1');
+ const [sources] = await db.query('SELECT * FROM prometheus_sources WHERE is_server_source = 1 AND type != "blackbox"');
if (sources.length === 0) {
return {
totalServers: 0,
@@ -751,7 +751,7 @@ app.get('/api/metrics/network-history', async (req, res) => {
const cached = await cache.get(cacheKey);
if (cached) return res.json(cached);
- const [sources] = await db.query('SELECT * FROM prometheus_sources WHERE is_server_source = 1');
+ const [sources] = await db.query('SELECT * FROM prometheus_sources WHERE is_server_source = 1 AND type != "blackbox"');
if (sources.length === 0) {
return res.json({ timestamps: [], rx: [], tx: [] });
}
@@ -780,7 +780,7 @@ app.get('/api/metrics/network-history', async (req, res) => {
// Get CPU usage history for sparklines
app.get('/api/metrics/cpu-history', async (req, res) => {
try {
- const [sources] = await db.query('SELECT * FROM prometheus_sources WHERE is_server_source = 1');
+ const [sources] = await db.query('SELECT * FROM prometheus_sources WHERE is_server_source = 1 AND type != "blackbox"');
if (sources.length === 0) {
return res.json({ timestamps: [], values: [] });
}