Offloading Nagios Data Base and use different MySQL Port

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
morabanc
Posts: 199
Joined: Tue Jul 10, 2012 8:14 am

Offloading Nagios Data Base and use different MySQL Port

Post by morabanc »

Hi,

We offloaded the database of one of our XI servers to an external SQL Farm. We followed the oficial document from NagiosXI

https://assets.nagios.com/downloads/nag ... Server.pdf

But, the problem is that the database server is using the port 3308 and not the default 3306.

This is not a problem, but inside /usr/local/nagiosxi/html/config.inc.php there is no line to change it.

“dbtype” => 'mysql',
“dbserver” => '<IP_OF_MYSQL_SERVER>',
“user” => 'nagios',
“pwd” => 'nagios',
“db” => 'nagios

What we did and is working is:

“dbtype” => 'mysql',
“dbserver” => '<IP_OF_MYSQL_SERVER:3308>',
“user” => 'nagios',
“pwd” => 'nagios',
“db” => 'nagios

But now if we go through the config manager --> Config Manager Admin --> Config Manager Settings the information that we can see is:


[nagios@plinag01 scripts]$ vi /usr/local/nagiosxi/etc/components/ccm_config.inc.php
<?php
/** DO NOT MANUALLY EDIT THIS FILE
This file is used internally by Nagios CCM.
Nagios CCM will override this file automatically with the latest settings. */

$CFG["plugins_directory"] = "/usr/local/nagios/libexec";
$CFG["command_file"] = "/usr/local/nagios/var/rw/nagios.cmd";
$CFG["default_language"] = "en_US";

// MySQL database connection info
$CFG["db"] = array(
"server" => "1.1.1.1:3308",
"port" => "3306",
"database" => "nagiosql",
"username" => "nagiosql",
"password" => "xxxxx"
);

Then how we can add the port configuration correctly to the config.inc.phph and ccm_config.inc.php.

Can we add a new line in config.inc.php like “port” => '3308', ?
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Offloading Nagios Data Base and use different MySQL Port

Post by tmcdonald »

I might have to test this, but what XI version are you on? I'll ask a dev but I am not 100% sure the CCM even uses that file anymore.
Former Nagios employee
morabanc
Posts: 199
Joined: Tue Jul 10, 2012 8:14 am

Re: Offloading Nagios Data Base and use different MySQL Port

Post by morabanc »

We are working with Nagios XI 2014R2.5.
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Offloading Nagios Data Base and use different MySQL Port

Post by tmcdonald »

I got this reply back from the devs:
The CCM uses ccm_config.inc.php like he edited.
So in the XI config he needs to use the ip:port for dbserver and in the CCM he needs to use the port variable for the port.
Former Nagios employee
morabanc
Posts: 199
Joined: Tue Jul 10, 2012 8:14 am

Re: Offloading Nagios Data Base and use different MySQL Port

Post by morabanc »

In /usr/local/nagiosxi/html/config.inc.php

We added the IP:3308

With /usr/local/nagiosxi/etc/components/ccm_config.inc.php we can not modify the file using the Nagios XI web interface and it shows:

Server IP:3308
Port 3306

But if we go through command line and change manually /usr/local/nagiosxi/etc/components/ccm_config.inc.php to:

Server IP
Port 3308

Then the Nagios XI shows the correct connection and looks like all it's working.

But, if ccm_config.inc.php have IP:3308 and Port 3306 looks like it's working to...
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: Offloading Nagios Data Base and use different MySQL Port

Post by ssax »

This looks like a bug, I've submitted a bug report:

Code: Select all

NEW TASK ID 5892 created - Nagios XI Bug Report: Changing mysql port does not reflect properly in ccm_config.inc.php
Here is a workaround, edit this file:

Code: Select all

/usr/local/nagiosxi/html/includes/components/ccm/ccm.inc.php
Change this code (around line 126):

Code: Select all

        $port = 3306;
To:

Code: Select all

        if (strstr($server, ':')) {
                $port = substr($server, strpos($server, ':') + 1);
                $server = strtok($server, ':');
        }
        else {
                $port = 3306;
        }
Then it should update the /usr/local/nagiosxi/etc/components/ccm_config.inc.php file properly.

If not, run this command:

Code: Select all

rm /usr/local/nagiosxi/etc/components/ccm_config.inc.php
Then go into the XI interface and got to Configure > Core Config Manager and it should regenerate that file.
Locked