5 # Provides: monitor-nagios
6 # Required-Start: mysqld sendmail
8 # Default-Stop: 0 1 2 6
9 # Description: Setup requirements for monitor to work with nagios
11 # Stephen Soltesz <soltesz@cs.princeton.edu>
12 # Copyright (C) 2010 The Trustees of Princeton University
17 for f in /etc/plc.d/functions /etc/plc.d/monitor.functions /etc/planetlab/plc_config ; do
18 if [ -f /etc/plc.d/functions ] ; then
23 # NOTE: expect that mysqld is already started.
27 if ! ( mysqladmin ping &> /dev/null ) ; then
28 echo "mysqld is not running; cannot continue; exit..."
32 # if it's a fresh install, there is no root passwd.
33 if ( mysqladmin -u root create nagios &> /dev/null ) ; then
34 cat <<EOF > /tmp/nagios.priv
35 GRANT ALL PRIVILEGES ON nagios.* TO ndouser@localhost IDENTIFIED BY 'ndopassword';
37 cat /tmp/nagios.priv | mysql -u root
39 cd /usr/share/doc/ndoutils-mysql-*/db
40 perl ./installdb -u ndouser -p ndopassword -d nagios
43 if ! ( grep -q /usr/lib/nagios/brokers/ndomod.so /etc/nagios/nagios.cfg ) ; then
44 echo "broker_module=/usr/lib/nagios/brokers/ndomod.so config_file=/etc/nagios/ndomod.cfg" >> /etc/nagios/nagios.cfg
47 if ( chkconfig --list ndo2db | grep -q 3:off ) ; then
48 /sbin/chkconfig ndo2db on
49 /sbin/service ndo2db start
51 #/sbin/service nagios restart
53 ## set passwd for /etc/nagios/passwd
54 if ! ( grep nagiosadmin /etc/nagios/passwd &> /dev/null ) ; then
55 htpasswd -b -c /etc/nagios/passwd nagiosadmin nagiospassword
58 # disable /etc/httpd/conf.d/nagios.conf restriction to only 127.0.0.1
59 if ( grep -q -E "^service_check_timeout=60" /etc/nagios/nagios.cfg ) ; then
60 # NOTE: PCU checks can take several minutes due to timeouts and internal delays
61 sed -i -e 's/service_check_timeout=.*/service_check_timeout=150/g' /etc/nagios/nagios.cfg
62 # NOTE: All 'action' commands are in the notification category.
63 # Complex actions such as 'repair.py' may take several minutes.
64 sed -i -e 's/notification_timeout=.*/notification_timeout=240/g' /etc/nagios/nagios.cfg
67 # disable /etc/httpd/conf.d/nagios.conf restriction to only 127.0.0.1
68 if ( grep -q -E "^ deny from all" /etc/httpd/conf.d/nagios.conf ) ; then
69 sed -i -e 's/ deny from all/ #allow from all/g' /etc/httpd/conf.d/nagios.conf
70 sed -i -e 's/ order deny,allow/ #order allow,deny/g' /etc/httpd/conf.d/nagios.conf
71 sed -i -e 's/ allow from 127.0.0.1/ /g' /etc/httpd/conf.d/nagios.conf
74 if [ ! -f /etc/nagios/objects/plc.cfg ] ; then
75 /usr/share/monitor/nagios/plc_hosts_to_nagios.py > /etc/nagios/objects/plc.cfg
78 if [ ! -f /etc/nagios/objects/plcusers.cfg ] ; then
79 /usr/share/monitor/nagios/plc_users_to_nagios.py > /etc/nagios/objects/plcusers.cfg
83 if ! ( grep -q "cfg_file=/etc/nagios/objects/plcnodes.cfg" /etc/nagios/nagios.cfg ) ; then
84 echo "cfg_file=/etc/nagios/objects/plcnodes.cfg" >> /etc/nagios/nagios.cfg
85 echo "cfg_file=/etc/nagios/objects/plcusers.cfg" >> /etc/nagios/nagios.cfg
88 if ( chkconfig --list sendmail | grep -q 3:off ) ; then
89 /sbin/chkconfig sendmail on
90 /sbin/service sendmail start
93 # change /etc/nagios/objects/contacts.cfg to some real email addr
94 # change /etc/nagios/nagios.cfg admin_email to some real email addr
99 # See how we were called.
105 echo "not implemented"
108 echo "not implemented"
111 echo "not implemented"
114 echo $"Usage: $0 {start|stop|status|condrestart|restart}"