NagFlux on Nagio/with Nagios

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
vnuna
Posts: 10
Joined: Fri Dec 08, 2017 4:00 pm

NagFlux on Nagio/with Nagios

Post by vnuna »

Hey Everyone.
So I am looking into Grafana to display on top for what we already have in place Nagiox XI

Already in Place:
1. Nagios XI already running 100%
2. Grafana installed and configured on Win 10 testing machine
3. InfluxDB installed and configured on same Win 10 testing machine
4. Added Datasource on Grafana to read from InfluxDB, tested working as I can see on InfluxDB screen for queries coming in
5. Chronograf installed and configured on same Win 10 testing machine

How can I configure the connection between Nagios XI (its a production machine) and sends the data to InfluxDB, there are bunch of connectors - Graphios, Nagflux. So far I have an eye on Nagflux, but where should I install this and configure, can I do it on Win 10 machine and simply pull Nagios data or it has to be installed on Nagiox XI itself and sends data from there? How?

Thanks
dwhitfield
Former Nagios Staff
Posts: 4583
Joined: Wed Sep 21, 2016 10:29 am
Location: NoLo, Minneapolis, MN
Contact:

Re: NagFlux on Nagio/with Nagios

Post by dwhitfield »

You posted this in Core, but mention XI. Can you send us a screenshot of what you are seeing?

If this is XI, please see https://support.nagios.com/forum/viewto ... 16&t=46257

If this is Core, please see https://exchange.nagios.org/directory/D ... na/details

If this is XI, once your second forum post is approved, can you PM me your Profile? You can download it by going to Admin > System Config > System Profile and click the ***Download Profile*** button towards the top. If for whatever reason you *cannot* download the profile, please put the output of View System Info (5.3.4+, Show Profile if older) in the thread (that will at least get us some info). This will give us access to many of the logs we would otherwise ask for individually. If security is a concern, you can unzip the profile take out what you like, and then zip it up again. We may end up needing something you remove, but we can ask for that specifically.

You can also generate a profile manually using the script at /usr/local/nagiosxi/html/includes/components/profile/getprofile.sh

That should generate a profile in /usr/local/nagiosxi/var/components/ which you can get off the server with an application such as FileZilla.

After you PM the profile, please update this thread. Updating this thread is the only way for it to show back up on our dashboard.

If you get an error that PROFILE BUILD FAILED, please see https://support.nagios.com/kb/article.p ... ategory=44
vnuna
Posts: 10
Joined: Fri Dec 08, 2017 4:00 pm

Re: NagFlux on Nagio/with Nagios

Post by vnuna »

Sorry for posting it in the wrong section.
I am a newbie for this "connection setup".

I see on Nagios web interface it says "Nagios XI", I have attached the screenshot of the web interface to confirm its Nagios XI
You do not have the required permissions to view the files attached to this post.
vnuna
Posts: 10
Joined: Fri Dec 08, 2017 4:00 pm

Re: NagFlux on Nagio/with Nagios

Post by vnuna »

Additonally, Thank you for the link, I had found that earlier as well but I am confused where to Install NagFlux - on Windows 10 testing machine or on Nagios XI?

Basically this part:

Install and configure nagflux
# export GOPATH=$HOME/gorepo
# mkdir $GOPATH
# go get -v -u github.com/griesbacher/nagflux
# go build github.com/griesbacher/nagflux

# vi config.gcfg
[main]
NagiosSpoolfileFolder = "/usr/local/nagios/var/spool/nagfluxperfdata"
NagiosSpoolfileWorker = 1
InfluxWorker = 2
MaxInfluxWorker = 5
DumpFile = "/usr/local/nagios/var/log/nagflux/nagflux.dump"
NagfluxSpoolfileFolder = "/usr/local/nagios/var/nagflux"
FieldSeparator = "&"
BufferSize = 1000

[Log]
#leave empty for stdout
LogFile = ""
#List of Severities https://godoc.org/github.com/kdar/factorlog#Severity
MinSeverity = "INFO"


# mkdir -p /usr/local/nagios/var/spool/nagfluxperfdata
# chown nagios:nagios /usr/local/nagios/var/spool/nagfluxperfdata

The scripts are necessary to write performance data to pnp4nagios and nagflux.
# vi /usr/local/nagios/libexec/process-host-perfdata-file-bulk
#!/bin/bash

/bin/cp -p /usr/local/nagios/var/host-perfdata /usr/local/nagios/var/spool/nagfluxperfdata/${1}.perfdata.host
/bin/mv /usr/local/nagios/var/host-perfdata /usr/local/nagios/var/spool/xidpe/${1}.perfdata.host


# vi /usr/local/nagios/libexec/process-service-perfdata-file-bulk
#!/bin/bash

/bin/cp -p /usr/local/nagios/var/service-perfdata /usr/local/nagios/var/spool/nagfluxperfdata/${1}.perfdata.service
/bin/mv /usr/local/nagios/var/service-perfdata /usr/local/nagios/var/spool/xidpe/${1}.perfdata.service


# chown apache:nagios /usr/local/nagios/libexec/process-*-perfdata-file-bulk
# chmod 755 /usr/local/nagios/libexec/process-*-perfdata-file-bulk
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: NagFlux on Nagio/with Nagios

Post by mcapra »

vnuna wrote:I am confused where to Install NagFlux - on Windows 10 testing machine or on Nagios XI?
It doesn't really matter. The important thing is that NagFlux knows where the Nagios performance data spool file lives and has access to it. NagFlux looks at a perfdata file and gobbles it up. That's the beginning and end of it's direct interactions with Nagios Core/XI.

The Nagios configuration file (nagios.cfg) has a few directives related to performance data, specifically for NagFlux:
  • host_perfdata_file -- The file to which the Host performance data is written
  • service_perfdata_file -- The file to which the Service performance data is written
  • host_perfdata_file_template -- The format (with Nagios compliant macros) used when the Host performance data is written to the aforementioned file. NagFlux has a specific format you need to use.
  • service_perfdata_file_template -- The format (with Nagios compliant macros) used when the Service performance data is written to the aforementioned file. NagFlux has a specific format you need to use.
Essentially, NagFlux wants you to point it (via the NagiosSpoolfileFolder directive) at the top-level path under which the host_perfdata_file and service_perfdata_file lives. It will then digest those files and stuff their contents into InfluxDB. That's the gist of what NagFlux does; Reads perfdata files then ETLs them into InfluxDB/ElasticSearch.

The problem with implementing NagFlux with Nagios XI is that, within Nagios XI, many of these settings are carefully tailored for Nagios XI's native performance data processing. These settings directly conflict with what NagFlux is trying to do; NagFlux wants to digest the perfdata files, but Nagios XI already does that so the two will inevitably butt heads. As mentioned in the post shared by @dwhitfield, there's a few workarounds that are non-trivial to implement.

The safest way (just one dude's opinion) would be to modify the host_perfdata_command and service_perfdata_command command definitions to ship perfdata to "Nagios XI" and, additionally, ship it to a file that NagFlux can digest. Essentially creating two perfdata records: one for Nagios XI and one for NagFlux.
Former Nagios employee
https://www.mcapra.com/
vnuna
Posts: 10
Joined: Fri Dec 08, 2017 4:00 pm

Re: NagFlux on Nagio/with Nagios

Post by vnuna »

OK great..Thanks for your response and to the right direction, much appreciate...so I am on the right track. I was able to successfully modify these files as mentioned:

Login to the web interface -> Core Config Manager -> Commands.
Modify the command: process-host-perfdata-file-bulk
/usr/local/nagios/libexec/process-host-perfdata-file-bulk $TIMET$

Modify the command: process-service-perfdata-file-bulk
/usr/local/nagios/libexec/process-service-perfdata-file-bulk $TIMET$
=> Apply Configuration
After some seconds you should see files in "/usr/local/nagios/var/spool/nagfluxperfdata" (nagflux will remove the files from the directory).

Start nagflux. Nagflux will not fork as a deamon, make sure to create a start script for it.
# ./nagflux


If I am running Nagflux on Windows, I can use nssm to create as a service and start it.

What about this part? I installed NagiosXI testing machine with Nagios running, to do this I need to use SSH but ssh upon login on ssh it fails and says Access is Denied.
I need to do this:
# mkdir -p /usr/local/nagios/var/spool/nagfluxperfdata
# chown nagios:nagios /usr/local/nagios/var/spool/nagfluxperfdata

The scripts are necessary to write performance data to pnp4nagios and nagflux.
# vi /usr/local/nagios/libexec/process-host-perfdata-file-bulk
#!/bin/bash

/bin/cp -p /usr/local/nagios/var/host-perfdata /usr/local/nagios/var/spool/nagfluxperfdata/${1}.perfdata.host
/bin/mv /usr/local/nagios/var/host-perfdata /usr/local/nagios/var/spool/xidpe/${1}.perfdata.host


# vi /usr/local/nagios/libexec/process-service-perfdata-file-bulk
#!/bin/bash

/bin/cp -p /usr/local/nagios/var/service-perfdata /usr/local/nagios/var/spool/nagfluxperfdata/${1}.perfdata.service
/bin/mv /usr/local/nagios/var/service-perfdata /usr/local/nagios/var/spool/xidpe/${1}.perfdata.service


# chown apache:nagios /usr/local/nagios/libexec/process-*-perfdata-file-bulk
# chmod 755 /usr/local/nagios/libexec/process-*-perfdata-file-bulk
vnuna
Posts: 10
Joined: Fri Dec 08, 2017 4:00 pm

Re: NagFlux on Nagio/with Nagios

Post by vnuna »

I am getting an error after I run this command on SSH:

#!/bin/bash

it says "V486 Pattern Not Found: bin"
:roll:
dwhitfield
Former Nagios Staff
Posts: 4583
Joined: Wed Sep 21, 2016 10:29 am
Location: NoLo, Minneapolis, MN
Contact:

Re: NagFlux on Nagio/with Nagios

Post by dwhitfield »

Maybe we should take a step back. What issue are you trying to resolve? The checks run on an interval, so sending data to different graph software isn't going to give you more fine-tuned data.

If things are too slow in XI, have you looked at https://assets.nagios.com/downloads/nag ... ios-XI.pdf ?
vnuna
Posts: 10
Joined: Fri Dec 08, 2017 4:00 pm

Re: NagFlux on Nagio/with Nagios

Post by vnuna »

Ok Lets rewind

After you said above that I can install Nagflux on any machine, I went and installed on Windows 10 testing machine. I had to download and build it from the source inside zip file.
Now that Naglux is running, how it would find these directories when NagiosXI sits on a separate Linux machine:

NagiosSpoolfileFolder = "/usr/local/nagios/var/spool/nagfluxperfdata"
DumpFile = "/usr/local/nagios/var/log/nagflux/nagflux.dump"
NagfluxSpoolfileFolder = "/usr/local/nagios/var/nagflux"


Another issue-
This command gives me an error on SSH:
#!/bin/bash

Besides these - I have Grafana is running, InfluxDB is running, Nagios XI is running with 1 host monitored, Chronograf (Admin Panel for InfluxDB) is running as well.
Downloaded zip file for Nagflux on Win 10 test, Build id, and ran (screenshot attached)
You do not have the required permissions to view the files attached to this post.
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: NagFlux on Nagio/with Nagios

Post by mcapra »

vnuna wrote: Now that Naglux is running, how it would find these directories when NagiosXI sits on a separate Linux machine:

NagiosSpoolfileFolder = "/usr/local/nagios/var/spool/nagfluxperfdata"
DumpFile = "/usr/local/nagios/var/log/nagflux/nagflux.dump"
NagfluxSpoolfileFolder = "/usr/local/nagios/var/nagflux"
DumpFile and NagfluxSpoolfileFolder are entirely internal to NagFlux (the GitHub page has documentation on what they do). You can locate them wherever you like.

If NagiosSpoolfileFolder exists on the Nagios XI machine, you could access it via a shared directory. Or via an SFTP/FTP pipe from Windows to the Linux machine. Or via a cron job that ships it to a Windows directory every day/hour/minute. Or via carrier pigeon transporting a MicroSD card (never underestimate the bandwidth of carrier pigeons equipped with MicroSD cards).

vnuna wrote:Another issue-
This command gives me an error on SSH:
#!/bin/bash
The shebang typically sits at the head of a script and isn't generally run as a stand-alone command.
Former Nagios employee
https://www.mcapra.com/
Locked