netways / check_disk_btrfs Goto Github PK
View Code? Open in Web Editor NEWIcinga Plugin checking the status of Btrfs volumes
License: GNU General Public License v2.0
Icinga Plugin checking the status of Btrfs volumes
License: GNU General Public License v2.0
File "./check_disk_btrfs", line 78
print " ".join(cmd)
^
SyntaxError: invalid syntax
(but deprecated version works)
The README states that the sudo permission line in /etc/sudoers needs to be set up as icinga ALL=(ALL) NOPASSWD: /usr/sbin/btrfs filesystem status *
But I can see from the code, that the called command is btrfs filesystem usage -b .
So the sudoers needs to be: icinga ALL=(ALL) NOPASSWD: /usr/sbin/btrfs filesystem usage *
3.1.0
The usage output might be wrong and or confusing. Maybe we'll just use the percentage the btrfs output shows.
Output from the plugin:
'Data,RAID1': 11.66842% used (0.42458TB/3.6387TB),
'Metadata,RAID1': 0.01452% used (0.00053TB/3.6387TB),
'System,RAID1': 0.0% used (0.0TB/3.6387TB
Output from btrfs filesystem usage
Data,RAID1: Size:469225177088, Used:466829971456 (99.49%)
/dev/sda 469225177088
/dev/sdb 469225177088
Metadata,RAID1: Size:2147483648, Used:580681728 (27.04%)
/dev/sda 2147483648
/dev/sdb 2147483648
System,RAID1: Size:41943040, Used:81920 (0.20%)
/dev/sda 41943040
/dev/sdb 41943040
Full output:
check_disk_btrfs --btrfs-path /usr/bin/btrfs -V /tank --no-sudo -w 100 -c 100 -v --missing --error
/usr/bin/btrfs filesystem usage -b /tank
Label: Data,RAID1, Total: 469225177088, Used: 466829971456
Label: Metadata,RAID1, Total: 2147483648, Used: 580730880
Label: System,RAID1, Total: 41943040, Used: 81920
/usr/bin/btrfs filesystem show /tank
/usr/bin/btrfs scrub stat /tank
OK: 'Data,RAID1': 11.66842% used (0.42458TB/3.6387TB), 'Metadata,RAID1': 0.01452% used (0.00053TB/3.6387TB), 'System,RAID1': 0.0% used (0.0TB/3.6387TB) | dataraid1_used=466829971456;100;100;; dataraid1_total=4000797868032;100;100;; metadataraid1_used=580730880;100;100;; metadataraid1_total=4000797868032;100;100;; systemraid1_used=81920;100;100;; systemraid1_total=4000797868032;100;100;;
/usr/bin/btrfs filesystem usage -b /tank
Overall:
Device size: 4000797868032
Device allocated: 942829207552
Device unallocated: 3057968660480
Device missing: 0
Device slack: 0
Used: 934821470208
Free (estimated): 1531379535872 (min: 1531379535872)
Free (statfs, df): 1531378462720
Data ratio: 2.00
Metadata ratio: 2.00
Global reserve: 485900288 (used: 0)
Multiple profiles: no
Data,RAID1: Size:469225177088, Used:466829971456 (99.49%)
/dev/sda 469225177088
/dev/sdb 469225177088
Metadata,RAID1: Size:2147483648, Used:580681728 (27.04%)
/dev/sda 2147483648
/dev/sdb 2147483648
System,RAID1: Size:41943040, Used:81920 (0.20%)
/dev/sda 41943040
/dev/sdb 41943040
Unallocated:
/dev/sda 1528984330240
/dev/sdb 1528984330240
See also #13
No response
Python 2 has been deprecated since the beginning of 2020. This script seems to require Python 2, nevertheless.
Some of the more obvious failures when running with Python 3:
print
is a function nowraise
assumes exceptions to classesHi,
I've created a btrfs mirror over two disks and try to monitor that using this plugin.
I could not find a way to make it work, I always get UNKNOWN state with an error.
root@nas:/usr/lib/nagios/plugins# ./check_disk_btrfs --btrfs-path /usr/bin/btrfs -V /tank --no-sudo -w 30 -c 40 -v --missing --error
/usr/bin/btrfs filesystem usage -b /tank
Label: Data,RAID1, Total: 469225177088, Used: 466829971456
Label: Metadata,RAID1, Total: 2147483648, Used: 580681728
Label: System,RAID1, Total: 41943040, Used: 81920
UNKNOWN - Error: ('Data,RAID1', ('469225177088', '466829971456'))
File "/usr/lib/nagios/plugins/./check_disk_btrfs", line 335, in <module>
sys.exit(main(ARGS))
^^^^^^^^^^
File "/usr/lib/nagios/plugins/./check_disk_btrfs", line 256, in main
(total, used) = values[label]
~~~~~~^^^^^^^
Looking into the raw output for the filesystem usage it shows:
root@nas:/usr/lib/nagios/plugins# /usr/bin/btrfs filesystem usage -b /tank
Overall:
Device size: 4000797868032
Device allocated: 942829207552
Device unallocated: 3057968660480
Device missing: 0
Device slack: 0
Used: 934821470208
Free (estimated): 1531379535872 (min: 1531379535872)
Free (statfs, df): 1531378462720
Data ratio: 2.00
Metadata ratio: 2.00
Global reserve: 485900288 (used: 0)
Multiple profiles: no
Data,RAID1: Size:469225177088, Used:466829971456 (99.49%)
/dev/sda 469225177088
/dev/sdb 469225177088
Metadata,RAID1: Size:2147483648, Used:580681728 (27.04%)
/dev/sda 2147483648
/dev/sdb 2147483648
System,RAID1: Size:41943040, Used:81920 (0.20%)
/dev/sda 41943040
/dev/sdb 41943040
Unallocated:
/dev/sda 1528984330240
/dev/sdb 1528984330240
As you can see, the "Data" section shows 99.49% usage, but that's only for the btrfs allocated stuff. Checking the real disk usage with df -h
shows about 24% usage:
root@nas:/usr/lib/nagios/plugins# df -h /tank
Filesystem Size Used Avail Use% Mounted on
/dev/sda 1.9T 436G 1.4T 24% /tank
I'm using the latest release, 3.1.0, running with python 3.11.6 on an updated ubuntu 20.04.
Thanks,
Simon
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.