<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:p="urn:schemas-microsoft-com:office:powerpoint" xmlns:a="urn:schemas-microsoft-com:office:access" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema" xmlns:b="urn:schemas-microsoft-com:office:publisher" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:c="urn:schemas-microsoft-com:office:component:spreadsheet" xmlns:odc="urn:schemas-microsoft-com:office:odc" xmlns:oa="urn:schemas-microsoft-com:office:activation" xmlns:html="http://www.w3.org/TR/REC-html40" xmlns:q="http://schemas.xmlsoap.org/soap/envelope/" xmlns:rtc="http://microsoft.com/officenet/conferencing" xmlns:D="DAV:" xmlns:Repl="http://schemas.microsoft.com/repl/" xmlns:mt="http://schemas.microsoft.com/sharepoint/soap/meetings/" xmlns:x2="http://schemas.microsoft.com/office/excel/2003/xml" xmlns:ppda="http://www.passport.com/NameSpace.xsd" xmlns:ois="http://schemas.microsoft.com/sharepoint/soap/ois/" xmlns:dir="http://schemas.microsoft.com/sharepoint/soap/directory/" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:dsp="http://schemas.microsoft.com/sharepoint/dsp" xmlns:udc="http://schemas.microsoft.com/data/udc" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:sub="http://schemas.microsoft.com/sharepoint/soap/2002/1/alerts/" xmlns:ec="http://www.w3.org/2001/04/xmlenc#" xmlns:sp="http://schemas.microsoft.com/sharepoint/" xmlns:sps="http://schemas.microsoft.com/sharepoint/soap/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:udcs="http://schemas.microsoft.com/data/udc/soap" xmlns:udcxf="http://schemas.microsoft.com/data/udc/xmlfile" xmlns:udcp2p="http://schemas.microsoft.com/data/udc/parttopart" xmlns:wf="http://schemas.microsoft.com/sharepoint/soap/workflow/" xmlns:dsss="http://schemas.microsoft.com/office/2006/digsig-setup" xmlns:dssi="http://schemas.microsoft.com/office/2006/digsig" xmlns:mdssi="http://schemas.openxmlformats.org/package/2006/digital-signature" xmlns:mver="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns:mrels="http://schemas.openxmlformats.org/package/2006/relationships" xmlns:spwp="http://microsoft.com/sharepoint/webpartpages" xmlns:ex12t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:ex12m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:pptsl="http://schemas.microsoft.com/sharepoint/soap/SlideLibrary/" xmlns:spsl="http://microsoft.com/webservices/SharePointPortalServer/PublishedLinksService" xmlns:Z="urn:schemas-microsoft-com:" xmlns:st="" xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:"Arial Bold";
        panose-1:2 11 7 4 2 2 2 2 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page Section1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.Section1
        {page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1" />
 </o:shapelayout></xml><![endif]-->
</head>

<body lang=EN-GB link=blue vlink=purple>

<div class=Section1>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>It's done: <a
href="http://xymonton.trantor.org/doku.php/monitors:smf.sh">http://xymonton.trantor.org/doku.php/monitors:smf.sh</a><o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>I hope I got the syntax right, it all looks good to me.<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>|\/|<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-family:"Arial","sans-serif";color:black'>-- 
<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-family:"Arial","sans-serif";color:black'>Martin
Ward<o:p></o:p></span></p>

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

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>

<p class=MsoNormal><span lang=IT style='font-size:10.0pt;font-family:"Arial","sans-serif";
color:black'>DDI:+44 (0) 20 7863 5218 / Fax: +44 (0)20 7863 9999 /  <a
href="http://www.colt.net/"><span style='color:black'>www.colt.net</span></a><o:p></o:p></span></p>

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

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>

<p class=MsoNormal><span style='font-size:7.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Help reduce your carbon footprint | Think before you print.
Registered in England and Wales, registered number 02452736, VAT number GB 645
4205 50<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>

<div style='border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt'>

<div>

<div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm'>

<p class=MsoNormal><b><span lang=EN-US style='font-size:10.0pt;font-family:
"Tahoma","sans-serif"'>From:</span></b><span lang=EN-US style='font-size:10.0pt;
font-family:"Tahoma","sans-serif"'> Vernon Everett
[mailto:everett.vernon@gmail.com] <br>
<b>Sent:</b> 29 July 2010 01:49<br>
<b>To:</b> xymon@xymon.com<br>
<b>Subject:</b> Re: [xymon] Feature? svcs<o:p></o:p></span></p>

</div>

</div>

<p class=MsoNormal><o:p> </o:p></p>

<p class=MsoNormal style='margin-bottom:12.0pt'>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">http://xymonton.trantor.org/doku.php/monitors</a><br>
<br>
Cheers<br>
    Vernon<br>
<br>
<br>
<o:p></o:p></p>

<div>

<p class=MsoNormal>On Wed, Jul 28, 2010 at 4:30 PM, Ward, Martin <<a
href="mailto:Martin.Ward@colt.net">Martin.Ward@colt.net</a>> wrote:<o:p></o:p></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">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<o:p></o:p></p>

<div>

<div>

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

</div>

</div>

</div>

<p class=MsoNormal><o:p> </o:p></p>

</div>

</div>

</body>

</html>