Sunday, March 31, 2024

Define your first objects: host / command / service


https://assets.nagios.com/downloads/nagioscore/docs/nagioscore/3/en/objectdefinitions.html

Nagios itself won't differentiate between the files you create or use to configure host monitoring. If you wanted you could create a separate file for each service and each command, though it would definitely create big mess. We start with this option here, to understand functioning.
Then you can rename your files to some other sort of extension like .cf_ or .cf*, so that nagios will ignore them. This way we can create a total new file like "touch nagios-server.cfg" and put all information into it. This way, we will have one .cfg file for each server we monitor.

----------------------------------------------------------

4 BASE NAGIOS ELEMENTS:
    PLUG-INs - nagios executable programs : binaries, Perl or Bash scripts, etc.
    COMMANDS - to launch plug-ins
    HOST - Supervisable equipment , most likely with an IP address
    SERVICE - something to supervise, like SSH, HTTP, DNS, DHCP etc.
----------------------------------------------------------
HOW TO DEFINE A COMMAND, exemple:
https://assets.nagios.com/downloads/nagioscore/docs/nagioscore/4/en/objectdefinitions.html#command

    
    # go to the our commands directory
    cd /usr/local/nagios/nag_test_conf
    
    # create a config file
    nano command.cfg
    
    # you add this for instance:
        define command {
            command_name check-ping-localhost
            command_line $USER1$/check_ping -H localhost -w 40,40% -c 60,60%
        }    
        
    #if you've opened /usr/local/nagios/etc/resource.cfg
    # you would see that macro: $USER1$=/usr/local/nagios/libexec

----------------------------------------------------------   
HOW TO DEFINE A HOST, example:
https://assets.nagios.com/downloads/nagioscore/docs/nagioscore/4/en/objectdefinitions.html#host
        
        # we will define for the moment simply our own server to probe
        # probe with the check ping service

        
        cd /usr/local/nagios/nag_test_conf
        nano nag_test.cfg
        
        define host {
                host_name        Nagios Server
                address            localhost
                check_command    check-ping-localhost
                max_check_attempts        3
                contacts         nagiosadmin
        }        
        
----------------------------------------------------------
HOW TO DEFINE A SERVICE, exemple:
https://assets.nagios.com/downloads/nagioscore/docs/nagioscore/4/en/objectdefinitions.html#service


        cd /usr/local/nagios/nag_test_conf
        nano nag_test.cfg
        
        # we test adding an SSH service check
        
        define command {
            command_name check-ssh-localhost
            command_line $USER1$/check_ssh localhost
        }
        
        # we apply it to our desired host (nag_host.cfg)
        
        define service {
            service_description SSH sur Nagios Server
            host_name Nagios Server
            check_command check-ssh-localhost
            max_check_attempts 3
            contacts nagiosadmin
            check_period 24x7
            notification_period 24x7
        }
----------------------------------------------------------       
PUT EVERYTHING INTO ONE FILE:
        
define command {
        command_name check-ping-localhost
        command_line $USER1$/check_ping -H localhost -w 40,40% -c 60,60%
}
define command {
        command_name check-ssh-localhost
        command_line $USER1$/check_ssh localhost
}
define host {
        host_name Nagios Server
        address localhost
        check_command check-ping-localhost
        max_check_attempts 3
        contacts nagiosadmin
}
define service {
        service_description SSH sur Nagios Server
        host_name Nagios Server
        check_command check-ssh-localhost
        max_check_attempts 3
        contacts nagiosadmin
        check_period 24x7
        notification_period 24x7
}        
        
        

_dnhyper

No comments:

Post a Comment

Sharepoint sync and lock issues - solutions

 Sharepoint synced down to your PC by onedrive can have a ton of errors. It is caused by the simple dis-functionality of this badly thought ...