Welcome to the PHP Server Monitor documentation!¶
Contents:
Introduction¶
Summary¶
PHP Server Monitor is a script that checks whether your websites and servers are up and running. It comes with a web based user interface where you can manage your services and websites, and you can manage users for each server with a mobile number and email address.
Features¶
- Monitor services and websites (see below).
- Email and SMS notifications.
- View history graphs of uptime and latency.
- User authentication with 2 levels (administrator and regular user).
- Logs of connection errors, outgoing emails and text messages.
- Easy cronjob implementation to automatically check your servers.
Servers¶
There are two different ways to monitor a server:
- Service
A connection will be made to the entered ip or domain, on the given port. This way you can check if certain services on your machine are still running. To check your IMAP service for example, enter port 143.
- Website
You can enter a link to a website, it will then use cURL to open the website and check the HTTP status code. If the HTTP status code is in the 4xx range, it means an error occurred and the website is not accessible to the public. You can also set a regular expression to match for content on the page itself. If the regular expression returns no matches, the website is considered down. In both cases the script will return a “status offline”, and will start sending out notifications.
Notifications¶
Each server has its own settings regarding notification. You can choose for email notification or text message (SMS). The following SMS gateways are currently available:
- Mollie - <http://www.mollie.nl>
- Spryng - <http://www.spryng.nl>
- Inetworx - <http://www.inetworx.ch>
- Clickatell - <https://www.clickatell.com>
- Mosms - <http://www.mosms.com>
- Textmarketer - <http://www.textmarketer.co.uk>
Please note: for these gateways you will need an account with sufficient credits.
Requirements¶
- Web server
- MySQL database
- PHP 5.3.7+
- PHP cURL package
- PHP PDO mysql driver
Installation¶
Install¶
Upload files¶
The first step is to upload your files to your webserver where you can reach them. You can rename the folder of the server monitor without any problems.
Run install.php¶
You can now run the install.php script located in the root dir.
The install script will guide you through setting up your configuration file and create the required database tables. If for some reason you can not generate your configuration file, you can do it manually using the steps below. Rename the config.php.sample file to config.php, then open the config.php file with a plain text editor such as Notepad. In this file you need to change the database information, which is stored using php’s define() function. To change these values correctly, only update the second parameter of the function:
define('PSM_DB_HOST', 'db_host');
define('PSM_DB_NAME', 'db_name');
define('PSM_DB_USER', 'db_user');
define('PSM_DB_PASS', 'db_user_password');
For example: to change your username you should ONLY change the ‘db_user’ part. Do NOT remove the quotes around your username as that will result in an error. After you have created the config.php, run the install.php again to create the database structure.
Configure your installation¶
Open the main page of the server monitor, by simply navigating to index.php. In the menu on the top find “Config”, it will open a page where you can change the necessary information for your tool.
Upgrade¶
For a regular upgrade, follow these steps:
- Replace all files except(!) config.php
- Navigate to install.php
- Follow the steps
- Enjoy
From 2.0¶
The structure of the project has changed quite a bit since 2.0, but if you have not made any local changes the upgrade is quite easy. The best thing to do is to replace all your current files with the new release, except for the config.inc.php file. The config file has actually been renamed since 2.0, but if you keep it there while upgrading the install script will use it to prefill your database information. The rest of the steps are identical to a regular upgrade (see above), except that you can remove the old config.inc.php file afterwards.
From 2.1¶
One of the new features introduced in 3.0 is a user authentication system. Because the users in previous versions do not have a password, after upgrading you would not be able to login. For that reason the upgrade script will ask you to create a new account during the upgrade, which you can then use to change the password for the existing accounts. If, for whatever reason this does not work, the upgrade script automatically changes the username of all existing users to their email addresses, which you could use for the forgot password screen.
Setting up a cronjob¶
In order to keep the server monitor up to date, the status updater has to run regularly. If you’re running this on a linux machine, the easiest way is to add a cronjob. If it is your own server or you have shell access and permission to open the crontab, locate the “crontab” file (usually in /etc/crontab, but depends on distro). Open the file (vi /etc/crontab), and add the following (change the paths to match your installation directories) to run it every 15 minutes:
*/15 * * * * root /usr/bin/php /var/www/html/phpservermon/cron/status.cron.php
As you can see, this line will run the status.cron.php script every 15 minutes. Change the line to suit your needs. If you do not have shell access, ask your web hosting provider to set it up for you.
The update script has been designed to prevent itself from running multiple times. It has a maximum timeout of 10 minutes. After that the script is assumed dead and the cronjob will run again. If you want to change the 10 minutes timeout, find the constant “PSM_CRON_TIMEOUT” in src/includes/psmconfig.inc.php.
Troubleshooting¶
If you have problems setting up or accessing your monitor and do not know why, enable debug mode to turn on error reporting. To enable debug mode, add the following line to your config.php file:
define('PSM_DEBUG', true);
Credits¶
Credits¶
The following people have contributed to the development of phpservermon:
- Pepijn Over <pep_at_neanderthal-technology.com>
- creator and project maintainer
- Jérôme Cabanis
- History graphs
- Date localisation
- Mobile compatibility
- Various fixes and improvements
- Perri Vardy-Mason
- Textmarketer SMS gateway
- Various fixes and improvements
- Luiz Alberto S. Ribeiro
- Bootstrap implementation
- Portuguese Brazilian translation
- Michael Greenhill
- Status page
- Andreas Ek
- Mosms SMS gateway
Translators¶
The following people have contributed to the translation of phpservermon:
- German
- Brunbaur Herbert
- French
- David Ribeiro
- Jérôme Cabanis
- Korean
- Ik-Jun
- Portuguese (Brazil)
- Luiz Alberto S. Ribeiro
- Bulgarian
- Plamen Vasilev
Vendors¶
The following libraries are being used by phpservermon:
- jqPlot <http://www.jqplot.com>
- Twitter Bootstrap <http://getbootstrap.com>
- PHP Mailer - Brent R. Matzelle
Copyright¶
Copyright (C) 2008-2014 Pepijn Over <pep_at_neanderthal-technology.com>
PHP Server Monitor is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
PHP Server Monitor is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with PHP Server Monitor. If not, see <http://www.gnu.org/licenses/>.