9bfb12ceeb535e005daba9e236f1f22901c1580d
[bottlenecks.git] / monitor / client_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 import requests
14 from oslo_serialization import jsonutils
15
16 logger = logging.getLogger(__name__)
17 ip_address = socket.gethostbyname(socket.gethostname())
18
19 for line in fileinput.input(inplace=1):
20     ip = "        Server \"" + str(ip_address)  +"\" \"25826\""
21     line = re.sub(r'.*Server.*25826.*', r''+str(ip), line.rstrip())
22     print(line)
23
24 for line in fileinput.input(inplace=1):
25     ip =     "    URL \"http://"+str(ip_address)+":9103/collectd-post\""
26     line = re.sub(r'.*URL.*collectd-post.*', r''+str(ip), line.rstrip())
27     print(line)