AnswerBun.com

Turn off a check on one host in icinga2

Server Fault Asked by Peter Nunn on December 25, 2020

I’m trying to turn off the http check for one host in my icinga2 setup. I’m new to this and am just going around in circles.

I’m using the standard install and have it successfully running against a number of linux sattelite machienes happily, but a few don’t have web servers running on them so I want to turn off the http check.

Following some inconclusive looking around I came across Avoiding Common Pitfalls with Apply Rules which seem to do what I want with the vars.no_web_check variable, but try as I might I can’t get it to work.

I’ve added the ignore line to groups.conf for the http test, but when I set up my host config in repository.d/hosts/ as follows

object Host "kvm3.infoteq.com.au" {
 import "satellite-host"
 check_command = "cluster-zone"
 vars.no_web_check = true
 }
}

I get an error when I try and reload icinga2 saying there is a problem with this config, Error: Value computed is not used.

The modified http stanza from groups.conf file is

 object ServiceGroup "http" {
  display_name = "HTTP Checks"

  assign where match("http*", service.check_command)
  ignore where host.vars.no_web_check
}

Is this where I should be adding this check? There must be an easier way to do this.

2 Answers

Can you not just the set vars.web_check = false and then in groups.conf:

assign where host.vars.web_check

which will just apply this service to the hosts where you have only web_check set to true. I think this should work as well:

assign where match("http*", service.check_command) && host.vars.web_check

Answered by Tux_DEV_NULL on December 25, 2020

For your service, I would try to use a service declaration and not a servicegroup, for example :

apply Service "Interface " for (interface_name => interface_config in host.vars.interfaces){
        import "generic-service"
        check_command = "check_netint_w2012_byifname"
        vars.interface = interface_name
        vars.warning= "650000"
        vars.critical ="800000"    
        vars.snmp_communaute = host.vars.snmp_communaute    
        vars += interface_config
        assign where host.name in ["server1", "server2", "server3"]

}

This service is applied to all hosts where their names are in the assign declaration.

You can use ignore to exclude some hosts. It's the syntax of assign.

Answered by Sorcha on December 25, 2020

Add your own answers!

Related Questions

How do i mount a Raid disk in linux

2  Asked on January 25, 2021

 

AH01630: client denied by server configuration Apache

3  Asked on January 24, 2021 by koulapic

     

Postfix/Dovecot-LMTP configuration confusion

2  Asked on January 24, 2021 by user8056359

         

Cannot sign in to aws console

0  Asked on January 22, 2021 by rosencreuz

     

Router drops connection

1  Asked on January 22, 2021 by deniz-zoeteman

     

Windows 10 computer won’t update

2  Asked on January 22, 2021 by hagen-von-eitzen

     

Error while mounting partition with Live CD

1  Asked on January 21, 2021 by sat

     

logrotate not rotating the logs

4  Asked on January 21, 2021 by carmen

 

How to troubleshoot GRE tunnel issues?

1  Asked on January 21, 2021 by linux911

     

Dell PowerEdge R430 iDRAC8 snmp OIDs for hardware

1  Asked on January 20, 2021 by alex_90

 

Snort in KVM machines

1  Asked on January 20, 2021 by emilio-macias

   

check_nrpe: ssocket time out after 10 seconds

1  Asked on January 19, 2021 by suganya

       

Ask a Question

Get help from others!

© 2022 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP