Monitoring your server resources

Through this guide, we will show you how to configure the regular sending of reports on the use of your server's hardware resources. From the data sent, our robots will monitor your server and will be able to alert you instantly if the machine is overloaded.

For the implementation of this article, we will use the Hitflow agent. This script being developed in Python, your server must have the necessary tools to execute such scripts. If this is not the case, you can adapt the installation by replacing our agent with an information collection script that you have developed yourself.

  • Summary

Add the server to your manager

The first step in setting up monitoring of your server is to generate access keys. Log in to your Hitflow account and click on the "Servers" tab in the "Monitoring" section of the navigation menu.

  1. From the server list, click on the Add Server button to display the form.
  2. First, enter the name of your server.
  3. Define the alert thresholds of the different properties of your server at which an alert will be triggered.
  4. Check the "online" alert to receive an alert when your server usage returns to normal after a period of disruption.
  5. Define the maximum waiting time allowed between two sending of a report by the server. If this time limit is exceeded, an alert will be sent indicating that the server may be unavailable.
  6. Finally, choose from the list of contacts the users who can intervene in case of an alert for this server.

By clicking on the Savebutton, you will generate the necessary elements for the installation of the agent on your server.

Installing the agent on the server

We will continue in this second step by installing the Hitflow agent on your server. In the previous step, you generated identifiers that will be used to authenticate your server when it sends status information.

Be careful not to use the same identifiers on several servers because technically there is nothing to prevent information from being sent from several servers.

Downloading Hitflow Agent

You can find the download link to our pre-configured python script from your server form under "Server Agent".

The script we have developed requires the use of the "psutil" and "uptime" libraries. You can install them using the following command: python3 -m pip install uptime psutil

Once the script has been transferred to your server, you can test its operation by executing the following command:

python3 hitflow-agent-server_5d112e7fd3f21a139310a813.py

You will see the message below appear if the script runs correctly:

{"error":0,"msg":"OK"}

To check that the sending of information has been received correctly or to have more details on the error encountered (case of an error code other than zero), go to the server report page to consult the request history in the "Data" section.

Creating a scheduled task

To complete the installation, all you have to do is create a scheduled task on your server to run the script at regular intervals.

Ubuntu system (linux)

To create a scheduled task under Ubuntu, we will open the cron tool with the command below:

sudo crontab -e

All you have to do is add a line as shown below by changing the file path and the sending interval, which is 15 minutes.

*/15 * * * * python3 /root/hitflow-agent-server_5d112e7fd3f21a139310a813.py &> /dev/null

Windows system

After you have installed the necessary software to run Python scripts on your server, open the start menu, enter the "planner" text and click on the proposed application:

Windows scheduler icon

  1. In the "General" tab, indicate the name of the task and add a comment if necessary.
  2. Choose the option "Run even if the user is not logged in".
  3. Click on the "Triggers" tab and then on the "New" button.
  4. In the trigger form, select the "Every day" option.
  5. Below check the option "Repeat the task every day" then choose the repetition frequency and define the duration to "1 day".
  6. Confirm the trigger by clicking on the "OK" button.
  7. Now open the "Actions" tab and click on the "New" button.
  8. In the "Program/script" field, specify the path of the Python executable followed by the script to be executed.
  9. Save the action by clicking on the "OK" button.
  10. Complete the task creation by confirming with the "OK" button.

Now that the task is created on your server, it only takes a few minutes to see the statistics appear on the server's report page.

Monitoring your website

With this guide, you have installed a program that automatically sends information to alert you if the server resources are overused. Now you can switch to configuring a monitoring robot for your website.