Sleep.awk script

For those using the sleep.awk script. You will need to change the 2015 in the script to 2016.

RAC

your software script has caused a system Y2K crash and all my data that was dependant on “sleep.awk” was deleted; this is not acceptable. You should begin work to fix this script error for 2017 by removing the dependancy on a hard coded year.

I think WD should fire this bunch of customers and get a new bunch that can provide bette support for themselves. :stuck_out_tongue:

Does that mean we are fired? But I was thinking about a better fix.

RAC

PS I how to can recover your data.
You do know that you will probably scare people away from the sleep.awk script.

too late to fix… as a customer you should know that QA is very important!! and your fix will only last a year too, what will the 2017 customers say?

you had 3 users, you lost 1

I thought I only had one.

RAC

sorry to hear. You need to advertise better but not before you fix the Y2.015 bug :stuck_out_tongue:

Here is the script with the Y2.015bug fixed. To bad I can’t add a zip file.

RAC

awk ’
NR==1 { a=substr($1,6,2); b=substr($1,9,2); c=substr($1,12,8) }
{if ($7 ~ /after/){
hh1=int($8/3600)
mm1=int(($8%3600)/60)
ss1=($8%3600)%60
Total = Total + $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(Total/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 “/2015 " c
“date +%Y”|getline year
end= substr($1,6,2) “/” substr($1,9,2) “/” year " " substr($1,12,8)
$1=start
cmd=“date --date=””$1"" +%s"
cmd|getline st
printf “Start %s\n” ,st
$1=end
cmd=“date --date=”"$1"" +%s"
cmd|getline end
printf “End %s\n” ,end
Total=end-st
hh1=int(Total/3600)
mm1=mm1=int((Total%3600)/60)
ss1=(Total%3600)%60
printf “Total Up Time: %2d:%02d:%02d\n” ,hh1,mm1,ss1
}’

hmmm don’t we need to change this to 2016?

No because currently the log has 2015 dates. I’ll look to see if there is a way to make the work for any date.

RAC

Here is the fix for that problem.

RAC

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
Total = Total + $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(Total/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
cmd=“date --date=”"$1"" +%s"
cmd|getline st
printf “Start %s\n” ,st
$1=end
cmd=“date --date=”"$1"" +%s"
cmd|getline end
printf “End %s\n” ,end
Total=end-st
hh1=int(Total/3600)
mm1=mm1=int((Total%3600)/60)
ss1=(Total%3600)%60
printf “Total Up Time: %2d:%02d:%02d\n” ,hh1,mm1,ss1
}’

1 Like

much better…

now for some documentation (since we don’t want to search for your last post on how to use your sleep.awk as well as how and where to install this. You should modify your first post, otherwise your users will get the wrong versions and have all their data deleted like I did when the year changed over.

I’m recommending you for a 25% pay raise and a user promotion.

25% x $0 and a title of “Customer Sleep Support ZZZZZzzzzzz…”

Is that better? Don’t give me a raise. I don’t want to be placed into a higher tax bracket.

RAC

1 Like

Still lasts longer than an official WD fix…

:+1::+1: