How to ignore, exclude partitions in check_disk plugin?

icinga2
check_disk
(Sarojamarraj) #1

Hello,

I want to know how do I exclude /var/lib/docker or multiple partitions or type of filesystem?

When i manually run on a remote server I get the proper output as mentioned below

Blockquote
root@superfly:/usr/lib/nagios/plugins# ./check_disk -w 80 -c 90 -A -I /var/lib/docker
DISK CRITICAL - free space: /dev 2956 MB (100% inode=99%); /run 502 MB (84% inode=98%); / 350369 MB (73% inode=34%); /dev/shm 2974 MB (99% inode=99%); /run/lock 5 MB (100% inode=99%); /sys/fs/cgroup 2974 MB (100% inode=99%); /boot 392 MB (87% inode=99%); /run/user/2351 594 MB (100% inode=99%); /run/user/0 594 MB (100% inode=99%); /pkg 93818 MB (96% inode=99%); /install 66222 MB (64% inode=95%);| /dev=0MB;2876;2866;0;2956 /run=92MB;514;504;0;594 /=126476MB;502308;502298;0;502388 /dev/shm=0MB;2894;2884;0;2974 /run/lock=0MB;-75;-85;0;5 /sys/fs/cgroup=0MB;2894;2884;0;2974 /boot=54MB;391;381;0;471 /run/user/2351=0MB;514;504;0;594 /run/user/0=0MB;514;504;0;594 /pkg=3461MB;97200;97190;0;97280 /install=36177MB;102320;102310;0;102400

root@superfly:/usr/lib/nagios/plugins# ./check_disk -w 80 -c 90 -A -i /var/lib/docker
DISK CRITICAL - free space: /dev 2956 MB (100% inode=99%); /run 502 MB (84% inode=98%); / 350416 MB (73% inode=34%); /dev/shm 2974 MB (99% inode=99%); /run/lock 5 MB (100% inode=99%); /sys/fs/cgroup 2974 MB (100% inode=99%); /boot 392 MB (87% inode=99%); /run/user/2351 594 MB (100% inode=99%); /run/user/0 594 MB (100% inode=99%); /pkg 93818 MB (96% inode=99%); /install 66222 MB (64% inode=95%);| /dev=0MB;2876;2866;0;2956 /run=92MB;514;504;0;594 /=126429MB;502308;502298;0;502388 /dev/shm=0MB;2894;2884;0;2974 /run/lock=0MB;-75;-85;0;5 /sys/fs/cgroup=0MB;2894;2884;0;2974 /boot=54MB;391;381;0;471 /run/user/2351=0MB;514;504;0;594 /run/user/0=0MB;514;504;0;594 /pkg=3461MB;97200;97190;0;97280 /install=36177MB;102320;102310;0;102400
root@superfly:/usr/lib/nagios/plugins#

Blockquote
I want to ignore “/var/lib/docker” and few filesystem “none”, “tmpfs”, “sysfs”, “proc”, “configfs”, “devtmpfs”, “devfs”, “mtmfs”, “tracefs”, “overlay”, “overlay2”, “aufs”, “nsfs”, “squashfs”

I’m trying to achieve this from Icinga server where everything is set to monitor using “by_ssh” plugin with passwordless authentication between Icinga and other remote servers

here’s the config:-

to check DISK usage

object CheckCommand “trial_disk_by_ssh” {
import “by_ssh”
vars.by_ssh_address = “$address$”
vars.by_ssh_command = [ “/usr/lib/nagios/plugins/check_disk”, “-w”, “$by_ssh_disk_warn$”, “-c”, “$by_ssh_disk_crit$”, “-W”, “$by_ssh_disk_inode_warn$”, “-K”, “$by_ssh_disk_inode_crit$”, “-A” ]
vars.by_ssh_logname = “root”
vars.by_ssh_disk_warn = “15%”
vars.by_ssh_disk_crit = “10%”
vars.by_ssh_disk_inode_warn = “85%”
vars.by_ssh_disk_inode_crit = “90%”
vars.disk_mountpoint = true
vars.disk_all = true
vars.disk_ignore_eregi_path = “/var/lib/docker”
vars.disk_timeout = 100
vars.disk_exclude_type = [ “none”, “tmpfs”, “sysfs”, “proc”, “configfs”, “devtmpfs”, “devfs”, “mtmfs”, “tracefs”, “cgroup”, “fuse.gvfsd-fuse”, “fuse.gvfs-fuse-daemon”, “fdescfs”, “overlay”, “overlay2”, “aufs”, “nsfs”, “squashfs” ]
vars.by_ssh_skip_stderr = true
vars.notification[“mail”] = {
/* The UserGroup icingaadmins is defined in usergroup.conf. */
groups = [ “icinga2admin” ]
}
}

(Aflatto) #2

you can use the

-X, --exclude-type=TYPE
Ignore all filesystems of indicated type (may be repeated)

or

-i, --ignore-ereg-path=PATH, --ignore-ereg-partition=PARTITION
Regular expression to ignore selected path or partition (may be repeated)

(Sarojamarraj) #3

Hello,

Thanks for the reply, as you can see i’m already using suggested options and it’s not working.

(Roland Sommer) #4

I use this kind of definition:

apply Service "trial_disk_by_ssh" {
	check_command = "by_ssh"
	vars.by_ssh_command = "/usr/lib/nagios/plugins/check_disk"
	vars.by_ssh_logname = host.vars.ssh_username
	vars.by_ssh_arguments = {
	 "-w" = "20%"
	 "-c" = "10%"
	 "-x" = [
			"none",
			"tmpfs",
			...
		]
	}

	assign where ...
}
(Rafael Voss) #5

-x not works with “,” on my test. try multiple “-x” e.g.

"-x none -x tmpfs"

maybe that will do the trick

(Sarojamarraj) #6

This is how it worked for me…

testing new comand for check_disk

object CheckCommand “new_disk_by_ssh” {
import “by_ssh”
vars.by_ssh_address = “$address$”
vars.by_ssh_command = [ “/usr/lib/nagios/plugins/check_disk”, “-w”, “$ssh_disk_warn$”, “-c”, “$ssh_disk_crit$”, “-W”, “$ssh_disk_inode_warn$”, “-K”, “$ssh_disk_inode_crit$”, “-A” ]
vars.ssh_disk_warn = “15%”
vars.ssh_disk_crit = “10%”
vars.ssh_disk_inode_warn = “85%”
vars.ssh_disk_inode_crit = “90%”
vars.by_ssh_logname = “root”
vars.by_ssh_arguments = {
“-I” = [ “/var/lib/docker”, “/run”, “/sys”, “/install”, “/rpm”, “/pkg”, “/dev/shm” ]
}
vars.disk_mountpoint = true
vars.disk_timeout = 100
vars.by_ssh_skip_stderr = true
vars.notification[“mail”] = {
/* The UserGroup icingaadmins is defined in usergroup.conf. */
groups = [ “icinga2admin” ]
}
}

Thanks for the help.