# Nagios [TOC] - [**My Nagios**](http://10.21.20.137/nagios/) ## Installation > OS: **Freebsd 13** > The **Nagios Core engine** and **Nagios plugin** both need to be install. ### SOP - [Nagios Core - Installing Nagios on FreeBSD](https://support.nagios.com/kb/article/nagios-core-installing-nagios-core-from-source-96.html#FreeBSD) > Note: the Nagios Plugins version should be **2.2.1** - Add user ```shell= htpasswd /usr/local/nagios/etc/htpasswd.users username ``` ### Path of files - Example of Nagios config file were under `/usr/local/nagios/etc/` ``` -rw-rw-r-- 1 nagios nagios 13710 Oct 17 10:24 cgi.cfg -rw-rw-r-- 1 nagios nagios 13710 Oct 17 08:51 cgi.cfg.old -rw-r--r-- 1 root nagios 95 Oct 20 12:02 htpasswd.users -rw-rw-r-- 1 nagios nagios 45847 Oct 17 10:24 nagios.cfg -rw-rw-r-- 1 nagios nagios 45847 Oct 17 08:51 nagios.cfg.old drwxrwxr-x 2 nagios nagios 512 Oct 17 10:24 objects -rw-rw---- 1 nagios nagios 1312 Oct 17 10:24 resource.cfg -rw-rw---- 1 nagios nagios 1312 Oct 17 08:51 resource.cfg.old ``` - Example of Apache config file were under `/usr/local/etc/apache24/` ## Config File - There are serveral sample config files you can refer to. All are under **`usr/local/nagios/etc/objects/`**. - Creat a dir called `demo` for configuration files. - Add a line to `/usr/local/nagios/etc/objects/nagios.cfg` ```shell= cfg_dir=/usr/local/nagios/etc/objects/obj_demo1 ``` - [Rules for Object Definitions](https://assets.nagios.com/downloads/nagioscore/docs/nagioscore/3/en/objectdefinitions.html) - There are several kinds of object could be defined - Host - Host group - Service - Service group - Contact - Contact group - Command - After creating the config file ```shell= /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg service nagios restart ``` ### Template - You can create your own defined objects, or just use the one defined in `template.cfg`. - Path of sample templates: `/usr/local/nagios/etc/objects/templates.cfg` - The configurations defined in the template will be applied on any host that is defined to use it. - ### Define Host - Define/Write down the hosts' information which would being managed. ### Define Host Group - Group the hosts you defined in `hosts.cfg`. ### Define Service - Check services with **non-default port number** - For example, if the host's **ssh** service via the port 3261, the command in *define service { }* should become: ``` check_command check_ssh!-p 3261 ``` ### Define Service Group ### Define Contact - Admin information ### Define Contact Group ### Define Command ## [Monitoring Linux/Unix Machines](https://assets.nagios.com/downloads/nagioscore/docs/nagioscore/4/en/monitoring-linux.html) ## [Monitoring Routers and Switches](https://assets.nagios.com/downloads/nagioscore/docs/nagioscore/4/en/monitoring-routers.html) ## Reference ### Official - [Nagios doc](https://assets.nagios.com/downloads/nagioscore/docs/nagioscore/4/en/toc.html) - [Guide articles list](https://support.nagios.com/kb/category.php?id=172) - [Tutorialspoint - Nagios](https://www.tutorialspoint.com/nagios/nagios_overview.htm) ### Article - [Add Hosts to Nagios Server For Monitoring](https://kifarunix.com/add-hosts-to-nagios-server-for-monitoring/) - [Install and Configure Nagios in FreeBSD12](https://www.osradar.com/install-and-configure-nagios-in-freebsd12/) - [Install Nagios Core on FreeBSD 13](https://kifarunix.com/install-nagios-core-on-freebsd-13/)