Announcement

Collapse
No announcement yet.

Suggestion: cpanel "addon" to send notification emails to customers when LVE limit exceeded.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Suggestion: cpanel "addon" to send notification emails to customers when LVE limit exceeded.

    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 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!

  • #2
    It makes sense, and something we plan to start working rather soon.

    Comment


    • #3
      It would be very helpfull ! Any info about this feature ?

      Comment


      • #4
        Did this ever happen?

        Comment


        • #5
          Not yet.

          Comment


          • #6
            Ok, looking forward to this one Igor. =)

            Comment


            • #7
              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

              Comment


              • #8
                +1 for this feature, its really important, thanks.

                Comment


                • #9
                  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! :-)

                  Comment


                  • #10
                    Great idea. Would be nice. Just do not want clients spammed
                    Hostking | Since 2013 | Web Hosting | WordPress Web Hosting

                    Comment


                    • #11
                      Im 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 shouldnt be *too* difficult to implement, as its 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.

                      Comment


                      • #12
                        +1 this request.

                        For me, it wouldnt matter to me if the notification were sent only to root@ or if it were sent to the customers email address(es) found in /var/cpanel/users/ or both. But it definitely would be useful to have.

                        M

                        Comment


                        • #13
                          Count me as a +1 on this one. Im with Scott.

                          Comment


                          • #14
                            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.

                            Comment


                            • #15
                              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). Its a php script (because Im 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...

                              Code:
                              //---------------
                              
                              $email_fr om = "support@yourcompany.com";
                              
                              $email_cc = "admin@yourcompany.com";  // Leave blank if not needed.
                              
                              $email_subject = "Hosting account resources exceeded";
                              
                              $lveinfo_period = 24; // Number of hours for the lveinfo to report.
                              
                              //---------------
                              Code:
                              //==================================================================================================
                              
                              $lveinfo_cmd = /usr/sbin/lveinfo --period=".$lveinfo_period.h" --by-fault="any" --display-username --csv --limit=999;
                              Code:
                              // lveinfo --period="2h" --by-fault="any" --display-username --limit=999
                              Code:
                              // 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.
                              Code:
                              // For each user in the list…
                              
                              foreach ($lve_cmd_output as $line) {
                              Code:
                               //echo "$line
                              ";
                              Code:
                               // Put the line into usable variables.
                              Code:
                               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);
                              Code:
                               //echo "$ID,$aCPU,$mCPU,$lCPU,$aEP,$mEP,$lEP,$aVMem,$mVMem,$lVMem,$VMemF,$EPf,$aPMem,$mPMem,$lPMem,$aNproc,$mNproc,$lNproc,$PMemF,$NprocF,$aIO,$mIO,$lIO 
                              ";
                              Code:
                               $message = "** ATTENTION **
                              
                              Your "".$ID."" web hosting account exceeded one or more of its resource limits within the last ".$lveinfo_period." hours:
                              
                              ";
                              Code:
                               // Determine what had a fault and/or exceeded a limit and make a message for user.
                              Code:
                               // 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.
                              ";
                              
                              }
                              Code:
                               // 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.
                              ";
                              
                              }
                              Code:
                               // 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.
                              ";
                              
                              }
                              Code:
                               // 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.
                              ";
                              
                              }
                              Code:
                               // 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.
                              ";
                              
                              }
                              Code:
                               // 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. 
                              ";
                              
                              }
                              Code:
                               //
                              
                              // Number of Inodes
                              
                              //
                              Code:
                               // Get users contact email(s) fr om cpanel account info.
                              Code:
                               $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]);
                              
                              }
                              Code:
                               }
                              Code:
                               // Only send emails to our direct customers... not resellers accounts. Cloudlinux does not (yet) have a way to effectively upsell resellers to higher resource lim it plans.
                              
                              if ($RESELLER == "reselleruser") {
                              Code:
                                // Add some helpful instructions for more info.
                              
                              $message = $message . "
                              To view full details about your web hosting accounts 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.
                              
                              ";
                              
                              $message = $message . "     http://".$WEBSITE."/cpanel
                              
                              ";
                              
                              $message = $message. "If your account is regularly exceeding its 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.
                              
                              ";
                              
                              $message = $message. "Sincerely,
                              
                              Your Friendly Web Hosting Support Team
                              
                              ";
                              Code:
                                // Send user the notification.
                              Code:
                                $email_to = $CONTACTEMAIL;
                              
                              if (rtrim($CONTACTEMAIL2) != "") {  $email_to = $email_to.",".$CONTACTEMAIL2; }
                              Code:
                                $headers = "From: ".$email_from;
                              
                              if (rtrim($send_cc) != "") {  $headers =  $headers. "
                              " ."CC: ".$email_cc; }
                              Code:
                                mail($email_to,$email_subject,$message,$headers);
                              Code:
                                echo $message;
                              Code:
                               }
                              Code:
                              }
                              Code:
                              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";
                              
                              }
                              Code:
                              ?>
                              I hope that is helpful to you. Perhaps if youre interested I can convert this into a simple WHM plugin that allows you to set the template, period, what limits to check, and if resellers should be notified about their over-lim it accounts.

                              Comment

                              Working...
                              X