forked from evolix/ansible-roles
tomcat-instance: deploy nagios check
This commit is contained in:
parent
f748b54df4
commit
52b643a1a1
|
@ -4,6 +4,7 @@
|
|||
register: tomcat_instance_stat
|
||||
|
||||
- include: tomcat.yml
|
||||
- include: nagios.yml
|
||||
- include: check.yml
|
||||
- include: user.yml
|
||||
- include: systemd.yml
|
||||
|
|
20
tomcat-instance/tasks/nagios.yml
Normal file
20
tomcat-instance/tasks/nagios.yml
Normal 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
|
18
tomcat-instance/templates/check_tomcat_instance.sh.j2
Normal file
18
tomcat-instance/templates/check_tomcat_instance.sh.j2
Normal 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
|
Loading…
Reference in a new issue