Adding CT Scripts to a Zabbix Proxy

Some of the templates used by Zabbix need to be installed on the Zabbix proxy to make the checks work. These can be downloaded automatically from the main server.

To get them download and update automatically every hour, follow these step. Note that this process will overwrite any scripts written locally on the proxy. To get them added to the server so they are available to you and everyone else, contact one of the admins.

Log in to your zabbix proxy and elevate to the root user.

Once logged in, create and open the script that will download and handle the scripts

touch /usr/sbin/getCTzabbixscripts.sh
chmod +x /usr/sbin/getCTzabbixscripts.sh
nano /usr/sbin/getCTzabbixscripts.sh

Add the following commands to the script, and save/exit.

#!/bin/bash

#Remove all the current scripts and zip folder
rm -rf /usr/lib/zabbix/externalscripts/*.*
rm /usr/lib/zabbix/externalscripts/last_run*

#Get the latest zip folder from the server and save it in the scripts folder
wget\
 https://monitoring.ctlondon.com/zabbix/publicscripts/publicscripts.tar.gz -P /usr/lib/zabbix/externalscripts

#Extract them into the external scripts folder
tar -xvzf /usr/lib/zabbix/externalscripts/publicscripts.tar.gz -C /usr/lib/zabbix/externalscripts/

Now we need to add this script to CRON so it is executed every hour. Open the crontab for editing…

crontab -e

And add this line to the end of the file.

02 * * * * /usr/sbin/getCTzabbixscripts.sh

Running the Script Manually

If you want to pull the lastest scripts manually, log into your proxy, elevate to root and run:

./usr/sbin/getCTzabbixscripts.sh

The download contains a timestamped file which will show you last time the folder of scripts was updated on the server.


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *