Xymon Mailing List Archive search

Synchronize disabled servers from one xymon installation to another?

6 messages in this thread

list Carl Melgaard · Tue, 9 Aug 2011 15:37:21 +0200 ·
Hi,

Is there an easy way to synchronize xymon disabled status (servers put in maintenance) from 1 xymon server to another (a standby server)?

/melgaard
list David W David Gore · Tue, 9 Aug 2011 21:42:16 -0400 ·
From TJ Yang, he probably has this posted on his site which I don't recall right now.  We may or may not have made edits.  We use it on Red Hat Linux Enterprise 5.6.

#! /bin/sh
# -----------------------------------------------------------------------------
#           S H E L L  S C R I P T   S P E C I F I C A T I O N
# -----------------------------------------------------------------------------
#
# NAME
#      bluesync.sh  - A shell script to replicate Primary Xymon Serverblue record
#                     to Secondary standby Xymon server.
#
#
# REVISION HISTORY
#      07/12/2009    Base on getblue.sh and putblue.sh by Ralph Mitchell <user-00a5e44c48c0@xymon.invalid>
#                    http://www.hswn.dk/hobbiton/2009/07/msg00214.html
#      10/19/2009    T.J. Yang merge two scripts into one for Xymon  High Availability setup.
#
# USAGE
#      This script is tested on Solaris 10 OS.
#      put this shell script in tasks.cfg as section like following.
#
# [bluesync]
# #     DISABLED
#       ENABLE
#       ENVFILE /etc/opt/hobbitserver42/hobbitserver.cfg
#       CMD /opt/hobbitserver42/ext/bluesync/bluesync.sh
#       LOGFILE $XYMONSERVERLOGS/bluesync.sh.log
#       INTERVAL 5m
#
# DESCRIPTION
#     Xymon keep its blue(maintenance) in memory, not in a file. This script
#     is to copy the blue records from primary Xymon A server into Xymon B secondary one.
#     This script is for use when running Active-Active type of Xymon server
#     High Availability setup. Xymon B is same as Xymon A except
#     the alerting function is disabled. There is another script running on Xymon B to
#     detect the outage of Xymon A and enable Xymon B to become primary one.
#
#
# Algorithems:
# 1. Pull blue records from Xymon1 and dump them into Xymon2's ext/xymon directory.
# 2. Process the lifetime fields' value
#     if lifetime is -1 and greater then zero
#       then run "bb xymon2.vzbi.com "disable hosname.test lifetime message"
#            to keep the blue record.
#     if  liftime =0
#       the run "bb xymon2.vzbi.com "enable  hostname.*d"  to enable this host blue record
#           since it is expired or was enabled on xymon1 server.
#

# RETURN CODE
#       SUCCESS (=0) - script completed sucessfully
#       ERROR   (=1) - error... bad things happened
#       WARNING (=2) - warning... something's not quite right, but it's
#                      not serious enough to prevent installation.
#
#
# set -x

# ---------------------------- CONSTANT DECLARATION ---------------------------
XYMONCFG="/home/xymon/server/etc/xymonserver.cfg"
BlueTxt="/tmp/xymon1.vzbi.com.blue.txt"
HB1="xymon1.vzbi.com"
SED="/bin/sed"
HB2="xymon2.vzbi.com"
NOW=`/bin/date +%s`
EXPR="/usr/bin/expr"
RM="/bin/rm"
SUCCESS=0
ERROR=1
WARNING=2
export SUCCESS ERROR WARNING
# inherit xymon server variables in configuration file
#. ${XYMONCFG}

# ---------------------------- VARIABLE DECLARATION ---------------------------
exit_code=${SUCCESS}

# ******************************** MAIN SCRIPT ********************************

# remove the old file first.
if [ -f ${BlueTxt} ]; then
        ${RM} ${BlueTxt}
        exit_code=$?
fi

# Getting blue records into a text file.

if [ ${exit_code} -eq ${SUCCESS} ]; then
   $XYMON ${HB1} "xymondboard color=blue fields=hostname,testname,disabletime,dismsg" |
           ${SED} -e 's/\\/\\\\/g'  > ${BlueTxt}
exit_code=$?
fi

if [ ${exit_code} -eq ${SUCCESS} ]; then
    cat ${BlueTxt} | while read line
    do
      OFS="$IFS"
      IFS="|"
      set $line
      IFS="$OFS"
      if [ "$3" -eq "-1" ]; then
        # found "disable until OK"
        lifetime="-1"
      else
        lifetime=`$EXPR $3 - ${NOW}`
        if [ "$lifetime" -le "0" ]; then
          # this one expired, enable it
          $XYMON ${HB2} "enable $1.*"
        else
          lifetime="$lifetime"s
        fi
      fi
      msg=`echo "$4" | $SED -e 's/\\\n/\n/g'`
      $XYMON ${HB2} "disable $1.$2 $lifetime $msg"
    done
exit_code=$?
fi

exit ${exit_code}


David Gore (v965-3670)
Network Management Systems (NMS)
IMPACT Transport Team Lead - SCSA, SCNA
Page: 1-800-PAG-eMCI pin 1406090
Vnet: 965-3676
quoted from Carl Melgaard

From: xymon-bounces at xymon.com [mailto:xymon-bounces at xymon.com] On Behalf Of Carl Melgaard
Sent: Tuesday, August 09, 2011 13:37
To: 'xymon at xymon.com'
Subject: [Xymon] Synchronize disabled servers from one xymon installation to another?

Hi,

Is there an easy way to synchronize xymon disabled status (servers put in maintenance) from 1 xymon server to another (a standby server)?

/melgaard
list Ralph Mitchell · Tue, 9 Aug 2011 23:13:55 -0400 ·
Well now, there's a blast from the past...  :-)

Ralph Mitchell


On Tue, Aug 9, 2011 at 9:42 PM, Gore, David W (David) <
quoted from David W David Gore
user-368fd67cc6bd@xymon.invalid> wrote:
From TJ Yang, he probably has this posted on his site which I don’t recall
right now.  We may or may not have made edits.  We use it on Red Hat Linux
Enterprise 5.6.****

** **

#! /bin/sh****

#
****

#           S H E L L  S C R I P T   S P E C I F I C A T I O N****

#
****

#****

# NAME****

#      bluesync.sh  - A shell script to replicate Primary Xymon Serverblue
record****

#                     to Secondary standby Xymon server.****

#****

#****

# REVISION HISTORY****

#      07/12/2009    Base on getblue.sh and putblue.sh by Ralph Mitchell
<user-00a5e44c48c0@xymon.invalid>****

#                    http://www.hswn.dk/hobbiton/2009/07/msg00214.html****

#      10/19/2009    T.J. Yang merge two scripts into one for Xymon  High
Availability setup.****

#****

# USAGE****

#      This script is tested on Solaris 10 OS.****

#      put this shell script in tasks.cfg as section like following.****

#****

# [bluesync]****

# #     DISABLED****

#       ENABLE****

#       ENVFILE /etc/opt/hobbitserver42/hobbitserver.cfg****

#       CMD /opt/hobbitserver42/ext/bluesync/bluesync.sh****

#       LOGFILE $XYMONSERVERLOGS/bluesync.sh.log****

#       INTERVAL 5m****

#****

# DESCRIPTION****

#     Xymon keep its blue(maintenance) in memory, not in a file. This
script****

#     is to copy the blue records from primary Xymon A server into Xymon B
secondary one.****

#     This script is for use when running Active-Active type of Xymon
server****

#     High Availability setup. Xymon B is same as Xymon A except****

#     the alerting function is disabled. There is another script running on
Xymon B to****

#     detect the outage of Xymon A and enable Xymon B to become primary
one.****

#****

#****

# Algorithems:****

# 1. Pull blue records from Xymon1 and dump them into Xymon2's ext/xymon
directory.****

# 2. Process the lifetime fields' value****

#     if lifetime is -1 and greater then zero****

#       then run "bb xymon2.vzbi.com "disable hosname.test lifetime
message"****

#            to keep the blue record.****

#     if  liftime =0****

#       the run "bb xymon2.vzbi.com "enable  hostname.*d"  to enable this
host blue record****

#           since it is expired or was enabled on xymon1 server.****

#****

** **

# RETURN CODE****

#       SUCCESS (=0) - script completed sucessfully****

#       ERROR   (=1) - error... bad things happened****

#       WARNING (=2) - warning... something's not quite right, but it's***
• #                      not serious enough to prevent installation.****

#****

#****

# set -x****

** **

# ---------------------------- CONSTANT DECLARATION
---------------------------****

XYMONCFG="/home/xymon/server/etc/xymonserver.cfg"****

BlueTxt="/tmp/xymon1.vzbi.com.blue.txt"****

HB1="xymon1.vzbi.com"****

SED="/bin/sed"****

HB2="xymon2.vzbi.com"****

NOW=`/bin/date +%s`****

EXPR="/usr/bin/expr"****

RM="/bin/rm"****

SUCCESS=0****

ERROR=1****

WARNING=2****

export SUCCESS ERROR WARNING****

# inherit xymon server variables in configuration file****

#. ${XYMONCFG}****

** **

# ---------------------------- VARIABLE DECLARATION
---------------------------****

exit_code=${SUCCESS}****

** **

# ******************************** MAIN SCRIPT
************************************

** **

# remove the old file first.****

if [ -f ${BlueTxt} ]; then****

        ${RM} ${BlueTxt}****

        exit_code=$?****

fi****

** **

# Getting blue records into a text file.****

** **

if [ ${exit_code} -eq ${SUCCESS} ]; then****

   $XYMON ${HB1} "xymondboard color=blue
fields=hostname,testname,disabletime,dismsg" |****

           ${SED} -e 's/\\/\\\\/g'  > ${BlueTxt}****

exit_code=$?****

fi****

** **

if [ ${exit_code} -eq ${SUCCESS} ]; then****

    cat ${BlueTxt} | while read line****

    do****

      OFS="$IFS"****

      IFS="|"****

      set $line****

      IFS="$OFS"****

      if [ "$3" -eq "-1" ]; then****

        # found "disable until OK"****

        lifetime="-1"****

      else****

        lifetime=`$EXPR $3 - ${NOW}`****

        if [ "$lifetime" -le "0" ]; then****

          # this one expired, enable it****

          $XYMON ${HB2} "enable $1.*"****

        else****

          lifetime="$lifetime"s****

        fi****

      fi****

      msg=`echo "$4" | $SED -e 's/\\\n/\n/g'`****

      $XYMON ${HB2} "disable $1.$2 $lifetime $msg"****

    done****

exit_code=$?****

fi****

** **

exit ${exit_code}****

** **

** **

David Gore (v965-3670)
Network Management Systems (NMS)
IMPACT Transport Team Lead - SCSA, SCNA
Page: 1-800-PAG-eMCI pin 1406090
Vnet: 965-3676****

** **

*From:* xymon-bounces at xymon.com [mailto:xymon-bounces at xymon.com] *On
Behalf Of *Carl Melgaard
*Sent:* Tuesday, August 09, 2011 13:37
*To:* 'xymon at xymon.com'
*Subject:* [Xymon] Synchronize disabled servers from one xymon
installation to another?****

** **

Hi,****

** **

Is there an easy way to synchronize xymon disabled status (servers put in
maintenance) from 1 xymon server to another (a standby server)?****

** **

/melgaard****

list Carl Melgaard · Wed, 10 Aug 2011 11:22:22 +0200 ·
Hi,

Thanks alot for this!

But I found a curiosity when trying to disable things:

./xymon localhost "disable host.conn 86028s Disabled by: blah @ 10.10.10.10 Reason: blah blah"

Doesn't put the host in maintenance for 86028 seconds (almost 24 hrs) - instead it uses minutes (59 days instead) - is there a bug with the "s"-suffix that I don't know about - or am I using xymon disable wrong?

/melgaard
quoted from Ralph Mitchell


Fra: Gore, David W (David) [mailto:user-368fd67cc6bd@xymon.invalid]
Sendt: 10. august 2011 03:42
Til: Carl Melgaard; 'xymon at xymon.com'
Emne: RE: Synchronize disabled servers from one xymon installation to another?

From TJ Yang, he probably has this posted on his site which I don't recall right now.  We may or may not have made edits.  We use it on Red Hat Linux Enterprise 5.6.

#! /bin/sh
# -----------------------------------------------------------------------------
#           S H E L L  S C R I P T   S P E C I F I C A T I O N
# -----------------------------------------------------------------------------
#
# NAME
#      bluesync.sh  - A shell script to replicate Primary Xymon Serverblue record
#                     to Secondary standby Xymon server.
#
#
list David W David Gore · Wed, 10 Aug 2011 06:18:19 -0400 ·
Carl,

I would guess it is similar to something what I  mentioned in my  posting asking about combos which has so far has garnered no response:


xymoncmd xymond_alert --test host service --duration=29 --color=red


00002332 2011-08-07 12:57:58 *** Match with 'EXHOST=$HOSTS_EXCLUDED HOST=* SERVICE=service COLOR=red' ***

00002332 2011-08-07 12:57:58 Matching host:service:page 'host:service:Site/Platform,Place' against rule line 432

00002332 2011-08-07 12:57:58 Failed 'SCRIPT=$SENDPAGE $PAGE_NMS DURATION>30m REPEAT=365d' (min. duration 1740<1800)


The duration above is in minutes when clearly the documentation specifies seconds?


       --test HOST SERVICE [options]

              Shows  which alert rules matches the given HOST/SERVICE combination.  Useful to debug configu-

              ration problems, and see what rules are used for an alert.


              The possible options are:

              --color=COLORNAME The COLORNAME parameter is the color of the alert: red, yellow or purple.

              --duration=SECONDS The SECONDS parameter is the duration of the alert in seconds.

              --group=GROUPNAME The GROUPNAME paramater is a groupid string from the analysis.cfg file.
signature


David Gore (v965-3670)
Network Management Systems (NMS)
IMPACT Transport Team Lead - SCSA, SCNA
Page: 1-800-PAG-eMCI pin 1406090
Vnet: 965-3676

quoted from Carl Melgaard
From: xymon-bounces at xymon.com [mailto:xymon-bounces at xymon.com] On Behalf Of Carl Melgaard
Sent: Wednesday, August 10, 2011 09:22
To: 'xymon at xymon.com'
Subject: Re: [Xymon] Synchronize disabled servers from one xymon installation to another?

Hi,

Thanks alot for this!

But I found a curiosity when trying to disable things:

./xymon localhost "disable host.conn 86028s Disabled by: blah @ 10.10.10.10 Reason: blah blah"

Doesn't put the host in maintenance for 86028 seconds (almost 24 hrs) - instead it uses minutes (59 days instead) - is there a bug with the "s"-suffix that I don't know about - or am I using xymon disable wrong?

/melgaard


Fra: Gore, David W (David) [mailto:user-368fd67cc6bd@xymon.invalid]
Sendt: 10. august 2011 03:42
Til: Carl Melgaard; 'xymon at xymon.com'
Emne: RE: Synchronize disabled servers from one xymon installation to another?

From TJ Yang, he probably has this posted on his site which I don't recall right now.  We may or may not have made edits.  We use it on Red Hat Linux Enterprise 5.6.

#! /bin/sh
# -----------------------------------------------------------------------------
#           S H E L L  S C R I P T   S P E C I F I C A T I O N
# -----------------------------------------------------------------------------
#
# NAME
#      bluesync.sh  - A shell script to replicate Primary Xymon Serverblue record
#                     to Secondary standby Xymon server.
#
#
list Carl Melgaard · Wed, 10 Aug 2011 12:43:28 +0200 ·
Hi,

Yeah, could be related - it's assuming minutes in 4.3.4 + an old 4.4.0-beta Im running too. Henrik - help! :)
quoted from David W David Gore

/melgaard

Fra: Gore, David W (David) [mailto:user-368fd67cc6bd@xymon.invalid]
Sendt: 10. august 2011 12:18
Til: Carl Melgaard; 'xymon at xymon.com'
Emne: RE: [Xymon] Synchronize disabled servers from one xymon installation to another?

Carl,

I would guess it is similar to something what I  mentioned in my  posting asking about combos which has so far has garnered no response:


xymoncmd xymond_alert --test host service --duration=29 --color=red


00002332 2011-08-07 12:57:58 *** Match with 'EXHOST=$HOSTS_EXCLUDED HOST=* SERVICE=service COLOR=red' ***

00002332 2011-08-07 12:57:58 Matching host:service:page 'host:service:Site/Platform,Place' against rule line 432

00002332 2011-08-07 12:57:58 Failed 'SCRIPT=$SENDPAGE $PAGE_NMS DURATION>30m REPEAT=365d' (min. duration 1740<1800)


The duration above is in minutes when clearly the documentation specifies seconds?

From: xymon-bounces at xymon.com [mailto:xymon-bounces at xymon.com] On Behalf Of Carl Melgaard
Sent: Wednesday, August 10, 2011 09:22
To: 'xymon at xymon.com'
Subject: Re: [Xymon] Synchronize disabled servers from one xymon installation to another?

Hi,

Thanks alot for this!

But I found a curiosity when trying to disable things:

./xymon localhost "disable host.conn 86028s Disabled by: blah @ 10.10.10.10 Reason: blah blah"

Doesn't put the host in maintenance for 86028 seconds (almost 24 hrs) - instead it uses minutes (59 days instead) - is there a bug with the "s"-suffix that I don't know about - or am I using xymon disable wrong?

/melgaard


Fra: Gore, David W (David) [mailto:user-368fd67cc6bd@xymon.invalid]
Sendt: 10. august 2011 03:42
Til: Carl Melgaard; 'xymon at xymon.com'
Emne: RE: Synchronize disabled servers from one xymon installation to another?

From TJ Yang, he probably has this posted on his site which I don't recall right now.  We may or may not have made edits.  We use it on Red Hat Linux Enterprise 5.6.

#! /bin/sh
# -----------------------------------------------------------------------------
#           S H E L L  S C R I P T   S P E C I F I C A T I O N
# -----------------------------------------------------------------------------
#
# NAME
#      bluesync.sh  - A shell script to replicate Primary Xymon Serverblue record
#                     to Secondary standby Xymon server.
#
#