
Script info pc:
#! /bin/bash
scutil --get ComputerName;
sw_vers | awk -F':\t' '{print $2}' | paste -d ' ' - - -;
uptime | awk '{print "Uptime : " $3 " " $4 " " $5 " " }';
sysctl -n machdep.cpu.brand_string;
#top -l 2 | awk '/CPU usage/ && NR > 5 {print $10, $12, $13}';
top -l 1 | awk '/PhysMem/ {print "Ram : 4096 tot = " $8 " used + " $10 " free." }' ;
df -hl | grep 'disk0s2' | awk '{print $4"/"$2" free ("$5" used)"}'
echo ----------------------------------------------
Script info rete con velocità e Provider:
#! /bin/bash
# get the current number of bytes in and bytes out
myvar1=`netstat -ib | grep -e "en0" -m 1 | awk '{print $7}'` # bytes in
myvar3=`netstat -ib | grep -e "en0" -m 1 | awk '{print $10}'` # bytes out
#wait one second
sleep 1
# get the number of bytes in and out one second later
myvar2=`netstat -ib | grep -e "en0" -m 1 | awk '{print $7}'` # bytes in again
myvar4=`netstat -ib | grep -e "en0" -m 1 | awk '{print $10}'` # bytes out again
# find the difference between bytes in and out during that one second
subin=$(($myvar2 - $myvar1))
subout=$(($myvar4 - $myvar3))
# convert bytes to kilobytes
kbin=`echo "scale=2; $subin/1024;" | bc`
kbout=`echo "scale=2; $subout/1024;" | bc`
# get the current number of bytes in and bytes out
myvarwifi1=`netstat -ib | grep -e "en1" -m 1 | awk '{print $7}'` # bytes in
myvarwifi3=`netstat -ib | grep -e "en1" -m 1 | awk '{print $10}'` # bytes out
#wait one second
sleep 1
# get the number of bytes in and out one second later
myvarwifi2=`netstat -ib | grep -e "en1" -m 1 | awk '{print $7}'` # bytes in again
myvarwifi4=`netstat -ib | grep -e "en1" -m 1 | awk '{print $10}'` # bytes out again
# find the difference between bytes in and out during that one second
subinwifi=$(($myvarwifi2 - $myvarwifi1))
suboutwifi=$(($myvarwifi4 - $myvarwifi3))
# convert bytes to kilobytes
kbinwifi=`echo "scale=2; $subinwifi/1024;" | bc`
kboutwifi=`echo "scale=2; $suboutwifi/1024;" | bc`
# print the results
myen0=`ifconfig en0 | grep "inet " | grep -v 127.0.0.1 | awk '{print $2}'`
if [ "$myen0" != "" ]
then
echo "LAN : $myen0"
echo "in: $kbin Kb/s"
echo "out: $kbout Kb/s"
echo ----------------------------------------------
else
echo "LAN : INACTIVE"
echo ----------------------------------------------
fi
myen2=`ifconfig en1 | grep "inet " | grep -v 127.0.0.1 | awk '{print $2}'`
if [ "$myen2" != "" ]
then
echo "WIFI : $myen2"
echo "in: $kbinwifi Kb/s"
echo "out: $kboutwifi Kb/s"
echo ----------------------------------------------
else
echo "WIFI : INACTIVE"
echo ----------------------------------------------
fi
myen1=`curl --silent http://checkip.dyndns.org | awk '{print $6}' |cut -f 1 -d"<"`
provider=`whois $myen1 |grep netname |awk '{print $2}'`
if [ "$myen1" != "" ]
then
echo "WAN : $myen1, $provider"
else
echo "WAN : INACTIVE"
fi
echo ----------------------------------------------
Script PING cisco e google
#! /bin/bash
HOST0=172.16.52.254
PING0=`ping -q -c 1 $HOST0`
if [[ $? -eq 0 ]] ; then
TIME0=`echo $PING0 |tail -1 | cut -d/ -f 5`
echo Longwave GW: ${TIME0} ms
else
echo non sei in LW
fi
HOST4=192.168.1.253
PING4=`ping -q -c 1 $HOST4`
if [[ $? -eq 0 ]] ; then
TIME4=`echo $PING4 |tail -1 | cut -d/ -f 5`
echo Home GW: ${TIME4} ms
else
echo non sei @Home
fi
HOST1=www.google.it
PING1=`ping -q -c 1 $HOST1`
if [[ $? -eq 0 ]] ; then
TIME1=`echo $PING1 |tail -1 | cut -d/ -f 5`
echo Google: ${TIME1} ms
else
echo Google.it could not be reached!!!
fi
HOST2=www.cisco.com
PING2=`ping -q -c 1 $HOST2`
if [[ $? -eq 0 ]] ; then
TIME2=`echo $PING2 |tail -1 | cut -d/ -f 5`
echo Cisco: ${TIME2} ms
else
echo Cisco.com could not be reached!!!
fi