Merge branch 'master' of mathias-kettner.de:omd
[omd.git] / packages / omd / CORE.hook
blobcebacbdebfe70ad4e73f393c669bf81d1ec26fad
1 #!/bin/bash
3 # Alias: Monitoring core
4 # Menu: Basic
5 # Description:
6 # Here you can choose your monitoring core to run. Currently available
7 # are Nagios and Shinken. You also can decide to run no monitoring core in
8 # this instance. This can be useful for instances running a GUI such
9 # as Check_MK Multisite or Thruk which can connect to other monitoring
10 # sites via Livestatus.
12 # Helper function that creates a symlink only if the
13 # target of the link exists
14 make_link ()
16 rel_dir=${2%/*}
17 if [ -e "$rel_dir/$1" ] ; then
18 ln -sfn "$1" "$2"
22 case "$1" in
23 default)
24 if [ -e $OMD_ROOT/bin/nagios ] ; then echo "nagios"
25 elif [ -e $OMD_ROOT/bin/icinga ] ; then echo "icinga"
26 elif [ -e $OMD_ROOT/bin/shinken-arbiter ] ; then echo "shinken"
27 else echo "none"
30 choices)
31 [ ! -e $OMD_ROOT/bin/nagios ] || echo "nagios: Nagios"
32 [ ! -e $OMD_ROOT/bin/icinga ] || echo "icinga: Icinga"
33 [ ! -e $OMD_ROOT/bin/shinken-arbiter ] || echo "shinken: Shinken"
34 echo "none: No monitoring core"
36 set)
37 # cleanup the former selection
38 if [ "$2" != "nagios" ]
39 then
40 rm -f $OMD_ROOT/etc/apache/conf.d/nagios.conf
41 rm -f $OMD_ROOT/etc/apache/conf.d/icinga.conf
43 if [ "$2" != "shinken" ]
44 then
45 rm -f $OMD_ROOT/etc/apache/conf.d/shinken.conf
46 rm -f $OMD_ROOT/etc/apache/conf.d/nagios.conf
47 rm -f $OMD_ROOT/etc/apache/conf.d/icinga.conf
49 rm -f $OMD_ROOT/etc/init.d/core
50 # now setup the new selection
51 if [ "$2" == "nagios" ]
52 then
53 make_link ../../nagios/apache.conf $OMD_ROOT/etc/apache/conf.d/nagios.conf
54 make_link ../../icinga/apache.conf $OMD_ROOT/etc/apache/conf.d/icinga.conf
55 make_link nagios $OMD_ROOT/etc/init.d/core
56 # Beware: do not change the number of spaces before '='. Otherwise we will get severe
57 # merge conflicts at 'omd mv'
58 sed -i -e "s|^nagios_binary[[:space:]]*=.*$|nagios_binary = '$OMD_ROOT/bin/$2'|" $OMD_ROOT/etc/check_mk/defaults
59 sed -i -e "s|^nagios_config_file[[:space:]]*=.*$|nagios_config_file = '$OMD_ROOT/tmp/$2/$2.cfg'|" $OMD_ROOT/etc/check_mk/defaults
60 sed -i -e "s|^nagios_url[[:space:]]*=.*$|nagios_url = '/$OMD_SITE/$2'|" $OMD_ROOT/etc/check_mk/defaults
61 sed -i -e "s|^nagios_cgi_url[[:space:]]*=.*$|nagios_cgi_url = '/$OMD_SITE/$2/cgi-bin'|" $OMD_ROOT/etc/check_mk/defaults
62 elif [ "$2" == "icinga" ]
63 then
64 make_link ../../nagios/apache.conf $OMD_ROOT/etc/apache/conf.d/nagios.conf
65 make_link ../../icinga/apache.conf $OMD_ROOT/etc/apache/conf.d/icinga.conf
66 make_link icinga $OMD_ROOT/etc/init.d/core
67 sed -i -e "s|^nagios_binary[[:space:]]*=.*$|nagios_binary = '$OMD_ROOT/bin/$2'|" $OMD_ROOT/etc/check_mk/defaults
68 sed -i -e "s|^nagios_config_file[[:space:]]*=.*$|nagios_config_file = '$OMD_ROOT/tmp/$2/$2.cfg'|" $OMD_ROOT/etc/check_mk/defaults
69 sed -i -e "s|^nagios_url[[:space:]]*=.*$|nagios_url = '/$OMD_SITE/$2'|" $OMD_ROOT/etc/check_mk/defaults
70 sed -i -e "s|^nagios_cgi_url[[:space:]]*=.*$|nagios_cgi_url = '/$OMD_SITE/$2/cgi-bin'|" $OMD_ROOT/etc/check_mk/defaults
71 elif [ "$2" == "shinken" ]
72 then
73 # Thruk is the default interface, but classic is possible
74 make_link ../../shinken/apache-cgi.conf $OMD_ROOT/etc/apache/conf.d/nagios.conf
75 make_link ../../icinga/apache.conf $OMD_ROOT/etc/apache/conf.d/icinga.conf
76 make_link ../../shinken/apache.conf $OMD_ROOT/etc/apache/conf.d/shinken.conf
77 make_link shinken $OMD_ROOT/etc/init.d/core
78 else
79 rm -f $OMD_ROOT/etc/apache/conf.d/nagios.conf
80 rm -f $OMD_ROOT/etc/apache/conf.d/icinga.conf
81 rm -f $OMD_ROOT/etc/apache/conf.d/shinken.conf
84 esac