Sunday, 30 October 2011
Blinking lights on the LAN
Thursday, 27 October 2011
Ping watchdog with Powershell
We have one unreliable virtual server which sometimes just loses its network connection. Until we have a permanent solution, the temporary fix is to have the computer reboot if it loses network connection.
Note: There is nothing as permanent as a temporary solution. With that warning, let's get to it.
Step 1 - Produce the following Powershell script into c:binpingdog.ps1
$netup = new-object Test-Connection -quiet "goo.gl"
if( $netup -eq $False ) {
Restart-Computer
}
Step 2 - Fix your security settings
Start Powershell. Enter Set-ExecutionPolicy RemoteSigned or whatever level you're comfortable with that'll still run your script.
Step 3 - Schedule it
If you're using Windows Server 2003 (like we, ungh) schedule a daily task to run %SystemRoot%system32WindowsPowerShellv1.0powershell.exe c:binpingdog.ps1
From the task's Properties, the Schedule tab, press the Advanced button. Tick Repeat Task, every 12 minutes (or whatever you fancy), and repeat for 24 hours.
If you're using Windows Server 2008 or later, you should be able to set the task to run evey x minutes right from the interface.
Step 4 - Check your logs
Keep an eye on the failing computer's system log to see if it's restarted when you looked away.
Monday, 24 October 2011
Happy UN day
Thursday, 6 October 2011
It blinks!
A while ago, i bought an Ethernet module from Sure electronics. I wasn't sure what to use it for or if i indeed would be able to use it for anything, but it was cheap and hey, you could connect it to the Ethernet. Can't be all bad :)
Having less than a raving success with controlling my garden lights with a Nanode, i decided i needed a break. And so i googled "Arduino Sure-electronics ethernet", and lo && behold(), up comes a blog post with just what i needed, but just didn't understand to expect: that it's really easy to interface an Arduino with the Ethernet, and that the magic is built on the EtherShield library which i was already using on Nanode.
So i soldered the seven pins needed to have the two devices talk with each other. Wired them together with neat and correctly coloured jumper wires. Copied the code into my editor. Changed the MAC and IP addresses. Verified the code ("It compiles! Ship it!"). Uploaded it to the Arduino board. And it - just - worked!
You can't imagine how excited i was when i was able to open up a web page, served from the Arduino, and was able to toggle a LED on and off over my LAN. I't just so neat! (or if you do know me, you can probably imagine just how excited i was :) I should have taken a picture, or a video!
So my thanks go out to Henrik Denhart who wrote the blog post and to Andrew Lindsay, coder and maintainer of the EtherShield library, and indeed the whole Arduino maker movement who with their enthusiasm and drive for openness make the platform such a wonderful thing it is!