Xymon Mailing List Archive search

Xymon script

3 messages in this thread

list Jody McKinzie · Wed, 21 Dec 2011 08:58:15 -0500 ·
Hello,

 
I am working on a script to configure alerts to notify different groups
when a specific filesystem gets too full.

 
For example, if mount point a gets 100% full notify group b

 
If mount point b gets to be 100%, notify group b.

 
Here is what I have so far.  But, I cannot seem to get the output to
produce the  output for these variables.

 
$PERCENTUSED

$PERCENTALERT

 
Also, how do I test via the command line?

 
Thanks in advance.

 
#!/bin/sh

single() {

while [ ! "$1" = "" ]

do

   while [ ! "$1" = "&red" ]

   do

      shift

      if [ "$1" = "" ]

      then

         exit

      fi

   done

   shift

#&red /mnt/testA (100% used) has reached the PANIC level (99%)

   MOUNTPOINT=$1

   PERCENTUSED=`cat $2 |cut -d"(" -f2`

   PERCENTALERT=`cat $9 |cut -d"(" -f2 |cut -d")" -f1`

   echo $MOUNTPOINT

   echo $PERCENTUSED

   echo $PERCENTALERT

   lookup $1

   echo $1 $2 $3 $4 $5 $6 $7 $8 $9

   shift

   shift

   shift

   shift

   shift

   shift

   shift

   shift

   shift

done

}

lookup() {

   MAILTOADDRESS=`grep $1 /usr/local/bin/bb/diskalerts/* |cut -d" " -f3`

   echo $BBHOSTNAME Disk Alert for $MOUNTPOINT reporting $PERCENTUSED of
$PERCENTALERT Limit >>/var/tmp/diskalert.$$

   echo To acknowledge use code $ACKCODE at >>/var/tmp/diskalert.$$

   echo $ACKCODE >/var/tmp/ACKCODE

   echo http://bigbrother.zic.pri/xymon-seccgi/bb-ack-enhanced.sh
/var/tmp/diskalert.$$
   echo >>/var/tmp/diskalert.$$

   cat /var/tmp/diskalert.$$ |mailx -s "Hobbit [$ACKCODE] ${BBHOSTNAME}
disk CRITICAL ($BBCOLORLEVEL)" $MAILTOADDRESS

#   rm /var/tmp/diskalert.$$

}

single $BBALPHAMSG

 
Regards,

 
Jody R. McKinzie

Sr. UNIX Administrator

Zenith Insurance Company

Desk: (XXX) XXX-XXXX

Cell:    (XXX) XXX-XXXX

Fax:    (XXX) XXX-XXXX

Email: user-57e71316b8e0@xymon.invalid <mailto:user-57e71316b8e0@xymon.invalid> 

www.TheZenith.com <http://www.TheZenith.com>; 

 
***********************************************************
NOTICE:
This e-mail, including attachments, contains information
that may be confidential, protected by the attorney/client
or other privileges, or exempt from disclosure under
applicable law.  Further, this e-mail may contain
information that is proprietary and/or constitutes a trade
secret.  This e-mail, including attachments, constitutes 
non-public information intended to be conveyed only to the
designated recipient of this communication, please be
advised that any disclosure, dissemination, distribution,
copying, or other use of this communication or any attached
document is strictly prohibited.  If you have received this
communication in error, please notify the sender
immediately by reply e-mail and promptly destroy all
electronic and printed copies of this communication and
attached documents.

***********************************************************
list Vernon Everett · Thu, 22 Dec 2011 00:00:31 +0800 ·
 "Historically speaking, the presence of *wheels* in Unix has never
precluded their reinvention." - *Larry Wall*

This feature exists already.
Look for GROUP= in the alerts.cfg man page.

Regards
    Vernon
quoted from Jody McKinzie

On 21 December 2011 21:58, McKinzie, Jody <user-57e71316b8e0@xymon.invalid> wrote:
Hello,****

** **

I am working on a script to configure alerts to notify different groups
when a specific filesystem gets too full.****

** **

For example, if mount point a gets 100% full notify group b****

** **

If mount point b gets to be 100%, notify group b.****

** **

Here is what I have so far.  But, I cannot seem to get the output to
produce the  output for these variables.****

** **

$PERCENTUSED****

$PERCENTALERT****

** **

Also, how do I test via the command line?****

** **

Thanks in advance.****

** **

#!/bin/sh****

single() {****

while [ ! "$1" = "" ]****

do****

   while [ ! "$1" = "&red" ]****

   do****

      shift****

      if [ "$1" = "" ]****

      then****

         exit****

      fi****

   done****

   shift****

#&red /mnt/testA (100% used) has reached the PANIC level (99%)****

   MOUNTPOINT=$1****

   PERCENTUSED=`cat $2 |cut -d"(" -f2`****

   PERCENTALERT=`cat $9 |cut -d"(" -f2 |cut -d")" -f1`****

   echo $MOUNTPOINT****

   echo $PERCENTUSED****

   echo $PERCENTALERT****

   lookup $1****

   echo $1 $2 $3 $4 $5 $6 $7 $8 $9****

   shift****

   shift****

   shift****

   shift****

   shift****

   shift****

   shift****

   shift****

   shift****

done****

}****

lookup() {****

   MAILTOADDRESS=`grep $1 /usr/local/bin/bb/diskalerts/* |cut -d" " -f3`**
**

   echo $BBHOSTNAME Disk Alert for $MOUNTPOINT reporting $PERCENTUSED of
$PERCENTALERT Limit >>/var/tmp/diskalert.$$****

   echo To acknowledge use code $ACKCODE at >>/var/tmp/diskalert.$$****

   echo $ACKCODE >/var/tmp/ACKCODE****

   echo http://bigbrother.zic.pri/xymon-seccgi/bb-ack-enhanced.sh>>/var/tmp/diskalert.$$
quoted from Jody McKinzie
****

   echo >>/var/tmp/diskalert.$$****

   cat /var/tmp/diskalert.$$ |mailx -s "Hobbit [$ACKCODE] ${BBHOSTNAME}
disk CRITICAL ($BBCOLORLEVEL)" $MAILTOADDRESS****

#   rm /var/tmp/diskalert.$$****

}****

single $BBALPHAMSG****

** **

------------------------------****

Regards,****

** **

*Jody R. McKinzie*

Sr. UNIX Administrator****

Zenith Insurance Company****

Desk: (XXX) XXX-XXXX****

Cell:    (XXX) XXX-XXXX****

Fax:    (XXX) XXX-XXXX****

Email: user-57e71316b8e0@xymon.invalid****

www.TheZenith.com****
quoted from Jody McKinzie

** **

***********************************************************
NOTICE:
This e-mail, including attachments, contains information
that may be confidential, protected by the attorney/client
or other privileges, or exempt from disclosure under
applicable law.  Further, this e-mail may contain
information that is proprietary and/or constitutes a trade
secret.  This e-mail, including attachments, constitutes
non-public information intended to be conveyed only to the
designated recipient of this communication, please be
advised that any disclosure, dissemination, distribution,
copying, or other use of this communication or any attached
document is strictly prohibited.  If you have received this
communication in error, please notify the sender
immediately by reply e-mail and promptly destroy all
electronic and printed copies of this communication and
attached documents.

***********************************************************

-- 

"While it is futile to try to eliminate risk, and questionable to try to
minimize it, it is essential that the risks taken be the right risks. "
- Peter F. Drucker
list Asif Iqbal · Wed, 21 Dec 2011 11:02:29 -0500 ·
quoted from Vernon Everett
On Wed, Dec 21, 2011 at 8:58 AM, McKinzie, Jody <user-57e71316b8e0@xymon.invalid> wrote:
Hello,


I am working on a script to configure alerts to notify different groups when
a specific filesystem gets too full.


For example, if mount point a gets 100% full notify group b


If mount point b gets to be 100%, notify group b.


Here is what I have so far.  But, I cannot seem to get the output to produce
the  output for these variables.


$PERCENTUSED

$PERCENTALERT


Also, how do I test via the command line?


Thanks in advance.


#!/bin/sh

single() {

while [ ! "$1" = "" ]

do

   while [ ! "$1" = "&red" ]

   do

      shift

      if [ "$1" = "" ]

      then

         exit

      fi

   done

   shift

#&red /mnt/testA (100% used) has reached the PANIC level (99%)

   MOUNTPOINT=$1

   PERCENTUSED=`cat $2 |cut -d"(" -f2`

   PERCENTALERT=`cat $9 |cut -d"(" -f2 |cut -d")" -f1`

   echo $MOUNTPOINT

   echo $PERCENTUSED

   echo $PERCENTALERT

   lookup $1

   echo $1 $2 $3 $4 $5 $6 $7 $8 $9

   shift

   shift

   shift

   shift

   shift

   shift

   shift

   shift

   shift

done

}

lookup() {

   MAILTOADDRESS=`grep $1 /usr/local/bin/bb/diskalerts/* |cut -d" " -f3`

   echo $BBHOSTNAME Disk Alert for $MOUNTPOINT reporting $PERCENTUSED of
$PERCENTALERT Limit >>/var/tmp/diskalert.$$

   echo To acknowledge use code $ACKCODE at >>/var/tmp/diskalert.$$

   echo $ACKCODE >/var/tmp/ACKCODE

   echo http://bigbrother.zic.pri/xymon-seccgi/bb-ack-enhanced.sh
/var/tmp/diskalert.$$
   echo >>/var/tmp/diskalert.$$

   cat /var/tmp/diskalert.$$ |mailx -s "Hobbit [$ACKCODE] ${BBHOSTNAME} disk
CRITICAL ($BBCOLORLEVEL)" $MAILTOADDRESS

#   rm /var/tmp/diskalert.$$

}

single $BBALPHAMSG
OR you could use hobbit's group tag to achieve that.


analysis.cfg
=========
HOST=myhost
DISK /a 85 90 GROUP=A
DISK /b 85 90 GROUP=B


alerts.cfg
=======
GROUP=A COLOR=red
   MAIL user-86591a3a9585@xymon.invalid
GROUP=B COLOR=red
   MAIL user-334202517cb1@xymon.invalid
quoted from Vernon Everett
Regards,


Jody R. McKinzie

Sr. UNIX Administrator

Zenith Insurance Company

Desk: (XXX) XXX-XXXX

Cell:    (XXX) XXX-XXXX

Fax:    (XXX) XXX-XXXX

Email: user-57e71316b8e0@xymon.invalid

www.TheZenith.com


***********************************************************
NOTICE:
This e-mail, including attachments, contains information
that may be confidential, protected by the attorney/client
or other privileges, or exempt from disclosure under
applicable law.  Further, this e-mail may contain
information that is proprietary and/or constitutes a trade
secret.  This e-mail, including attachments, constitutes
non-public information intended to be conveyed only to the
designated recipient of this communication, please be
advised that any disclosure, dissemination, distribution,
copying, or other use of this communication or any attached
document is strictly prohibited.  If you have received this
communication in error, please notify the sender
immediately by reply e-mail and promptly destroy all
electronic and printed copies of this communication and
attached documents.

***********************************************************

-- 

Asif Iqbal
PGP Key: 0xE62693C5 KeyServer: pgp.mit.edu
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?