Style-check for monitoring scripts
[bottlenecks.git] / monitor / dispatch / server_ip_configure.py
1 ##############################################################################
2 # Copyright (c) 2018 Huawei Tech and others.
3 #
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
9 import fileinput
10 import re
11 import logging
12 import socket
13
14 logger = logging.getLogger(__name__)
15 ip_address = socket.gethostbyname(socket.gethostname())
16
17 for line in fileinput.input(inplace=1):
18     ip = "        Listen \"" + str(ip_address) + "\" \"25826\""
19     line = re.sub(r'.*Listen.*25826.*', r'' + str(ip), line.rstrip())
20     print(line)
21
22 for line in fileinput.input(inplace=1):
23     ip = "    URL \"http://" + str(ip_address) + ":9103/collectd-post\""
24     line = re.sub(r'.*URL.*collectd-post.*', r'' + str(ip), line.rstrip())
25     print(line)