Projet

Général

Profil

Révision bffbc23a

IDbffbc23a4e118c16b90273e331b1a5b812fe56da
Parent 675dedf1
Enfant 6f0e91f8

Ajouté par HaseHarald il y a plus de 5 ans

Fix linting issues.

Voir les différences:

plugins/disk/btrfs_device_usage
1
#!/usr/bin/python3
1
#!/usr/bin/env python3
2 2
#
3 3
# This file contains a munin-plugin to gather btrfs statistics per device.
4 4
#
......
22 22

  
23 23
def munin_config(fs):
24 24
    fsid = str(fs.fsid).replace('-', '_')
25
    
25

  
26 26
    print("multigraph btrfs_device_usage_byte_" + fsid)
27 27
    print("graph_title btrfs usage by device in bytes on " + fs.path)
28 28
    print("graph_args --base 1024 -l 0")
......
30 30
    print("graph_vlabel bytes")
31 31
    print("graph_category disk")
32 32
    print("graph_info This graph shows bytes used by btrfs on every device")
33
    
33

  
34 34
    devices = fs.devices()
35 35
    for this_device in devices:
36 36
        this_dev_info = fs.dev_info(this_device.devid)
37 37
        this_dev_name = this_dev_info.path.replace('/dev/', '')
38 38
        print("btrfs_bytes_" + fsid + "_" + str(this_device.devid) +
39
            ".label " + this_dev_name)
40
    
39
              ".label " + this_dev_name)
40

  
41 41
    print("")
42
    
42

  
43 43
    print("multigraph btrfs_device_usage_percent_" + fsid)
44 44
    print("graph_title btrfs usage by device in percent on " + fs.path)
45 45
    print("graph_args --base 1000 -l 0")
......
47 47
    print("graph_vlabel %")
48 48
    print("graph_category disk")
49 49
    print("graph_info This graph shows percentage used by btrfs on every \
50
            device. Maesured in percentage of device capacity.")
51
    
50
          device. Maesured in percentage of device capacity.")
51

  
52 52
    devices = fs.devices()
53 53
    for this_device in devices:
54 54
        this_dev_info = fs.dev_info(this_device.devid)
55 55
        this_dev_name = this_dev_info.path.replace('/dev/', '')
56 56
        print("btrfs_percent_" + fsid + "_" + str(this_device.devid) +
57
            ".label " + this_dev_name)
57
              ".label " + this_dev_name)
58 58
        print("btrfs_percent_" + fsid + "_" + str(this_device.devid) + ".warning 95")
59 59
        print("btrfs_percent_" + fsid + "_" + str(this_device.devid) + ".critical 98")
60
    
60

  
61 61
    print("")
62 62

  
63 63

  
64 64
def munin_values(fs):
65 65
    fsid = str(fs.fsid).replace('-', '_')
66 66
    devices = fs.devices()
67
    
67

  
68 68
    print("multigraph btrfs_device_usage_byte_" + fsid)
69
    
69

  
70 70
    for this_device in devices:
71 71
        this_dev_info = fs.dev_info(this_device.devid)
72 72
        print("btrfs_bytes_" + fsid + "_" + str(this_device.devid) +
73
            ".value " + str(this_dev_info.bytes_used))
74
    
73
              ".value " + str(this_dev_info.bytes_used))
74

  
75 75
    print("")
76
    
76

  
77 77
    # Reset device iterator
78 78
    devices = fs.devices()
79
    
79

  
80 80
    print("multigraph btrfs_device_usage_percent_" + fsid)
81
    
81

  
82 82
    for this_device in devices:
83 83
        this_dev_info = fs.dev_info(this_device.devid)
84 84
        usage = 100.0 * this_dev_info.bytes_used / this_dev_info.total_bytes
85 85
        print("btrfs_percent_" + fsid + "_" + str(this_device.devid) +
86
            ".value " + str(round(usage, 2)))
87
    
86
              ".value " + str(round(usage, 2)))
87

  
88 88
    print("")
89
    
89

  
90 90

  
91 91
def main():
92 92
    for path in btrfs.utils.mounted_filesystem_paths():

Formats disponibles : Unified diff