Suggestion: cpanel "addon" to send notification emails to customers when LVE limit exceeded.
Forum
  1. Forums
  2. CloudLinux and Control Panels
  3. CloudLinux and cPanel
  1. Host Provider
  2. Thursday, 16 February 2012
  3.  Subscribe via email
Hello,

Is it possible to create an addon for cpanel that would send a notification email to the customer (cpanel contact email) if their account exceeds any of its LVE limits?

For example, if customer exceeds their CPU limit... often the customer will have no idea this has occured. However, they might receive complaints fr om their website visitors that their website is slow and not working properly... and then they will blame us because they think the server is poorly managed or too much load, etc.

(Of course, they could easiliy see that their website was cpu-limited by logging into cpanel \"Resource Usage\" area... but most customers don\'t even think about that.)

It is the same problem when a customer exceeds their disk space or bandwidth, etc. In this case, they contact us to complain their site is not working and we must explain how to login to cpanel and look at the usage stats...

This is ok.. but the customer is now already upset at us, even though we are not at fault. I do not like to give our customers *any* reason to be upset with us, even if we did nothing actually wrong and we are not at fault.

Often, it is very helpful for the customer to receive a pro-active notification fr om cpanel system that they are exceeding their disk space or bandwidth, etc. This way, they are aware that their website has a problem, and they can do something about it. So when they contact us, it is not because they are already upset (wrongly) and want us to FIX IT RIGHT NOW! Instead, they contact us for help, and it is an opportunity we have to assist them without any conflict, and even to upsell them to higher hosting plans.

So what if the LVE limitation system of Cloud Linux were able to generate an email notification to the user to inform them their website is using too much resources and was limited recently?

For example... once per day (unless disabled by customer), they would receive a notification that their website was limited within the last 24 hours.

This could be a seperate cpanel cron job that runs daily or every x hours (like bandwidth stats updater) and checks the lve-stats log for this customer to see if any limit was reached.

So on the cpanel plugin page for cloud linux, we would have this new field:

Send email notification when website exceeds any ehecked limit below within the previous 24 hours?

[ ] CPU
[ ] Entry Processes
[ ] Memory


And then this daily cloud linux cron job would check if each notification option is enabled. So for example, if \"CPU\" is enabled, then check the lve-stats log to see if their website was slowed down within the last 24 hours because of high cpu usage. If so, then send notification to customer, with a link to the Resource Usage page, so they can easily login and look by just clicking a link in the email.

Same thing if customer has enabled notifications for Memory or Entry Processes.

The cron would run once per day only (or whatever time is configured by admin), since it is not reasonable to send notifications as they occur.

I hope that makes sense?

The idea behind this feature request is that it would really help to tell customers if their website has been lim ited BEFORE they come and complain to us about the server having problems. It is a good sales tool for us, but most importantly, it shows the customer that the problem is NOT with our server being slow... but that their website is being lim ited because of too much usage.

Thanks!
Rate this post:
  1. 16.02.2012 21:02:08
  2. # 1
Igor Seletskiy Accepted Answer
Posts: 1201
Joined: 09.02.2010
0
Votes
Undo
It makes sense, and something we plan to start working rather soon.
  1. 23.07.2012 05:07:22
  2. # 2
Wojciech Babicz Accepted Answer
Posts: 5
Joined: 21.03.2012
0
Votes
Undo
It would be very helpfull ! Any info about this feature ?
  1. 07.07.2013 16:07:59
  2. # 3
Tommy K Accepted Answer
Posts: 14
Joined: 03.07.2013
0
Votes
Undo
Did this ever happen?
  1. 07.07.2013 20:07:55
  2. # 4
Igor Seletskiy Accepted Answer
Posts: 1201
Joined: 09.02.2010
0
Votes
Undo
Not yet.
  1. 08.07.2013 02:07:49
  2. # 5
Tommy K Accepted Answer
Posts: 14
Joined: 03.07.2013
0
Votes
Undo
Ok, looking forward to this one Igor. =)
  1. 05.10.2013 01:10:55
  2. # 6
Scott Neader Accepted Answer
Posts: 7
Joined: 05.10.2013
0
Votes
Undo
Hi Igor.  We talked about this feature, and a similar one (to alert the system administrator, rather than the customer), during the cPanel 2013 Conference.  I understand you are working on this feature, which is fantastic.  Just adding my two cents here about how much this feature would be appreciated.

- Scott
  1. 16.10.2013 13:10:50
  2. # 7
Xanubi Accepted Answer
Posts: 12
Joined: 21.06.2010
0
Votes
Undo
+1 for this feature, it\'s really important, thanks.
  1. 31.12.2013 18:12:59
  2. # 8
Sol 2010 Accepted Answer
Posts: 3
Joined: 31.12.2013
0
Votes
Undo
I would also love this feature. I am new to CloudLinux and still testing the waters, but so far it seems very nice, stable and an excellent tool.

But the one thing it is missing is notifications.  I would like to see an admin notification also, so that we can pro-actively manage or scale a user if there is a need.

As "Host Provider" mentioned above - "I do not like to give our customers *any* reason to be upset with us..."

Notifications would be a fantastic addition.

Look forward to hearing about an update :-)

Happy New Year!  :-)
  1. 04.01.2014 15:01:31
  2. # 9
Hostking Accepted Answer
Posts: 38
Joined: 07.11.2012
0
Votes
Undo
Great idea. Would be nice. Just do not want client\'s spammed :)
  1. 07.01.2014 15:01:22
  2. # 10
Host Provider Accepted Answer
Posts: 48
Joined: 31.01.2012
0
Votes
Undo
I'm not sure what is the delay with this feature request, as I think this would only add value to CloudLinux.  Perhaps it is too difficult or confusing to implement, but I thought I made the feature description/outline pretty clear.

At the very least... it would be nice to have a daily summary email sent to reseller and/or website owner (cpanel contact) for cloudlinux faults.  So at least the website owner (or reseller) knows there are problems with their website(s)...   This shouldn't be *too* difficult to implement, as it's essentially just summarizing LVE status for each user via cront, and emailing cpanel contact address if fault > 0.

This would be better than nothing.

Thanks.
  1. 07.01.2014 16:01:59
  2. # 11
Mike Tindor Accepted Answer
Posts: 35
Joined: 08.11.2013
0
Votes
Undo
+1 this request.

For me, it wouldn't matter to me if the notification were sent only to [email protected] or if it were sent to the customer's email address(es) found in /var/cpanel/users/ or both.   But it definitely would be useful to have.

M
  1. 07.01.2014 18:01:47
  2. # 12
Infopro Accepted Answer
Posts: 1
Joined: 09.07.2013
0
Votes
Undo
Count me as a +1 on this one. I\'m with Scott.


:)
  1. 08.01.2014 21:01:25
  2. # 13
Igor Seletskiy Accepted Answer
Posts: 1201
Joined: 09.02.2010
0
Votes
Undo
I think we will abandon plans to redo our stats and implement notifications system using existing stats instead. This will be something we can do much faster.
We can improve it later on based on new statistics system.
  1. 09.01.2014 12:01:55
  2. # 14
Host Provider Accepted Answer
Posts: 48
Joined: 31.01.2012
0
Votes
Undo
Hello,

OK, I spent a bit of time and created a simple script to send a notification/warning email to any customer who exceeds their cloudlinux limit(s).  It's a php script (because I'm an even worse bash and python programmer), so it should be run by PHP on your system.  Set it to run once per day by cron, etc...


//---------------
$email_fr om = "[email protected]";
$email_cc = "[email protected]";  // Leave blank if not needed.
$email_subject = "Hosting account resources exceeded";
$lveinfo_period = 24; // Number of hours for the lveinfo to report.
//---------------
//==================================================================================================
$lveinfo_cmd = '/usr/sbin/lveinfo --period="'.$lveinfo_period.'h" --by-fault="any" --display-username --csv --limit=999';
// lveinfo --period="2h" --by-fault="any" --display-username --limit=999
// Get list of users who have had faults or exceeded limits.
exec($lveinfo_cmd, $lve_cmd_output);
array_shift($lve_cmd_output); // Remove 1st line of output array, since it is just header info.
// For each user in the list…
foreach ($lve_cmd_output as $line) {
 //echo "$line\n";
 // Put the line into usable variables.
 list($ID,$aCPU,$mCPU,$lCPU,$aEP,$mEP,$lEP,$aVMem,$mVMem,$lVMem,$VMemF,$EPf,$aPMem,$mPMem,$lPMem,$aNproc,$mNproc,$lNproc,$PMemF,$NprocF,$aIO,$mIO,$lIO) = explode(",", $line);
 //echo "$ID,$aCPU,$mCPU,$lCPU,$aEP,$mEP,$lEP,$aVMem,$mVMem,$lVMem,$VMemF,$EPf,$aPMem,$mPMem,$lPMem,$aNproc,$mNproc,$lNproc,$PMemF,$NprocF,$aIO,$mIO,$lIO \n";
 $message = "** ATTENTION **\n\nYour \"".$ID."\" web hosting account exceeded one or more of its resource limits within the last ".$lveinfo_period." hours:\n\n";
 // Determine what had a fault and/or exceeded a limit and make a message for user.
 // CPU
 if ( $mCPU >= $lCPU ) {
   $message = $message . "- Exceeded the CPU limit of $lCPU% of total server CPU. Your website was forced to load slower to reduce its CPU usage.\n";
 }
 // Concurrent Connections
 if ( $EPf >> 0 ) {
   $message = $message . "- Exceeded the maximum of $lEP concurrent website connections. Your website was not available $EPf times because of this problem.\n";
 }
 // Virtual Memory
 if ( $VMemF >> 0 ) {
   $message = $message . "- Exceeded the ".displayFileSize($lVMem)." virtual memory limit. Your website was not available $VMemF times because of this problem.\n";
 }
 // Physical Memory
 if ( $PMemF >> 0 ) {
   $message = $message . "- Exceeded the ".displayFileSize($lPMem)." physical memory limit. Your website was not available $PMemF times because of this problem.\n";
 }
 // Number of Processes
 if ( $NprocF >> 0 ) {
   $message = $message . "- Exceeded the maximum of $mNproc total account processes. Your website was not available $NprocF times because of this problem.\n";
 }
 // Disk IO
 if ( $mIO >> $lIO ) {
   $message = $message . "- Exceeded the maximum disk io rate. You used ".displayFileSize($mIO)." of ".displayFileSize($lIO).". The disk io speed for your account was slowed as a result of this problem. \n";
 }
 //
 // Number of Inodes
 //
 // Get user's contact email(s) fr om cpanel account info.
 $cpanel_account_info = file("/var/cpanel/users/".$ID);
 array_shift($cpanel_account_info); // Remove 1st two lines.
 array_shift($cpanel_account_info);
 foreach ($cpanel_account_info as $line) {
  if (strpos($line,'CONTACTEMAIL=') !== false) { // Does the string contain first contact email?
   $values = explode("=", $line);
   $CONTACTEMAIL = rtrim($values[1]);
  }
  elseif (strpos($line,'CONTACTEMAIL2=') !== false) { // Does the string contain second contact email?
   $values = explode("=", $line);
   $CONTACTEMAIL2 = rtrim($values[1]);
  }
  elseif (strpos($line,'DNS=') !== false) {
   $values = explode("=", $line);
   $WEBSITE = rtrim($values[1]);
  }
  elseif (strpos($line,'OWNER=') !== false) {
   $values = explode("=", $line);
   $RESELLER = rtrim($values[1]);
  }
 }
 // Only send emails to our direct customers... not reseller's accounts. Cloudlinux does not (yet) have a way to effectively upsell resellers to higher resource lim it plans.
 if ($RESELLER == "reselleruser") {
  // Add some helpful instructions for more info.
  $message = $message . "\nTo view full details about your web hosting account's resource usage, including the time of each incident listed above, please click the link below and log into your cpanel hosting control panel, then click the \"Resource Usage\" link under the \"Logs and Statistics\" section.\n\n";
  $message = $message . "     http://".$WEBSITE."/cpanel\n\n";
  $message = $message. "If your account is regularly exceeding it's available resources, please consider upgrading to a higher level hosting plan that includes more resources.  If you have any questions or need help with anything, just reply to this email and let us know.\n\n";
  $message = $message. "Sincerely,\n\nYour Friendly Web Hosting Support Team\n\n";
  // Send user the notification.
  $email_to = $CONTACTEMAIL;
  if (rtrim($CONTACTEMAIL2) != "") {  $email_to = $email_to.",".$CONTACTEMAIL2; }
  $headers = "From: ".$email_from;
  if (rtrim($send_cc) != "") {  $headers =  $headers. "\r\n" ."CC: ".$email_cc; }
  mail($email_to,$email_subject,$message,$headers);
  echo $message;
 }
}
function displayFileSize($size,$unit="") {
  if( (!$unit && $size >= 1<<30) || $unit == "GB")
    return number_format($size/(1<<30))."GB";
  if( (!$unit && $size >= 1<<20) || $unit == "MB")
    return number_format($size/(1<<20))."MB";
  if( (!$unit && $size >= 1<<10) || $unit == "KB")
    return number_format($size/(1<<10))."KB";
  return number_format($size)." bytes";
}
?>


I hope that is helpful to you.  Perhaps if you're interested I can convert this into a simple WHM plugin that allows you to set the template, period, what limits to check, and if reseller's should be notified about their over-lim it accounts.
  1. 10.01.2014 03:01:00
  2. # 15
Pioneer Websites Accepted Answer
Posts: 3
Joined: 10.01.2014
0
Votes
Undo
Excellent script, thanks for sharing. This very same need is what I've wanted since beginning with CloudLinux and I finally began searching for it today. In our case, we'd prefer only admin gets the alert so if you do proceed to a WHM plugin please consider that as an option.

N.B. The script has a space in one variable at the top: $email_fr om
Also mismatching CODE tags have found their way into the second section.

For those who aren't sure: Save the script to a folder, and add it to the crontab using CLI:
$ crontab -e
like this:
0 5 * * * /usr/bin/php -q /yourfolder/lvealert.php
and it runs once a day at 5am.
  1. 11.01.2014 13:01:36
  2. # 16
Igor Seletskiy Accepted Answer
Posts: 1201
Joined: 09.02.2010
0
Votes
Undo
Anything missing? http://ow.ly/i/4glsN
  1. 11.01.2014 14:01:26
  2. # 17
Host Provider Accepted Answer
Posts: 48
Joined: 31.01.2012
0
Votes
Undo

Anything missing? http://ow.ly/i/4glsN



Instead of giving them only a few time options, let them specify whatever they want, like this:

Run notifications every [  x  ]   [ minutes/hours/days]

So in the first box they can put a number.  In the 2nd box they can choose minutes or hours or days as the time.  So this way, they can choose any timing they want.  :)

Also might want to have a link that shows the template that will be used, or at least where the template can be manually edited. 
  1. 11.01.2014 15:01:01
  2. # 18
Pioneer Websites Accepted Answer
Posts: 3
Joined: 10.01.2014
0
Votes
Undo
Looks great Igor, thanks.

+1 for Host Providers suggestions.

If it\'s all the same, may as well add check boxes for \'type of fault\' notification and even \'threshold\', like the current stats filter.
  1. 11.01.2014 22:01:03
  2. # 19
Scott Neader Accepted Answer
Posts: 7
Joined: 05.10.2013
0
Votes
Undo
Agreed with Host Provider and Pioneer:
  1. Please allow for our own notification schedule (XX minutes/hours/days).
  2. Please let us choose which fault types and thresholds will trigger a notification.
  3. Please allow for the email templates to be edited.
Thanks very much for this, Igor!!  Even if we do not get any of the above options, I will still be very happy to have notifications!

- Scott
  1. 12.01.2014 05:01:56
  2. # 20
Igor Seletskiy Accepted Answer
Posts: 1201
Joined: 09.02.2010
0
Votes
Undo
What would be the reason to have threshold? Why not notify a customer, even if his site failed just once?
  • Page :
  • 1
  • 2


There are no replies made for this post yet.
Be one of the first to reply to this post!
Guest
Submit Your Response
Upload files or images for this discussion by clicking on the upload button below. Supports gif,jpg,png,zip,rar,pdf
• Insert • Remove Upload Files (Maximum File Size: 2 MB)
Captcha
To protect the site from bots and unauthorized scripts, we require that you enter the captcha codes below before posting your question.