-
Notifications
You must be signed in to change notification settings - Fork 1
/
60-bcache.conf
12 lines (8 loc) · 1.79 KB
/
60-bcache.conf
1
2
3
4
5
6
7
8
9
10
11
12
UserParameter=bcache.discovery.cset,python3 -c "import os.path; b=['{\"{#BCSET}\":\"' + f + '\"}' for f in os.listdir('/sys/fs/bcache') if (os.path.isdir(os.path.join('/sys/fs/bcache',f))) ];print('{\"data\":[' + ','.join(b) + ']}')"
UserParameter=bcache.discovery.bdev,python3 -c "import os.path; b=['{\"{#BBDEV}\":\"' + f + '\"}' for f in os.listdir('/sys/block') if ('bcache' in f) ];print('{\"data\":[' + ','.join(b) + ']}')"
UserParameter=bcache.discovery.cdev,python3 -c "import subprocess; b=['{\"{#BCDEV}\":\"' + f + '\"}' for f in [ x.split('/')[-3] for x in [ k for k in subprocess.check_output(['find','/sys/devices','-name','cache_replacement_policy']).decode().splitlines()] ]]; print('{\"data\":[' + ','.join(b) + ']}')"
UserParameter=bcache.cset.stats[*],cat /sys/fs/bcache/$1/stats_$2/$3 2>/dev/null
UserParameter=bcache.bdev.stats[*],cat /sys/block/$1/bcache/stats_$2/$3 2>/dev/null
UserParameter=bcache.cset.item[*],awk '{ if ($$0~/^[0-9].*k/) {o=sprintf("%.3f",strtonum($$1)/1024)} else if ($$0~/^[0-9].*M/) {gsub(/M/,"");print} else if ($$0~/^[0-9].*G/) {o=strtonum($$1)*1024} else if ($$0~/^[0-9].*T/) {o=strtonum($$1)*1024*1024} else {o=$$0} print o}' /sys/fs/bcache/$1/$2 2>/dev/null
UserParameter=bcache.bdev.item[*],awk '{ if ($$0~/^[0-9].*k/) {o=sprintf("%.3f",strtonum($$1)/1024)} else if ($$0~/^[0-9].*M/) {gsub(/M/,"");print} else if ($$0~/^[0-9].*G/) {o=strtonum($$1)*1024} else if ($$0~/^[0-9].*T/) {o=strtonum($$1)*1024*1024} else {o=$$0} print o}' /sys/block/$1/bcache/$2 2>/dev/null
UserParameter=bcache.cdev.item[*],awk '{ if ($$0~/^[0-9].*k/) {o=sprintf("%.3f",strtonum($$1)/1024)} else if ($$0~/^[0-9].*M/) {gsub(/M/,"");print} else if ($$0~/^[0-9].*G/) {o=strtonum($$1)*1024} else if ($$0~/^[0-9].*T/) {o=strtonum($$1)*1024*1024} else {o=$$0} print o}' /sys/block/$1/bcache/$2 2>/dev/null