从 Icinga2 输出中删除 NFS 挂载分区?
Remove NFS mounted partitions from Icinga2 output?
我们大约有 10 台服务器,它们都安装了 NFS 分区。 Icinga 上的所有主机都显示该 NFS 分区,因此当达到 NFS 分区阈值时,将针对该特定错误发送 10 封邮件通知。
问题是如何从不同主机删除 NFS 分区。
目前默认配置如下:
apply Service for (display_name => config in host.vars.snmp.disks) {
import "generic-service-faxir"
check_command = "snmp-storage-parameteric"
vars += config
if (vars.snmp_warn == ""){
vars.snmp_warn = "70"
}
if (vars.snmp_crit == ""){
vars.snmp_crit = "85"
}
//Converting capacity to percentage
if(vars.capacity != ""){
if(vars.capacity_warn != ""){
vars.snmp_warn = 100 * vars.capacity_warn / vars.capacity
}
if(vars.capacity_crit != ""){
vars.snmp_crit = 100 * vars.capacity_crit / vars.capacity
}
}
//ext2, ext3, and ext4 has 5% reserved for OS
if (host.vars.os == "Linux"){
vars.snmp_storage_reserved = 5
}
ignore where host.vars.os !in ["Linux", "Windows"]
}
编辑 1:
命令代码如下:
/**
* based on:
* snmp storage - Disk/Memory
* Url reference: http://nagios.manubulon.com/snmp_storage.html
*/
object CheckCommand "snmp-storage-parameteric" {
import "snmp-manubulon-command"
command = [ ManubulonPluginDir + "/check_snmp_storage.pl" ]
arguments += {
"-m" = "$snmp_storage_name$"
"-f" = {
set_if = "$snmp_perf$"
}
"-R" = "$snmp_storage_reserved$"
"-T" = "$snmp_storage_type$"
"-G" = ""
}
vars.snmp_storage_name = "^/$$"
vars.snmp_storage_type = "pu"
vars.snmp_warn = 80
vars.snmp_crit = 90
vars.snmp_perf = true
vars.snmp_storage_reserved=0
}
我没试过,不过你可以看看下面的命令参数:
匹配名称模式 - https://github.com/dnsmichi/manubulon-snmp/blob/master/plugins/check_snmp_storage.pl#L164
-m, --name=NAME
Name in description OID (can be mounpoints '/home' or 'Swap Space'...)
This is treated as a regexp : -m /var will match /var , /var/log, /opt/var ...
Test it before, because there are known bugs (ex : trailling /)
No trailing slash for mountpoints !
排除特定卷 - https://github.com/dnsmichi/manubulon-snmp/blob/master/plugins/check_snmp_storage.pl#L180
-e, --exclude
Select all storages except the one(s) selected by -m
No action on storage type selection
select一种存储类型 - https://github.com/dnsmichi/manubulon-snmp/blob/master/plugins/check_snmp_storage.pl#L169
"-q, --storagetype=[Other|Ram|VirtualMemory|FixedDisk|RemovableDisk|FloppyDisk
CompactDisk|RamDisk|FlashMemory|NetworkDisk]
最好是在命令行上测试各种参数,然后将它们添加到您的 CheckCommand 和服务定义中。
我们大约有 10 台服务器,它们都安装了 NFS 分区。 Icinga 上的所有主机都显示该 NFS 分区,因此当达到 NFS 分区阈值时,将针对该特定错误发送 10 封邮件通知。
问题是如何从不同主机删除 NFS 分区。
目前默认配置如下:
apply Service for (display_name => config in host.vars.snmp.disks) {
import "generic-service-faxir"
check_command = "snmp-storage-parameteric"
vars += config
if (vars.snmp_warn == ""){
vars.snmp_warn = "70"
}
if (vars.snmp_crit == ""){
vars.snmp_crit = "85"
}
//Converting capacity to percentage
if(vars.capacity != ""){
if(vars.capacity_warn != ""){
vars.snmp_warn = 100 * vars.capacity_warn / vars.capacity
}
if(vars.capacity_crit != ""){
vars.snmp_crit = 100 * vars.capacity_crit / vars.capacity
}
}
//ext2, ext3, and ext4 has 5% reserved for OS
if (host.vars.os == "Linux"){
vars.snmp_storage_reserved = 5
}
ignore where host.vars.os !in ["Linux", "Windows"]
}
编辑 1: 命令代码如下:
/**
* based on:
* snmp storage - Disk/Memory
* Url reference: http://nagios.manubulon.com/snmp_storage.html
*/
object CheckCommand "snmp-storage-parameteric" {
import "snmp-manubulon-command"
command = [ ManubulonPluginDir + "/check_snmp_storage.pl" ]
arguments += {
"-m" = "$snmp_storage_name$"
"-f" = {
set_if = "$snmp_perf$"
}
"-R" = "$snmp_storage_reserved$"
"-T" = "$snmp_storage_type$"
"-G" = ""
}
vars.snmp_storage_name = "^/$$"
vars.snmp_storage_type = "pu"
vars.snmp_warn = 80
vars.snmp_crit = 90
vars.snmp_perf = true
vars.snmp_storage_reserved=0
}
我没试过,不过你可以看看下面的命令参数:
匹配名称模式 - https://github.com/dnsmichi/manubulon-snmp/blob/master/plugins/check_snmp_storage.pl#L164
-m, --name=NAME Name in description OID (can be mounpoints '/home' or 'Swap Space'...) This is treated as a regexp : -m /var will match /var , /var/log, /opt/var ... Test it before, because there are known bugs (ex : trailling /) No trailing slash for mountpoints !
排除特定卷 - https://github.com/dnsmichi/manubulon-snmp/blob/master/plugins/check_snmp_storage.pl#L180
-e, --exclude Select all storages except the one(s) selected by -m No action on storage type selection
select一种存储类型 - https://github.com/dnsmichi/manubulon-snmp/blob/master/plugins/check_snmp_storage.pl#L169
"-q, --storagetype=[Other|Ram|VirtualMemory|FixedDisk|RemovableDisk|FloppyDisk CompactDisk|RamDisk|FlashMemory|NetworkDisk]
最好是在命令行上测试各种参数,然后将它们添加到您的 CheckCommand 和服务定义中。