-
Notifications
You must be signed in to change notification settings - Fork 34
/
INFLUXDB_HTTP_TCP_PORT.hook
executable file
·48 lines (45 loc) · 1.93 KB
/
INFLUXDB_HTTP_TCP_PORT.hook
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/bash
# Alias: TCP port the influxdb admin daemon listens on
# Menu: Addons
# Description:
# If you enabled influxdb, this is the
# listening http port.
case "$1" in
default)
echo 127.0.0.1:8086
;;
choices)
echo "[a-zA-Z0-9\.\-:]+"
;;
set)
BEFORE=$2
EXTRACTED_ADDRESS=$(echo $2 | perl -lne 'print $1 if /^([a-zA-Z0-9\.\-]*:)?([0-9]+)/')
EXTRACTED_PORT=$(echo $2 | perl -lne 'print $2 if /([a-zA-Z0-9\.\-]+:)?([0-9]+)/')
PORT=$($OMD_ROOT/lib/omd/port_is_used INFLUXDB_HTTP_TCP_PORT $EXTRACTED_PORT)
if [ "$EXTRACTED_ADDRESS" = ":" ] ; then
EXTRACTED_ADDRESS="0.0.0.0:"
fi
if [ "$EXTRACTED_ADDRESS" = "" ] ; then
EXTRACTED_ADDRESS="127.0.0.1:"
fi
LOCAL_ADDRESS=$EXTRACTED_ADDRESS
if [ "$EXTRACTED_ADDRESS" = "0.0.0.0:" ] ; then
LOCAL_ADDRESS="127.0.0.1:"
fi
sed -e '/^\[http\]/,/^\[/{s/bind-address = .*$/bind-address = "'$EXTRACTED_ADDRESS$PORT'"/}' -i $OMD_ROOT/etc/influxdb/influxdb.conf
sed -e '/^\[InfluxDB \"nagflux\"\]/,/^\[/{s%^\s*Address = "http.*$%\tAddress = "http://'$LOCAL_ADDRESS$PORT'"%}' -i $OMD_ROOT/etc/nagflux/config.gcfg
sed -e 's%^url = "http.*/query?\(.*$\)%url = "http://'$LOCAL_ADDRESS$PORT'/query?\1%' -i $OMD_ROOT/etc/histou/histou.ini
if [ -e $OMD_ROOT/etc/dataScryer/config.ini ]; then
sed -i $OMD_ROOT/etc/dataScryer/config.ini \
-e 's%^Address_Read = http.*$%Address_Read = http://'$LOCAL_ADDRESS$PORT'%' \
-e 's%^Address_Write = http.*$%Address_Write = http://'$LOCAL_ADDRESS$PORT'%'
fi
if [ "$BEFORE" != "$EXTRACTED_ADDRESS$PORT" ] ; then
echo "$EXTRACTED_ADDRESS$PORT"
fi
sed -e 's%^\*url:.*$% url: "http://'$EXTRACTED_ADDRESS$PORT'%' -i $OMD_ROOT/etc/influxdb/grafana_datasources.yml
;;
depends)
[ "$CONFIG_INFLUXDB" = "on" ]
;;
esac