Ansible Scripts for Automated Deployment of Server-Device Monitors

You can find here Ansible script templates that you can use for bulk adding Server-Device monitors on your Linux server.

The scripts use Monitis API for adding monitors.

The scripts allow adding the following Server-Device monitors:

and the following uptime monitor:

monitors added by ansible

The scripts will also install Smart Agent for Linux if not installed.

By default, the monitors will be added on a new tab, with the name of the tab being the name of your Linux agent, preceded by “NEW_”.

To run the scripts, follow these steps:

1. Install Ansible on your Linux OS (you can refer to Ansible documentation here for details:

2. Download the your_ansible zip file from here.

3. Extract and copy the your_ansible folder to /etc/ansible/.

4. Go to /etc/ansible/your_ansible/hosts and find there the hosts file, where under the [MonitisMonitoring] you should type the IP address of the server that you are going to monitor.

ip for server to add monitors

5. In /etc/ansible/your_ansible/host_vars/ find a file named IP_address. Change the name of the file to be the IP address of your server that you are going to monitor.

file to configure server monitoring

6. You can edit this file to make any change to the monitoring parameters.

monitoring parameters in ansible scripts

If you want to setup monitoring for several hosts you should:

  • In /etc/ansible/your_ansible/hosts under [MonitisMonitoring] enter the IP addresses of all hosts that you want to monitor.
  • Create files in /etc/ansible/your_ansible/host_vars/ with the names being the IP addresses of the hosts that you want to monitor. For each file, copy the contents of the IP_Address file and make your changes as necessary to the parameters there in the files. E.g. you can:
    • Change the API key and Secret Key of the account.
    • Provide the Agent Key to set up the Agent.
    • Provide the agent name and installation path, etc.
    • Set parameters for the monitors to be installed.

7. In /etc/ansible/your_ansible/ you can find the site.yml file containing the Ansible roles.

You can edit this file to only run the roles you want. For example, if you want to add only the CPU monitor you can comment out all those roles except the add_CPU_monitor role and the set_global_vars_and_add_tab role, which should always be active.

.yml file containing the ansible roles

Note: in case you already have one or more of the monitors added on your agent you should comment out those monitors’ roles. Otherwise when trying to install a monitor that already exists the script execution will be aborted.

8. After that in the /etc/ansible/your_ansible/ path enter this command to run Ansible:

ansible-playbook -i hosts site.yml

run ansible scripts