sensu-plugins / sensu-plugins-filesystem-checks

This plugin provides native instrumentation for monitoring and metrics collection, including:health, usage, and various metrics of filesystem attributes.
http://sensu-plugins.io
MIT License
8 stars 25 forks source link

check-fs-writable.rb fails to check chrooted mounts #9

Open dmanchado opened 8 years ago

dmanchado commented 8 years ago

When checking filesystems writable using auto mode it complains of chrooted mounts (bind dns in my case). Check failed to run: Not a directory @ rb_sysopen - /var/named/chroot/etc/named.conf/.sensu20160621-20363-mv70jc

I have not seen a pattern to filter out when checking /proc/self/mounts, if we were using the output from mount command it would make sense to filter out the' type none' ones.

/proc/self/mounts

/dev/mapper/VolGroup-lv_root /var/named/chroot/etc/named ext4 rw,seclabel,relatime,barrier=1,data=ordered 0 0
/dev/mapper/VolGroup-lv_root /var/named/chroot/etc/named.conf ext4 rw,seclabel,relatime,barrier=1,data=ordered 0 0
/dev/mapper/VolGroup-lv_root /var/named/chroot/etc/named.rfc1912.zones ext4 rw,seclabel,relatime,barrier=1,data=ordered 0 0
/dev/mapper/VolGroup-lv_root /var/named/chroot/etc/rndc.key ext4 rw,seclabel,relatime,barrier=1,data=ordered 0 0
/dev/mapper/VolGroup-lv_root /var/named/chroot/usr/lib64/bind ext4 rw,seclabel,relatime,barrier=1,data=ordered 0 0
/dev/mapper/VolGroup-lv_root /var/named/chroot/etc/named.iscdlv.key ext4 rw,seclabel,relatime,barrier=1,data=ordered 0 0
/dev/mapper/VolGroup-lv_root /var/named/chroot/etc/named.root.key ext4 rw,seclabel,relatime,barrier=1,data=ordered 0 0

check-fs-writable.rb -a

Check failed to run: Not a directory @ rb_sysopen - /var/named/chroot/etc/named.conf/.sensu20160621-21727-cy7hc, ["/opt/sensu/embedded/lib/ruby/2.3.0/tempfile.rb:133:in `initialize'", "/opt/sensu/embedded/lib/ruby/2.3.0/tempfile.rb:133:in `open'", "/opt/sensu/embedded/lib/ruby/2.3.0/tempfile.rb:133:in `block in initialize'", "/opt/sensu/embedded/lib/ruby/2.3.0/tmpdir.rb:130:in `create'", "/opt/sensu/embedded/lib/ruby/2.3.0/tempfile.rb:131:in `initialize'", "/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugins-filesystem-checks-0.2.0/bin/check-fs-writable.rb:103:in `new'", "/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugins-filesystem-checks-0.2.0/bin/check-fs-writable.rb:103:in `block in rw_test?'", "/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugins-filesystem-checks-0.2.0/bin/check-fs-writable.rb:101:in `each'", "/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugins-filesystem-checks-0.2.0/bin/check-fs-writable.rb:101:in `rw_test?'", "/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugins-filesystem-checks-0.2.0/bin/check-fs-writable.rb:124:in `auto_discover'", "/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugins-filesystem-checks-0.2.0/bin/check-fs-writable.rb:151:in `run'", "/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugin-1.2.0/lib/sensu-plugin/cli.rb:56:in `block in <class:CLI>'"]
dmanchado commented 8 years ago

PR submitted https://github.com/sensu-plugins/sensu-plugins-filesystem-checks/pull/11

jakerobb commented 4 years ago

I ran into a similar issue; the error is the same "Not a directory @ rb_sysopen". In my case, the mounts are files. @dmanchado's PR (which expired due to inactivity after he didn't respond to a request to add a unit test and a changelog) checks the filesystem type to see if it's none; my mounts have type ext4, so his fix wouldn't address my issue.

I think it would be better to check whether the mount is a directory than to check its fstype. I'm assuming that dmanchado's named.conf, et al are not directories.

If it's not a directory, I'm not sure what further recourse there is to verify that it's writable.