Closed pbrzica closed 4 years ago
The plugin currently uses the bytes_free from filesystem.stat which does not factor in privileged access (reserved). filesystem.stat does also surface bytes_available that Returns the amount of free space available to unprivileged processes.
. However, changing the default behavior at this point in the plugin's lifecycle, is inadvisable.
If you would like to offer up a PR with a new command line option to use bytes_available instead, that would be acceptable.
That's odd. I use the sensu-go asset and it depends on which ruby I use to run the script. I've added following lines to script
free = to_human(fs_info.bytes_free)
printf("%s used: %s free: %s total: %s\n",line.mount_point,used,free,total)
The "old" sensu embedded ruby works as expected: Doesn't count in privileged.
/opt/sensu/embedded/bin/ruby --version
ruby 2.4.5p335 (2018-10-18 revision 65137) [x86_64-linux]
/opt/sensu/embedded/bin/ruby /var/cache/sensu/sensu-agent/0253c3eb83ca95ef21c1aede03f8e7ec80431a1e363246a4eb4c9b6e2d619060f1d06f6c11eef107e7eb8bd9b16be236ca53120839255362699ed4c05644d596/lib/ruby/2.4.0/bundler/gems/sensu-plugins-disk-checks-0bd87037cbdb/bin/check-disk-usage.rb |grep snapsh
/snapshots used: 980.25 GiB free: 3.06 GiB total: 983.30 GiB
CheckDisk CRITICAL: /snapshots 99.69% bytes usage (980.25 GiB/983.30 GiB)
But the output of the same script output in sensu-go Web GUI is not correct. Looks like the ruby from ruby runtime-asset https://bonsai.sensu.io/assets/sensu/sensu-ruby-runtime actually works with privileged bytes as if it was normal bytes.
# ruby runtime asset
/var/cache/sensu/sensu-agent/a28952fd93fc63db1f8988c7bc40b0ad815eb9f35ef7317d6caf5d77ecfbfd824a9db54184400aa0c81c29b34cb48c7e8c6e3f17891aaf84cafa3c134266a61a/bin/ruby --version
ruby 2.4.4p296 (2018-03-28 revision 63013) [x86_64-linux]
/snapshots used: 930.23 GiB free: 53.07 GiB total: 983.30 GiB
CheckDisk OK: All disk usage under 75% and inode usage under 85%
@nixwiz I can't find any mention of bytes_available
in Filesystem.stat docu, https://www.rubydoc.info/gems/sys-filesystem/1.1.4/Sys/Filesystem/Stat , can you point me to your source please?
Please ignore the request about docu. I was checking old version. https://www.rubydoc.info/gems/sys-filesystem/Sys/Filesystem/Stat PR is on the way.
OS:
Ruby:
Sensu:
Issue:
check-disk-usage.rb
reports disk usage at 75% anddf -h
reports disk usage at 80%. Is there any way to get the check to account for system reserved blocks as well?