Arduino Network Uptime Monitor with Twitter Updates

IMG_20140217_193610We’ve been looking for excuses to use our Arduino Ethernet shield in more projects recently; we had the idea today to see if we could get it monitoring our network servers and report the status of them to Twitter.

It was actually surprisingly easy; we had the Twitter posting code from the previous project and we found an Arduino ICMP library so that we could test a ping to the hosts and see if it was responding or not, we added this to our task scheduling code and the rest just fell into place.

So, what’s needed?

Click on any of the above links to download them. In order to use the Twitter library you will need to generate a Secret Token for your Twitter account – There are instructions on how to do this on the library page linked above. You will also need to place both the Twitter library and ICMP Ping library in your Arduino Libraries folder (or import it via the menu in the IDE).

That’s about it really for the set-up, the actual code to make this work is all posted below:

Network Monitor Sketch:

The first thing you’ll need to do is change your IP/DNS/Gateway for the Ethernet shield on your network, after you have done this you will need to enter your Twitter Secret that you created earlier; this is so that it can authenticate with Twitter properly without needing your username/password.

You’ll notice that the servers are in a struct; so you’ll need to enter a friendly name and IP address of the host you wish to monitor, as well as increase the size of the array if you’re adding more hosts. Adding hosts is as simple as changing the servers serverList[3]; to servers serverList[x]; where x is the number of hosts you wish to monitor. You can add more hosts by using the function below in the setup() section of the sketch:

The first parameter is the unique ID, the second parameter is the name of the host (this will appear in the Tweet) and the third, forth, fifth and sixth is the octets for the IP address you wish to add.

You can modify the schedules for the updates by modifying the two lines below: Note that the numbers are in milliseconds.

You should now be all up and running! You can remove the commented out Serial.print functions to see some debug output in the Serial Monitor; but hopefully you’ll see the updates on your Twitter account and should look something like the below:

tweets

We’ve had this running on our test Twitter account for a couple of hours and it seems to be running well, the only downside is that if you choose a large name for the host and you go over the 200 Twitter character limit then you will not see all of the data, this could be easily modified to give a summary of servers instead of full names though.

This should provide a solid base for making an Arduino network uptime monitor.

That’s about it for now. Let us know how you get on.

Email this to someoneShare on Google+Pin on PinterestTweet about this on TwitterShare on RedditShare on Facebook

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">