-
Notifications
You must be signed in to change notification settings - Fork 0
/
ext4_writes_
executable file
·46 lines (40 loc) · 1.24 KB
/
ext4_writes_
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env python
# -*- python -*-
#
# Wildcard-plugin to monitor ext4 Lifetime writes
#
#%# capabilities=autoconf suggest
#%# family=auto
import os, sys, string, glob
plugin_name=list(os.path.split(sys.argv[0]))[1]
plugin_version="1.0"
device=plugin_name[string.rindex(plugin_name,'_')+1:]
def get_lifetime_writes(device):
path = "/sys/fs/ext4/" + device + "/lifetime_write_kbytes"
f = open(path)
writes = int(f.readline()) * 1024
f.close()
return writes
def get_devices():
devices = glob.glob("/sys/fs/ext4/*/lifetime_write_kbytes")
return [d[13:string.index(d, '/', 13)] for d in devices]
arg = sys.argv[1] if len(sys.argv) == 2 else None
if arg == "config":
print('graph_title EXT4 lifetime writes on '+device)
print('graph_vlabel Lifetime Writes (bytes)')
print('graph_args --base 1024')
print('graph_category disk')
print('writes.label Lifetime writes')
elif arg == "autoconf":
devices = get_devices()
if len(devices) == 0:
print("no (no ext4 filesystems)")
else:
print("yes")
elif arg == "suggest":
for d in get_devices():
print (d)
elif arg == "version":
print('ext4_writes_ Munin plugin, version '+plugin_version)
else:
print('writes.value ' + str(get_lifetime_writes(device)))