Running PHP Server Monitor for FREE… Azure

Maybe you have heard of the great monitoring tool, called PHP Server Monitor, it’s a great FREE tool to monitor your services from the outside, requirements are simple:

  • PHP 5.3.7+
  • PHP packages: cURL, MySQL
  • MySQL Database

And it can be downloaded here:

Well where does the free Azure part come in?

Azure uses serviceplans, and one of the is free:

App Service Plans | Microsoft Azure

Discover the capabilities and limits available within App Service Plans.

This free plan, can be used with a WebApp, so let get thing done in Azure:

Login to the Azure Portal and choose to create a new WebApp:


The App name you chosse, will be the URL for your free website, so choose wisely, it will tell you, if the name you try to pick, is occupied:



Then click “App service plan/location” and choose “Create New”


Fill in the name and click “Pricing Tier”


Choose the free plan “F1” and click Apply.

Click “OK”

Click “Create” and wait for Azure to deploy the new site.
(Remember only Windows can run on the free plan, not Linux, but PHP is still supported!)

Check if things are working:

Open browser and ty pe the URL you just made:

Then go and add free SSL to your site with redirect and TLS 1.2:

No need to press save or OK, its done automatically.

Now we need to setup FTP access:


Fill in the fields and press save, head to the “overview” pane, left side:

Here you have the infos.

Connect to to the FTP site with your favorite FTP client and upload to the wwwroot (/site/wwwroot) directory, the files you downloaded from PHP Server Monitor (extracted).

Next, as PHP Server Monitor use MySQL, we will enable the In the portal:

Press “ON” and “MySQL general log ON” and SAVE and you have MySQL features 🙂

Now comes the tricky part, Azure do no provide direct access for MySQL, and furthermore, they use a non standard MYSQL port, so we need to fetch theese informations from Azure, this can be done by modifying the config.php of PSM to the following:

$servername = "";
$username = "";
$password = "";
$dbname = "";

// Parsing connnection string
foreach ($_SERVER as $key => $value) {
if (strpos($key, "MYSQLCONNSTR_") !== 0) {

$servername = preg_replace("/^.*Data Source=(.+?);.*$/", "\\1", $value);
$dbname = preg_replace("/^.*Database=(.+?);.*$/", "\\1", $value);
$username = preg_replace("/^.*User Id=(.+?);.*$/", "\\1", $value);
$password = preg_replace("/^.*Password=(.+?)$/", "\\1", $value);

define('PSM_DB_PREFIX', 'monitor_');
define('PSM_DB_USER', $username);
define('PSM_DB_PASS', $password);
define('PSM_DB_NAME', $dbname);
define('PSM_DB_HOST', $servername);
define('PSM_DB_PORT', '');
define('PSM_BASE_URL', '');

define('PSM_DEBUG', false);

// IP addresses that may run the CRON
$PSM_CRON_ALLOW = array("","yyy.yyy.yyy.yyy");

The custom MySQL port number, will be delivered in the $servername in the format “hostname:port” so when port changes your system will auto-adapt, therefore is PSM_DB_PORT blank thus needed to be stated for PSM, else it will not work 🙂

Go ahead and test it out, visit:

You should see this:

Press “Let’s go”

After you have typed the credentials you want to use with PSM, you should see this.

Continue the setup, login to the portal and you get this page:


So now PSM is working……..not quite!

We need to setup a cron job! Else nothing will run and check your monitored systems!

There is Azure Webjobs, who actually can do this, you can also set it up, it works, but efter some hours, it’s stopping, claiming that your website have to have “Always-on” enabled for Webjobs to run, hey, let’s go and enable Always-On:

Dammit, that’s not supported in the Free Service Plan, why aren’t whole Azure free 🙂

So what to do now, we need something to visit this URL every 5 minutes:

I have searched the net, you can run it locally, but when your net goes down, nothin would activate the poller, so i found this one, which is ALSO free 🙂

Go create an account and set it up:

But as we not want everyone to activate our cron, remember the settings in config.php?

// IP addresses that may run the CRON
$PSM_CRON_ALLOW = array(“”,”yyy.yyy.yyy.yyy”);

Go to

Here we find this:

So add this IP to your CRON statement in config.php.

Remember, PSM will throw this error message at you, if the IP received is wrong :

But this is to get rid of bots, “hackers” a.s.o.

Check the logs at cron-job for it:

All is good 🙂

Now go into PSM and setup the servers / services you want to monitor and choose your notification services (email, sms and pushover)

test it out, if it works now, you are all done and have a nice and free monitor solution….running in AZURE 🙂



1 Comment

  1. Eric Schümann

    Hi Martin,
    thank you for this tutorial.
    In the section for the cron job, it should say:
    define(‘PSM_CRON_ALLOW’, array(“”, “yyy.yyy.yyy.yyy”, “zzz.zzz.zzz.zzz”));

    Best, Eric


Leave a Comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.