哪吒监控所在的服务器快到期了,昨天看文档打包转移到了新服务器上,但是重启面板后所有agent端都离线了,怎么才能重新激活?之前用客户端的命令重新安装的时候会 出现重复服务器的问题,有没有办法不重新安装而激活呢?
重新安装时加上NZ_UUID?
这个。。。。可以吗?
佬友这个主题不错啊?是自己写的吗?
curl -L https://raw.githubusercontent.com/nezhahq/scripts/main/agent/install.sh -o agent.sh && chmod +x agent.sh && env NZ_SERVER=x.x.x.x:8008 NZ_TLS=false NZ_CLIENT_SECRET=xxxxxx NZ_UUID=被控机UUID ./agent.sh
像这样在被控机重装agent时,在后面加上被控机的UUID就不会出现重复服务器
我记得老版本里面有个设置能一键通知客户端切地址,不知道现在有没有
不是不是,NS论坛拿来的
<script>
window.CustomBackgroundImage="https://easyimage.01011205.xyz/i/0/2024/12/18/isgmmj-0.webp"; /* 页面背景图 */
window.CustomLogo = "https://easyimage.01011205.xyz/i/2024/09/08/nlnmn5.png"; /* 自定义Logo */
window.ShowNetTransfer = "true"; /* 卡片显示上下行流量 */
window.DisableAnimatedMan = "true"; /* 关掉动画人物插图 */
window.CustomIllustration = 'https://img.028029.xyz/1734592545615.png'; /*替换人物插图。如果需要关闭请把上面一行取消注释 */
window.CustomDesc ="针不错"; /* 自定义描述 */
</script>
<style>
.world-map-box {
display: none !important;
}
window.FixedTopServerName = true; /* 固定顶部显示服务器名称 */
setInterval(function() {
function formatFileSize(bytes) {
if (bytes === 0) return { value: '0', unit: 'B' };
const units = ['B', 'KB', 'MB', 'GB', 'TB', 'PB'];
let unitIndex = 0;
let size = bytes;
while (size >= 1024 && unitIndex < units.length - 1) {
size /= 1024;
unitIndex++;
}
let decimalPlaces = 1;
if (unitIndex === 0) decimalPlaces = 0;
return {
value: size.toFixed(decimalPlaces),
unit: units[unitIndex]
};
}
function calculatePercentage(used, total) {
if (typeof used === 'string') used = Number(used);
if (typeof total === 'string') total = Number(total);
if (used > 1e15 || total > 1e15) {
used = used / 1e10;
total = total / 1e10;
}
return (used / total * 100).toFixed(1);
}
fetch('/api/v1/service')
.then(response => response.json())
.then(data => {
if (data.success) {
const trafficData = data.data.cycle_transfer_stats;
const serverMap = new Map();
for (const cycleId in trafficData) {
const cycle = trafficData[cycleId];
if (cycle.server_name && cycle.transfer) {
for (const serverId in cycle.server_name) {
const serverName = cycle.server_name[serverId];
const transfer = cycle.transfer[serverId];
const max = cycle.max;
if (serverName && transfer !== undefined && max) {
serverMap.set(serverName, {
id: serverId, // 服务器ID
transfer: transfer, // 已使用流量(字节)
max: max, // 最大流量(字节)
name: cycle.name // 流量包名称
});
}
}
}
}
serverMap.forEach((serverData, serverName) => {
const targetElement = Array.from(document.querySelectorAll('section.grid.items-center.gap-2')).find(el =>
el.textContent.trim().includes(serverName));
if (targetElement) {
const usedFormatted = formatFileSize(serverData.transfer);
const totalFormatted = formatFileSize(serverData.max);
const percentage = calculatePercentage(serverData.transfer, serverData.max);
const uniqueClassName = 'traffic-stats-for-server-' + serverData.id;
const insertedElement = targetElement.parentNode.querySelector('.' + uniqueClassName);
if (insertedElement) {
const usedSpan = insertedElement.querySelector('.used-traffic');
const usedUnitSpan = insertedElement.querySelector('.used-unit');
const totalSpan = insertedElement.querySelector('.total-traffic');
const totalUnitSpan = insertedElement.querySelector('.total-unit');
const percentageSpan = insertedElement.querySelector('.percentage-value');
const progressBar = insertedElement.querySelector('.progress-bar');
if (usedSpan) usedSpan.textContent = usedFormatted.value;
if (usedUnitSpan) usedUnitSpan.textContent = usedFormatted.unit;
if (totalSpan) totalSpan.textContent = totalFormatted.value;
if (totalUnitSpan) totalUnitSpan.textContent = totalFormatted.unit;
if (percentageSpan) percentageSpan.textContent = percentage + '%';
if (progressBar) progressBar.style.width = percentage + '%';
return;
}
let currentElement = targetElement;
for (let i = 0; i < 2; i++) {
currentElement = currentElement.nextElementSibling;
if (!currentElement) {
currentElement = targetElement;
currentElement = currentElement.nextElementSibling;
}
}
const newElement = document.createElement('div');
newElement.classList.add('space-y-1.5', 'new-inserted-element', uniqueClassName);
newElement.style.width = '100%';
newElement.innerHTML = `
<div class="flex items-center justify-between">
<div class="flex items-baseline gap-1">
<span class="text-sm font-medium text-neutral-800 dark:text-neutral-200 used-traffic">${usedFormatted.value}</span>
<span class="text-sm font-medium text-neutral-800 dark:text-neutral-200 used-unit">${usedFormatted.unit}</span>
<span class="text-xs text-neutral-500 dark:text-neutral-400">/ </span>
<span class="text-xs text-neutral-500 dark:text-neutral-400 total-traffic">${totalFormatted.value}</span>
<span class="text-xs text-neutral-500 dark:text-neutral-400 total-unit">${totalFormatted.unit}</span>
</div>
<span class="text-xs font-medium text-neutral-600 dark:text-neutral-300 percentage-value">${percentage}%</span>
</div>
<div class="relative h-1.5">
<div class="absolute inset-0 bg-neutral-100 dark:bg-neutral-800 rounded-full"></div>
<div class="absolute inset-0 bg-emerald-500 rounded-full transition-all duration-300 progress-bar" style="width: ${percentage}%;"></div>
</div>
`;
currentElement.insertAdjacentElement('afterend', newElement);
} else {
console.log(`没有找到服务器 ${serverName}(ID: ${serverData.id}) 的元素`);
}
});
} else {
console.log('API请求成功但返回数据不正确');
}
})
.catch(error => {
console.error('获取流量数据失败:', error);
});
}, 3000);
</style>
1 个赞
好的,我去试试。谢啦
是按照这个搬的吗
你在新服务器运行 ./nezha.sh 就是重启并更新面板


