From faf9fdd312fa3ef66d8c4d412240f2714db0fb73 Mon Sep 17 00:00:00 2001 From: Eric Loyd Date: Wed, 18 Sep 2019 20:05:08 -0400 Subject: [PATCH] Failover looking much better with proper rsync --- failover/Makefile | 7 ++++-- failover/failover.sh | 9 ++++++-- .../custom-includes/css/header-gradient.css | 7 ++++++ .../css/header-gradient.css.primary | 7 ++++++ .../css/header-gradient.css.secondary | 7 ++++++ .../components/custom-includes/css/header.css | 8 +++++++ failover/restore_xi.sh | 4 +++- failover/rsync_xi.sh | 22 +++++++++---------- 8 files changed, 55 insertions(+), 16 deletions(-) create mode 100644 failover/local/usr/local/nagiosxi/html/includes/components/custom-includes/css/header-gradient.css create mode 100644 failover/local/usr/local/nagiosxi/html/includes/components/custom-includes/css/header-gradient.css.primary create mode 100644 failover/local/usr/local/nagiosxi/html/includes/components/custom-includes/css/header-gradient.css.secondary create mode 100644 failover/local/usr/local/nagiosxi/html/includes/components/custom-includes/css/header.css diff --git a/failover/Makefile b/failover/Makefile index eeb7a24..a73994e 100644 --- a/failover/Makefile +++ b/failover/Makefile @@ -1,5 +1,8 @@ primary: - ./failover.sh -p 192.168.56.113 -s 192.168.56.114 -H 192.168.56.113 + ./failover.sh -P 192.168.56.113 -S 192.168.56.114 -H 192.168.56.113 secondary: - ./failover.sh -p 192.168.56.113 -s 192.168.56.114 -H 192.168.56.114 + ./failover.sh -P 192.168.56.113 -S 192.168.56.114 -H 192.168.56.114 + +sync: + rsync -avu --stats . clone:/root/princeton/failover diff --git a/failover/failover.sh b/failover/failover.sh index 1c3c5e0..28a9ec4 100755 --- a/failover/failover.sh +++ b/failover/failover.sh @@ -10,14 +10,16 @@ PATH=/usr/sbin:/sbin:/usr/bin:/bin primary="nagiosxi-p.princeton.edu" secondary="nagiosxi-f.princeton.edu" +synconly="false" hostname=`/bin/hostname` while [ -n "$1" ]; do case "$1" in -H | --hostname) hostname="$2"; shift 2;; - -s | --secondary) secondary="$2"; shift 2;; - -p | --primary) primary="$2"; shift 2;; + -S | --secondary) secondary="$2"; shift 2;; + -P | --primary) primary="$2"; shift 2;; + -s | --sync-only) synconly="true"; shift 1;; *) shift 1;; esac done @@ -39,6 +41,9 @@ do_secondary() { mysqlfile=`ls -tr1 /store/backups/nagiosxi/ | tail -1` [ -z "$mysqlfile" ] && echo "No MySQL Backup file." && exit 2 ./restore_xi.sh /store/backups/nagiosxi/$mysqlfile + ./nagios_startstop.sh stop + cp /usr/local/nagiosxi/html/includes/components/custom-includes/css/header-gradient.css.secondary /usr/local/nagiosxi/html/includes/components/custom-includes/css/header-gradient.css + cd /usr/local/nagiosxi/scripts && ./reconfigure_nagios.sh } case "$hostname" in diff --git a/failover/local/usr/local/nagiosxi/html/includes/components/custom-includes/css/header-gradient.css b/failover/local/usr/local/nagiosxi/html/includes/components/custom-includes/css/header-gradient.css new file mode 100644 index 0000000..ace83bc --- /dev/null +++ b/failover/local/usr/local/nagiosxi/html/includes/components/custom-includes/css/header-gradient.css @@ -0,0 +1,7 @@ +#header { + background: rgb(59,234,2); + background: -moz-linear-gradient(90deg, rgba(59,234,2,1) 0%, rgba(8,124,8,1) 35%); + background: -webkit-linear-gradient(90deg, rgba(59,234,2,1) 0%, rgba(8,124,8,1) 35%); + background: linear-gradient(90deg, rgba(59,234,2,1) 0%, rgba(8,124,8,1) 35%); + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr="#3bea02",endColorstr="#087c08",GradientType=1); +} diff --git a/failover/local/usr/local/nagiosxi/html/includes/components/custom-includes/css/header-gradient.css.primary b/failover/local/usr/local/nagiosxi/html/includes/components/custom-includes/css/header-gradient.css.primary new file mode 100644 index 0000000..ace83bc --- /dev/null +++ b/failover/local/usr/local/nagiosxi/html/includes/components/custom-includes/css/header-gradient.css.primary @@ -0,0 +1,7 @@ +#header { + background: rgb(59,234,2); + background: -moz-linear-gradient(90deg, rgba(59,234,2,1) 0%, rgba(8,124,8,1) 35%); + background: -webkit-linear-gradient(90deg, rgba(59,234,2,1) 0%, rgba(8,124,8,1) 35%); + background: linear-gradient(90deg, rgba(59,234,2,1) 0%, rgba(8,124,8,1) 35%); + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr="#3bea02",endColorstr="#087c08",GradientType=1); +} diff --git a/failover/local/usr/local/nagiosxi/html/includes/components/custom-includes/css/header-gradient.css.secondary b/failover/local/usr/local/nagiosxi/html/includes/components/custom-includes/css/header-gradient.css.secondary new file mode 100644 index 0000000..dd7f429 --- /dev/null +++ b/failover/local/usr/local/nagiosxi/html/includes/components/custom-includes/css/header-gradient.css.secondary @@ -0,0 +1,7 @@ +#header { + background: rgb(234,59,2); + background: -moz-linear-gradient(90deg, rgba(234,59,2,1) 0%, rgba(121,51,11,1) 35%); + background: -webkit-linear-gradient(90deg, rgba(234,59,2,1) 0%, rgba(121,51,11,1) 35%); + background: linear-gradient(90deg, rgba(234,59,2,1) 0%, rgba(121,51,11,1) 35%); + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr="#ea3b02",endColorstr="#79330b",GradientType=1); +} diff --git a/failover/local/usr/local/nagiosxi/html/includes/components/custom-includes/css/header.css b/failover/local/usr/local/nagiosxi/html/includes/components/custom-includes/css/header.css new file mode 100644 index 0000000..d6ae7a9 --- /dev/null +++ b/failover/local/usr/local/nagiosxi/html/includes/components/custom-includes/css/header.css @@ -0,0 +1,8 @@ +;#header { +; background: #3cb371; +;} + +#header { + background: #c71585; +} + diff --git a/failover/restore_xi.sh b/failover/restore_xi.sh index de3be8a..10db47c 100755 --- a/failover/restore_xi.sh +++ b/failover/restore_xi.sh @@ -100,6 +100,7 @@ mysqlpass="$themysqlpass" ############################## # RESTORE DATABASES ############################## +restore_databases() { echo "Restoring MySQL databases..." if [[ "$cfg__db_info__ndoutils__dbserver" == *":"* ]]; then ndoutils_dbport=`echo "$cfg__db_info__ndoutils__dbserver" | cut -f2 -d":"` @@ -204,6 +205,7 @@ fi echo "Restarting database servers..." $BASEDIR/manage_services.sh restart mysqld +} ############################## # RESTART SERVICES @@ -230,6 +232,6 @@ echo "===============" echo "Restarting Nagios XI" cd /usr/local/nagiosxi/scripts -./resconfigure_nagios +./reconfigure_nagios.sh exit 0 diff --git a/failover/rsync_xi.sh b/failover/rsync_xi.sh index c20b948..d75ce18 100755 --- a/failover/rsync_xi.sh +++ b/failover/rsync_xi.sh @@ -96,14 +96,14 @@ mkdir -p $mydir do_rsync() { - rsync -avun --delete --delete-after $1 ${secondary}:${1} + rsync -avu --delete --delete-after $1 ${secondary}:${1} } # Only backup NagiosQL if it exists if [ -d "/var/www/html/nagiosql" ]; then echo "Backing up NagiosQL..." - do_rsync /var/www/html/nagiosql - do_rsync /etc/nagiosql + do_rsync /var/www/html/nagiosql/ + do_rsync /etc/nagiosql/ fi echo "Backing up Nagios Core..." @@ -116,26 +116,26 @@ if [ -f "/etc/sysconfig/nagios" ]; then fi echo "Backing up Nagios XI..." -do_rsync /usr/local/nagiosxi +do_rsync /usr/local/nagiosxi/ echo "Backing up MRTG..." -do_rsync /var/lib/mrtg +do_rsync /var/lib/mrtg/ do_rsync /etc/mrtg/mrtg.cfg -do_rsync /etc/mrtg/conf.d +do_rsync /etc/mrtg/conf.d/ # SNMP configs and MIBS echo "Backing up the SNMP directories" -do_rsync /etc/snmp -do_rsync /usr/share/snmp +do_rsync /etc/snmp/ +do_rsync /usr/share/snmp/ echo "Backing up NRDP..." -do_rsync /usr/local/nrdp +do_rsync /usr/local/nrdp/ echo "Backing up Nagvis..." -do_rsync /usr/local/nagvis +do_rsync /usr/local/nagvis/ echo "Backing up nagios user home dir..." -do_rsync /home/nagios +do_rsync /home/nagios/ ############################## # BACKUP DATABASES