move squid autodetection only to configuration file
paulfantom committed
Jul 6, 2016 at 10:06 UTC
81d56ff19e405752b18bcc974c4d29b91c88f51b
2 files changed
+44
-14
conf.d/python.d/squid.conf
new
+29
@@ -0,0 +1,29 @@
1
+# Example configuration of mysql.chart.py
2
+# YAML format
3
+
4
+update_every: 1
5
+
6
+tcp1:
7
+ name : 'local'
8
+ host: : 'localhost'
9
+ port : 3128
10
+ request : 'cache_object://localhost:3128/counters'
11
+
12
+tcp2:
13
+ name : 'local'
14
+ host: : 'localhost'
15
+ port : 8080
16
+ request : 'cache_object://localhost:3128/counters'
17
+
18
+tcp3:
19
+ name : 'local'
20
+ host: : 'localhost'
21
+ port : 3128
22
+ request : 'squid-internal-mgr//counters'
23
+
24
+tcp4:
25
+ name : 'local'
26
+ host: : 'localhost'
27
+ port : 8080
28
+ request : 'squid-internal-mgr//counters'
29
+
python.d/squid.chart.py
+15
-14
@@ -83,20 +83,21 @@ class Service(NetSocketService):
83
if not req.endswith(" HTTP/1.0\r\n\r\n"):
84
req += " HTTP/1.0\r\n\r\n"
85
self.request = req.encode()
86
-
87
- # autodetect squid
88
- if type(self.port) is tuple:
89
- ports = self.port
90
- for port in ports:
91
- self.port = port
92
- urls = ["cache_object://" + self.host + ":" + str(port) + "/counters",
93
- "/squid-internal-mgr/counters"]
94
- for url in urls:
95
- tmp = "GET " + url + " HTTP/1.0\r\n\r\n"
96
- self.request = tmp.encode()
97
- if self._get_data() is not None:
98
- return True
99
- else:
86
+ #
87
+ # # autodetect squid
88
+ # if type(self.port) is tuple:
89
+ # ports = self.port
90
+ # for port in ports:
91
+ # self.port = port
92
+ # urls = ["cache_object://" + self.host + ":" + str(port) + "/counters",
93
+ # "/squid-internal-mgr/counters"]
94
+ # for url in urls:
95
+ # tmp = "GET " + url + " HTTP/1.0\r\n\r\n"
96
+ # self.request = tmp.encode()
97
+ # if self._get_data() is not None:
98
+ # return True
99
+ # else:
100
+ if True:
101
if self._get_data() is not None:
102
return True
103
else: