Server monitoring for Linux(EN)

by Kuba


Posted on Wed Jan 10 13:40:00 GMT 2018


View of Cula
Server monitoring for Linux. CULA

Let’s get real… monitoring is what? Fundamental. Read our entry to find out about its benefits.

This tutorial will show you how to configure CULA and the bash script to allow CULA to monitor your server.

What you need:

  • a free CULA account :)
  • about 10 minutes to configure the basics such as the processor or memory usage on your server
  • access to a server based on Linux which has a bash console and cURL
  • basic knowledge of server admin

Think about the parameters that are of interest to you. Here, we’re going to use basic paratemters such as the CPU and memory (CPU and MEM) usage and the disk usage (DISK_USAGE) on your server. While adding a new server, CPU and MEM are generated automatically. They can be easily deleted if you do not find them necessary.

After adding a server, go to its settings. The screenshot below presents the initial view.

Each parameter has the following options:

1. active (checkbox) - when the script is generated this parameter will be taken into account.
2. id (text) - a unique value on the server identifying the parameter. Alphanumeric signs are allowed and the sign "_". Examples: cpu, free_mem, no_of_processes
3. description (text) - a description can be added to allow better identification of the parameter.
4. alarm threshold (number) - when the threshold is exceeded, CULA will send you an alert. Available when the alert is switched on (point 5).
5. alerts (checkbox) - checking the box activates email alerts (point 4).
6. removing a parameter (button) - deletes a parameter.
7. adding a parameter (button) - adds a new parameter to the list.
8. generating a bash script (button) - generates a script that is based on the above-set parameter. Take a look below to see an example.
9. generating a powershell script (button) - generates a script that is based on the above-set parameter. (this is for Windows users)

Example settings for a server:

Now the script needs to be generated so that you can run it on your server.
How do I use the generated script?
The script is as easy as it can be to make sure you will understand how to use it. It’ll send the monitored parameters to CULA. It’ll happen every 120 seconds. More frequent tries will be rejected by the server. Take a look at representative server parameters. The generated script should look like this:

Each generated function in the script should return the value of the parameter. In each generated function you need to implement (in #TO_IMPLEMENT) the code responsible for getting the value of the parameter. You can use the examples attached to the script. The name of the function should not be changed. For our parameter under the id = ’cpu’ in CULA’s server settings, the name of the function will follow this pattern: function collect_cpu(), identically for the id = ’disk_usage’: function collect_disk_usage(). The value must be above zero. The floating-point values are allowed. It’s important for the returning of the values to be included in the last line with the echo command, for example echo 0. The representative implementation of the function that returns the value of the memory available on the server:

function collect_mem_total() {
total_mem=$(free -m | grep ^Mem | tr -s ’ ’ | cut -d ’ ’ -f 2)
echo $total_mem
}

An example of a correctly configured script:

PAY ATTENTION
The script needs to be activated at the starting of a server. It’ll allow the monitoring to start immediately.


If you have configured everything according to this tutorial, after logging into CULA and selecting your server (the right-hand panel) you’ll see a dashboard with the selected parameters.

Don’t hesitate to get in touch with us with comments, questions or feedback via our chat or contact@cula.io

You can create a free CULA account here
Cula, Katowice, Poland