miskcoo / ugreen_leds_controller

An LED Controller for UGREEN's DX/DXP NAS Series
179 stars 26 forks source link

add ATA disk mapping, zpool check, netdev check, and a config file #15

Closed miskcoo closed 5 months ago

miskcoo commented 5 months ago

HCTL Mapping

lsblk -S -o name,hctl -x hctl


Below are some de-compiled codes of `hwmonitor` in UGOS, so I think the ATA mapping would be a good choice:
```c
int diskGetAllSataDiskName(long param_1)
{
  int iVar1;
  int iVar2;
  int iVar3;
  undefined4 local_2e;
  undefined2 local_2a;

  iVar2 = 0;
  local_2e = 0x31617461;   // this is "ata1"
  local_2a = 0;
  for (iVar3 = 0; iVar3 < g_DISK_TOTAL; iVar3 = iVar3 + 1) {
    local_2e = CONCAT13((char)iVar3 + '1',(undefined3)local_2e);  // concat_string("ata", iVat3 + '1')
    iVar1 = getDevNameByInterface(&local_2e,*(undefined8 *)(param_1 + (long)iVar2 * 8));
    iVar2 = (iVar2 + 1) - (uint)(iVar1 == 0);
  }
  return iVar2;
}

undefined8 getDevNameByInterface(char *param_1,char *param_2)
{
  char *__s1;
  int iVar1;
  DIR *__dirp;
  dirent *pdVar2;
  ssize_t sVar3;
  char *pcVar4;
  undefined8 uVar5;
  char local_d8 [32];
  char local_b8 [136];

  if ((param_1 != (char *)0x0) && (param_2 != (char *)0x0)) {
    __dirp = opendir("/sys/block");
    if (__dirp != (DIR *)0x0) {
      do {
        do {
          pdVar2 = readdir(__dirp);
          if (pdVar2 == (dirent *)0x0) {
            uVar5 = 0xffffffff;
            goto LAB_0010632c;
          }
          __s1 = pdVar2->d_name;
          iVar1 = strncmp(__s1,"sd",2);
        } while ((iVar1 != 0) && (iVar1 = strncmp(__s1,"nvme",4), iVar1 != 0));
        snprintf(local_d8,0x20,"/sys/block/%s",__s1);
        sVar3 = readlink(local_d8,local_b8,0x80);
      } while ((sVar3 == -1) || (pcVar4 = strstr(local_b8,param_1), pcVar4 == (char *)0x0));
      uVar5 = 0;
      snprintf(param_2,0x20,"/dev/%s",__s1);
LAB_0010632c:
      closedir(__dirp);
      return uVar5;
    }
    xlog_out(0,"disk.c","getDevNameByInterface",0x16e,"open /sys/block failed!\n");
  }
  return 0xffffffff;
}
miskcoo commented 5 months ago

Hope someone with other devices can test the new script (especially those have DXP6800), and check the outputs of the above commands. It uses the ATA mapping by default.

sgreiner commented 5 months ago

Awesome! ugreen-netdevmon@.service working fine, including gateway check and link speed detection and colors.

sgreiner commented 5 months ago

Hope someone with other devices can test the new script (especially those have DXP6800), and check the outputs of the above commands. It uses the ATA mapping by default.

I can confirm the correctness for DXP6800 for these two mappings hctl_map=("2:0:0:0" "3:0:0:0" "4:0:0:0" "5:0:0:0" "0:0:0:0" "1:0:0:0") ata_map=("ata3" "ata4" "ata5" "ata6" "ata1" "ata2")

dieneuser commented 5 months ago

https://github.com/miskcoo/ugreen_dx4600_leds_controller/blob/90e530cf702b774a9782a10bcfd9d3df57a5d042/scripts/ugreen-diskiomon#L54

There is no model series DX4600, the correct series would be DXP4800 (Plus).

        DXP4800*)   # tested on DXP4800 Plus
            echo "Found UGREEN DXP4800 series" 
miskcoo commented 5 months ago

https://github.com/miskcoo/ugreen_dx4600_leds_controller/blob/90e530cf702b774a9782a10bcfd9d3df57a5d042/scripts/ugreen-diskiomon#L54

There is no model series DX4600, the correct series would be DXP4800 (Plus).

        DXP4800*)   # tested on DXP4800 Plus
            echo "Found UGREEN DXP4800 series" 

Oh, my model is 4600, it is a version sold only in China (~2023).

dieneuser commented 5 months ago

https://github.com/miskcoo/ugreen_dx4600_leds_controller/blob/90e530cf702b774a9782a10bcfd9d3df57a5d042/scripts/ugreen-diskiomon#L54

There is no model series DX4600, the correct series would be DXP4800 (Plus).

        DXP4800*)   # tested on DXP4800 Plus
            echo "Found UGREEN DXP4800 series" 

Oh, my model is 4600, it is a version sold only in China (~2023).

Oh how interesting, then the block has to be expanded to include the 4800 models.