All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
PHP/JSON low end box Status Monitor script (no database)
DEMO
How it works:
On every server you set a cronjob for the client script. This is a bash script which outputs a bunch of text formatted as json, like this:
{ "Services": { "lighttpd" : "running","sshd" : "running","syslog" : "running","munin-node" : "running" }, "Disk" : { "total" : "15360M", "used" : "10820M", "free" : "4541M", "percentage" : "71%" }, "Load" : "0.01,", "Users logged on" : "0", "Uptime" : "29days,", "Free RAM" : "204", "Total RAM" : "256", "IPv4" : "209.141.58.74/32", "Hostname" : "vps5", "External IPv4" : " 209.141.58.74 ","JSON" : "close" }
The server has a php script (the one in the demo) which does the magic to make it look good. Since I discovered this JSON thing I'm almost in love with it .
It also has a script to get the json files from every monitored server. (in my case rsync, but I might do it via wget).
Plans
- Implement a better down-check. If it cannot fetch a json file from a server, it should output a time since when it is down.
- Implement apt-get package update checks (and yum, is someone donates me a centos server :P )
- Source will be released some time in these two weeks, MIT/X11 license from http://raymii.org
Ideas? Comments? please tell me
Comments
This is very cool. Great web interface!
Nice interface, good job!
Why not just build the communication on top of HTTP?
Very nice work.
Will wait for release.
@klikli
The client is a bash script which is called by cron on a set interval.
The communication is now liek this because the JSON stat files do not have to be public now. If I do it over HTTP, it also would require a lot of javascript (i think) and I'm not very skilled in that.
Cool, waiting for the release.
Feedback
Update!
Ok, just did some coding. I've added a package update monitor, network traffic stats and a little ping thingie.
http://raymii.nl/stat.php
Detail page is now not functional, that will be a history page in any of the next releases.
@Asim your feedback is the thing I'll work on next.
Request
Can any of you test this code to check for package updates:
debian
arch
yum (centos/fedora/RHEL)
Does it output a number of packages that can be updated? (or 0 for no packages)? I've got no other non-debian boxes atm to test...
Ran the command, seems to work on both CentOS 5 and 6:
CentOS 5:
[root@test ~]# echo
yum -q check-update | wc -l
17
CentOS 6:
[root@main~]# echo
yum -q check-update | wc -l
125
Reminds me I really could use a yum update.
deb 6 32b
cool
I like it. I'm anxious for the source; i'd like to add a current-network-transfer graph.
Release planned for tomorrow (monday). Here's the readme file as a teaser:
Ray-Mon - A PHP/Bash decentralized server monitoring script
Ray-Mon is a server monitoring script written in PHP and Bash, utilizing JSON for decentralized monitoring.
It is free / libre open source software currently supporting debian and CentOS.
Features
Planned features include:
Installation & Configuration
Download the .zip package and unzip it to a directory of choice.
Client
Edit the client.sh script to include the services you want, change the default four ones or add new ones by copying these lines:
Note that the last service to monitor has to be without a comma for valid JSON.
Edit the network interface you want to use for IP address display
or
iface="eth0"
(first one is for OpenVZ virtualized containers)
Also edit the interface you want to use for traffic monitoring
or
iface2="eth0"
(first one again is for OpenVZ virtualized containers. If you are on XEN or bare metal hardware you probably use eth0, eth1 or bond0 or something.)
Last thing to edit is fot the package updates. If you are on debian/ubuntu you can leave it as it is, if you are on Fedora/CentOS/RHEL, or Arch Linux you have to comment the debian line and uncomment the arch or RHEL/CentOS/Fedora (yum) line.
Now save the script and put it on all the servers you want to monitor. A good location is to put it in a users home directory, or the root home directory:
Repeat that for all the servers you want to monitor.
SSH into every server and add a ROOT cronjob to run the script. If you do not run the cronjob as root you cannot monitor package updates.
As you can see this cronjob redirects the output to the wwwroot so that the monitor server can get the stat.json file. If you do not want the stat.json file to be seen publicly you can setup restrictions in your webserver config or pump the stat.json files over via scp or rsync to the monitoring server.
Verify if the client runs correct:
If you get a permission error you might need to chmod it to make it executable:
Server
The server needs a webserver and PHP install working. You can verify your PHP install via <?php phpinfo(); ?>. If you do not know how to setup a LAMP stack I recommend you to take a look on HowToForge.
Copy the stat.php file and the statget.sh to your wwwroot. Edit the statget.sh file to get the status files from the hosts were you've setup the client.sh script. You can move the statget.sh file to a non-wwwroot location, but make sure it can run. Also edit the paths were needed.
This script should also run from a cronjob, every 5 minutes or so.
Now edit the stat.php file. The host config is at the bottom of the file. For every host needed add a line like this:
Were the first parameter is the json status file (here it is in the same directory (/var/www/). PHP must be able to read the file.
The second parameter is the hostname. (it is used to display errors if it cannot read the json file)
For the ping monitoring you need to edit the Ping section in the stat.php file. To add a host, add or edit a line like this:
Were the first parameter is the host you want to ping (ip or hostname), the second is the port (usually 80) and the last parameter is the timeout in seconds.
Now save the file and see if it runs. If so, you get a nice monitoring panel, and if not you might see some errors.
In case of errors, verify that the statget.sh file runs correctly, and make sure it can get the files from the clients.
License
Copyright (c) 2012 Remy van Elst
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
#
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
#
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Ray-Mon uses the excellent HTML5 Kickstart framework for the interface, found at 99lime.com.
It is inspired by the LowEndTalk community, by Munin, Nagios, OpenStatus and Pingdom.
Feel free to suggest features, ask questions and leave comments using the comment form on the page. Or send me a message via the contact form.
@Raymii
Are we allowed to modify the interface for example use bootstrap?
@martip07 Yes, you can do everything unless the license says you cannot
Very cool. Look forward to toying with it tomorrow
I like LET
Thanks Remy
M
be nice to have this up on github
Lubuntu 12.10 32 bit
Looking forward to this!
Looking really good, I might use this
@tux it probably means you have no updates...
@FRCorey I might put it up on gitorious
GitLab is awesome too (If you want to host it yourself)
Beta release 1
For all of you to test and try out. if it works well, I'll do an official release on Raymii.org.
Not github or gitorious yet, probably after first final.
DOWNLOAD!!!
Download .zip of Ray-Mon v0.0.1 BETA
You forgot a http:// there
fixed
Thanks bud
Will try. Good job and thank you @Raymii.
I'd like to see some of the setups you guys/gals make. If you don't mind, please post some links?
@Raymii: I haven't used it yet (i'm still setting up some servers). Sorry bud
Hosted with torqhost, Loving this! http://46.22.208.210/raymon/stat.php