Before coming to Amahi I spent some time testing out WHS and one thing I came to appreciate, even with its limitations, was an addon that would send system errors to twiiter, so I decided to create a script in python that would be able to send me information about the server, has I don't run any critical applications on my server I just want to know how things are from time to time.
In twitter terms I have an account just for the server that only allows private followers
This is how the message looks like :
For all but upload and download I used common system calls, so you can easily change the code for your own applications the only really specific case is the up/down, as I only have an Ethernet port active, I can't use its statistics (they would get mixed up with lan usage) so I had to fetch the data from my router statistics page that uses the Tomato firmware, If you are able to use it for other routers pls post here
Any suggestions and tips are really welcome!
TIPS: As the passwords are not safe I recommend that you make sure that only root can read it (chmod 711 for example as root).
Don't spam it, I for example only run it during the day and only in 4 hours interval (my crontab entrie 1 11,15,19,23 * * * /usr/local/bin/twitCron.py)
ATTENTION: this was written with the propose of getting to know python for shell scripting, this was in fact the second program I have ever written in python, I have a large experience in other languages but had never tried it, so do not yell if the code isn't the better you have ever seen...
Twitter server monitor
Twitter server monitor
- Attachments
-
- twitCron.py.zip
- V1 of twirCron a server monitor script using Twitter
- (1.63 KiB) Downloaded 252 times
-
- Posts: 124
- Joined: Mon Jun 29, 2009 9:41 am
- Location: Hazel Park, MI
- Contact:
Re: Twitter server monitor
Very nice, I will have to give this a try sometime soon.
Testmaster Manager
Amahi HDA Custom Dual 2.7 GHz, 3 GB DDR2 (667MHz) Ram, 80GB HDD for OS + 1TB and 320GB HDD for Share Drives
Amahi HDA Custom Dual 2.7 GHz, 3 GB DDR2 (667MHz) Ram, 80GB HDD for OS + 1TB and 320GB HDD for Share Drives
Re: Twitter server monitor
This is very cool!!
We should turn this into an app!
We should turn this into an app!
My HDA: Intel(R) Core(TM) i5-3570K CPU @ 3.40GHz on MSI board, 8GB RAM, 1TBx2+3TBx1
Re: Twitter server monitor
hey there!
we implemented a notification api for amahi.org inspired by your twittercron code!
the notification is by email (to your amahi.org account email) now. later we can do twitter, not too hard.
here is one simple example of how to use it, in ruby:
i got the email below!
very coool!
now, an app to do a little plugin/app to monitor various things and send the events over the api should be fairly easy to do.
we could turn your twitCron code into a server and build a little web UI to control what things are notified.
--
edit
you will need a small patch to the amahi_api.rb code. this is part of the latest platform test rpm that you can have if you want.
otherwise , you can add these two lines before the last end closing the class in the /var/hda/platform/html/lib/amahi_api.rb
we implemented a notification api for amahi.org inspired by your twittercron code!
the notification is by email (to your amahi.org account email) now. later we can do twitter, not too hard.
here is one simple example of how to use it, in ruby:
Code: Select all
bash$ cd /var/hda/platform/html
/var/hda/platform/html
bash$ ./script/console
Loading development environment (Rails 2.1.1)
>> AmahiApi::api_key = Setting.get("api-key")
=> "this-is-my-hda's-api-key"
>> te = AmahiApi::TimelineEvent.new(:kind => "network", :message => "This is my first ever Amahi notification event") and te.save
=> true
>>
bash$
very coool!
now, an app to do a little plugin/app to monitor various things and send the events over the api should be fairly easy to do.
we could turn your twitCron code into a server and build a little web UI to control what things are notified.
Code: Select all
Date: Fri, 17 Jul 2009 03:02:00 -0700
From: Amahi <no-reply@amahi.org>
To: [my-email]
Subject: [Amahi Direct Message] network event
Hi, you have a new network event from your Amahi HDA:
This is my first ever Amahi notification event
--
Turn off these emails at: http://www.amahi.org/user/notifications
Please do not reply to this message; it was sent from an unmonitored email address.
edit
you will need a small patch to the amahi_api.rb code. this is part of the latest platform test rpm that you can have if you want.
otherwise , you can add these two lines before the last end closing the class in the /var/hda/platform/html/lib/amahi_api.rb
Code: Select all
class TimelineEvent < Base
end
My HDA: Intel(R) Core(TM) i5-3570K CPU @ 3.40GHz on MSI board, 8GB RAM, 1TBx2+3TBx1
Re: Twitter server monitor
here are some ideas on what events to notify:
- running low on available disk space
- logins to the network and logouts (DHCP/DDNS events)
- high temperature in disk drives
- high temperature in the CPU
- high CPU load?
- server powerdown/powerup (in case of power failures, maybe UPS events?)
- bandwidth usage
- VPN logins/logouts
- ...
My HDA: Intel(R) Core(TM) i5-3570K CPU @ 3.40GHz on MSI board, 8GB RAM, 1TBx2+3TBx1
-
- Posts: 124
- Joined: Mon Jun 29, 2009 9:41 am
- Location: Hazel Park, MI
- Contact:
Re: Twitter server monitor
services stopped, started or restarted
terminal logins, might be included in this
terminal logins, might be included in this
logins to the network and logouts (DHCP/DDNS events)
Testmaster Manager
Amahi HDA Custom Dual 2.7 GHz, 3 GB DDR2 (667MHz) Ram, 80GB HDD for OS + 1TB and 320GB HDD for Share Drives
Amahi HDA Custom Dual 2.7 GHz, 3 GB DDR2 (667MHz) Ram, 80GB HDD for OS + 1TB and 320GB HDD for Share Drives
Re: Twitter server monitor
humm I think he means physical layer events there.services stopped, started or restarted
terminal logins, might be included in thislogins to the network and logouts (DHCP/DDNS events)
I think we should keep it simple or the server admin would end up overwhelmed with info and start ignore it, we can't forget this is a home server and ppl just want to be informed of important and possible nefarious things, so the only terminal login that would be useful is root imho. Of course we can put everything there as an option for the most security "freaks" of us
Re: Twitter server monitor
I have the following command run on my webhosting server when someone logs in on the terminal (which should only be me ):
the output what I get in my mailbox looks like this (with the subject "Server Access" so I can filter it easily):
works like a charm for me
Code: Select all
mail -s 'Server Access' myname@domain.tld <<end
$(who)
$(date)
end
Code: Select all
username pts/0 2009-07-17 20:38 (XXX.ISP.nl)
fr jul 17 20:38:25 CEST 2009
echo '16i[q]sa[ln0=aln100%Pln100/snlbx]sbA0D2173656C7572206968616D41snlbxq' | dc
Galileo - HP Proliant ML110 G6 quad core Xeon 2.4GHz, 4GB RAM, 2x750GB RAID1 + 2x1TB RAID1 HDD
Galileo - HP Proliant ML110 G6 quad core Xeon 2.4GHz, 4GB RAM, 2x750GB RAID1 + 2x1TB RAID1 HDD
Re: Twitter server monitor
Well I have been studying the network monitor cause in my case i just used the monitor on my router and didn't have to worry about anything else, but other ppl may not be using an open source router, so we to have a way of monitoring the data in the server himself, as I am not a network expert I went looking for something already coded , first I tired vnstat and its really light and easy to use but the problem is that it doesn't have any packet filtering it isn't able to distinguish the traffic, so for people like me that just wants to know the internet traffic it isnt a viable solution. Then I tried ntop and that one is really a fantastic tool but it has a lot of futures that are mostly suited in a router/gateway not a home server (imho). Finally I came across darkstat and it really seems like the way to go, it supports all kinds of filtering and is a lot more simple and lightweight than ntop (can't find the rpm on forge had to download from here http://packages.sw.be/darkstat/darkstat ... f.i386.rpm).
Tomorrow I will try to get the data and place it on the new ruby app, but now its 3h20am and tomorrow morning I have kendo practice .
Tomorrow I will try to get the data and place it on the new ruby app, but now its 3h20am and tomorrow morning I have kendo practice .
Re: Twitter server monitor
Just say NO to Twitter.......your life will be better : )
gjc1000
Chi pecora si fa, il lupo se la mangia.
Chi pecora si fa, il lupo se la mangia.
Who is online
Users browsing this forum: No registered users and 20 guests