Unable to apply config after 5.8.2 update

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
dchurch
Posts: 858
Joined: Wed Oct 07, 2020 12:46 pm
Location: Yo mama

Re: Unable to apply config after 5.8.2 update

Post by dchurch »

I figured it out: the permissions are such on /usr/local/nagios/etc that the Apply Config process doesn't actually write new config files. It's still using the old ones from before you upgraded.

Run this code to fix it:

Code: Select all

chown -R apache:nagios /usr/local/nagios/etc
find /usr/local/nagios/etc -type d -exec chmod 0775 {} \;
find /usr/local/nagios/etc -type f -exec chmod 0664 {} \;
rm -f /tmp/ndo.cfg*
If you didn't get an 8% raise over the course of the pandemic, you took a pay cut.

Discussion of wages is protected speech under the National Labor Relations Act, and no employer can tell you you can't disclose your pay with your fellow employees.
rferebee
Posts: 733
Joined: Wed Jul 11, 2018 11:37 am

Re: Unable to apply config after 5.8.2 update

Post by rferebee »

Ok, I ran those commands. I think manually running the Delete/Write/Verify did the trick though.

I am still seeing issues with my BPI configs after updating to 5.8.2. These entries repeat over and over in the BPI.log:

Code: Select all

Can't find the host: moodle, check configuration for group: 'PI_CC'<br />Error: 
Can't find the host: edbsp14cc.nvdps, check configuration for group: 'DOABilling'<br />Error: 
Can't find the host: edbst13cc.nvdps, check configuration for group: 'DOABilling'<br />Error: 
Can't find the host: edbst14cc.nvdps, check configuration for group: 'DOABilling'<br />Error: 
Can't find the host: edbsp13cc.nvdps, check configuration for group: 'DOABilling'<br />Error: 
Can't find the host: edbst13cc.nvdps, check configuration for group: '1365Billing'<br />Error: 
Can't find the host: edbst14cc.nvdps, check configuration for group: '1365Billing'<br />Error: 
Can't find the host: edbsp13cc.nvdps, check configuration for group: '1365Billing'<br />Error: 
Can't find the host: edbsp14cc.nvdps, check configuration for group: '1365Billing'<br />Error: 
Can't find the host: cjistst, check configuration for group: 'PI_DPS'<br />Error: 
Can't find the host: edbsp14cc.nvdps, check configuration for group: 'PI_DPS'<br />Error: 
Can't find the host: cjisdev, check configuration for group: 'PI_DPS'<br />Error: 
Can't find the host: edbst13cc.nvdps, check configuration for group: 'PI_DPS'<br />Error: 
Can't find the host: edbst14cc.nvdps, check configuration for group: 'PI_DPS'<br />Error: 
Can't find the host: edbsp13cc.nvdps, check configuration for group: 'PI_DPS'<br />Error: 
Can't find the host: cjisprd, check configuration for group: 'PI_DPS'<br />
What's strange is that all of those hosts show up in the correct Host Group, so I'm not sure why XI is stating that it can't find them? They are all also active objects in CCM.
rferebee
Posts: 733
Joined: Wed Jul 11, 2018 11:37 am

Re: Unable to apply config after 5.8.2 update

Post by rferebee »

This is the command being used for BPI checks:

Code: Select all

/usr/bin/php $USER1$/check_bpi.php $ARG1$
This is the error I'm seeing in the console:

Code: Select all

(Service check timed out after 60.01 seconds)
It's not happening to every BPI host group or service check.
dchurch
Posts: 858
Joined: Wed Oct 07, 2020 12:46 pm
Location: Yo mama

Re: Unable to apply config after 5.8.2 update

Post by dchurch »

What are the timestamps on the BPI log entries?

If you successfully applied config, there shouldn't be any more of those entries getting added to the ends of the BPI log, just old ones.
If you didn't get an 8% raise over the course of the pandemic, you took a pay cut.

Discussion of wages is protected speech under the National Labor Relations Act, and no employer can tell you you can't disclose your pay with your fellow employees.
rferebee
Posts: 733
Joined: Wed Jul 11, 2018 11:37 am

Re: Unable to apply config after 5.8.2 update

Post by rferebee »

I don't see any timestamps in the log itself, however the last change date on the file is from 2018.

I see these, are these "system time"?

Code: Select all

CONFIG ERRORS: System1533154666
dchurch
Posts: 858
Joined: Wed Oct 07, 2020 12:46 pm
Location: Yo mama

Re: Unable to apply config after 5.8.2 update

Post by dchurch »

Yes that's a Unix timestamp, and it's from 2018. It's an old log entry.

As far as the BPI host group check (syncall) timing out at 60 seconds, what happens if you go to the BPI page and click "Sync Hostgroups"?
If you didn't get an 8% raise over the course of the pandemic, you took a pay cut.

Discussion of wages is protected speech under the National Labor Relations Act, and no employer can tell you you can't disclose your pay with your fellow employees.
rferebee
Posts: 733
Joined: Wed Jul 11, 2018 11:37 am

Re: Unable to apply config after 5.8.2 update

Post by rferebee »

I get an error banner which states, "Hostgroup sync was unsuccessful. Unable to match string in config file."

But, right underneath that it states, "BPI configuration applied successfully."
dchurch
Posts: 858
Joined: Wed Oct 07, 2020 12:46 pm
Location: Yo mama

Re: Unable to apply config after 5.8.2 update

Post by dchurch »

Put your bpi.conf in /root/bpi.conf.orig, run a few commands and it will fix up the bpi.conf duplicates thing and some other stuff that was found, validate first with this tool:
Use sh scriptname /root/bpi.conf.orig

Code: Select all

#!/bin/bash
BPI_FILE="${1:-/usr/local/nagiosxi/etc/components/bpi.conf}"
# Getting some initial counts
echo -n "TOTAL BPI GROUPS: " && grep -c 'define' "$BPI_FILE"
echo -n "TOTAL DUPLICATES: " && grep 'define' "$BPI_FILE" | sort | uniq -d | wc -l
# Grab NON hg_/sg_ BPI groups
grep -zPo 'define (?!hg_|sg_).* (\{([^{}]++|(?1))*\})' "$BPI_FILE" > NO_HG_SG
# Get the count
COUNT_NO_HG_SG=$(grep -c 'define' NO_HG_SG)
# Grab hg_/sg_ BPI groups
grep -zPo 'define (hg_|sg_).* (\{([^{}]++|(?1))*\})' "$BPI_FILE" > HG_SG
# Get the count
COUNT_HG_SG=$(grep -c 'define' HG_SG)
# Grab all hg_ BPI groups
grep -zPo 'define hg_.* (\{([^{}]++|(?1))*\})' "$BPI_FILE" > HG
# Get the count
COUNT_HG=$(grep -c 'define' HG)
# Grab all sg_ BPI groups
grep -zPo 'define sg_.* (\{([^{}]++|(?1))*\})' "$BPI_FILE" > SG
# Get the count
COUNT_SG=$(grep -c 'define' SG)
# Debug
echo "COUNT_NO_HG_SG = $COUNT_NO_HG_SG"
echo "COUNT_HG_SG = $COUNT_HG_SG"
echo "COUNT_HG = $COUNT_HG"
echo "COUNT_SG = $COUNT_SG"
----
Then analyze the output and get a count of hostgroups/servicegroups to do validation
Then run these commands:

Code: Select all

mkdir bpifixtmp
cd bpifixtmp
Then create a php file with this as the contents in bpifixtmp/ ie (bpi_fixer_thing.php):

Code: Select all

<?php
/**
 * Grabs data from bpi.conf file and turns into an array.
 *
 * @return mixed array $vars an array of key values read from the bpi.conf file.
 */
function parse_bpi_conf()
{
    $f = fopen('/root/bpi.conf.orig', "r") or exit("Unable to open BPI Config file:");
    $grab = 0;
    $keystring = 'define';
    $vars = array();
    // Read through file and assign host and service status into separate arrays
    while (!feof($f))
    {
        $line = fgets($f);
        // Line is a comment, continue
        if (preg_match('/#/', $line) || trim($line) == '') {
            continue;
        }
        if (preg_match('/' . $keystring . '/', $line)) {
            $grab = 1;
            $title = substr($line, (strpos($line, $keystring) + strlen($keystring)), (strlen($line)));
            $title = trim(preg_replace('/{/', '', $title));
            $vars[$title] = array();
        }
        if (preg_match('/}/', $line)) {
            $grab = 0;
        }
        // Grab variables according to the enabled boolean switch
        if ($grab == 1) {
            if (!preg_match('/' . $keystring . '/', $line) && preg_match('/=/', $line)) {
                $strings = explode('=', trim($line));
                $key = trim($strings[0]);
                $value = trim($strings[1]);
                $vars[$title][$key] = $value;
            }
        }
    }
    fclose($f);
    return $vars;
}
$myarray=parse_bpi_conf();
foreach ($myarray as $group => $item) {
    $count = 0;
    $name = str_replace(array('hg_', 'sg_'), '', $group);
    $title = $item['title'];
    $desc = $item['desc'];
    $primary = $item['primary'];
    $info = $item['info'];
    $members = $item['members'];
    $warning_threshold = $item['warning_threshold'];
    $critical_threshold = $item['critical_threshold'];
    $priority = $item['priority'];
    $type = $item['type'];
    $auth_users = $item['auth_users'];
    while (file_exists("${name}_${count}")) {
        $count++;
    }
    if (preg_match('/^hg_.*/', $group) || array_key_exists("hg_${group}", $myarray)) {
        #echo "HG DETECTED: $group\n";
        $pre = "hg_";
        $members = "";
    } elseif (preg_match('/^sg_.*/', $group) || array_key_exists("sg_${group}", $myarray)) {
        #echo "SG DETECTED: $group\n";
        $pre = "sg_";
        $members = "";
    } else {
        #echo "NONO DETECTED: $group\n";
        $pre = "";
    }
    $namefinal = "$pre$name";
    $config = <<<TEST
define {$namefinal} {
        title={$title}
        desc={$desc}
        primary={$primary}
        info={$info}
        members={$members}
        warning_threshold={$warning_threshold}
        critical_threshold={$critical_threshold}
        priority={$priority}
        type={$type}
        auth_users={$auth_users}
}\n
TEST;
    if (!file_exists("${name}_${count}")) {
         file_put_contents("${name}_${count}", $config);
    }
}
Then run these commands:
-- Make sure you're in the bpifixtmp dir

Code: Select all

php bpi_fixer_thing.php
yum install fdupes -y
fdupes -d -N .
mv bpi_fixer_thing.php ../
cat * >> /root/bpi.conf.BESTIGOT
The final /root/bpi.conf/BESTIGOT is the best I got, check for bugs, etc.
If you didn't get an 8% raise over the course of the pandemic, you took a pay cut.

Discussion of wages is protected speech under the National Labor Relations Act, and no employer can tell you you can't disclose your pay with your fellow employees.
rferebee
Posts: 733
Joined: Wed Jul 11, 2018 11:37 am

Re: Unable to apply config after 5.8.2 update

Post by rferebee »

Sorry, I'm not following this part:
Use sh scriptname /root/bpi.conf.orig
I'm guessing there's supposed to be something after sh besides 'scriptname'?
dchurch
Posts: 858
Joined: Wed Oct 07, 2020 12:46 pm
Location: Yo mama

Re: Unable to apply config after 5.8.2 update

Post by dchurch »

That first code block, if dump it into a file called, e.g. /tmp/foo.sh, then you'd run sh /tmp/foo.sh /root/bpi.conf.orig
If you didn't get an 8% raise over the course of the pandemic, you took a pay cut.

Discussion of wages is protected speech under the National Labor Relations Act, and no employer can tell you you can't disclose your pay with your fellow employees.
Locked