• Skip to primary navigation
  • Skip to content
  • Skip to primary sidebar

The Urban Penguin

The Urban Penguin - Linux Training

  • Home
  • About
  • Shop
  • OpenStack
  • LPI Training
    • LPI Linux Essentials
    • LPIC-1 Linux Administrator
    • LPIC-2 Certified Linux Engineer
    • LPIC-3 Senior Level Certification
      • LPIC-3 Exam 300 : Mixed Environments
      • LPIC-3 Exam 303 : Security
      • LPIC-3 Exam 304 : Virtualization and High Availability
    • Live and Pluralsight hosted courses
  • Linux Technologies
    • Apache HTTPD Server
    • Learning PHP
    • Learning PUPPET
    • Learning SAMBA
    • Linux File-Systems
    • Monitoring with Nagios Core
    • MYSQL
    • openLDAP Directories on Linux
  • Programming
    • Master Editing Text Files Using VIM
    • Learn Shell Scripting with BASH
    • PERL Scripting in Linux
    • Ruby Scripting in Linux
    • Scripting with PowerShell
    • Learn C Programming using Linux and the Raspberry Pi
    • General Java Tutorials
    • Java 7 OCA Exam 1ZO-803
  • OS Tutorials
    • Linux Foundation Training (CentOS 7)
    • Learning SUSE
    • Learning Ubuntu
    • Red Hat and CentOS Training
    • Solaris 11 OCA 1ZO-821
  • Pluralsight Courses
You are here: Home / Linux / nagios / Nagios Defining a new host

Nagios Defining a new host

October 22, 2013 by The Urban Penguin


In this tutorial we look a the method in Nagios defining a new host. So buckle up and get ready to enjoy the ride. So far we have just completed the installation and the server will monitor itself. To monitor other hosts we start be defining a host within the nagios.cfg configuration. Once we have the host defined we can look at adding them to groups and associating services with these hosts so we can monitor the HTTP server, database server or what ever we need. So lets start by looking  at the configuration directory. Can you remember where we said it was? …. Yes you are correct /etc/nagios3

/etc/nagios3

This is the configuration directory for Nagios on Ubuntu 12.04.  The main configuration file is nagios.cfg found in this directory. To make adding new entries easier though the main nagios.cfg file includes other directories. We can view this with the command

grep cfg_dir /etc/nagios3/nagios.cfg

The directive cfg_dir includes the complete directory, cfg_file just a single file.

We can see from the output of grep the the /etc/nagios3/conf.d directory is included and we will a new file to this directory. The name of the file does not matter but I will add it for a host called store so naming it store.cfg makes sense.

define host {
  host_name store.tup.local
  alias store
  address 192.168.0.8
  max_check_attempts 3
  check_period 24x7
  check_command check-host-alive
  contacts root
  notification_interval 60
  notification_period 24x7
}

The host definition is within the braces and of course this is just an extension on the nagios.cfg , so we could define more than one host or other settings in this file. Later we will add services to monitor on this host.

We are checking that the host is alive throughout the 24 hour period 7 days a week. The check is a ping and 3 failed pings will raise a host down alert. The configuration is still quite basic but it is enough to get us started on monitoring with Nagios Core.

Once we have saved the file we can run the pre-flight checks, so we do not try to restart Nagios without having verified the entries we have added.

sudo nagios3 -v /etc/nagios3/nagios.cfg | less

Once we are happy with the config we can restart the monitoring server

sudo /etc/init.d/nagios3 restart

Then connect with a browser and check all is happy.

Share this:

  • Click to share on Twitter (Opens in new window)
  • Click to share on Facebook (Opens in new window)
  • Click to share on LinkedIn (Opens in new window)
  • Click to share on Reddit (Opens in new window)
  • Click to share on Pinterest (Opens in new window)
  • Click to share on Tumblr (Opens in new window)
  • Click to share on Google+ (Opens in new window)
  • Click to print (Opens in new window)

Filed Under: nagios, Ubuntu

Primary Sidebar

Newest Video

The Urban Penguin On Youtube

Categories

Pages

  • About The Urban Penguin
  • Contact Us
  • Shop
    • Basket
    • Checkout
    • My Account
  • LPI Training from The Urban Penguin
    • Live and Pluralsight hosted courses
    • Complete Linux Essentials
    • Scheduled Linux Essentials Classes
    • LPIC-3 Senior Level Certification
      • LPIC-3 Exam 300 : Mixed Environments
      • LPIC-3 Exam 303 : Security
      • LPIC-3 Exam 304 : Virtualization and High Availability
    • LPIC-2 Certified Linux Engineer
    • LPIC-1 Linux Administrator
    • LPI Linux Essentials for Raspberry Pi
    • LPI Linux Essentials
  • Operating System Tutorials
    • Linux Foundation Training
    • Solaris 11 OCA 1ZO-821
    • Learning Ubuntu
    • Learning SUSE
    • Red Hat and CentOS Training
  • Scripting – the power of repetition!
    • Java 7 OCA Exam 1ZO-803
    • General Java Tutorials
    • Learn C Programming using Linux and the Raspberry Pi
    • Ruby Scripting in Linux
    • Scripting with PowerShell
    • PERL Scripting in Linux
    • Learn Shell Scripting with BASH
    • Master Editing Text Files Using VIM
  • Linux Technologies
    • Learning PUPPET
    • openLDAP Directories on Linux
    • Monitoring with Nagios Core
    • Linux File-Systems
    • Learning SAMBA
    • Apache HTTPD Server
    • Learning PHP
    • MYSQL
  • OpenStack
    • Pluralsight
    • Udemy
    • Raspberry Pi Tutorials
    • Citrix Videos

© 2019 The Urban Penguin · All Rights Reserved

We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.Ok