I know there is a better way to do this in Perl - would Net:SSH lend a hand here or is there a steep learning curve? Thanks!
for HOST in `cat /tmp/hosts` do MODEL="" USER="" IDLE="" RELEASE="" host $HOST |grep "not found">>/dev/null #Check if the host is switched on and in DNS (due to our autom +agicaldns entry magic) if [ "$?" == "1" ] ; then # Grab the model name from AD (remember to kinit) MODEL=`/opt/adi/bin/adcat.py -x computer $HOST|grep M +odel|awk '{print $3}'` # ssh into the box, pick through the last entries, see + if a user logged into the console rather than via ssh # if so then thats probably the primary user, if nobod +y logged in then we're SOL. USER=`ssh $HOST "last|grep ':0\ + '|awk '{print \\$1}'|head -n1" 2>/dev/null` if [ "x$USER" == "x" ] ; then USER="NO-LOCAL" fi IDLE="0" AVERAGE="0" SUM="0" NUM="0" # SSH into the box, for each sar entry display the cpu + usage and average it for IDLE in `ssh $HOST 'for i in /var/log/sa/sa*; do s +ar -f $i 2>/dev/null; done' 2>/dev/null|awk '{print $7}'|grep -v idle +|sed -e s/...$// ` do SUM=$[$SUM + $IDLE] NUM=$[$NUM + 1] done AVERAGE=$[$SUM / $NUM] RELEASE=`ssh $HOST "uname -r" 2>/dev/null` fi echo "$HOST $MODEL $USER $IDLE $RELEASE" done

In reply to Usage gathering query by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.