MCPcopy Create free account
hub / github.com/TeleBoxOrg/TeleBox_Plugins / fetchServiceMonitorFull

Function fetchServiceMonitorFull

nezha/nezha.ts:273–299  ·  view source on GitHub ↗
(
  config: NeZhaConfig,
  serverId: number
)

Source from the content-addressed store, hash-verified

271 let secret = config.secret;
272 if (config.configPath) {
273 const fileSecret = readSecretFromConfig(config.configPath);
274 if (fileSecret) secret = fileSecret;
275 }
276 const token = generateJWT(secret);
277 const apiUrl = config.url.replace(/\/$/, "") + `/api/v1/service/${serverId}`;
278 const response = await axios.get<ServiceMonitorData>(apiUrl, {
279 timeout: 10000,
280 headers: {
281 Cookie: `nz-jwt=${token}`,
282 "User-Agent": "TeleBox-NeZha-Plugin/1.0",
283 },
284 });
285 if (response.data.success && response.data.data) {
286 return response.data.data;
287 }
288 } catch (error: any) {
289 console.error(`[NeZha Debug] Service monitor full API error:`, error.message || error);
290 }
291 return [];
292}
293
294function generateChartConfig(monitorData: ServiceMonitorItem[], serverName: string): object {
295 const colors = [
296 "rgb(0, 255, 255)",
297 "rgb(255, 99, 132)",
298 "rgb(50, 205, 50)",
299 "rgb(255, 215, 0)",
300 "rgb(255, 105, 180)",
301 "rgb(255, 165, 0)",
302 ];

Callers 1

nezhaFunction · 0.85

Calls 3

readSecretFromConfigFunction · 0.85
generateJWTFunction · 0.85
errorMethod · 0.80

Tested by

no test coverage detected