🎉 Sync 2026-03-23 03:47:01

This commit is contained in:
github-actions[bot] committed 2026-03-23 03:47:01 +08:00
1 parent 9028beac27
commit 5e79f3a579
78 files changed
+1873 -11153

No files matched your search

@@ -1,53 +0,0 @@
#!/usr/bin/ucode
/*
* SPDX-License-Identifier: GPL-2.0-only
*
* Copyright (C) 2021-2025 sirpdboy <herboy2008@gmail.com> https://github.com/sirpdboy/luci-app-netdata
*/
'use strict';
import { access, popen } from 'fs';
function get_netdata_version() {
if (!access('/usr/sbin/netdata'))
return null;
const fd = popen("a=`/usr/sbin/netdata -v`&&echo $a |awk -F v '{printf $2}'");
if (fd) {
let output = trim(fd.read('all'));
fd.close();
// 方法1: 简单替换(推荐)
let version_with_v = replace(output, "netdata ", "");
// 方法2: 去掉 v 前缀
let version_clean = replace(version_with_v, "v", "");
return version_with_v; // 返回 "v2.3.2"
}
return null;
}
const methods = {
get_version: {
call: function() {
let version = get_netdata_version();
if (!version)
return { version: null, error: '无法获取 netdata 版本' };
return { version: version };
}
},
get_version_clean: {
call: function() {
let version = get_netdata_version();
if (!version)
return { version: null, error: '无法获取 netdata 版本' };
// 去掉 "v" 前缀,返回纯数字版本
let clean_version = replace(version, /^v/, "");
return { version: clean_version };
}
}
};
return { 'luci.netdata': methods };