The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

The easiest way to get CPU, RAM usage and Mail Queue

Discussion in 'General Discussion' started by Ovidiu Sopa, Jun 19, 2017.

  1. Ovidiu Sopa

    Ovidiu Sopa Registered

    Joined:
    Jun 19, 2017
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Sibiu, Romania
    cPanel Access Level:
    Root Administrator
    Hello everyone,

    I want to build an "Home Dashboard" website, hosted on a local RaspberryPi (actually BananaPi as I want to add a SATA drive to it), the webpage will be displayed on a few 10" ( cheap) tablets, one in my house, and one in my office/workshop.

    On this dashboard next to weather, a few google calendars (mine, wife, kids), and other informations I want to display the Mail Queue size of each server (I have 2 cPanel dedicated servers, one in Romania and one in USA) and also CPU and RAM usage, but mail queue is the most important as from time to time I have clients that either get a virus or they didn't update their website (it happen in 99% of the cases on wordpress websites) and the result was they send lot's of spam mails. I lowered the limit of "Maximum percentage of failed or deferred messages a domain may send per hour." to 5 emails to have as few as possible sent emails .. but I want a way to quickly notice when the queue is large and fix their problem or suspend the account.

    I want to get some ideas on what is the quickest/easiest way to fetch that information, either the BananaPi to connect to the server (at least every 5 minutes) .. connect either directly to cPanel (through API or ...) or if there is a way to place that information on a webpage hosted on the server, and access that page directly to fetch the information, or save the information in a database on the server and than the bananaPi to connect to that database to read the last row.

    If it will be easier to have my hosting server push the information in my local database, this can be an option too, I have a fixed IP address, an will open the mysql port in my router if it's needed.

    Any suggestions are welcome

    Here's a screenshot of the webpage that displays all the LAN devices (the ideea is to display if there are new -unknown- devices, or if some devices that must be online 24/7, are not )

    - Removed -
     
    #1 Ovidiu Sopa, Jun 19, 2017
    Last edited by a moderator: Jun 19, 2017
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    37,086
    Likes Received:
    1,288
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello,

    The following WHM API 1 function is available if you want to obtain the server's load average:

    WHM API 1 Functions - loadavg - Software Development Kit - cPanel Documentation

    You may also find this WHM API 1 function helpful:

    WHM API 1 Functions - servicestatus - Software Development Kit - cPanel Documentation

    As far as fetching the number of emails in the mail queue, you could develop your script to provide the output from the following bash command:

    Code:
    exim -bpc
    This will output the number of emails currently queued.

    Thank you.
     
  3. Ovidiu Sopa

    Ovidiu Sopa Registered

    Joined:
    Jun 19, 2017
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Sibiu, Romania
    cPanel Access Level:
    Root Administrator
    Thank you for the reply.

    As for the API I haven't found how I will authentificate to the server before requesting the loadavg using JSON.

    But if I won't be able to get the queue using the API I think I will focus on a script , as you showed me the command exim -bpc , I could use some other commands to get CPU and RAM usage, and save the informations in either a local database on the server, or directly in the remote database, I have in my office.

    I think a single script setup in the cron should be ok for what I want.
     
  4. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    37,086
    Likes Received:
    1,288
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
Loading...

Share This Page