check_disk on Ubuntu 16.04 xenial reports DISK CRITICAL: / not found

Written by - 0 comments

Published on - Listed in Nagios Icinga Monitoring Linux


Recently I wrote about how an Ubuntu xenial container can be created on an Ubuntu trusty host. As I've started to create new xenial containers like this in the last days and added them into Icinga 2 monitoring, I was pretty surprised when check_disk wasn't working.

Instead of showing the usage of a given partition (with the -p parameter), it reported that the partition could not be found:

root@xenial:~# /usr/lib/nagios/plugins/check_disk -w 10% -c 5% -p /
DISK CRITICAL: / not found

First I suspected a problem from check_disk itself, because Xenial now uses the package monitoring-plugins instead of nagios-plugins:

root@xenial:~# apt-cache search nagios-plugins
nagios-plugins - transitional dummy package (nagios-plugins to monitoring-plugins)
[...]

As I mentioned above, this xenial container runs on a trusty host. I copied the check_disk plugin from within the container onto the trusty host and ran it:

root@trusty:/tmp# ./check_disk -w 10% -c 5% -p /
DISK OK - free space: / 2412 MB (55% inode=57%);| /=1897MB;4107;4335;0;4564

So it's working. Where's the difference? With strace I was able to find out the following:

root@xenial:~# strace /usr/lib/nagios/plugins/check_disk -w 10% -c 5% -p
execve("./check_disk_trusty", ["./check_disk_trusty", "-w", "10%", "-c", "5%", "-p", "/"], [/* 36 vars */]) = 0
brk(NULL)                               = 0x7f4e00293000
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f4dff4df000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=18670, ...}) = 0
mmap(NULL, 18670, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f4dff4da000
close(3)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/lib/x86_64-linux-gnu/libpthread.so.0", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\360`\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=138744, ...}) = 0
mmap(NULL, 2212904, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f4dfee8f000
mprotect(0x7f4dfeea7000, 2093056, PROT_NONE) = 0
mmap(0x7f4dff0a6000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x17000) = 0x7f4dff0a6000
mmap(0x7f4dff0a8000, 13352, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f4dff0a8000
close(3)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0P\t\2\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1864888, ...}) = 0
mmap(NULL, 3967488, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f4dfeac6000
mprotect(0x7f4dfec86000, 2093056, PROT_NONE) = 0
mmap(0x7f4dfee85000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1bf000) = 0x7f4dfee85000
mmap(0x7f4dfee8b000, 14848, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f4dfee8b000
close(3)                                = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f4dff4d9000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f4dff4d8000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f4dff4d7000
arch_prctl(ARCH_SET_FS, 0x7f4dff4d8700) = 0
mprotect(0x7f4dfee85000, 16384, PROT_READ) = 0
mprotect(0x7f4dff0a6000, 4096, PROT_READ) = 0
mprotect(0x7f4dff4e1000, 4096, PROT_READ) = 0
mprotect(0x7f4dff2d1000, 4096, PROT_READ) = 0
munmap(0x7f4dff4da000, 18670)           = 0
set_tid_address(0x7f4dff4d89d0)         = 17605
set_robust_list(0x7f4dff4d89e0, 24)     = 0
rt_sigaction(SIGRTMIN, {0x7f4dfee94b90, [], SA_RESTORER|SA_SIGINFO, 0x7f4dfeea03d0}, NULL, 8) = 0
rt_sigaction(SIGRT_1, {0x7f4dfee94c20, [], SA_RESTORER|SA_RESTART|SA_SIGINFO, 0x7f4dfeea03d0}, NULL, 8) = 0
rt_sigprocmask(SIG_UNBLOCK, [RTMIN RT_1], NULL, 8) = 0
getrlimit(RLIMIT_STACK, {rlim_cur=8192*1024, rlim_max=RLIM64_INFINITY}) = 0
brk(NULL)                               = 0x7f4e00293000
brk(0x7f4e002b4000)                     = 0x7f4e002b4000
open("/usr/lib/locale/locale-archive", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=2981280, ...}) = 0
mmap(NULL, 2981280, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f4dfe7ee000
close(3)                                = 0
open("/etc/mtab", O_RDONLY|O_CLOEXEC)   = 3
futex(0x7f4dfee8c068, FUTEX_WAKE_PRIVATE, 2147483647) = 0
fstat(3, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
read(3, "", 4096)                       = 0
close(3)                                = 0
stat("/", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
open("/etc/mtab", O_RDONLY|O_CLOEXEC)   = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
read(3, "", 4096)                       = 0
close(3)                                = 0
open("/usr/share/locale/locale.alias", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=2995, ...}) = 0
read(3, "# Locale name alias data base.\n#"..., 4096) = 2995
read(3, "", 4096)                       = 0
close(3)                                = 0
open("/usr/share/locale/en_US/LC_MESSAGES/nagios-plugins.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en/LC_MESSAGES/nagios-plugins.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale-langpack/en_US/LC_MESSAGES/nagios-plugins.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale-langpack/en/LC_MESSAGES/nagios-plugins.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
fstat(1, {st_mode=S_IFCHR|0600, st_rdev=makedev(136, 17), ...}) = 0
write(1, "DISK CRITICAL: / not found\n", 27DISK CRITICAL: / not found
) = 27
exit_group(2)                           = ?
+++ exited with 2 +++

The relevant part is this one:

open("/etc/mtab", O_RDONLY|O_CLOEXEC)   = 3
futex(0x7f4dfee8c068, FUTEX_WAKE_PRIVATE, 2147483647) = 0
fstat(3, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
read(3, "", 4096)                       = 0
close(3)                                = 0
stat("/", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
open("/etc/mtab", O_RDONLY|O_CLOEXEC)   = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
read(3, "", 4096)                       = 0
close(3)                                = 0

The file /etc/mtab is used by check_disk to get the values. However this file is empty in the xenial container:

root@xenial:~# ls -la /etc/mtab
-rw-r--r-- 1 root root 0 Apr 22 07:09 /etc/mtab

root@xenial:~# cat /etc/mtab
root@xenial:~#

A solution to this if /etc/mtab is symlinked to /proc/mounts which should contain the same information:

root@xenial:~# test -f /etc/mtab && rm /etc/mtab; ln -s /proc/mounts /etc/mtab
rm: remove regular empty file '/etc/mtab'? y

root@xenial:~# cat /etc/mtab
rootfs / rootfs rw 0 0
/dev/vglxc/xenial / ext4 rw,relatime,data=ordered 0 0
proc /proc proc rw,nosuid,nodev,noexec,relatime 0 0
sysfs /sys sysfs rw,relatime 0 0
none /sys/fs/fuse/connections fusectl rw,relatime 0 0
none /sys/kernel/debug debugfs rw,relatime 0 0
none /sys/kernel/security securityfs rw,relatime 0 0
none /sys/fs/pstore pstore rw,relatime 0 0
devpts /dev/lxc/console devpts rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 0 0
devpts /dev/lxc/tty1 devpts rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 0 0
devpts /dev/lxc/tty2 devpts rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 0 0
devpts /dev/lxc/tty3 devpts rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 0 0
devpts /dev/lxc/tty4 devpts rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 0 0
devpts /dev/pts devpts rw,relatime,gid=5,mode=620,ptmxmode=666 0 0
devpts /dev/ptmx devpts rw,relatime,gid=5,mode=620,ptmxmode=666 0 0
none /sys/fs/cgroup tmpfs rw,relatime,size=4k,mode=755 0 0
none /run tmpfs rw,nosuid,noexec,relatime,size=611212k,mode=755 0 0
none /run/lock tmpfs rw,nosuid,nodev,noexec,relatime,size=5120k 0 0
none /run/shm tmpfs rw,nosuid,nodev,relatime 0 0
none /run/user tmpfs rw,nosuid,nodev,noexec,relatime,size=102400k,mode=755 0 0

And now the check_disk plugin works again:

root@xenial:~# /usr/lib/nagios/plugins/check_disk -w 10% -c 5% -p /
DISK OK - free space: / 1060 MB (57% inode=77%);| /=773MB;1755;1853;0;1951


Add a comment

Show form to leave a comment

Comments (newest first)

No comments yet.

RSS feed

Blog Tags:

  AWS   Android   Ansible   Apache   Apple   Atlassian   BSD   Backup   Bash   Bluecoat   CMS   Chef   Cloud   Coding   Consul   Containers   CouchDB   DB   DNS   Database   Databases   Docker   ELK   Elasticsearch   Filebeat   FreeBSD   Galera   Git   GlusterFS   Grafana   Graphics   HAProxy   HTML   Hacks   Hardware   Icinga   Icingaweb   Icingaweb2   Influx   Internet   Java   KVM   Kibana   Kodi   Kubernetes   LVM   LXC   Linux   Logstash   Mac   Macintosh   Mail   MariaDB   Minio   MongoDB   Monitoring   Multimedia   MySQL   NFS   Nagios   Network   Nginx   OSSEC   OTRS   Office   PGSQL   PHP   Perl   Personal   PostgreSQL   Postgres   PowerDNS   Proxmox   Proxy   Python   Rancher   Rant   Redis   Roundcube   SSL   Samba   Seafile   Security   Shell   SmartOS   Solaris   Surveillance   Systemd   TLS   Tomcat   Ubuntu   Unix   VMWare   VMware   Varnish   Virtualization   Windows   Wireless   Wordpress   Wyse   ZFS   Zoneminder   


Update cookies preferences