check_logfiles: 3.7.5.1
[omd.git] / packages / nagvis / NAGVIS_URLS.hook
blobc0f83ca42d8f7531a65e09a70344d437d77f462d
1 #!/bin/bash
3 # Alias: NagVis linked Web GUI
4 # Menu: Addons
5 # Description:
6 # When clicking on NagVis map icons the user is redirected to another
7 # Web-GUI. By default this is the classic Nagios webinterface. With
8 # this switch the targeted Web-GUI can be changed.
10 # Makes it possible to switch all the links from NagVis
11 # to the default Web GUI to the choosen GUI or a defined
12 # other one.
14 case "$1" in
15 default)
16 echo "nagios"
18 choices)
19 echo "nagios: Classic Nagios webinterface"
20 echo "check_mk: The Check_MK's Multisite GUI"
21 echo "thruk: Thruk Monitoring Webinterface"
22 echo "none: Use NagVis default behaviour"
24 set)
25 # Skip this hook when NagVis configuration directory does not exist
26 if [ ! -d $OMD_ROOT/etc/nagvis ]; then
27 exit 0
30 CFG_FILE=$OMD_ROOT/etc/nagvis/conf.d/urls.ini.php
31 GUI=$2
33 # When a user sets NAGVIS_URL to "none", previous config files are
34 # deleted and the hook finishes. NagVis will use it's defaults or the
35 # configuration which has been made in the NagVis configuration manually.
36 if [ "$GUI" == "none" ]; then
37 if [ -f $CFG_FILE ]; then
38 rm $CFG_FILE
40 exit 0
43 # Previous OMD versions offered the option "auto", which is not possible
44 # anymore. Behave like the default value has been selected.
45 if [ "$GUI" == "auto" ]; then
46 GUI=nagios
49 if [ ! -d $OMD_ROOT/etc/nagvis/conf.d ]; then
50 mkdir -p $OMD_ROOT/etc/nagvis/conf.d
53 if [ "$GUI" == "check_mk" ]; then
54 HTMLCGI="/$OMD_SITE/check_mk"
55 HOSTURL="[htmlcgi]/view.py?view_name=host&site=&host=[host_name]"
56 SERVICEURL="[htmlcgi]/view.py?view_name=service&site=&host=[host_name]&service=[service_description]"
57 HOSTGROUPURL="[htmlcgi]/view.py?view_name=hostgroup&site=&hostgroup=[hostgroup_name]"
58 SERVICEGROUPURL="[htmlcgi]/view.py?view_name=servicegroup&site=&servicegroup=[servicegroup_name]"
59 ACTION_URLS="host_downtime_url=\"\"\nhost_ack_url=\"\"\nservice_downtime_url=\"\"\nservice_ack_url=\"\"\n"
60 else
61 HTMLCGI="/$OMD_SITE/$GUI/cgi-bin"
62 HOSTURL="[htmlcgi]/status.cgi?host=[host_name]"
63 HOSTGROUPURL="[htmlcgi]/status.cgi?hostgroup=[hostgroup_name]"
64 SERVICEURL="[htmlcgi]/extinfo.cgi?type=2&host=[host_name]&service=[service_description]"
65 SERVICEGROUPURL="[htmlcgi]/status.cgi?servicegroup=[servicegroup_name]&style=detail"
66 ACTION_URLS=""
69 # Now write the NagVis configuration. This is a dedicated file so we can easily write it out here
70 cat > $CFG_FILE <<EOF
71 ; <?php exit(1); ?>
72 ; Do not edit this file. Your changes will be overwritten.
73 ; This file is controlled by the OMD hook NAGVIS_URLS.
75 ; Written by OMD hook NAGVIS_URLS at $(date).
76 [paths]
77 htmlcgi="$HTMLCGI"
79 [defaults]
80 hosturl="$HOSTURL"
81 hostgroupurl="$HOSTGROUPURL"
82 serviceurl="$SERVICEURL"
83 servicegroupurl="$SERVICEGROUPURL"
84 EOF
85 echo -ne "$ACTION_URLS" >> $CFG_FILE
88 esac