New on LowEndTalk? Please Register and read our Community Rules.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
ray-mon v2, bash+php only status monitoring + history
So, updating my status monitoring program. New things include History per host and a (IMHO nicer) layout. Requires only php,bash and a webserver.
Version 2, the new one:
http://vps11.sparklingclouds.nl/status/stat.php
Version 1, the old one:
http://vps11.sparklingclouds.nl/status/index.php
Suggestions welcome. Will be released under a BSD style license when finished.
Comments
Love the new look! Good job.
Quick update, the server part is now completely php, it does not require a bash script anymore. It does however requires php to be able to get remote files (via file_get_contents). Do you hosts allow that, on shared?
Most shared hosts have "allow_url_fopen" disabled, so "file_get_contents" on a remote server wouldn't work... Some shared hosts have cURL enabled though which you could add as a backup.
Check if "allow_url_fopen" is disabled, then check if cURL exists, if it does then proceed or else throw an error.
Release of version 2!
https://github.com/RaymiiOrg/raymon
Ray-Mon - PHP/Bash server status monitoring
Ray-Mon is a linux server monitoring script written in PHP and Bash, utilizing JSON as data storage. It requires only bash and a webserver on the client side, and only php on the server side. The client currently supports monitoring processes, uptime, updates, amount of users logged in, disk usage, RAM usage and network traffic.
Live Demo
This is a live demo of this script, monitoring the sparkling network (my vps servers)
Features
Download
Either git clone the github repo:
Or download the zipfile from github:
https://github.com/RaymiiOrg/raymon/zipball/master
Or download the zipfile from Raymii.org
https://raymii.org/cms/content/downloads/raymon-0.0.2.zip
Changelog
v0.0.2
v0.0.1
Install
Client
The client.sh script is a bash script which outputs JSON. It requires root access and should be run as root. It also requires a webserver, so that the server can get the json file.
Software needed for the script:
Setup a webserver (lighttpd, apache, boa, thttpd, nginx) for the script output. If there is already a webserver running on the server you dont need to install another one.
Edit the script:
Network interfaces. First one is used for the IP, the second one is used for bandwith calculations. This is done because openVZ has the "venet0" interface for the bandwith, and the venet0:0 interface with an IP. If you run bare-metal or KVM or vserver etc. you can set these two to the same value (eth0 eth1 etc).
The IP address of the server, this is used by me when deploying this script via chef or ansible. You can set it, but it is not required.
Services are checked by doing a ps to see if the process is running. The last service should be defined without a comma, for valid JSON. The code below monitors "sshd", "lighttpd", "munin-node" and "syslog".
To add a service, copy the 2 lines and replace the SERVICE=processname with the actual process name:
And, make sure the last service montiored does not echo a comma at the end, else the JSON is not valid and the php script fails.
Now setup a cronjob to execute the script on a set interval and save the JSON to the webserver directory.
As root, create the file /etc/cron.d/raymon-client with the following contents:
In my case, the client script is in /root/scripts, and my webserver directory is /var/www. Change this to your own setup. Also, you might want to change the time interval. */5 executes every 5 minutes. The sed line is in there to remove the newlines, this creates a shorter JSOn file, saves some KB's. The root after the cron time is special for a file in /etc/cron.d/, it tells cron as which user it has to execute the crontab file.
When this is setup you should get a stat.json file in the /var/www/ folder containing the status json. If so, the client is setup correctly.
Server
The status server is a php script which fetches the json files from the clients every 5 minutes, saves them and shows them. It also saves the history, but that is defined below.
Requirements:
Steps:
Create a new folder on the webserver and make sure the webserver user (www-data) can write to it.
Place the php file "stat.php" in that folder.
Edit the host list in the php file to include your clients:
The first parameter is the filename the json file is saved to, and the second is the URL where the json file is located.
Edit the values for the ping monitor:
Edit the threshold values:
History
To save the history you have to setup a cronjob to get the status page with a special "history key". You define this in the stat.php file:
And then the cronjob to get it:
The cronjob can be on any server which can access the status page, but preferably on the host where the status page is located.
Release of version 2!
https://github.com/RaymiiOrg/raymon
You should make this guy the official logo of Raymon
Hehe, I think Ubisoft will sue my ass when I do that.