Page 1 of 1

Beginner: Pass host specific parameter to disk_check_smb?

Posted: Fri Jul 31, 2015 4:14 pm
by itsmee
Hi,

just started to look inside Nagios, so this might be an easy one.. Would be very happy if you can point me the right direction..

I'd like to achieve:
- define HOSTGROUP samba including x hosts
- define generic service check
- provide per host variables (share name, user name, pwd)

I've managed #1 + #2 - but so far I cannot use a host variable in service.cfg or /etc/nagios-plugins/config/disk-smb.cfg directly..
I've tried different format, e.g. <user>, $user$ - no avail so far..

Thanks!

Code: Select all

define hostgroup {
        hostgroup_name  samba-servers
                alias           SAMBA servers
                members         banana,power,office
        }

Code: Select all

define service {
        hostgroup_name                  samba-servers
        service_description             SAMBA
        check_command                   check_disk_smb!share!user!password
        max_check_attempts              3
        normal_check_interval           2
        retry_check_interval            1
        process_perf_data               1
        use                             generic-service
        notification_interval           0 
}

Code: Select all

define host{
        use             generic-host
        host_name       banana
        alias           banana
        address         192.168.177.70 
        _smb_share      share
        _smb_user       user
        _smb_pwd        password
        }

Re: Beginner: Pass host specific parameter to disk_check_smb

Posted: Sun Aug 02, 2015 11:56 pm
by Box293
Host custom variables need to be in the format $_HOSTMY_VARIABLE_NAME$.

For example:

Code: Select all

$_HOSTSMB_SHARE$
$_HOSTSMB_USER$
$_HOSTSMB_PWD$
Here's some reading material:
https://assets.nagios.com/downloads/nag ... tvars.html

Re: Beginner: Pass host specific parameter to disk_check_smb

Posted: Mon Aug 03, 2015 3:19 pm
by itsmee
Perfect - works like a charm, thanks for the reference, very useful.

ItsMee

Re: Beginner: Pass host specific parameter to disk_check_smb

Posted: Mon Aug 03, 2015 3:24 pm
by tmcdonald
I'll be closing this thread now, but feel free to open another if you need anything in the future!