Skip to content
Snippets Groups Projects
Commit 397028d1 authored by Chris Hines's avatar Chris Hines
Browse files
parents 2af31e24 e1d8dc2b
No related branches found
No related tags found
1 merge request!32Simons updates
File added
#!/usr/bin/python
import sys, os, pwd
import getopt
import commands
import subprocess
STATE_OK=0
STATE_WARNING=1
check_munge=subprocess.Popen("/usr/sbin/service munge status", shell=True, stdout=subprocess.PIPE)
munge_status=check_munge.communicate()[0]
if "run" in munge_status:
print "Munge is Running"
sys.exit(STATE_OK)
else:
print "Munge is NOT Running !!"
sys.exit(STATE_WARNING)
sys.exit(STATE_OK)
---
- name: create nagios user
user: name=nagios system=yes createhome=yes home=/var/lib/nagios shell=/bin/bash
sudo: true
- name: authorize_key
authorized_key: user=nagios key="{{ monitor_pubkey }}"
sudo: true
- name: make scripts directory
file: path=/var/lib/nagios/scripts state=directory owner=nagios mode=755
sudo: true
- name: install monitor scripts
copy: dest=/var/lib/nagios/scripts/{{ item }} src=scripts/{{ item }} mode=755
with_items:
- check_load
- check_munge
sudo: true
---
- name: copy priv key
template: src={{ monitor_privkey_file }} dest=/var/lib/nagios/.ssh/id_rsa mode=600 owner=nagios
sudo: true
- name: install packages
apt: name={{ item }} state=installed
with_items:
- nagios3
- python-passlib
- python3-passlib
sudo: true
- name: configure nagios authentication
htpasswd: path=/etc/nagios3/htpasswd.users name={{ nagios_username }} password={{ nagios_password }}
sudo: true
- name: configure monitoring
template: src={{ item }}_nagios2.cfg.j2 dest=/etc/nagios3/conf.d/{{ item }}_nagios2.cfg
with_items:
- 'hostgroups'
- 'hosts'
- 'commands'
- 'services'
- 'extinfo'
sudo: true
- name: force restart
service: name=nagios3 state=restarted
sudo: true
define command {
command_name check_mount
command_line /usr/lib/nagios/plugins/check_by_ssh -H $HOSTADDRESS$ -C "/var/lib/nagios/scripts/check_mount.pl -m $ARG1$"
}
define command {
command_name check_munge
command_line /usr/lib/nagios/plugins/check_by_ssh -H $HOSTADDRESS$ -C "/var/lib/nagios/scripts/check_munge"
}
# Some generic hostgroup definitions
## A simple wildcard hostgroup
#define hostgroup {
# hostgroup_name all
# alias All Servers
# members *
# }
## A list of your Debian GNU/Linux servers
#define hostgroup {
# hostgroup_name debian-servers
# alias Debian GNU/Linux Servers
# members localhost
# }
## A list of your web servers
#define hostgroup {
# hostgroup_name http-servers
# alias HTTP servers
# members localhost
# }
## A list of your ssh-accessible servers
#define hostgroup {
# hostgroup_name ssh-servers
# alias SSH servers
# members *
# }
{% for group in groups %}
#{ % if group != "all" % }
{% set nodelist = [] %}
{% for node in groups[group] %}
{% if nodelist.append(node) %}
{% endif %}
{% endfor %}
define hostgroup {
hostgroup_name {{ group }}
members {{ nodelist|unique|join(',') }}
}
#{ % endif % }
{% endfor %}
{% set nodelist = [] %}
{% for group in groups %}
{% for node in groups[group] %}
{% if nodelist.append(node) %}
{% endif %}
{% endfor %}
{% endfor %}
{% for host in nodelist|unique %}
define host{
use generic-host
host_name {{ host }}
address {{ hostvars[host]['ansible_hostname'] }}
}
{% endfor %}
{% for service in nagios_services %}
define service {
service_description {{ service.description }}
hostgroup_name {{ service.groups|join(',') }}
check_command {{ service.command }}
use generic-service
notification_interval 0
}
{% endfor %}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment