Linode Managed and CloudFlare

Linode Staff

I have Linode Managed, but my website is behind CloudFlare. How can I get consistent and accurate alerts while also using CloudFlare?

1 Reply

Since CloudFlare uses website caching, the alerts may not always provide the most current information. In this case, in order to get accurate alerts for this monitor, you will need to use a workaround.

This can be done by utilizing cPanel's userdirs to access files from the site directly through the IP address using a link like the ones below. Please note that you may not be able to access userdir directly because cPanel might have a protection enabled for this user. You will need to disable it and also modruid using the below steps also linked here.

Security Center >> Apache mod_userdir Tweak

  • Uncheck Enable mod_userdir Protection
  • Save
  • Go to EA4 and disable/remove the Ruidmod from Apache.

Be sure to replace besthost with the name of the cPanel account username that is hosting the domain.

cPanel format
http://12.34.56.78/~besthost/cgi-bin/status.cgi

WHM format
http://12.34.56.78/~besthost/monitor.php

You will need to create the directory and change the permissions of the file before the script can be used successfully. First, put it in a new folder owned by the cPanel user and use chmod to change the permissions to 755.

mkdir /home/besthost/public_html/cgi-bin/

touch /home/besthost/public_html/cgi-bin/status.php

chown -R besthost:besthost /home/besthost/public_html/cgi-bin/

chmod -R 755 /home/besthost/public_html/cgi-bin/

You'll need to add the following shebang at the top of your php script if cPanel is using php-fpm and not php-cgi.

#!/opt/cpanel/ea-php70/root/usr/bin/php-cgi -dcgi.force_redirect=0

Use ps aux to grep for the correct php version.

ps aux | grep "php"

Here is a sample script to check the status of MySQL and httpd. You can always replace the names of these services with the names of any you would like to use. Just save this script in /home/besthost/public_html/cgi-bin/.

status.php

<?php
header ("content-type: text/plain");
if (shell_exec("pgrep 'mysqld'") != ''){
 echo "Mysqld = [running...]";
}else{
 echo "Mysqld = [down] ";
}
echo "\r\n";
if (shell_exec("pgrep 'httpd'") != ''){
 echo "Httpd = [running...]";
}else{
 echo "Httpd = [down] ";
}
?>

Then, you can add the monitor in Cloud Manager.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct