tomcat-instance: deploy nagios check

This commit is contained in:
Victor LABORIE 2017-01-04 16:00:58 +01:00
parent f748b54df4
commit 52b643a1a1
3 changed files with 39 additions and 0 deletions

View File

@ -4,6 +4,7 @@
register: tomcat_instance_stat
- include: tomcat.yml
- include: nagios.yml
- include: check.yml
- include: user.yml
- include: systemd.yml

View File

@ -0,0 +1,20 @@
---
- name: Intall monitorings plugins
apt:
name: monitoring-plugins
state: present
- name: Mount /usr in rw
command: mount -o remount,rw /usr warn=no
changed_when: False
- name: Create Nagios plugins dir
file:
path: '/usr/local/lib/nagios/plugins'
state: directory
- name: Copy Tomcat instance check
template:
src: 'templates/check_tomcat_instance.sh.j2'
dest: '/usr/local/lib/nagios/plugins/check_tomcat_instance.sh'
mode: 0755

View File

@ -0,0 +1,18 @@
#!/bin/bash
TOMCAT_ROOT='{{ tomcat_instance_root }}'
alert=0
for instance in $(ls $TOMCAT_ROOT); do
port=$(id -u $instance)
if [ -h ${TOMCAT_ROOT}/${instance}/.config/systemd/user/default.target.wants/tomcat.service ]; then
echo -n "$instance ($port) : "
/usr/lib/nagios/plugins/check_tcp -p $port
ret=$?
if [ $ret != 0 ]; then
alert=$ret
fi
fi
done
exit $alert