Vai al contenuto


Archived

Questa discussione è archiviata e chiusa a future risposte.

flapane

[SW mio]Statistiche dettagliate del proprio pc

Recommended Posts

Ho creato questo codice in bash, prendendo spunto sempre dalla mia versione per linux LINK. Spesso serve qualcosa di testuale, magari da inviare via mail o simili in automatico, o non si ha voglia di aprire la dashboard per istat nano, o semplicemente si è fanatici del terminale -.-

CODICE

#!/bin/bash
#Mac os stats from my old linux stats script http://peek.snipurl.com/2zgm9 
#author flapane (www.flapane.com)
#last rev. 9-sep-08

#get temps by [email protected]
sensors=`ioreg -n IOHWSensor | awk '/location/ || /current-value/ || /"type"/' | sed -e 's/[^"]*"//' -e 's/" =//' -e 's/location//' -e 's/type//' -e 's/"//g' | awk '{ if ((NR % 3) == 0) print $0; else printf $0 " " }'`

#get other datas
sysprofhw=`system_profiler SPHardwareDataType`
sysprofpow=`system_profiler SPPowerDataType`
up=`uptime`
wire=`top -l 1 | grep PhysMem | awk '{print $2}' | sed -e 's/M.*//'`
act=`top -l 1 | grep PhysMem | awk '{print $4}' | sed -e 's/M.*//'`
netstat=`netstat -ib | grep en1` 

a=`echo "$sysprofhw" | awk '/Machine Name/ || /Machine Model/ || /CPU Type/' | sed 's/[^:]*: //' | awk '{printf $0 " " }'`

b=`uname -r`

c=`echo "$sysprofhw" | grep CPU | grep Speed | awk '{print $3}'`

d=`echo "$sensors" | grep 'temperature' | awk '{ for(i=1;i<5;i++) if ($i=="current-value") $(i+1)=((( (($(i+1) / 2^13) - ($(i+1) / 2^13) % 1 ) / 2^3) - .5)" C\t"); print $0 }' | sed -e 's/current-value //' -e 's/temperature//' | grep CPU | awk '{print $1 $2}'`

e=`system_profiler SPSoftwareDataType | grep Mac | awk '{print $6}'`

f=`echo "$netstat" | awk '{print $7}' | sed 1q`

g=`echo "$netstat" | awk '{print $10}' | sed 1q`

mbytesin=`expr $f \/ 1024000`
mbytesout=`expr $g \/ 1024000`

h=`echo "$wire+$act" | bc`

j=`system_profiler SPHardwareDataType | grep Memory | awk '{print $2}'`

k=`expr $j \* 1024`

l=`echo "$sensors" | grep 'temperature' | awk '{ for(i=1;i<5;i++) if ($i=="current-value") $(i+1)=((( (($(i+1) / 2^13) - ($(i+1) / 2^13) % 1 ) / 2^3) - .5)" C\t"); print $0 }' | sed -e 's/current-value //' -e 's/temperature//' | grep GPU | awk '{print $1 $2}'`

m=`echo "$sensors" | grep 'temperature' | awk '{ for(i=1;i<5;i++) if ($i=="current-value") $(i+1)=((( (($(i+1) / 2^13) - ($(i+1) / 2^13) % 1 ) / 2^3) - .5)" C\t"); print $0 }' | sed -e 's/current-value //' -e 's/temperature//' | grep BATTERY | awk '{print $1 $2}'`

n=`echo "$sensors" | grep -v 'temperature' | awk '{ for(i=1;i<5;i++) if ($i=="current-value") $(i+1)=(substr((($(i+1)/2^16)"\t"),1,); print $0 }' | sed -e 's/current-value //' | grep CORE | awk '{print $1}'`

o=`echo "$sysprofpow" | grep Full | grep Charge | awk '{print $5}'`

p=`echo "$sysprofpow" | grep Remain | awk '{print $4}'`

#shows airport name
#q=`dmesg | grep Active | sed q | awk '{print $4}'`

#upday=`echo "$up" | awk '{ print $3,$4 }' | awk -F, '{ print $1 }'`
#uphour=`echo "$up" | awk '{ print $5 }' | sed -e 's/:.*//'`
#upmin=`echo "$up" | awk '{ print $5 }' | sed s/'.*: *'// | sed -e 's/,.*//'`

uptotal=`uptime | awk '
   $4 ~ /mins/ { d=0;  h=0;  m=$3; exit }
   $4 ~ /day/  { d=$3; split($5,a,":"); h=a[1]; m=a[2]; exit }
   { d=0; split($3,a,":"); h=a[1]; m=a[2]; exit }
   END { printf("-=[ Uptime: %d day%s, %d hours, %d mins ]=-\n",
                 d, (d == 1 ? "" : "s"), h, m) }
'`

#echo stats
echo "PC statistic"
echo "-=[ Kernel info: Darwin $b ]=-"
echo "-=[ Mac OS X $e ]=-"
echo "-=[ CPU Info: $a @$c Ghz ]=-"
echo "-=[ CPU Temperature: $d ]=-"
echo "-=[ CPU Vcore: $n V ]=-"
echo "-=[ GPU Temperature: $l ]=-"
echo "-=[ Battery Temperature: $m ]=-"
echo "-=[ Battery Capacity: $p on $o mAh ]=-"
echo "-=[ Incoming/Outgoing wlan: $mbytesin MB / $mbytesout MB ]=-"
echo "-=[ Used/Total memory: $h MB / $k MB ]=-"
echo "$uptotal"

Risultato:

PC statistic

-=[ Kernel info: Darwin 8.11.0 ]=-

-=[ Mac OS X 10.4.11 ]=-

-=[ CPU Info: iBook G4 PowerBook6,7 PowerPC G4 (1.5) @1.33 Ghz ]=-

-=[ CPU Temperature: 52.25C ]=-

-=[ CPU Vcore: 1.12242 V ]=-

-=[ GPU Temperature: 53.5C ]=-

-=[ Battery Temperature: 33.5C ]=-

-=[ Battery Capacity: 3890 on 4013 mAh ]=-

-=[ Incoming/Outgoing wlan: 431 MB / 30 MB ]=-

-=[ Used/Total memory: 545 MB / 1024 MB ]=-

-=[ Uptime: 1 day, 9 hours, 9 mins ]=-

N.B Pare che su Intel le temperature siano rilevate in maniera differente, se qualcuno può verificare...

Condividi questo messaggio


Link di questo messaggio
Condividi su altri siti



×