sebhildebrandt / systeminformation

System Information Library for Node.JS
MIT License
2.65k stars 300 forks source link

DiskLayout return empty array for some VPS on Ubuntu 22.04 LTS #919

Open NodeFarmer opened 5 days ago

NodeFarmer commented 5 days ago

Describe the bug On some VPS from specific providers (eg. Racknerd), the DiskLayout function won't pass the following filter : devices = outJSON.blockdevices.filter(item => { return (item.type === 'disk') && item.size > 0 && (item.model !== null || (item.mountpoint === null && item.label === null && item.fstype === null && item.parttype === null && item.path && item.path.indexOf('/ram') !== 0 && item.path.indexOf('/loop') !== 0 && item['disc-max'] && item['disc-max'] !== 0)); });

Indeed, for some VPS, model is empty and disc-max = 0

To Reproduce Steps to reproduce the behavior:

  1. used function 'DiskLayout'
  2. code snippet : devices = outJSON.blockdevices.filter(item => { return (item.type === 'disk') && item.size > 0 && (item.model !== null || (item.mountpoint === null && item.label === null && item.fstype === null && item.parttype === null && item.path && item.path.indexOf('/ram') !== 0 && item.path.indexOf('/loop') !== 0 && item['disc-max'] && item['disc-max'] !== 0)); });
  3. start app / code
  4. See output/error : empty array []

Expected behavior Virtual disk with no model or disc-max with 0 should be listed

Environment (please complete the following information):

Additional context Here is the result of following command on this VPS for vda disk that should be listed : export LC_ALL=C; lsblk -ablJO 2>/dev/null; unset LC_ALL

{ "name": "vda", "kname": "vda", "path": "/dev/vda", "maj:min": "252:0", "fsavail": null, "fssize": null, "fstype": null, "fsused": null, "fsuse%": null, "fsroots": [ null ], "fsver": null, "mountpoint": null, "mountpoints": [ null ], "label": null, "uuid": null, "ptuuid": "48791ef7-02bb-4e82-9b4f-c54cc3d49f2e", "pttype": "gpt", "parttype": null, "parttypename": null, "partlabel": null, "partuuid": null, "partflags": null, "ra": 128, "ro": false, "rm": false, "hotplug": false, "model": null, "serial": null, "size": 32212254720, "state": null, "owner": "root", "group": "disk", "mode": "brw-rw----", "alignment": 0, "min-io": 512, "opt-io": 0, "phy-sec": 512, "log-sec": 512, "rota": true, "sched": "mq-deadline", "rq-size": 256, "type": "disk", "disc-aln": 0, "disc-gran": 0, "disc-max": 0, "disc-zero": false, "wsame": 0, "wwn": null, "rand": false, "pkname": null, "hctl": null, "tran": null, "subsystems": "block:virtio:pci", "rev": null, "vendor": "0x1af4", "zoned": "none", "dax": false },