library/roles/smartgears/resource_checker_se_plugin: Add the nagios check to monitor the resources status.

This commit is contained in:
Andrea Dell'Amico 2017-06-02 15:34:32 +02:00
parent 0a378caa58
commit 167cb17a88
4 changed files with 43 additions and 0 deletions

View File

@ -8,3 +8,5 @@ resource_checker_se_plugin_name: 'resource-checker-se-plugin'
resource_checker_se_plugin_extension: 'jar'
resource_checker_se_plugin_classifier: 'jar-with-dependencies'
resource_checker_se_plugin_file: '{{ resource_checker_se_plugin_name }}-{{ resource_checker_se_plugin_version }}-jar-with-dependencies.{{ resource_checker_se_plugin_extension }}'
resource_checker_nagios_nrpe: True

View File

@ -12,3 +12,16 @@
become_user: '{{ smartgears_user }}'
when: resource_checker_se_plugin_install
tags: [ 'smartgears', 'resource_checker_se', 'tomcat' ]
- block:
- name: Install the resource checker nagios check
template: src=check_missing_resources.sh.j2 dest={{ nagios_plugdir | default('/usr/lib/nagios/plugins') }}/check_missing_resources mode=0755
- name: Install the nrpe job to run the check
template: src=resource_checker_nrpe.cfg.j2 dest=/etc/nagios/nrpe.d/resource_checker_nrpe.cfg owner=root group=root mode=0444
notify: Reload NRPE server
become: False
when: resource_checker_se_plugin_install and resource_checker_nagios_nrpe
tags: [ 'smartgears', 'resource_checker_se', 'nagios' ]

View File

@ -0,0 +1,26 @@
#!/bin/bash
COMMON_SH_LIB={{ nagios_isti_plugdir }}/check_library.sh
RESOURCES_STATUS_FILE={{ smartgears_user_home }}/missing_resources/identifiers
if [ -f $COMMON_SH_LIB ] ; then
. $COMMON_SH_LIB
else
echo "UNKNOWN - Library file $COMMON_SH_LIB does not exist"
exit $NAGIOS_UNKNOWN
fi
if [ ! -f $RESOURCES_STATUS_FILE ] ; then
echo "UNKNOWN - File $RESOURCES_STATUS_FILE does not exist"
exit $NAGIOS_UNKNOWN
fi
RESOURCES_DATA=$( cat $RESOURCES_STATUS_FILE )
if [ "$RESOURCES_DATA" == "none" ] ; then
echo "OK - No resources are missing"
exit $NAGIOS_OK
else
echo "CRITICAL - Missing resources: $RESOURCES_DATA"
exit $NAGIOS_CRITICAL
fi

View File

@ -0,0 +1,2 @@
command[nrpe_resource_checker]={{ nagios_plugdir | default('/usr/lib/nagios/plugins') }}/check_missing_resources