Permalink
Browse files

Working database defaults for NEMS 1.5

  • Loading branch information...
NEMS Linux
NEMS Linux committed Nov 19, 2018
1 parent 507d689 commit 5b1a22e41eee3292092e87d39d09ea5cbd6fb0f1
Showing with 26 additions and 18 deletions.
  1. +19 −18 nems-db-to-cfg.sh
  2. +7 −0 nems-push-db.sh
@@ -2,9 +2,9 @@
# Convert NEMS Nconf Database to Nagios Config files.
# Used to create the default reconciliation files
# Should run this and replace the config files in NEMS Migrator any time you update NEMS-Sample mysql db (so they match)
# Automatically replaces the config files in NEMS Migrator any time you update NEMS-Sample mysql db (so they match)
dest=/tmp/nems-dump
dest=/root/nems/nems-migrator/data/1.5/nagios/conf
if [[ ! -d $dest ]]; then
mkdir $dest
fi
@@ -17,22 +17,23 @@ if [[ ! -d 'Default_collector' ]]; then
fi
# Global
/var/www/nconf/bin/get_items.pl -c timeperiod -f > $dest/global/timeperiods.cfg
/var/www/nconf/bin/get_items.pl -c misccommand -f > $dest/global/misccommands.cfg
/var/www/nconf/bin/get_items.pl -c checkcommand -f > $dest/global/checkcommands.cfg
/var/www/nconf/bin/get_items.pl -c contact -f > $dest/global/contacts.cfg
/var/www/nconf/bin/get_items.pl -c contactgroup -f > $dest/global/contactgroups.cfg
/var/www/nconf/bin/get_items.pl -c host-template -f > $dest/global/host_templates.cfg
/var/www/nconf/bin/get_items.pl -c service-template -f > $dest/global/service_templates.cfg
/var/www/nconf/bin/get_items.pl -c timeperiod -f > $dest/global/timeperiods.cfg
/var/www/nconf/bin/get_items.pl -c misccommand -f > $dest/global/misccommands.cfg
/var/www/nconf/bin/get_items.pl -c checkcommand -f > $dest/global/checkcommands.cfg
#/var/www/nconf/bin/get_items.pl -c contact -f > $dest/global/contacts.cfg
# Use the default contact from NEMS 1.4 instead
cp -f /root/nems/nems-migrator/data/1.4/nagios/conf/global/contacts.cfg /root/nems/nems-migrator/data/1.5/nagios/conf/global/contacts.cfg
/var/www/nconf/bin/get_items.pl -c contactgroup -f > $dest/global/contactgroups.cfg
/var/www/nconf/bin/get_items.pl -c host-template -f > $dest/global/host_templates.cfg
/var/www/nconf/bin/get_items.pl -c service-template -f > $dest/global/service_templates.cfg
# Default Collector
/var/www/nconf/bin/get_items.pl -c host -f > $dest/Default_collector/hosts.cfg
/var/www/nconf/bin/get_items.pl -c hostgroup -f > $dest/Default_collector/hostgroups.cfg
/var/www/nconf/bin/get_items.pl -c host-dependency -f > $dest/Default_collector/host_dependencies.cfg
/var/www/nconf/bin/get_items.pl -c service -f > $dest/Default_collector/services.cfg
/var/www/nconf/bin/get_items.pl -c advanced-service -f > $dest/Default_collector/advanced_services.cfg && /bin/sed -i -- 's,advancedservice,service,g' $dest/Default_collector/advanced_services.cfg
/var/www/nconf/bin/get_items.pl -c servicegroup -f > $dest/Default_collector/servicegroups.cfg
/var/www/nconf/bin/get_items.pl -c service-dependency -f > $dest/Default_collector/service_dependencies.cfg
/var/www/nconf/bin/get_items.pl -c host -f > $dest/Default_collector/hosts.cfg
/var/www/nconf/bin/get_items.pl -c hostgroup -f > $dest/Default_collector/hostgroups.cfg
/var/www/nconf/bin/get_items.pl -c host-dependency -f > $dest/Default_collector/host_dependencies.cfg
/var/www/nconf/bin/get_items.pl -c service -f > $dest/Default_collector/services.cfg
/var/www/nconf/bin/get_items.pl -c advanced-service -f > $dest/Default_collector/advanced_services.cfg && /bin/sed -i -- 's,advancedservice,service,g' $dest/Default_collector/advanced_services.cfg
/var/www/nconf/bin/get_items.pl -c servicegroup -f > $dest/Default_collector/servicegroups.cfg
/var/www/nconf/bin/get_items.pl -c service-dependency -f > $dest/Default_collector/service_dependencies.cfg
echo Done. Files are located in $dest'
echo You can now copy these (upon review) to NEMS-Migrator's nagios/conf folder
echo Done. Files in $dest have been updated.
@@ -7,6 +7,13 @@
mysql -u nconf -pnagiosadmin nconf -e "TRUNCATE History"
systemctl stop nagios
# Convert the database to new default config files (for reconciliation)
/root/nems/nems-admin/nems-db-to-cfg.sh
# Proceed with DB conversion and migration
systemctl stop mysql
if [[ -d /tmp/mysql ]]; then

0 comments on commit 5b1a22e

Please sign in to comment.