Hi Martin<br><br>Gave it a try this arvo, and it looks good.<br>Then came the comments from my colleagues.<br>The comments were all good, but they wanted more. (Don't they always)<br><br>One of the features what the ability to monitor a service to ensure it was disabled, and go red if it was enabled.<br>
<br>So, I started adding some features to your code. I thought I would do a put-back as version 2.0<br>But it's slowly becoming very different.<br>Besides the feature above, it takes one service per line in client-local.cfg and it's in ksh now. (I just prefer ksh over sh)<br>
<br>Once it's done, I will put it onto Xymonton as smf2 or something similar.<br>It's going to be different enough to warrant a new name.<br><br>Cheers<br>    Vernon<br><br><br><br><br><div class="gmail_quote">On Thu, Jul 29, 2010 at 7:50 PM, Vernon Everett <span dir="ltr"><<a href="mailto:everett.vernon@gmail.com">everett.vernon@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">Looks good.<br>I will try it on our systems tomorrow, when I get back to the office.<br><br>
Thanks.<br><br>Regards<br><font color="#888888">    Vernon</font><div><div></div><div class="h5"><br><br><br><div class="gmail_quote">On Thu, Jul 29, 2010 at 6:49 PM, Ward, Martin <span dir="ltr"><<a href="mailto:Martin.Ward@colt.net" target="_blank">Martin.Ward@colt.net</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">








<div link="blue" vlink="purple" lang="EN-GB">

<div>

<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);">It's done: <a href="http://xymonton.trantor.org/doku.php/monitors:smf.sh" target="_blank">http://xymonton.trantor.org/doku.php/monitors:smf.sh</a></span></p>



<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);"> </span></p>

<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);">I hope I got the syntax right, it all looks good to me.</span></p>

<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);"> </span></p>

<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);">|\/|</span></p>

<p class="MsoNormal"><span style="color: black;">-- 
</span></p>

<p class="MsoNormal"><span style="color: black;">Martin
Ward</span></p>

<p class="MsoNormal"><b><span style="font-family: "Arial Bold"; color: black;">Manager,
Technical Services</span></b></p>

<p class="MsoNormal"><span style="font-size: 10pt; color: rgb(31, 73, 125);"> </span></p>

<p class="MsoNormal"><span style="font-size: 10pt; color: black;" lang="IT">DDI:+44 (0) 20 7863 5218 / Fax: +44 (0)20 7863 9999 /  <a href="http://www.colt.net/" target="_blank"><span style="color: black;">www.colt.net</span></a></span></p>



<p class="MsoNormal"><span style="font-size: 10pt; color: black;">Colt Technology Services, </span><span style="font-size: 10pt; color: black;">Unit 12, Powergate Business Park,
Volt Avenue, Park Royal, London, NW10 6PW,</span><span style="font-size: 10pt; color: black;"> UK.</span></p>

<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);"> </span></p>

<p class="MsoNormal"><span style="font-size: 7pt; color: rgb(31, 73, 125);">Help reduce your carbon footprint | Think before you print.
Registered in England and Wales, registered number 02452736, VAT number GB 645
4205 50</span></p>

<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);"> </span></p>

<div style="border-width: medium medium medium 1.5pt; border-style: none none none solid; border-color: -moz-use-text-color -moz-use-text-color -moz-use-text-color blue; padding: 0cm 0cm 0cm 4pt;">

<div>

<div style="border-width: 1pt medium medium; border-style: solid none none; border-color: rgb(181, 196, 223) -moz-use-text-color -moz-use-text-color; padding: 3pt 0cm 0cm;">

<p class="MsoNormal"><b><span style="font-size: 10pt;" lang="EN-US">From:</span></b><span style="font-size: 10pt;" lang="EN-US"> Vernon Everett
[mailto:<a href="mailto:everett.vernon@gmail.com" target="_blank">everett.vernon@gmail.com</a>] <br>
<b>Sent:</b> 29 July 2010 01:49<br>
<b>To:</b> <a href="mailto:xymon@xymon.com" target="_blank">xymon@xymon.com</a><br>
<b>Subject:</b> Re: [xymon] Feature? svcs</span></p>

</div>

</div><div><div></div><div>

<p class="MsoNormal"> </p>

<p class="MsoNormal" style="margin-bottom: 12pt;">Funny that. About a year ago I
discussed using that method with a colleague. <br>
We never got that far, and I forgot all about it.<br>
<br>
And excellent way to do it.<br>
<br>
Have you considered posting your script on Xymonton?<br>
Here <a href="http://xymonton.trantor.org/doku.php/monitors" target="_blank">http://xymonton.trantor.org/doku.php/monitors</a><br>
<br>
Cheers<br>
    Vernon<br>
<br>
<br>
</p>

<div>

<p class="MsoNormal">On Wed, Jul 28, 2010 at 4:30 PM, Ward, Martin <<a href="mailto:Martin.Ward@colt.net" target="_blank">Martin.Ward@colt.net</a>> wrote:</p>

<p class="MsoNormal">I have a script that is one step further than yours, the
main difference<br>
being that I have defined the services to be monitored in the<br>
client-local.cfg file as you want:<br>
<br>
In client-local.cfg for example:<br>
<br>
[nmc-dhcp1]<br>
log:/var/adm/messages:10240<br>
svc:/network/ssh:default|svc:/site/network/dhcpd:default<br>
<br>
Data from this file is sent to the client (in this case a server called<br>
nmc-dhcp1) and stored in $BBTMP/logfetch.$MACHINEDOTS.cfg, so in the<br>
client-side script I have:<br>
<br>
SVCS=`grep '^svc:' $BBTMP/logfetch.$MACHINEDOTS.cfg`<br>
<br>
I was being lazy so have separated the services with the | symbol in<br>
client-local.cfg, this means I can then use the following code with no<br>
pre-processing:<br>
<br>
svcs -a | ${EGREP} "${SVCS}" > $SVCFILE<br>
<br>
The reason I store the 'svcs -a' output is because I include it in the<br>
data sent back to Xymon.<br>
<br>
Service states are checked using the following code:<br>
<br>
cat $SVCFILE | while read SVC<br>
do<br>
       STATE=`echo ${SVC} | ${AWK} '{print $1}'`<br>
<br>
       case "${STATE}" in<br>
'uninitialized'|'offline'|'degraded')<br>
               if [
"${COLOUR}" != "RED" ]<br>
               then<br>
                     
 COLOUR="YELLOW"<br>
               fi<br>
               ;;<br>
'maintenance'|'disabled')<br>
               COLOUR="RED"<br>
               ;;<br>
       esac<br>
       echo ${COLOUR} > $COLOURFILE<br>
done<br>
<br>
COLOUR=`cat ${COLOURFILE}`<br>
<br>
To be honest I don't know why I am storing the colour in a file and then<br>
re-reading it outside the loop, the value shouldn't change at the end of<br>
the while loop. This script was thrown together so it's likely I<br>
intended to remove it but forgot.<br>
<br>
Anyway, after that loop I call $BB and pass it all the parameters.<br>
<br>
It doesn't have the options that you want, but it does allow for<br>
different return colours depending on the return state. I coded it to<br>
return RED if a service is in a disabled state since I want to monitor<br>
specific services rather than all of them.<br>
<br>
The final code is here:<br>
<br>
----<br>
#!/bin/sh<br>
<br>
# A Hobbit script to examine specific Solaris 10 services.<br>
<br>
# Author: Martin Ward 19 Feb 2008.<br>
# Version: 1.0 - Initial version.<br>
# V1.1  Script now takes the list of services to monitor from the server<br>
#       via the logfetch file.<br>
<br>
# SVCS is a list of services to examine the status of. Each name must be<br>
# specific enough to make it unique in the output from the 'svcs -a'<br>
command.<br>
# Separate each service with a | so that we can use ${EGREP} to search<br>
for them.<br>
# The services themselves are configured on the Hobbit server in the<br>
# ~hobbit/server/etc/client-local.cfg file. The line will look something<br>
like:<br>
# svc:/network/ssh:default|svc:/site/tftpd:default<br>
<br>
# Verify existence of the config file<br>
if [ ! -f $BBTMP/logfetch.$MACHINEDOTS.cfg ]<br>
then<br>
       echo "Unable to retrieve services
descriptions."<br>
       exit 1<br>
fi<br>
<br>
SVCS=`grep '^svc:' $BBTMP/logfetch.$MACHINEDOTS.cfg`<br>
<br>
# The name of the column in Hobbit<br>
COLUMN=smf<br>
<br>
# COLOUR defaults to green<br>
COLOUR=GREEN<br>
<br>
# When you modify a variable inside a while loop its value is local to<br>
that<br>
# loop. This means that when you reach the end of the loop the variable<br>
will<br>
# be the same value that it was before the loop was entered. For this<br>
reason<br>
# we have to store the services and colour in temporary files.<br>
SVCFILE=/tmp/svcs.$$<br>
COLOURFILE=/tmp/svcs.colour.$$<br>
<br>
# Set up the initial colour<br>
echo "WHITE" > $COLOURFILE<br>
<br>
# Get the svcs header line first<br>
MSGH=`svcs -a | head -1`<br>
<br>
# Scan through the svcs -a list. Use -a to ensure we get everything.<br>
svcs -a | ${EGREP} "${SVCS}" > $SVCFILE<br>
<br>
cat $SVCFILE | while read SVC<br>
do<br>
       STATE=`echo ${SVC} | ${AWK} '{print $1}'`<br>
<br>
       case "${STATE}" in<br>
'uninitialized'|'offline'|'degraded')<br>
               if [
"${COLOUR}" != "RED" ]<br>
               then<br>
                     
 COLOUR="YELLOW"<br>
               fi<br>
               ;;<br>
'maintenance'|'disabled')<br>
               COLOUR="RED"<br>
               ;;<br>
       esac<br>
       echo ${COLOUR} > $COLOURFILE<br>
done<br>
<br>
COLOUR=`cat ${COLOURFILE}`<br>
<br>
# Tell Hobbit about it<br>
$BB $BBDISP "status $MACHINE.$COLUMN $COLOUR `date`<br>
<br>
${MSGH}<br>
`cat ${SVCFILE}`<br>
"<br>
<br>
rm -f ${SVCFILE} ${COLOURFILE}<br>
<br>
exit 0<br>
----<br>
<br>
<br>
|\/|artin<br>
<br>
[Colt Disclaimer]<br>
The message is intended for the named addressee only and may not be disclosed<br>
to or used by anyone else, nor may it be copied in any way. The contents of<br>
this message and its attachments are confidential and may also be subject to<br>
legal privilege. If you are not the named addressee and/or have received this<br>
message in error, please advise us by e-mailing <a href="mailto:abuse@colt.net" target="_blank">abuse@colt.net</a>
and delete the<br>
message and any attachments without retaining any copies. Internet<br>
communications are not secure and Colt does not accept responsibility for this<br>
message, its contents nor responsibility for any viruses. No contracts can be<br>
created or varied on behalf of Colt Technology Services, its subsidiaries,<br>
group companies or affiliates ("Colt") and any other party by email<br>
communications unless expressly agreed in writing with such other party.<br>
Please note that incoming emails will be automatically scanned to eliminate<br>
potential viruses and unsolicited promotional emails. For more information<br>
refer to <a href="http://www.colt.net" target="_blank">www.colt.net</a> or
contact us on +44(0)20 7390 3900</p>

<div>

<div>

<p class="MsoNormal" style="margin-bottom: 12pt;"><br>
<br>
To unsubscribe from the xymon list, send an e-mail to<br>
<a href="mailto:xymon-unsubscribe@xymon.com" target="_blank">xymon-unsubscribe@xymon.com</a><br>
<br>
</p>

</div>

</div>

</div>

<p class="MsoNormal"> </p>

</div></div></div>

</div>

</div>


</blockquote></div><br>
</div></div></blockquote></div><br>