Very elegant.<br>And something new for me. I have never used the "bbcmd bbhostshow" command.<br>It's a much better way of getting the complete contents of all the bb-hosts with includes.<br>Every day is a schoolday. :-)<br>
<br>I would suggest one or two improvements though.<br>egrep '^[1-9][0-9]*\.' doesn't cater for my Wintel hosts which are defined with IP address 0.0.0.0<br>We let Xymon use DNS for them, so I dropped the first [1-9].<br>
<br><span style="font-family: courier new,monospace;">bb localhost "clientlog {} section=osversion"</span> only works for Wintel.<br>I changed it to the following<br><span style="font-family: courier new,monospace;">bb localhost "clientlog {} section=osversion,uname"</span><br>
This will grab the relevant info for Wintel as well as Solaris.<br><br>I then need to modify the output for Solaris, because the uname string includes the hostname.<br>I eventually ended up with this.<br><span style="font-family: courier new,monospace;">./server/bin/bbcmd bbhostshow | egrep '^[0-9]*\.' \<br>
                              | awk '{print $2}' \<br>                              | sort -u \<br>                              | xargs -I{} ./server/bin/bb localhost "clientlog {} section=osversion,uname" \<br>
                              | grep -v "^\[" \<br>                              | awk ' $1 == "SunOS" { print $1" "$3" "$4}; $1 != "SunOS" {print} ' \<br>                              | sort \<br>
                              | uniq -c</span><br><br>That last awk might need to be seriously adapted for other OS types, or perhaps pipe the output to another similar awk.<br>(Also, for SunOS, <span style="font-family: courier new,monospace;">$4</span> is the patch level. Hack that to <span style="font-family: courier new,monospace;">print $1" "$3</span> for OS version only)<br>
<br>I ended up with output that looked like this<br><span style="font-family: courier new,monospace;">  10 Microsoft  (build 7600)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">   2 Microsoft Windows Server 2003 R2, Standard Edition Service Pack 2 (build 3790)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">   6 Microsoft Windows Server 2008 , 64-bit Service Pack 2 (build 6002)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">   1 SunOS 5.10 Generic_139556-08</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">   4 SunOS 5.10 Generic_141444-09</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">  90 SunOS 5.10 Generic_142900-03</span><br>
Useful?<br>I have no idea.<br><br>And yes, I agree, temp files are bad. But unfortunately, a necessary evil sometimes.<br><br>Cheers<br>     Vernon<br><br><br><div class="gmail_quote">On Tue, Sep 21, 2010 at 3:07 PM, David Baldwin <span dir="ltr"><<a href="mailto:david.baldwin@ausport.gov.au">david.baldwin@ausport.gov.au</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">All you need is this 'one liner' for the count of each version:<br>
<br>
bbcmd bbhostshow | egrep '^[1-9][0-9]*\.' | awk '{print $2}' | sort -u |<br>
xargs -I{} bb localhost "clientlog {} section=osversion" | sort | uniq<br>
-c | egrep -v '^[[:space:]]*[0-9]+( \[osversion\]|[[:space:]]*$)'<br>
<br>
Look! No temporary files! (Pet hate of mine ;)<br>
<br>
David.<br>
<div class="im">> How does a wget call compare to using the bb command?<br>
><br>
> I replaced the wget with:<br>
>     $BBHOME/server/bin/bb localhost "clientlog $HOSTNAME<br>
> section=osversion" | grep -v osversion > $HOSTNAME<br>
><br>
> and the OSVER with:<br>
>    OSVER=$(sed -e :a -e 's/<[^>]*>//g;/</N;//ba' $HOSTNAME)<br>
><br>
><br>
><br>
> On Mon, Sep 20, 2010 at 9:33 AM, Vernon Everett<br>
</div><div class="im">> <<a href="mailto:everett.vernon@gmail.com">everett.vernon@gmail.com</a> <mailto:<a href="mailto:everett.vernon@gmail.com">everett.vernon@gmail.com</a>>> wrote:<br>
><br>
>     Bugger!<br>
>     Was pretty busy today, and completely forgot.<br>
><br>
>     Here's something that will help.<br>
>     #!/bin/ksh<br>
>     export BBHOME=/usr/lib/hobbit<br>
>     typeset -L20 HOST<br>
>     mkdir -p /usr/lib/hobbit/custom/data<br>
>     cd /usr/lib/hobbit/custom/data<br>
>     INCLUDES=$(grep ^include /etc/hobbit/bb-hosts | awk '{ print $2 }')<br>
>     cat /etc/hobbit/bb-hosts $INCLUDES | egrep -h -v<br>
>     "^#|^page|^$|^title|^subpage|^group|^include" | awk '{ print $2 }' \<br>
>        | sort | uniq \<br>
>        | while read HOSTNAME<br>
>          do<br>
>             wget -O $HOSTNAME -o /dev/null<br>
>     <a href="http://hobbit/hobbit-cgi/bb-hostsvc.sh%5C?HOST%5C=$HOSTNAME%5C&SERVICE%5C=info" target="_blank">http://hobbit/hobbit-cgi/bb-hostsvc.sh\?HOST\=$HOSTNAME\&SERVICE\=info</a><br>
</div>>     <<a href="http://hobbit/hobbit-cgi/bb-hostsvc.sh%5C?HOST%5C=$HOSTNAME%5C&SERVICE%5C=info" target="_blank">http://hobbit/hobbit-cgi/bb-hostsvc.sh%5C?HOST%5C=$HOSTNAME%5C&SERVICE%5C=info</a>><br>

<div class="im">>     &<br>
>          done<br>
>     wait<br>
>     for HOSTNAME in /usr/lib/hobbit/custom/data/*<br>
>     do<br>
>        OSVER=$(grep OS: $HOSTNAME | sed 's/OS://g'| sed -e :a -e<br>
>     's/<[^>]*>//g;/</N;//ba')<br>
>        HOST=$(basename $HOSTNAME)<br>
>        echo "$HOST    $OSVER"<br>
>     done<br>
>     rm /usr/lib/hobbit/custom/data/*<br>
><br>
>     This will generate a list of hosts, and OS version.<br>
>     You want a list of number of OS versions, pipe the output to awk<br>
>     '{ print $2 }' | sort | uniq -c | awk '{ print $2":"$1}<br>
>     You can feed this back to Hobbit using bb, as a test and graph it.<br>
><br>
>     I recommend you use stack graphs for more interesting looking graphs.<br>
><br>
>     Let me know how you go.<br>
><br>
>     Regards<br>
>          Vernon<br>
><br>
><br>
><br>
><br>
>     On Mon, Sep 20, 2010 at 8:25 PM, Martin Flemming<br>
</div><div class="im">>     <<a href="mailto:martin.flemming@desy.de">martin.flemming@desy.de</a> <mailto:<a href="mailto:martin.flemming@desy.de">martin.flemming@desy.de</a>>> wrote:<br>
><br>
><br>
>             Got some code stubs I can post later when I get to work.<br>
><br>
><br>
>         That's will be great :-)<br>
><br>
>         thanks & cheers,<br>
><br>
>           martin<br>
><br>
><br>
>         On Mon, 20 Sep 2010, Vernon Everett wrote:<br>
><br>
>             Easy enough to knock together.<br>
>             Read it out of the server, then feed it back.<br>
><br>
>             Got some code stubs I can post later when I get to work.<br>
><br>
>             Cheers<br>
>                V<br>
><br>
><br>
>             On Sun, Sep 19, 2010 at 1:47 AM, Martin Flemming<br>
</div>>             <<a href="mailto:martin.flemming@desy.de">martin.flemming@desy.de</a> <mailto:<a href="mailto:martin.flemming@desy.de">martin.flemming@desy.de</a>>><br>
<div class="im">>             wrote:<br>
><br>
>                  Hi !<br>
><br>
>                  Got somebody an working script for counting OS of<br>
>             alle clients<br>
>                  ( RHEl3/4/5 Solaris .5.8/5.19./5.10 etc ..) with<br>
>             graphing .. ?<br>
><br>
>                  I know some old threads about that request,<br>
>                  But hey didn't really work for me are without graphs<br>
>             .. :-(<br>
><br>
>                  thanks & cheers,<br>
><br>
><br>
>                        Martin<br>
><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>
</div>>             <mailto:<a href="mailto:xymon-unsubscribe@xymon.com">xymon-unsubscribe@xymon.com</a>><br>
<div class="im">><br>
><br>
>         To unsubscribe from the xymon list, send an e-mail to<br>
</div>>         <a href="mailto:xymon-unsubscribe@xymon.com">xymon-unsubscribe@xymon.com</a> <mailto:<a href="mailto:xymon-unsubscribe@xymon.com">xymon-unsubscribe@xymon.com</a>><br>
><br>
><br>
><br>
<br>
<br>
--<br>
David Baldwin - IT Unit<br>
Australian Sports Commission          <a href="http://www.ausport.gov.au" target="_blank">www.ausport.gov.au</a><br>
Tel 02 62147830 Fax 02 62141830       PO Box 176 Belconnen ACT 2616<br>
<a href="mailto:david.baldwin@ausport.gov.au">david.baldwin@ausport.gov.au</a>          Leverrier Street Bruce ACT 2617<br>
<br>
<br>
-------------------------------------------------------------------------------------<br>
Keep up to date with what's happening in Australian sport visit <a href="http://www.ausport.gov.au" target="_blank">http://www.ausport.gov.au</a><br>
<br>
This message is intended for the addressee named and may contain confidential and privileged information. If you are not the intended recipient please note that any form of distribution, copying or use of this communication or the information in it is strictly prohibited and may be unlawful. If you receive this message in error, please delete it and notify the sender.<br>

-------------------------------------------------------------------------------------<br>
<div><div></div><div class="h5"><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>
<br>
</div></div></blockquote></div><br>