Posted on Wed Aug 01 14:04:01 GMT 2018
If you monitor your server resources you would like to be sure that your metrics are always collected. Our APM scripts are designed the way it is the easiest for our users to try it. One just needs to execute the downloaded script and results are immediately present in CULA.
However, simple execution of the script does not guarantee the infinite running (after the system reboot or crash). We decided to write this simple tutorial post in order to help our users who might be not super-familiar with system administration.
Let's start with downloading Cula APM Script. If your server happens not to have any GUI and Browser, you can do this little trick: Just login to CULA and go to your server settings. Then open your browser's developer tools (F12 for most of the modern browsers) and choose the "NETWORK" tab. After that click the "download bash script button". Then you should be able to right-click the request and copy as a bash's CURL command (see the screenshot below). Paste the command and add:
> cula_script.sh(or any other name you'd like to use. Then run:
chmod +x cula_script.shin order to make your script executable.
The most popular way of scheduling the task is to use CRON. In order to use Cula APM Script with CRON properly, we will need to make some adjustments.
In CRON, the task is scheduled every some specified time (CRON expression). However, our default Cula APM Script is wrapped in the infinite loop. So let's get rid of it (please notice hashtags (#) which need to be put in front of 4 lines, see screenshot below).
crontab -eand press enter, which is going to open the default editor (likely VI). For those who don't know how to VI:
*/2 * * * * /path/to/script.sh(run every 2 minutes - according to Cula rate-limiting)
:wqand hit Enter
Other way of ensuring your script is running after reboot or crash is using the supervisord. This small tool checks if your desired script is up and in the opposite case supervisord starts it.
In order to use supervisor you have to install it using your favourite package manager. You can find a nice tutorial here.
Once the supervisord is installed, we need to configure it to take care of our Cula APM Script. In order to do that, we need to edit
supervisord.conf file, usually located somewhere nearby
/etc/init.d/supervisord.conf. See the example, basic configuration on the screenshot.
WARNING! The supervisord way should use Cula APM Script WITH loop.
After editing the config file, you need to restart the service:
service supervisord restartIn case of any difficulties, questions, suggestions, do not hestitate to contact us via chat, email or in the comment section below.