Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cpu min MHz和max Mhz里的cpu应该是CPU,在我的机器上是这样的 #3

Open
lpdswing opened this issue Aug 18, 2023 · 5 comments

Comments

@lpdswing
Copy link

我的机器是4核心cpu

        {
          itemId: 'thermal',
          colspan: 2,
          printBar: false,
          title: gettext('CPU温度'),
          textField: 'thermalstate',
          renderer:function(value){
              // const p0 = value.match(/Package id 0.*?\+([\d\.]+)Â/)[1];  // CPU包温度
              const c0 = value.match(/Core 0.*?\+([\d\.]+)?/)[1];  // CPU核心1温度
              const c1 = value.match(/Core 1.*?\+([\d\.]+)?/)[1];  // CPU核心2温度
              const c2 = value.match(/Core 2.*?\+([\d\.]+)?/)[1];  // CPU核心3温度
              const c3 = value.match(/Core 3.*?\+([\d\.]+)?/)[1];  // CPU核心4温度
              // const b0 = value.match(/temp1.*?\+([\d\.]+)?/)[1];  // 主板温度
              // const b1 = value.match(/temp2.*?\+([\d\.]+)?/)[1];  // 主板温度2
              return ` 核心1: ${c0} ℃ | 核心2: ${c1} ℃ | 核心3: ${c2} ℃ | 核心4: ${c3} ℃`  // 不带主板温度
              // return `Package: ${p0} ℃ || 核心1: ${c0} ℃ | 核心2: ${c1} ℃ | 核心3: ${c2} ℃ | 核心4: ${c3} ℃ || 主板: ${b0} ℃ | ${b1} ℃ `  // 带主板温度
            }
    },
        {
          itemId: 'MHz',
          colspan: 2,
          printBar: false,
          title: gettext('CPU频率'),
          textField: 'cpusensors',
          renderer:function(value){
                          const f0 = value.match(/cpu MHz.*?([\d]+)/)[1];
                          const f1 = value.match(/CPU min MHz.*?([\d]+)/)[1];
                          const f2 = value.match(/CPU max MHz.*?([\d]+)/)[1];
                          return `CPU实时: ${f0} MHz | 最小: ${f1} MHz | 最大: ${f2} MHz `
            }
        },
        // /* 检测不到相关参数的可以注释掉---需要的注释本行即可
        /* 风扇转速
        {
          itemId: 'RPM',
          colspan: 2,
          printBar: false,
          title: gettext('CPU风扇'),
          textField: 'thermalstate',
          renderer:function(value){
                          const fan1 = value.match(/fan1:.*?\ ([\d.]+) R/)[1];
                          const fan2 = value.match(/fan2:.*?\ ([\d.]+) R/)[1];
                          return `CPU风扇: ${fan1} RPM | 系统风扇: ${fan2} RPM `
            }
        },
        // 检测不到相关参数的可以注释掉---需要的注释本行即可  */
        // /* 检测不到相关参数的可以注释掉---需要的注释本行即可
        // NVME硬盘温度
        {
          itemId: 'nvme_ssd-temperatures',
          colspan: 2,
          printBar: false,
          title: gettext('NVME硬盘'),
          textField: 'nvme_ssd_temperatures',
          renderer:function(value){
          if (value.length > 0) {
          let nvmedevices = value.matchAll(/^Model.*:\s*([\s\S]*?)(\n^Total.*\[[\s\S]*?\]$|\s{0}$)\n^Temperature:\s*([\d]+)\s*Celsius\n^Percentage.*([\d]+\%)\n^Data Units.*\[([\s\S]*?)\]\n^Data Units.*\[([\s\S]*?)\]\n^Power.*:\s*([\s\S]*?)\n/gm);
          for (const nvmedevice of nvmedevices) {
          for (var i=5; i<8; i++) {
          nvmedevice[i] = nvmedevice[i].replace(/ |,/gm, '');
          }
          if (nvmedevice[2].length > 0) {
          let nvmecapacity = nvmedevice[2].match(/.*\[([\s\S]*?)\]/);
          nvmecapacity = nvmecapacity[1].replace(/ /, '');
          value = `${nvmedevice[1]} | 已使用寿命: ${nvmedevice[4]} (累计读取: ${nvmedevice[5]}, 累计写入: ${nvmedevice[6]}) | 容量: ${nvmecapacity} | 已通电: ${nvmedevice[7]}小时 | 温度: ${nvmedevice[3]}°C\n`;
          } else {
          value = `${nvmedevice[1]} | 已使用寿命: ${nvmedevice[4]} (累计读取: ${nvmedevice[5]}, 累计写入: ${nvmedevice[6]}) | 已通电: ${nvmedevice[7]}小时 | 温度: ${nvmedevice[3]}°C\n`;
          }
          }
          return value.replace(/\n/g, '<br>');
          } else {
          return `提示: 未安装硬盘或已直通硬盘控制器`;
          }
          }
          },
        // /* 检测不到相关参数的可以注释掉---需要的注释本行即可  */
          // SATA硬盘温度
          {
          itemId: 'hdd-temperatures',
          colspan: 2,
          printBar: false,
          title: gettext('SATA硬盘'),
          textField: 'hdd_temperatures',
          renderer:function(value){
          if (value.length > 0) {
          let devices = value.matchAll(/(\s*Model.*:\s*[\s\S]*?\n){1,2}^User.*\[([\s\S]*?)\]\n^\s*9[\s\S]*?\-\s*([\d]+)[\s\S]*?(\n(^19[0,4][\s\S]*?$){1,2}|\s{0}$)/gm);
          for (const device of devices) {
          if(device[1].indexOf("Family") !== -1){
          devicemodel = device[1].replace(/.*Model Family:\s*([\s\S]*?)\n^Device Model:\s*([\s\S]*?)\n/m, '$1 - $2');
          } else {
          devicemodel = device[1].replace(/.*Model:\s*([\s\S]*?)\n/m, '$1');
          }
          device[2] = device[2].replace(/ |,/gm, '');
          if(value.indexOf("Min/Max") !== -1){
          let devicetemps = device[5].matchAll(/19[0,4][\s\S]*?\-\s*(\d+)(\s\(Min\/Max\s(\d+)\/(\d+)\)$|\s{0}$)/gm);
          for (const devicetemp of devicetemps) {
          value = `${devicemodel} | 容量: ${device[2]} | 已通电: ${device[3]}小时 | 温度: ${devicetemp[1]}°C\n`;
          }
          } else if (value.indexOf("Temperature") !== -1){
          let devicetemps = device[5].matchAll(/19[0,4][\s\S]*?\-\s*(\d+)/gm);
          for (const devicetemp of devicetemps) {
          value = `${devicemodel} | 容量: ${device[2]} | 已通电: ${device[3]}小时 | 温度: ${devicetemp[1]}°C\n`;
          }
          } else {
          value = `${devicemodel} | 容量: ${device[2]} | 已通电: ${device[3]}小时 | 提示: 未检测到温度传感器\n`;
          }
          }
          return value.replace(/\n/g, '<br>');
          } else {
          return `提示: 未安装硬盘或已直通硬盘控制器`;
          }
          }
          },
@shidahuilang
Copy link
Owner

image

@shidahuilang
Copy link
Owner

最初是大写的,pve升级8.0以后我就改为了小写,8.0经过几个版本更新应该是bug都给修复了

@lpdswing
Copy link
Author

image 我的是8.0.4版本

@lpdswing
Copy link
Author

f1,f2 match的应该是CPU, 你看看你的命令出来的是不是大写

@shidahuilang
Copy link
Owner

f1,f2 match的应该是CPU, 你看看你的命令出来的是不是大写

image
ok

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants