Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change usage output to percent #18

Closed
wants to merge 1 commit into from
Closed

Change usage output to percent #18

wants to merge 1 commit into from

Conversation

martialblog
Copy link
Member

  • Removes unused --no-unallocated flag. This flag was never used and --unallocated is better suited for the use-case.

Fixes #17

 - Removes unused --no-unallocated flag.
   This flag was never used and `--unallocated` is better suited for the use-case.
@martialblog martialblog added this to the 3.1.1 milestone Feb 9, 2024
@martialblog martialblog self-assigned this Feb 9, 2024
@martialblog
Copy link
Member Author

@bratkartoffel I think is more what you and also me would expect, right?

@bratkartoffel
Copy link

bratkartoffel commented Feb 9, 2024

Nope, that results in showing the 99.49% as usage again, whereas 24% should be correct:

root@nas:/opt/check_disk_btrfs-patch18# ./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: 580780032
Label: System,RAID1, Total: 41943040, Used: 81920
/usr/bin/btrfs filesystem show /tank
/usr/bin/btrfs scrub stat /tank
CRITICAL: 'Data,RAID1': 99.49% used OK: 'Metadata,RAID1': 27.04% used, 'System,RAID1': 0.20% used | dataraid1_used=466829971456;30;40;; dataraid1_total=469225177088;30;40;; metadataraid1_used=580780032;30;40;; metadataraid1_total=2147483648;30;40;; systemraid1_used=81920;30;40;; systemraid1_total=41943040;30;40;;
root@nas:/opt/check_disk_btrfs-patch18# df -h /tank
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda        1.9T  436G  1.4T  24% /tank

// Edit: And setting the --unallocated is even more unexpected:

root@nas:/opt/check_disk_btrfs-patch18# ./check_disk_btrfs --btrfs-path /usr/bin/btrfs -V /tank --no-sudo -w 30 -c 40 -v --missing --error --unallocated
/usr/bin/btrfs filesystem usage -b /tank
Label: Data,RAID1, Total: 469225177088, Used: 466829971456
Label: Metadata,RAID1, Total: 2147483648, Used: 580780032
Label: System,RAID1, Total: 41943040, Used: 81920
/usr/bin/btrfs filesystem show /tank
/usr/bin/btrfs scrub stat /tank
OK: 'Data,RAID1': 11.67% used, 'Metadata,RAID1': 0.01% used, 'System,RAID1': 0.00% used | dataraid1_used=466829971456;30;40;; dataraid1_total=4000797868032;30;40;; metadataraid1_used=580780032;30;40;; metadataraid1_total=4000797868032;30;40;; systemraid1_used=81920;30;40;; systemraid1_total=4000797868032;30;40;;

// Edit-2: I think, the unallocated stuff should only count to Data and the percentages should only be used for Metadata and System. I'd remove the unallocated flag altogether.

Thank you so much for taking care of these issues so fast!

@martialblog
Copy link
Member Author

Yeah I think I see my mistake...

Thanks for the feedback

@martialblog martialblog marked this pull request as draft February 9, 2024 15:38
@martialblog
Copy link
Member Author

First)

Had a look at the code a bit. The unallocated and no-unallocated flags are strange indeed.

Setting the unallocated flag will use the Device size for all usage percentage calculations instead of data, metadata, system separately. The flag is also set to true by default, so there was no way to unset it, since no-unallocated is unused.

So removing or reworking the no-unallocated and unallocated flags might be an idea.

Second)

I think the df output and btrfs filesystem usage cannot be directly compared.

But I have to read up on btrfs and the intention of this plugin (I didn't write it and is was ported from an older Perl based script from what I can tell).

Right now, I guess the intention was to compare these usage in percent against the given warning/critical thresholds:

Data,RAID1: Size:469225177088, Used:466829971456 (99.49%)
Metadata,RAID1: Size:2147483648, Used:580681728 (27.04%)
System,RAID1: Size:41943040, Used:81920 (0.20%)

So -w 80 -c 90 with 99.49% would give you a CRITICAL. But I could be wrong.

@martialblog martialblog removed this from the 3.1.1 milestone Feb 9, 2024
@martialblog
Copy link
Member Author

OK I think it's back to the drawing board for this one. I'll move the conversation to the Issue #17

@martialblog martialblog closed this Feb 9, 2024
@martialblog martialblog deleted the fix/usage-calc branch February 9, 2024 16:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature]: Extend metrics being evaluated in the plugin
2 participants