Solaris 10 SMF monitor [was RE: Ext script to monitor Solaris 10 services]

Ward, Martin Martin.Ward at colt.net
Tue Feb 19 13:36:28 CET 2008


This originally came about because I have a need to monitor a TFTP server. This uses UDP rather than TCP so unless I write a very specific script to transfer an existing file, monitoring the UDP server remotely is going to be difficult.

However, if I monitor the TFTP service on the box itself it is much easier. I could simply do "ps -ef|grep tftpd | grep -v grep | wc -l" and if there is < 1 line then it's not running, but I thought it would be nicer to come up with a more generic script that actually monitors the SMF services. To my mind you ought to be able to specify which services you want monitored and have them all checked at once.

In this manner I can check the TFTP daemon (which uses UDP), the syslog daemon (which is only accessible from the server) and anything that isn't TCP-enabled.

As Ulric Eriksson has also pointed out, it is simple to parse the output from svcs -a, I was just trying not to reinvent the wheel.

So, having scripted around a couple of issues with sh(1) I have written the following. You are welcome to comment on it or suggest improvements.

Find below bb-smf.sh
----
#!/bin/sh

# A Hobbit script to examine specific Solaris 10 services.

# Author: Martin Ward 19 Feb 2008.
# Version: 1.0 - Initial version.

# SVCS is a list of services to examine the status of. Each name must be
# enough to make it unique in the svcs list. Separate each service with
# a | so that we can use ${EGREP} to search for them.
SVCS='svc:/network/ssh:default|svc:/site/tftpd:default'

# The name of the column in Hobbit
COLUMN=smf

# COLOUR defaults to green
COLOUR=GREEN

# When you modify a variable inside a while loop its value is local to that
# loop. This means that when you reach the end of the loop the variable will
# be the same value that it was before the loop was entered. For this reason
# we have to store the services and colour in temporary files.
SVCFILE=/tmp/svcs.$$
COLOURFILE=/tmp/svcs.colour.$$

# Get the svcs header line first
MSGH=`svcs -a | head -1`

# Scan through the svcs -a list. Use -a to ensure we get everything.
svcs -a | ${EGREP} "${SVCS}" > $SVCFILE

cat $SVCFILE | while read SVC
do
        STATE=`echo ${SVC} | ${AWK} '{print $1}'`

        case "${STATE}" in
'uninitialized'|'offline'|'degraded')
                if [ "${COLOUR}" != "RED" ]
                then
                        COLOUR="YELLOW"
                fi
                ;;
'maintenance'|'disabled')
                COLOUR="RED"
                ;;
        esac
        echo ${COLOUR} > $COLOURFILE
done

COLOUR=`cat ${COLOURFILE}`

# Tell Hobbit about it
$BB $BBDISP "status $MACHINE.$COLUMN $COLOUR `date`

${MSGH}
`cat ${SVCFILE}`
"

rm -f ${SVCFILE} ${COLOURFILE}

exit 0
----
|\/|artin
-- 



> -----Original Message-----
> From: pkc_mls [mailto:pkc_mls at yahoo.fr] 
> Sent: 19 February 2008 09:44
> To: hobbit at hswn.dk
> Subject: Re: [hobbit] Ext script to monitor Solaris 10 services
> 
> 
> Ward, Martin a écrit :
> >
> > Hi all,
> >
> > I need a Hobbit ext script to monitor Solaris 10 services 
> and a quick
> > search of the 'net reveals that there was a discussion about such a 
> > beast in this very mailing list. Did anything come of it? Does this 
> > script exist or should I go and try and write it myself?
> >
> you can check some network services from the server.
> for the process, perhaps have a look at the procs settings in 
> the client. if that doesn't answer the question, could you 
> please explain a little 
> bit more what you mean by services ?
> >
> > |\/|artin
> > --
> > Martin Ward
> > *Network Systems Operations Specialist*
> > DDI:    +44 (0) 20 7863 5218
> > Fax:    +44 (0) 20 7863 5610
> > Mob:    +44 (0) 7971 97 77 21
> > _www.colt.net_ <file://www.colt.net>
> >
> > Data | Voice | Managed Services
> >
> > Help reduce your carbon footprint | Think before you print
> >
> > COLT Telecommunications, Beaufort House, 15 St Botolph 
> Street, London,
> > EC3A 7QN UK
> > Registered in England and Wales, registered number 02452736, VAT 
> > number GB 645 4205 50
> >
> >
> >
> > 
> **********************************************************************
> > ***************
> > The message is intended for the named addressee only and may not be 
> > disclosed to or used by anyone else, nor may it be copied 
> in any way.
> >
> > The contents of this message and its attachments are 
> confidential and
> > may also be subject to legal privilege. If you are not the named 
> > addressee and/or have received this message in error, 
> please advise us 
> > by e-mailing security at colt.net and delete the message and any 
> > attachments without retaining any copies.
> >
> > Internet communications are not secure and COLT does not accept
> > responsibility for this message, its contents nor 
> responsibility for 
> > any viruses.
> >
> > No contracts can be created or varied on behalf of COLT
> > Telecommunications, its subsidiaries or affiliates ("COLT") and any 
> > other party by email Communications unless expressly agreed 
> in writing 
> > with such other party.
> >
> > Please note that incoming emails will be automatically scanned to
> > eliminate potential viruses and unsolicited promotional emails. For 
> > more information refer to www.colt.net or contact us on 
> +44(0)20 7390 
> > 3900.
> > 
> --------------------------------------------------------------
> ----------
> >
> > To unsubscribe from the hobbit list, send an e-mail to 
> > hobbit-unsubscribe at hswn.dk
> >   
> 
> 
> To unsubscribe from the hobbit list, send an e-mail to 
> hobbit-unsubscribe at hswn.dk
> 
> 
> 


*************************************************************************************
The message is intended for the named addressee only and may not be disclosed to or used by anyone else, nor may it be copied in any way. 

The contents of this message and its attachments are confidential and may also be subject to legal privilege.  If you are not the named addressee and/or have received this message in error, please advise us by e-mailing security at colt.net and delete the message and any attachments without retaining any copies. 

Internet communications are not secure and COLT does not accept responsibility for this message, its contents nor responsibility for any viruses. 

No contracts can be created or varied on behalf of COLT Telecommunications, its subsidiaries or affiliates ("COLT") and any other party by email Communications unless expressly agreed in writing with such other party.  

Please note that incoming emails will be automatically scanned to eliminate potential viruses and unsolicited promotional emails. For more information refer to www.colt.net or contact us on +44(0)20 7390 3900.




More information about the Xymon mailing list