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*
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*
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 />
Code: Select all
/usr/bin/php $USER1$/check_bpi.php $ARG1$Code: Select all
(Service check timed out after 60.01 seconds)Code: Select all
CONFIG ERRORS: System1533154666Code: 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"
Code: Select all
mkdir bpifixtmp
cd bpifixtmpCode: 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);
}
}Code: Select all
php bpi_fixer_thing.php
yum install fdupes -y
fdupes -d -N .
mv bpi_fixer_thing.php ../
cat * >> /root/bpi.conf.BESTIGOTI'm guessing there's supposed to be something after sh besides 'scriptname'?Use sh scriptname /root/bpi.conf.orig