notify 10 {
match "system" "ACPI";
match "subsystem" "Lid";
action "/etc/myscript $notify";
};
sysctl debug.acpi.suspend_bounce=1
followed by acpiconf -s 3
(taken from here). I apologize. I thought you were making jokes by saying:Ok, run a cron job.
I use zzz().
I didn't know zzz is an app. ? I thought about this picture "?"In your script, you can make your server fall asleep (zzz).
zzz
command there are still missing both mentioned conditions before running zzz
as well as the sensing for that condition.#!what-ever-shell
// pseudo coded draft
idletime=0
while true do
check if idle=100%-99% do idletime++ else idletime=0
check if jails=0 and idletime>=60 do
zzz // server go to bed
done
delay 1 second
done
#!what-ever-shell
// pseudo coded draft
check if idle=100%-99% do set env-idletime++ else set env-idletime=0
check if jails=0 and env-idletime>=60 do
zzz // server go to bed
done
What about exporting the value to environment variable?If you want to test each second, then the simplest way is to create two Cron job IMHO.
One put the last date if no idle in /tmp/lastNoIdleTime each second.
The second that runzzz
if the file does not exist or ifnow - date > 60
.
But there is maybe a simpler way.
I am not sure that two cron jobs shares env vars. To be tested ?What about exporting the value to environment variable?
Cron jobs are being executed as same user (root), so they should be able to read globally exported env vars of root, right? I didn't try it before, too. It might be a security issue if it is possible ... On the other hand, there should be an initial export of some env var to set the value like on login by bash due to .bashrc, I think. So, if you just boot up a system there should be no env var available until root logs in, except you set export command in crontab, if there is no environmental isolation. Logical, but sounds like an stupid idea ... Let's give it a try ... ?I am not sure that two cron jobs shares env vars. To be tested ?
. script1.sh
. script2.sh
// pseudo code
on cpu.event "idle" do // event by devd?
if 0 <= uptime.load <= 0.3 and numberOf.jails == 0 do
zzz // good night
done
done
-v Verbose mode. Messages about power changes will be printed to stdout and powerd will operate in the foreground.
// pseudo code
if (grep idle stdin) do
if 0 <= uptime.load <= 0.3 and numberOf.jails == 0 do
zzz // good night
done
done
powerd -v | ./check.sh
zzz
and WOL by hand on your server to make sure they work before scripting anything. sleep
in it. You will likely have to poll to get the jail count and CPU usage, and if you're polling anyway, there's nothing wrong with using sleep
. cron
at boot time or run it as a service. Let it run for a while and then make improvements if needed.What about the idle couter?
top
, vmstat
or iostat
?$ top -Sb | sed -Enr 's/^CPU: .+ (.+)% idle/\1/p'
70.5
$ vmstat | awk 'NR==3 {print $(NF)}'
71
$ iostat | awk 'NR==3 {print $(NF)}'
71
Maybetop
,vmstat
oriostat
?
Bash:$ top -Sb | sed -Enr 's/^CPU: .+ (.+)% idle/\1/p' 70.5 $ vmstat | awk 'NR==3 {print $(NF)}' 71 $ iostat | awk 'NR==3 {print $(NF)}' 71
wake is being executed on linux ... does FreeBSD have wake?make sure WoL functionality is enabled in a machine’s / servers BIOS so that it can be used to power on machines from a remote system without having physical access to them. The syntax is:
wake mac-address-here
wake link-layer-address-here
wake interface link-layer-address-here
To wake up server using link-layer-address 00:11:32:11:15:fc, enter:
$ sudo wake 00:11:32:11:15:fc
OR use em0 interface, enter:
$ sudo wake em0 00:11:32:11:15:fc
Is there anything else that I should be looking into?
sysrc kld_list
sorry.. new to this.. when I type the command given I get.sysrc kld_list
What's listed?
Obscurely (no mention of keyword wake anywhere in the FreeBSD Handbook):
sysrc: unknown variable 'kld_list'
sysrc: unknown variable 'kld_list'
pciconf -lv | grep -B 3 -A 2 display
vgapci0@pci0:1:0:0: class=0x030000 rev=0xa1 hdr=0x00 vend
or=0x10de device=0x104a subvendor=0x19da subdevice=0x6222
vendor = 'NVIDIA Corporation'
device = 'GF119 [GeForce GT 610]'
class = display
subclass = VGA
hdac0@pci0:1:0:1: class=0x040300 rev=0xa1 hdr=0x00 vend
or=0x10de device=0x0e08 subvendor=0x19da subdevice=0x6222