jadams / sysinfo

MIT License
1 stars 1 forks source link

_get_disks() error on OpenVZ virtualized instances #8

Closed tcarrio closed 8 years ago

tcarrio commented 8 years ago

The current implementation from my fork uses both outputs from df -h and mount to get disk information.

On OpenVZ the output of the proxy filesystem partitions does not use the same naming scheme for both these commands. The current key in use for the dictionary uses the device name from df -h, e.g. /dev/sda1, which won't match the output of the same partition in mount.

The proposal is to use the mounting location as the key, which would allow us to maintain information from both df -h and mount which an identifier that is unique to both.

The resulting dict would instead be:

{
  "/media":{
    "mount":"/dev/md0",
    "type":"ext4",
    "permission":"rw",
    "size":"2.7T",
    "used":"885G",
    "avail":"1.7T",
    "use%":"34%"
  },
  "/mnt":{
    "name":"/dev/md1",
    "type":"btrfs",
    "permission":"rw",
    "size":"2.7T",
    "used":"765G",
    "avail":"1.8T",
    "use%":"34%"
  },
  "/boot":{
    "name":"/dev/sdb1",
    "type":"xfs",
    "permission":"rw",
    "size":"497M",
    "used":"162M",
    "avail":"336M",
    "use%":"33%",
  }
}

If this works for you let me know.

tcarrio commented 8 years ago

Nearly finished with the alternative implementation on this. Testing tonight.

tcarrio commented 8 years ago

OpenVZ compatibility was fixed in merge #9