How to use Alerta to monitor Nagios alerts on CentOS 7

Advent

Alerta ^(http://alerta.io/) is a Internet utility that integrates and regenerates indicators from more than one tracking programs and visualizes on a unmarried display. Alerta can also be built-in with various well known tracking gear comparable to Nagios, Zabbix, Sensu, InfluxData Kapacitor. ^(http://alerta.io/)
On this instructional, you’ll arrange Alerta and configure it to show notifications from Nagios ^(http://nagios.org/)(Common Open Supply Tracking Device).

must haves

To apply this instructional, you’ll want:
  • Set ^(http://www.howtoing.com/initial-server-setup-with-centos-7/) up two CentOS 7 servers by means of following the CentOS 7 Preliminary Server Setup Information ^(http://www.howtoing.com/initial-server-setup-with-centos-7/) , together with a sudo non-root person and a firewall.
  • At the first CentOS server, you’ll run Nagios and set up the next parts:
    • Apache, MySQL and PHP, apply this instructional on how one can set up Linux, Apache, MySQL, PHP (LAMP) on CentOS 7 ^(http://www.howtoing.com/how-to-install-linux-apache-mysql-php-lamp-stack-on-centos-7/) .
    • Nagios 4, thru the next tutorials to set up how one can set up Nagios 4 on CentOS 7 and observe your server ^(http://www.howtoing.com/how-to-install-nagios-4-and-monitor-your-servers-on-centos-7/) and its configuration must haves.
  • On the second one CentOS server, we will be able to set up Alerta on this instructional to put in the next parts:
    • Nginx, set up the ^(http://www.howtoing.com/how-to-install-nginx-on-centos-7/) following instructional on how one can set up Nginx on CentOS 7 ^(http://www.howtoing.com/how-to-install-nginx-on-centos-7/) .
    • MongoDB, set up the ^(http://www.howtoing.com/how-to-install-mongodb-on-centos-7/) following instructional on how one can set up MongoDB on CentOS 7 ^(http://www.howtoing.com/how-to-install-mongodb-on-centos-7/) .
    • Alerta, thru the next steps 1 to 6, how one can use the Alerta on CentOS 7 to observe Zabbix indicators ^(http://www.howtoing.com/how-to-monitor-zabbix-alerts-with-alerta-on-centos-7/) .

Step 1 – Set up the Nagios-to-Alerta tournament agent module

You’ll use the Nagios Match Dealer (NEB) module to increase Nagios capability. NEB is Nagios tournament integration mechanism, NEB module is the opposite products and services can also be built-in with Nagios shared library. On this step, we put in Nagios  ^(https://github.com/alerta/nagios-alerta)to Alerta Gateway ^(https://github.com/alerta/nagios-alerta) , the NEB module that may ship notification to Alerta. ^(https://github.com/alerta/nagios-alerta) ^(https://github.com/alerta/nagios-alerta)
Go browsing to the Nagios server as a non-root person:
ssh [email protected]your_nagios_server_ip
Nagios to Alerta Gateway does now not have a preconfigured gadget bundle, so that you will have to construct it from the supply code. To try this, you want to put in some building gear and information. You additionally wish to set up Git as a way to get the supply code from GitHub.
yum set up -y git curl gcc make libcurl-devel
With the necessities put in, use Git to clone the supply code from the mission’s GitHub repository:
git clone https://github.com/alerta/nagios-alerta.git
Then exchange to the brand new listing:nagios-indicators
cd nagios-alerta
Then use the makecompilation module:nagios-alerta
make nagios4
You’ll see the next output:
cd ./src && make nagios4
make
[1]: Coming into listing `/root/nagios-alerta/src'
gcc -fPIC -g -O2 -DHAVE_CONFIG_H -I../come with -I../come with/nagios4 -lcurl -o alerta-neb.o alerta-neb.c -shared -lcurl
make[1]: Leaving listing `
/root/nagios-alerta/src'
In the event you see other content material, you should definitely have put in all of the must haves.
Now run the set up activity:
sudo make set up
You’ll see this output, indicating that the module is put in in :/usr/lib/nagios
cd ./src && make set up
make
[1]: Coming into listing `/root/nagios-alerta/src'
[ -d /usr/lib/nagios ] || mkdir /usr/lib/nagios
set up -m 0644 alerta-neb.o /usr/lib/nagios
make[1]: Leaving listing `
/root/nagios-alerta/src'
After putting in the module, we will be able to configure Nagios to make use of this new module.

Step 2 – Configure the Nagios-to-Alerta module

Let’s configure Nagios to ship a notification message to Alerta.

First, permit the newly put in Alerta proxy module within the Nagios primary configuration report. Open the Nagios profile within the editor:

sudo vi /usr/native/nagios/and so on/nagios.cfg

To find broker_modulethe phase that comprises the instruction:
/usr/native/nagios/and so on/nagios.cfg
...
# EVENT BROKER MODULE(S)
# This directive is used to specify an tournament dealer module that are supposed to
# by means of loaded by means of Nagios at startup. Use more than one directives if you need
# to load greater than one module. Arguments that are supposed to be handed to
# the module at startup are separated from the module trail by means of an area.
#
[...]
#broker_module=/someplace/module1.o
#broker_module=/someplace/module2.o arg1 arg2=3 debug=0
...
To configure the Alerta module, you want to supply two necessary parameters:
  • URL : The deal with used to keep in touch with the Alerta API. You have got configured how one can use Alerta to observe Zabbix indicators on CentOS 7 in ^(http://www.howtoing.com/how-to-monitor-zabbix-alerts-with-alerta-on-centos-7/) step 3 of this instructional .
  • key : How does ^(http://www.howtoing.com/how-to-monitor-zabbix-alerts-with-alerta-on-centos-7/) the API key you ^(http://www.howtoing.com/how-to-monitor-zabbix-alerts-with-alerta-on-centos-7/) created in step 4 of this instructional use Alerta on CentOS 7 to observe the Zabbix alert ^(http://www.howtoing.com/how-to-monitor-zabbix-alerts-with-alerta-on-centos-7/) . You wish to have this option with the intention to authenticate with Alerta and submit occasions.
Upload this line to a report to configure Alerta integration:
/usr/native/nagios/and so on/nagios.cfg
...
broker_module
=/usr/lib/nagios/alerta-neb.o http://your_alerta_server_ip/api key=ALERTA_API_KEY
...
There are some further non-compulsory parameters that can be specified:
  • env : Specifies the surroundings title. The default surroundings title is ” Manufacturing.
  • hard_only : ahead most effective in laborious state. You’ll to find extra details about the Nagios standing kind within the Nagios documentation ^(https://assets.nagios.com/downloads/nagioscore/docs/nagioscore/4/en/statetypes.html) . Set it 1to permit this mode.
  • Debug : – Permits the debug mode of the module. Set it 1to permit this mode.
To specify all of those choices, use this line as an alternative:
/usr/native/nagios/and so on/nagios.cfg
...
broker_module
=/usr/lib/nagios/alerta-neb.o http://your_alerta_server_ip/api key=ALERTA_API_KEY env=Manufacturing hard_only=1 debug=1
...
Save the report and go out the editor.
In an effort to establish indicators in response to the surroundings and repair title, you want to make use of the Nagios customized object variable ^(https://assets.nagios.com/downloads/nagioscore/docs/nagioscore/4/en/customobjectvars.html) to set the surroundings and repair title. To try this, use the configuration _Environmentand _Servicevariables. Now let’s configure them.
Open the default Nagios host object configuration report, which you’ll to find within the listing:/usr/native/nagios/and so on/items/
sudo vi /usr/native/nagios/and so on/items/localhost.cfg
We can mark all alarms for this host as manufacturing indicators, and we will be able to name the default provider Nagios . To find the next host definitions:
/usr/native/nagios/and so on/items/localhost.cfg
...
outline host


...
The _Environmentand _Servicevalues added to the configuration:
/usr/native/nagios/and so on/items/localhost.cfg
...
host_name localhost
alias localhost
deal with
127.0.0.1
_Environment Manufacturing
_Service Nagios
}
...
All occasions related to the gadget partitio area are actually marked as a gadget alert. To find this a part of the report that defines how one can take a look at the to be had area:
/usr/native/nagios/and so on/items/localhost.cfg
...
outline provider

...
Alter it to Deviceaffiliate it with the provider:
/usr/native/nagios/and so on/items/localhost.cfg
...
outline provider

...
Save the report and go out the editor. Reboot Nagios to use those new settings:
sudo systemctl restart nagios.provider
Via checking its standing to be sure that the provider is working:
systemctl standing nagios.provider
You’ll see the next output:
...
Jul 01 08:44:31 nagios nagios[8914]: [alerta] Initialising Nagios-Alerta Gateway module, v3.4.1
Jul 01 08:44:31 nagios nagios[8914]: [alerta] debug is off
Jul 01 08:44:31 nagios nagios[8914]: [alerta] states=Arduous/Cushy
Jul 01 08:44:31 nagios nagios[8914]: [alerta] Ahead provider tests, host tests and downtime to http://your_alerta_server_ip/api
Jul 01 08:44:31 nagios nagios[8914]: Match dealer module '/usr/lib/nagios/alerta-neb.o' initialized effectively.
Jul 01 08:44:31 nagios nagios[8914]: Effectively introduced command report employee with pid 8920
Nagios will now ship a notification once any gadget or provider is closed. Let’s generate a take a look at tournament.

Step 3 – Generate a take a look at alert to ensure Nagios-Alerta integration

Let’s generate a take a look at alert to verify all connections. Via default, Nagios tracks the dimensions of disk area to be had at the server. We can create a big sufficient brief report to cause the Nagios report gadget to make use of the alert.
First, decide how a lot unfastened area is at the Nagios server. You’ll use the dfcommand to determine:
df -h
You’ll see the next output:
    Filesystem      Measurement  Used Avail Use% Fixed on
/dev/vda1 20G 3.1G 16G 17% /
Take a look at the dimensions of the to be had area. On this case, the to be had area is 16GBYour to be had area is also other.
Use the fallocatecommand to create a report that occupies greater than 80% of the to be had disk area, which must be enough to cause an alert:
fallocate -l 14G /tmp/temp.img
Inside of a couple of mins, Nagios triggers an alert in regards to the quantity of unfastened disk area and sends a notification message to Alerta. You’ll see this new notification within the Alerta dashboard:
Now that you realize that the alert is working, delete the brief report you created as a way to reclaim disk area:
rm -f /tmp/temp.img
After some time, Nagios will ship a restoration message. Then the alarm will disappear from the primary Alerta dashboard, however you’ll see all closed occasions by means of deciding on Off .
You’ll click on the development line to look extra main points.

in conclusion

On this instructional, you will have configured Nagios to ship notifications to some other server working Alerta.

Alerta gives you a handy position to trace many gadget indicators. For instance, for those who use Nagios in some portions of your infrastructure and different portions use Zabbix, you’ll mix the notifications for each programs into one panel.
Source howtoforge ^(https://www.howtoforge.com/)