[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

oscount osrep



base off  Vernon Everett posted script:
osrep Vernons code with more filtering added
oscount Vernons code with more filtering added with my code added to produce os/version count.

oscount:

#!/bin/ksh
# oscount
export BBHOME=/home/mnemeth/sunhobbit
typeset -L32 HOST

mkdir -p /home/mnemeth/sunhobbit/custom/data
unalias cd
cd /home/mnemeth/sunhobbit/custom/data

INCLUDES=$(grep ^include /home/mnemeth/sunhobbit/server/etc/bb-hosts | awk '{ print $2 }')
cat /home/mnemeth/sunhobbit/server/etc/bb-hosts $INCLUDES| \
egrep -h -v "^#|^page|^$|^subparent|^subpage|^group|^include|^title"\
|sed  -e 's/^[ \t]*//' -e'/^$/d' | awk '{ print $2 }' \
  | while read HOSTNAME
    do
/usr/sfw/bin/wget -O $HOSTNAME -o /dev/null http://phlccase/hobbit-cgi/bb-hostsvc.sh\?HOST\=$HOSTNAME\&SERVICE\=info &
    done
wait
for HOSTNAME in /home/mnemeth/sunhobbit/custom/data/*

do
OSVER=$(grep OS: $HOSTNAME | sed 's/OS://g'| sed -e :a -e 's/<[^>]*>//g;/</N;//ba')
  HOST=$(basename $HOSTNAME)
  echo  "$OSVER" >>OSCOUNT$$
done
sed  -e '/^$/d' OSCOUNT$$ |  awk '{print $1, " ", $3, ":" } ' | awk -F\: '\
{
#for (i = 1; i  <= NF; i++)

freq[$1]++
}

END {
for (word in freq)
printf "%s\t%d\n", word, freq[word]
}' | sort

TOT=` sed  -e '/^$/d' OSCOUNT$$ |wc -l  `
echo " Total: $TOT "
rm /home/mnemeth/sunhobbit/custom/data/*

osrep:
#!/bin/ksh
# osrep
export BBHOME=/home/mnemeth/sunhobbit
typeset -L32 HOST

mkdir -p /home/mnemeth/sunhobbit/custom/data
unalias cd
cd /home/mnemeth/sunhobbit/custom/data

INCLUDES=$(grep ^include /home/mnemeth/sunhobbit/server/etc/bb-hosts | awk '{ print $2 }')
cat /home/mnemeth/sunhobbit/server/etc/bb-hosts $INCLUDES|\
 egrep -h -v "^#|^page|^$|^subparent|^subpage|^group|^include|^title" |\
sed  -e 's/^[ \t]*//' -e'/^$/d' | awk '{ print $2 }' \
  | while read HOSTNAME
    do
/usr/sfw/bin/wget -O $HOSTNAME -o /dev/null http://phlccase/hobbit-cgi/bb-hostsvc.sh\?HOST\=$HOSTNAME\&SERVICE\=info &
    done
wait
for HOSTNAME in /home/mnemeth/sunhobbit/custom/data/*

do
OSVER=$(grep OS: $HOSTNAME | sed 's/OS://g'| sed -e :a -e 's/<[^>]*>//g;/</N;//ba')
  HOST=$(basename $HOSTNAME)
  echo "$HOST  $OSVER"
done
rm /home/mnemeth/sunhobbit/custom/data/*