On the gen1 you can look at the /var/log/user.log. On the gen2 you don’t have this information. On the gen1 you can use this script. load these two script to the Public folder. SSH into the device cd to the Public folder and run sleep.sh
sleeptime.sh
gunzip -c /var/log/user.log.2.gz > tmpuserlog
cat tmpuserlog /var/log/user.log.1 /var/log/user.log|/nfs/Public/sleep.awk
rm tmpuserlog
sleep.awk
awk ’
NR==1 { a=substr($1,6,2); b=substr($1,9,2); c=substr($1,12,8); y=substr($1,1,4)}
{if ($7 ~ /after/){
hh1=int($8/3600)
mm1=int(($8%3600)/60)
ss1=($8%3600)%60
TotalSleep = TotalSleep + $8
printf “%2s %2s %8s %8s %5d %2d:%02d:%02d\n”,substr($1,6,2),substr($1,9,2) ,substr($11,0,9),substr($
1,12,8),$8 ,hh1,mm1,ss1}}
END {
hh1=int(TotalSleep/3600)
mm1=mm1=int(($8%3600)/60)
ss1=($8%3600)%60
printf “Total Sleep Time: %2d:%02d:%02d\n” ,hh1,mm1,ss1
start= a “/” b “/” y " " c
“date +%Y”|getline year
end= substr($1,6,2) “/” substr($1,9,2) “/” year " " substr($1,12,8)
$1=start
#print start " " end
cmd=“date --date="”$1"" +%s"
#print cmd
cmd|getline st
printf “Start %s\n” ,st
$1=end
cmd=“date --date="”$1"" +%s"
cmd|getline end
#print cmd
printf “End %s\n” ,end
Total=end-st
hh1=int(Total/3600)
mm1=mm1=int((Total%3600)/60)
ss1=(Total%3600)%60
Percent=int((TotalSleep/Total)*100)
WakeTime= int(100 - Percent)
printf “Total Up Time: %2d:%02d:%02d %2d%% Sleep %2d%% Wake\n” ,hh1,mm1,ss1,Percent,WakeTime
}’