Applies To: CLOUD VPS DEDICATED

One of the more powerful features of the Memset Advanced Monitoring is that it allows you to set up an alert to check for the presence of text on a web page. This can be used in its simplest form to check that the correct website is responding by checking that some (static) text on the normal page is being served. Should the site or server encounter an error then the normal text will be replaced with an error page, or no page at all. When the monitoring server fails to find the normal test it will cause an alert to be generated.

Text to Check

We reccomend you pick something static to check like a Phone Number or Postal Code, something that does not change often, but also something that would not be included by default on any custom error pages setup.

The example below is for a Website running a PHP script which checks that the connection to the database is functioning correctly.

To configure this, Log in to your control panel and click 'Your Services'. Next to the server you want to monitor, click 'Status' then 'Add or Modify rules'.

From there add a new rule as per the screenshot below;

Once the rule has been added click the 'Submit' button to save your changes.


Example Code for Database Status

The below example PHP code will provide a quick status page for the Database Connection, you can adapt this as required to give you the desired outputs.

Please Note: This code is provided "as is" and is not supported by Memset or the Memset Technical Support Team
<?php

// If PHP can not connect to MySQL, the script will print "Connect failed"
$dbh = @mysql_connect("127.0.0.1", "user", "password");
if (!$dbh) {
  die("Connect failed");
}
// If a query of the 'users' table fails, the script will print "Query failed"
if (!mysql_query($dbh, "select id from users limit 1")) {
  die("Query failed");
}
// If everything is OK, the script prints "OK"
echo "OK";
?>
PHP