Projet

Général

Profil

Révision 16d38264

ID16d38264aa1d6f4d173bc970c145b9fdb8dda95a
Parent fea81596
Enfant 87280ed7

Ajouté par HaseHarald il y a presque 4 ans

[btrfs_device_usage] fix division by zero when btrfs pool is unhealthy

During certain situations, a device in the btrfs pool can show a total
capacity of 0 bytes. This is aspecially true when replacing or removing a
failed disk.

This fix stops the plugin from crashing in that situation but just report
the devices percentage as unknown (U). That way other devices in the pool
stil can be monitored.

Voir les différences:

plugins/disk/btrfs_device_usage
155 155

  
156 156
    for this_device in devices:
157 157
        this_dev_info = fs.dev_info(this_device.devid)
158
        usage = 100.0 * this_dev_info.bytes_used / this_dev_info.total_bytes
159
        print("btrfs_percent_" + fsid + "_" + str(this_device.devid) +
160
              ".value " + str(round(usage, 2)))
158
        if this_dev_info.total_bytes > 0:
159
            usage = 100.0 * this_dev_info.bytes_used / this_dev_info.total_bytes
160
            print("btrfs_percent_" + fsid + "_" + str(this_device.devid) +
161
                  ".value " + str(round(usage, 2)))
162
        else:
163
            print("btrfs_percent_" + fsid + "_" + str(this_device.devid) +
164
                  ".value U")
165
          
161 166

  
162 167
    print("")
163 168

  

Formats disponibles : Unified diff