Xymon Mailing List Archive search

ext script does not show up at webpage

4 messages in this thread

list Simon Højberg Jespersen · Tue, 13 May 2014 13:25:53 +0200 ·
Hi xymon list
This is my first post, and it is about a custom script on a sun solaris client.

I have a script placed at
/home/bb/client/ext/monitorfs_xymon.sh on the client


It is doing some disk check and end up with this command
$xymon $XYMSRV "status $MACHINE.$COLUMN $COLOR `date` ${MSG}"

When I echo this command line to a file for debug
The full commandline looks lige this

/home/bb/bin/xymon "10.83.82.9 status aarapp144.available storage green Tuesday, 13 May 2014 13:10:20 CEST Looking good"

When I try to run it from commandline the output is

Xymon version 4.3.17
Usage: /home/bb/bin/xymon [--debug] [--merge] [--proxy=http://ip.of.the.proxy:port/] RECIPIENT DATA
  RECIPIENT: IP-address, hostname or URL
  DATA: Message to send, or "-" to read from stdin

Can anybody help me to figure what is wrong , I think i followed to description in tips & tricks.
Another question, can I use the cfg script to source my own variable to use in scripts ?

Regards Simon
PS..
/* the whole script */

#!/usr/bin/bash
FILESYSTEMS=/,/export,/local
IFS=","
MACHINE=`hostname`
COLUMN="available storage"
COLOR=green
MSG="Looking good"
TRESHOLDUSEDGB=50
TRESHOLDMAXPROCENTUSED=100
TRESHOLDAVAILGB=10
        function teratogb {
        tb=$1
                echo $((GB*1024))

        }
        function kbtogb {
                kb=$1
                #echo $1
                echo $((kb/1024*1024))
        }

        function measurement {
                in=$1
                len=${#in}
                tp=${in:len -1:1}
                        if [ "$tp" == "K" ]
                                then
                                        in=${in:0:len -1}

                                        kbtogb $in
                        fi
                        if [ "$tp" == "T" ]
                                then
                                        echo "$1 :call teratogb with"
                                        echo ${in:0:len -1}

                        fi
                        if [ "$tp" == "G" ]  || [ "$tp" == "%" ]
                                then
                                        value=${in:0:len -1}
                                        x=0
                                        returnvalue=""
                                while [ $x -lt $len  ]
                                do
                                        ch=${value:$x:1}
                                        if [ "$ch" == "." ]
                                        then
                                                break
                                        else
                                                returnvalue=$returnvalue$ch
                                        fi
                                        x=$((x + 1))

                                done
                                        echo $returnvalue
                        fi
        }
        for i in ${FILESYSTEMS};do
                lfil=`df -h  $i | tail -1` >> /dev/null

                usedgb=`echo $lfil | awk ' { print $3 } '` >> /dev/null
                usedgb=`measurement $usedgb` >> /dev/null
                                        if [ $usedgb -ge  $TRESHOLDUSEDGB ]
                                then
                                        COLOR="red"
                                        MSG="Treshold used space  on $i exceeded the limit set on $TRESHOLDUSEDGB gb "
                        fi

                availgb=`echo $lfil | awk ' { print $4 } '` >> /dev/null
                availgb=`measurement $availgb`
                       if [ $availgb -le $TRESHOLDAVAILGB ]
                                then
                                        COLOR=red
                                        MSG="Treshold available diskspace on $i exceeded the limit set on at least $TRESHOLDAVAILGB gb "
                        fi
                procentused=`echo $lfil | awk ' { print $5 } '` >> /dev/null
                procent=`measurement $procentused` >> /dev/null

                        if [ $procent -ge $TRESHOLDMAXPROCENTUSED ]
                                then
                                COLOR=red
                                       MSG="treSHOLD ON MAXIMUM USED DISKSPACE IN PROCENT ON $I EXCEEDED THE LIMIT SET TO $trESHOLDMAXPROCENTUSED"

                        fi
        done

echo "$XYMON $XYMSRV status $MACHINE.$COLUMN $COLOR `date` ${MSG}" >> /tmp/du_i_run.log
$XYMON $XYMSRV "status $MACHINE.$COLUMN $COLOR `date` ${MSG}"
exit 0
list Torsten Richter · Tue, 13 May 2014 14:53:59 +0200 ·
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

it is not possible to have a column name that consists of more than 1 word.
I think if you change "available storage" to "available_storage" then
your test should appear.

HTH
Torsten
quoted from Simon Højberg Jespersen

On 13.05.2014 13:25, Simon Højberg Jespersen wrote:
Hi xymon list
This is my first post, and it is about a custom script on a sun solaris client.

I have a script placed at
/home/bb/client/ext/monitorfs_xymon.sh on the client


It is doing some disk check and end up with this command
$xymon $XYMSRV "status $MACHINE.$COLUMN $COLOR `date` ${MSG}"

When I echo this command line to a file for debug
The full commandline looks lige this

/home/bb/bin/xymon "10.83.82.9 status aarapp144.available storage green Tuesday, 13 May 2014 13:10:20 CEST Looking good"

When I try to run it from commandline the output is

Xymon version 4.3.17
Usage: /home/bb/bin/xymon [--debug] [--merge] [--proxy=http://ip.of.the.proxy:port/] RECIPIENT DATA
  RECIPIENT: IP-address, hostname or URL
  DATA: Message to send, or "-" to read from stdin

Can anybody help me to figure what is wrong , I think i followed to description in tips & tricks.
Another question, can I use the cfg script to source my own variable to use in scripts ?

Regards Simon
PS..
/* the whole script */

#!/usr/bin/bash
FILESYSTEMS=/,/export,/local
IFS=","
MACHINE=`hostname`
COLUMN="available storage"
COLOR=green
MSG="Looking good"
TRESHOLDUSEDGB=50
TRESHOLDMAXPROCENTUSED=100
TRESHOLDAVAILGB=10
        function teratogb {
        tb=$1
                echo $((GB*1024))

        }
        function kbtogb {
                kb=$1
                #echo $1
                echo $((kb/1024*1024))
        }

        function measurement {
                in=$1
                len=${#in}
                tp=${in:len -1:1}
                        if [ "$tp" == "K" ]
                                then
                                        in=${in:0:len -1}

                                        kbtogb $in
                        fi
                        if [ "$tp" == "T" ]
                                then
                                        echo "$1 :call teratogb with"
                                        echo ${in:0:len -1}

                        fi
                        if [ "$tp" == "G" ]  || [ "$tp" == "%" ]
                                then
                                        value=${in:0:len -1}
                                        x=0
                                        returnvalue=""
                                while [ $x -lt $len  ]
                                do
                                        ch=${value:$x:1}
                                        if [ "$ch" == "." ]
                                        then
                                                break
                                        else
                                                returnvalue=$returnvalue$ch
                                        fi
                                        x=$((x + 1))

                                done
                                        echo $returnvalue
                        fi
        }
        for i in ${FILESYSTEMS};do
                lfil=`df -h  $i | tail -1` >> /dev/null

                usedgb=`echo $lfil | awk ' { print $3 } '` >> /dev/null
                usedgb=`measurement $usedgb` >> /dev/null
                                        if [ $usedgb -ge  $TRESHOLDUSEDGB ]
                                then
                                        COLOR="red"
                                        MSG="Treshold used space  on $i exceeded the limit set on $TRESHOLDUSEDGB gb "
                        fi

                availgb=`echo $lfil | awk ' { print $4 } '` >> /dev/null
                availgb=`measurement $availgb`
                       if [ $availgb -le $TRESHOLDAVAILGB ]
                                then
                                        COLOR=red
                                        MSG="Treshold available diskspace on $i exceeded the limit set on at least $TRESHOLDAVAILGB gb "
                        fi
                procentused=`echo $lfil | awk ' { print $5 } '` >> /dev/null
                procent=`measurement $procentused` >> /dev/null

                        if [ $procent -ge $TRESHOLDMAXPROCENTUSED ]
                                then
                                COLOR=red
                                       MSG="treSHOLD ON MAXIMUM USED DISKSPACE IN PROCENT ON $I EXCEEDED THE LIMIT SET TO $trESHOLDMAXPROCENTUSED"

                        fi
        done

echo "$XYMON $XYMSRV status $MACHINE.$COLUMN $COLOR `date` ${MSG}" >> /tmp/du_i_run.log
$XYMON $XYMSRV "status $MACHINE.$COLUMN $COLOR `date` ${MSG}"
exit 0

- -- 
+---------------------------------------------------------+

| E-mail  : user-c862b499d9fa@xymon.invalid			  |
|							  |
| Homepage: http://www.richter-it.net/			  |
+---------------------------------------------------------+
Download my public key from:
http://gpg-keyserver.de/pks/lookup?search=0x899093AC&op=get
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)

iEYEARECAAYFAlNyFecACgkQ7DlmxomQk6zXhQCfaIbeoBbklmiCw24zyExI/F98
UMAAmwZDaWNMDATLVwBSlaGgmWsXs7sA
=4vdP
-----END PGP SIGNATURE-----
list Simon Højberg Jespersen · Wed, 14 May 2014 12:18:55 +0200 ·
Thank you!

That did it :-)
quoted from Torsten Richter


-----Oprindelig meddelelse-----
Fra: Torsten Richter [mailto:user-c862b499d9fa@xymon.invalid] 
Sendt: 13. maj 2014 14:54
Til: xymon at xymon.com
Emne: Re: [Xymon] ext script does not show up at webpage

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

it is not possible to have a column name that consists of more than 1 word.
I think if you change "available storage" to "available_storage" then
your test should appear.

HTH
Torsten

On 13.05.2014 13:25, Simon Højberg Jespersen wrote:
Hi xymon list
This is my first post, and it is about a custom script on a sun solaris client.

I have a script placed at
/home/bb/client/ext/monitorfs_xymon.sh on the client


It is doing some disk check and end up with this command
$xymon $XYMSRV "status $MACHINE.$COLUMN $COLOR `date` ${MSG}"

When I echo this command line to a file for debug
The full commandline looks lige this

/home/bb/bin/xymon "10.83.82.9 status aarapp144.available storage green Tuesday, 13 May 2014 13:10:20 CEST Looking good"

When I try to run it from commandline the output is

Xymon version 4.3.17
Usage: /home/bb/bin/xymon [--debug] [--merge] [--proxy=http://ip.of.the.proxy:port/] RECIPIENT DATA
  RECIPIENT: IP-address, hostname or URL
  DATA: Message to send, or "-" to read from stdin

Can anybody help me to figure what is wrong , I think i followed to description in tips & tricks.
Another question, can I use the cfg script to source my own variable to use in scripts ?

Regards Simon
PS..
/* the whole script */

#!/usr/bin/bash
FILESYSTEMS=/,/export,/local
IFS=","
MACHINE=`hostname`
COLUMN="available storage"
COLOR=green
MSG="Looking good"
TRESHOLDUSEDGB=50
TRESHOLDMAXPROCENTUSED=100
TRESHOLDAVAILGB=10
        function teratogb {
        tb=$1
                echo $((GB*1024))

        }
        function kbtogb {
                kb=$1
                #echo $1
                echo $((kb/1024*1024))
        }

        function measurement {
                in=$1
                len=${#in}
                tp=${in:len -1:1}
                        if [ "$tp" == "K" ]
                                then
                                        in=${in:0:len -1}

                                        kbtogb $in
                        fi
                        if [ "$tp" == "T" ]
                                then
                                        echo "$1 :call teratogb with"
                                        echo ${in:0:len -1}

                        fi
                        if [ "$tp" == "G" ]  || [ "$tp" == "%" ]
                                then
                                        value=${in:0:len -1}
                                        x=0
                                        returnvalue=""
                                while [ $x -lt $len  ]
                                do
                                        ch=${value:$x:1}
                                        if [ "$ch" == "." ]
                                        then
                                                break
                                        else
                                                returnvalue=$returnvalue$ch
                                        fi
                                        x=$((x + 1))

                                done
                                        echo $returnvalue
                        fi
        }
        for i in ${FILESYSTEMS};do
                lfil=`df -h  $i | tail -1` >> /dev/null

                usedgb=`echo $lfil | awk ' { print $3 } '` >> /dev/null
                usedgb=`measurement $usedgb` >> /dev/null
                                        if [ $usedgb -ge  $TRESHOLDUSEDGB ]
                                then
                                        COLOR="red"
                                        MSG="Treshold used space  on $i exceeded the limit set on $TRESHOLDUSEDGB gb "
                        fi

                availgb=`echo $lfil | awk ' { print $4 } '` >> /dev/null
                availgb=`measurement $availgb`
                       if [ $availgb -le $TRESHOLDAVAILGB ]
                                then
                                        COLOR=red
                                        MSG="Treshold available diskspace on $i exceeded the limit set on at least $TRESHOLDAVAILGB gb "
                        fi
                procentused=`echo $lfil | awk ' { print $5 } '` >> /dev/null
                procent=`measurement $procentused` >> /dev/null

                        if [ $procent -ge $TRESHOLDMAXPROCENTUSED ]
                                then
                                COLOR=red
                                       MSG="treSHOLD ON MAXIMUM USED DISKSPACE IN PROCENT ON $I EXCEEDED THE LIMIT SET TO $trESHOLDMAXPROCENTUSED"

                        fi
        done

echo "$XYMON $XYMSRV status $MACHINE.$COLUMN $COLOR `date` ${MSG}" >> /tmp/du_i_run.log
$XYMON $XYMSRV "status $MACHINE.$COLUMN $COLOR `date` ${MSG}"
exit 0

- -- 
+---------------------------------------------------------+
| E-mail  : user-c862b499d9fa@xymon.invalid			  |
|							  |
| Homepage: http://www.richter-it.net/			  |
+---------------------------------------------------------+
Download my public key from:
http://gpg-keyserver.de/pks/lookup?search=0x899093AC&op=get
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)

iEYEARECAAYFAlNyFecACgkQ7DlmxomQk6zXhQCfaIbeoBbklmiCw24zyExI/F98
UMAAmwZDaWNMDATLVwBSlaGgmWsXs7sA
=4vdP
-----END PGP SIGNATURE-----
list Steff Watkins · Wed, 14 May 2014 11:19:39 +0000 ·
Message: 1
quoted from Simon Højberg Jespersen
Date: Tue, 13 May 2014 13:25:53 +0200
From: Simon H?jberg Jespersen <user-4687e7996cc1@xymon.invalid>
Subject: [Xymon] ext script does not show up at webpage
I have a script placed at
/home/bb/client/ext/monitorfs_xymon.sh on the client

It is doing some disk check and end up with this command $xymon $XYMSRV "status $MACHINE.$COLUMN $COLOR `date` ${MSG}"
/home/bb/bin/xymon "10.83.82.9 status aarapp144.available storage green Tuesday, 13 May 2014 13:10:20 CEST Looking good"
Hello Simon,

 If you look at the line you are expecting to get from the script and the line you are actually getting from the script you will see that they are different in format. The line you have given as output from the script includes the $XYMSRV within the double-quoted content section that is meant to be passed on the the xymon binary rather than passed as the first, separate option stating the recipient host.

As such, the xymon binary is being called and given its first parameter as a complex string containing pjrases such as 'status' and 'thursday', rather than being given the IP details of the system that it is meant to be forwarding the message onto. This shows up in the output you get on commandline (as follows):
quoted from Simon Højberg Jespersen
When I try to run it from commandline the output is

Xymon version 4.3.17
Usage: /home/bb/bin/xymon [--debug] [--merge] [--
proxy=http://ip.of.the.proxy:port/] RECIPIENT DATA
  RECIPIENT: IP-address, hostname or URL
  DATA: Message to send, or "-" to read from stdin
The xymon binary is running and then saying "I don't know what it is you have just sent to me but it isn't a host's IP details!"

Looking at the script you supplied I can see the following line:
 
 echo "$XYMON $XYMSRV status $MACHINE.$COLUMN $COLOR `date` ${MSG}" >> /tmp/du_i_run.log $XYMON $XYMSRV "status $MACHINE.$COLUMN $COLOR `date` ${MSG}"
 
 Is it meant to be a run-on line like this with the call to $XYMON after the /tmp/du_i_run.log? If so I doubt that the script would get beyond the echo call to du_i_run.log . The rest of the line would not be interpreted as a command/action but as spare operands on the line. So, you would need to actually split that line into two lines, between du_i_run.log and $XYMON, to make that one line back into two separate lines.

The echo command will still run but now you will have an executable commandline, starting $XYMON, would would successfully forward your output to $XYMSRV.

Give those a try.

Regards,
Steff Watkins
Steff Watkins                           Natural History Museum, Cromwell Road, London,SW75BD 
Systems programmer                      Email: user-03bd19bb3c11@xymon.invalid 
Systems Team                            Phone: +XX (X)XX XXXX XXXX opt 2
========
"Many were increasingly of the opinion that they'd all made a big mistake in coming down from the trees in the first place. And some said that even the trees had been a bad move, and that no one should ever have left the oceans." - HHGTTG