We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[mcache] report `listen_disable_num`
I propose to report `listen_disable_num` value from Memcached statistics. It's of much value when diagnosing connection errors, etc. [memcached Wiki](https://code.google.com/p/memcached/wiki/Timeouts) recommends consulting this value at the first when troubleshooting timeouts. So it would make sense to monitor the increase of such events.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `checks.d/mcache.py`
Content:
```
1 # 3rd party
2 import memcache
3 
4 # project
5 from checks import AgentCheck
6 
7 # Ref: http://code.sixapart.com/svn/memcached/trunk/server/doc/protocol.txt
8 # Name              Type     Meaning
9 # ----------------------------------
10 # pid               32u      Process id of this server process
11 # uptime            32u      Number of seconds this server has been running
12 # time              32u      current UNIX time according to the server
13 # version           string   Version string of this server
14 # pointer_size      32       Default size of pointers on the host OS
15 #                            (generally 32 or 64)
16 # rusage_user       32u:32u  Accumulated user time for this process
17 #                            (seconds:microseconds)
18 # rusage_system     32u:32u  Accumulated system time for this process
19 #                            (seconds:microseconds)
20 # curr_items        32u      Current number of items stored by the server
21 # total_items       32u      Total number of items stored by this server
22 #                            ever since it started
23 # bytes             64u      Current number of bytes used by this server
24 #                            to store items
25 # curr_connections  32u      Number of open connections
26 # total_connections 32u      Total number of connections opened since
27 #                            the server started running
28 # connection_structures 32u  Number of connection structures allocated
29 #                            by the server
30 # cmd_get           64u      Cumulative number of retrieval requests
31 # cmd_set           64u      Cumulative number of storage requests
32 # get_hits          64u      Number of keys that have been requested and
33 #                            found present
34 # get_misses        64u      Number of items that have been requested
35 #                            and not found
36 # delete_misses     64u      Number of deletions reqs for missing keys
37 # delete_hits       64u      Number of deletion reqs resulting in
38 #                            an item being removed.
39 # evictions         64u      Number of valid items removed from cache
40 #                            to free memory for new items
41 # bytes_read        64u      Total number of bytes read by this server
42 #                            from network
43 # bytes_written     64u      Total number of bytes sent by this server to
44 #                            network
45 # limit_maxbytes    32u      Number of bytes this server is allowed to
46 #                            use for storage.
47 # threads           32u      Number of worker threads requested.
48 #                            (see doc/threads.txt)
49 #     >>> mc.get_stats()
50 # [('127.0.0.1:11211 (1)', {'pid': '2301', 'total_items': '2',
51 # 'uptime': '80', 'listen_disabled_num': '0', 'version': '1.2.8',
52 # 'limit_maxbytes': '67108864', 'rusage_user': '0.002532',
53 # 'bytes_read': '51', 'accepting_conns': '1', 'rusage_system':
54 # '0.007445', 'cmd_get': '0', 'curr_connections': '4', 'threads': '2',
55 # 'total_connections': '5', 'cmd_set': '2', 'curr_items': '0',
56 # 'get_misses': '0', 'cmd_flush': '0', 'evictions': '0', 'bytes': '0',
57 # 'connection_structures': '5', 'bytes_written': '25', 'time':
58 # '1306364220', 'pointer_size': '64', 'get_hits': '0'})]
59 
60 # For Membase it gets worse
61 # http://www.couchbase.org/wiki/display/membase/Membase+Statistics
62 # https://github.com/membase/ep-engine/blob/master/docs/stats.org
63 
64 
65 class Memcache(AgentCheck):
66 
67     SOURCE_TYPE_NAME = 'memcached'
68 
69     DEFAULT_PORT = 11211
70 
71     GAUGES = [
72         "total_items",
73         "curr_items",
74         "limit_maxbytes",
75         "uptime",
76         "bytes",
77         "curr_connections",
78         "connection_structures",
79         "threads",
80         "pointer_size"
81     ]
82 
83     RATES = [
84         "rusage_user",
85         "rusage_system",
86         "cmd_get",
87         "cmd_set",
88         "cmd_flush",
89         "get_hits",
90         "get_misses",
91         "delete_misses",
92         "delete_hits",
93         "evictions",
94         "bytes_read",
95         "bytes_written",
96         "cas_misses",
97         "cas_hits",
98         "cas_badval",
99         "total_connections"
100     ]
101 
102     SERVICE_CHECK = 'memcache.can_connect'
103 
104     def get_library_versions(self):
105         return {"memcache": memcache.__version__}
106 
107     def _get_metrics(self, server, port, tags):
108         mc = None  # client
109         service_check_tags = ["host:%s" % server, "port:%s" % port]
110         try:
111             self.log.debug("Connecting to %s:%s tags:%s", server, port, tags)
112             mc = memcache.Client(["%s:%s" % (server, port)])
113             raw_stats = mc.get_stats()
114 
115             assert len(raw_stats) == 1 and len(raw_stats[0]) == 2,\
116                 "Malformed response: %s" % raw_stats
117 
118 
119             # Access the dict
120             stats = raw_stats[0][1]
121             for metric in stats:
122                 # Check if metric is a gauge or rate
123                 if metric in self.GAUGES:
124                     our_metric = self.normalize(metric.lower(), 'memcache')
125                     self.gauge(our_metric, float(stats[metric]), tags=tags)
126 
127                 # Tweak the name if it's a rate so that we don't use the exact
128                 # same metric name as the memcache documentation
129                 if metric in self.RATES:
130                     our_metric = self.normalize(
131                         "{0}_rate".format(metric.lower()), 'memcache')
132                     self.rate(our_metric, float(stats[metric]), tags=tags)
133 
134             # calculate some metrics based on other metrics.
135             # stats should be present, but wrap in try/except
136             # and log an exception just in case.
137             try:
138                 self.gauge(
139                     "memcache.get_hit_percent",
140                     100.0 * float(stats["get_hits"]) / float(stats["cmd_get"]),
141                     tags=tags,
142                 )
143             except ZeroDivisionError:
144                 pass
145 
146             try:
147                 self.gauge(
148                     "memcache.fill_percent",
149                     100.0 * float(stats["bytes"]) / float(stats["limit_maxbytes"]),
150                     tags=tags,
151                 )
152             except ZeroDivisionError:
153                 pass
154 
155             try:
156                 self.gauge(
157                     "memcache.avg_item_size",
158                     float(stats["bytes"]) / float(stats["curr_items"]),
159                     tags=tags,
160                 )
161             except ZeroDivisionError:
162                 pass
163 
164             uptime = stats.get("uptime", 0)
165             self.service_check(
166                 self.SERVICE_CHECK, AgentCheck.OK,
167                 tags=service_check_tags,
168                 message="Server has been up for %s seconds" % uptime)
169         except AssertionError:
170             self.service_check(
171                 self.SERVICE_CHECK, AgentCheck.CRITICAL,
172                 tags=service_check_tags,
173                 message="Unable to fetch stats from server")
174             raise Exception(
175                 "Unable to retrieve stats from memcache instance: {0}:{1}."
176                 "Please check your configuration".format(server, port))
177 
178         if mc is not None:
179             mc.disconnect_all()
180             self.log.debug("Disconnected from memcached")
181         del mc
182 
183     def check(self, instance):
184         socket = instance.get('socket')
185         server = instance.get('url')
186         if not server and not socket:
187             raise Exception('Either "url" or "socket" must be configured')
188 
189         if socket:
190             server = 'unix'
191             port = socket
192         else:
193             port = int(instance.get('port', self.DEFAULT_PORT))
194         custom_tags = instance.get('tags') or []
195 
196         tags = ["url:{0}:{1}".format(server, port)] + custom_tags
197 
198         self._get_metrics(server, port, tags)
199
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/checks.d/mcache.py b/checks.d/mcache.py
--- a/checks.d/mcache.py
+++ b/checks.d/mcache.py
@@ -46,6 +46,8 @@
 #                            use for storage.
 # threads           32u      Number of worker threads requested.
 #                            (see doc/threads.txt)
+# listen_disabled_num 32u    How many times the server has reached maxconns
+#                            (see https://code.google.com/p/memcached/wiki/Timeouts)
 #     >>> mc.get_stats()
 # [('127.0.0.1:11211 (1)', {'pid': '2301', 'total_items': '2',
 # 'uptime': '80', 'listen_disabled_num': '0', 'version': '1.2.8',
@@ -96,7 +98,8 @@
         "cas_misses",
         "cas_hits",
         "cas_badval",
-        "total_connections"
+        "total_connections",
+        "listen_disabled_num"
     ]
 
     SERVICE_CHECK = 'memcache.can_connect'

{"golden_diff": "diff --git a/checks.d/mcache.py b/checks.d/mcache.py\n--- a/checks.d/mcache.py\n+++ b/checks.d/mcache.py\n@@ -46,6 +46,8 @@\n #                            use for storage.\n # threads           32u      Number of worker threads requested.\n #                            (see doc/threads.txt)\n+# listen_disabled_num 32u    How many times the server has reached maxconns\n+#                            (see https://code.google.com/p/memcached/wiki/Timeouts)\n #     >>> mc.get_stats()\n # [('127.0.0.1:11211 (1)', {'pid': '2301', 'total_items': '2',\n # 'uptime': '80', 'listen_disabled_num': '0', 'version': '1.2.8',\n@@ -96,7 +98,8 @@\n         \"cas_misses\",\n         \"cas_hits\",\n         \"cas_badval\",\n-        \"total_connections\"\n+        \"total_connections\",\n+        \"listen_disabled_num\"\n     ]\n \n     SERVICE_CHECK = 'memcache.can_connect'\n", "issue": "[mcache] report `listen_disable_num`\nI propose to report `listen_disable_num` value from Memcached statistics. It's of much value when diagnosing connection errors, etc. [memcached Wiki](https://code.google.com/p/memcached/wiki/Timeouts) recommends consulting this value at the first when troubleshooting timeouts. So it would make sense to monitor the increase of such events.\n\n", "before_files": [{"content": "# 3rd party\nimport memcache\n\n# project\nfrom checks import AgentCheck\n\n# Ref: http://code.sixapart.com/svn/memcached/trunk/server/doc/protocol.txt\n# Name              Type     Meaning\n# ----------------------------------\n# pid               32u      Process id of this server process\n# uptime            32u      Number of seconds this server has been running\n# time              32u      current UNIX time according to the server\n# version           string   Version string of this server\n# pointer_size      32       Default size of pointers on the host OS\n#                            (generally 32 or 64)\n# rusage_user       32u:32u  Accumulated user time for this process\n#                            (seconds:microseconds)\n# rusage_system     32u:32u  Accumulated system time for this process\n#                            (seconds:microseconds)\n# curr_items        32u      Current number of items stored by the server\n# total_items       32u      Total number of items stored by this server\n#                            ever since it started\n# bytes             64u      Current number of bytes used by this server\n#                            to store items\n# curr_connections  32u      Number of open connections\n# total_connections 32u      Total number of connections opened since\n#                            the server started running\n# connection_structures 32u  Number of connection structures allocated\n#                            by the server\n# cmd_get           64u      Cumulative number of retrieval requests\n# cmd_set           64u      Cumulative number of storage requests\n# get_hits          64u      Number of keys that have been requested and\n#                            found present\n# get_misses        64u      Number of items that have been requested\n#                            and not found\n# delete_misses     64u      Number of deletions reqs for missing keys\n# delete_hits       64u      Number of deletion reqs resulting in\n#                            an item being removed.\n# evictions         64u      Number of valid items removed from cache\n#                            to free memory for new items\n# bytes_read        64u      Total number of bytes read by this server\n#                            from network\n# bytes_written     64u      Total number of bytes sent by this server to\n#                            network\n# limit_maxbytes    32u      Number of bytes this server is allowed to\n#                            use for storage.\n# threads           32u      Number of worker threads requested.\n#                            (see doc/threads.txt)\n#     >>> mc.get_stats()\n# [('127.0.0.1:11211 (1)', {'pid': '2301', 'total_items': '2',\n# 'uptime': '80', 'listen_disabled_num': '0', 'version': '1.2.8',\n# 'limit_maxbytes': '67108864', 'rusage_user': '0.002532',\n# 'bytes_read': '51', 'accepting_conns': '1', 'rusage_system':\n# '0.007445', 'cmd_get': '0', 'curr_connections': '4', 'threads': '2',\n# 'total_connections': '5', 'cmd_set': '2', 'curr_items': '0',\n# 'get_misses': '0', 'cmd_flush': '0', 'evictions': '0', 'bytes': '0',\n# 'connection_structures': '5', 'bytes_written': '25', 'time':\n# '1306364220', 'pointer_size': '64', 'get_hits': '0'})]\n\n# For Membase it gets worse\n# http://www.couchbase.org/wiki/display/membase/Membase+Statistics\n# https://github.com/membase/ep-engine/blob/master/docs/stats.org\n\n\nclass Memcache(AgentCheck):\n\n    SOURCE_TYPE_NAME = 'memcached'\n\n    DEFAULT_PORT = 11211\n\n    GAUGES = [\n        \"total_items\",\n        \"curr_items\",\n        \"limit_maxbytes\",\n        \"uptime\",\n        \"bytes\",\n        \"curr_connections\",\n        \"connection_structures\",\n        \"threads\",\n        \"pointer_size\"\n    ]\n\n    RATES = [\n        \"rusage_user\",\n        \"rusage_system\",\n        \"cmd_get\",\n        \"cmd_set\",\n        \"cmd_flush\",\n        \"get_hits\",\n        \"get_misses\",\n        \"delete_misses\",\n        \"delete_hits\",\n        \"evictions\",\n        \"bytes_read\",\n        \"bytes_written\",\n        \"cas_misses\",\n        \"cas_hits\",\n        \"cas_badval\",\n        \"total_connections\"\n    ]\n\n    SERVICE_CHECK = 'memcache.can_connect'\n\n    def get_library_versions(self):\n        return {\"memcache\": memcache.__version__}\n\n    def _get_metrics(self, server, port, tags):\n        mc = None  # client\n        service_check_tags = [\"host:%s\" % server, \"port:%s\" % port]\n        try:\n            self.log.debug(\"Connecting to %s:%s tags:%s\", server, port, tags)\n            mc = memcache.Client([\"%s:%s\" % (server, port)])\n            raw_stats = mc.get_stats()\n\n            assert len(raw_stats) == 1 and len(raw_stats[0]) == 2,\\\n                \"Malformed response: %s\" % raw_stats\n\n\n            # Access the dict\n            stats = raw_stats[0][1]\n            for metric in stats:\n                # Check if metric is a gauge or rate\n                if metric in self.GAUGES:\n                    our_metric = self.normalize(metric.lower(), 'memcache')\n                    self.gauge(our_metric, float(stats[metric]), tags=tags)\n\n                # Tweak the name if it's a rate so that we don't use the exact\n                # same metric name as the memcache documentation\n                if metric in self.RATES:\n                    our_metric = self.normalize(\n                        \"{0}_rate\".format(metric.lower()), 'memcache')\n                    self.rate(our_metric, float(stats[metric]), tags=tags)\n\n            # calculate some metrics based on other metrics.\n            # stats should be present, but wrap in try/except\n            # and log an exception just in case.\n            try:\n                self.gauge(\n                    \"memcache.get_hit_percent\",\n                    100.0 * float(stats[\"get_hits\"]) / float(stats[\"cmd_get\"]),\n                    tags=tags,\n                )\n            except ZeroDivisionError:\n                pass\n\n            try:\n                self.gauge(\n                    \"memcache.fill_percent\",\n                    100.0 * float(stats[\"bytes\"]) / float(stats[\"limit_maxbytes\"]),\n                    tags=tags,\n                )\n            except ZeroDivisionError:\n                pass\n\n            try:\n                self.gauge(\n                    \"memcache.avg_item_size\",\n                    float(stats[\"bytes\"]) / float(stats[\"curr_items\"]),\n                    tags=tags,\n                )\n            except ZeroDivisionError:\n                pass\n\n            uptime = stats.get(\"uptime\", 0)\n            self.service_check(\n                self.SERVICE_CHECK, AgentCheck.OK,\n                tags=service_check_tags,\n                message=\"Server has been up for %s seconds\" % uptime)\n        except AssertionError:\n            self.service_check(\n                self.SERVICE_CHECK, AgentCheck.CRITICAL,\n                tags=service_check_tags,\n                message=\"Unable to fetch stats from server\")\n            raise Exception(\n                \"Unable to retrieve stats from memcache instance: {0}:{1}.\"\n                \"Please check your configuration\".format(server, port))\n\n        if mc is not None:\n            mc.disconnect_all()\n            self.log.debug(\"Disconnected from memcached\")\n        del mc\n\n    def check(self, instance):\n        socket = instance.get('socket')\n        server = instance.get('url')\n        if not server and not socket:\n            raise Exception('Either \"url\" or \"socket\" must be configured')\n\n        if socket:\n            server = 'unix'\n            port = socket\n        else:\n            port = int(instance.get('port', self.DEFAULT_PORT))\n        custom_tags = instance.get('tags') or []\n\n        tags = [\"url:{0}:{1}\".format(server, port)] + custom_tags\n\n        self._get_metrics(server, port, tags)\n", "path": "checks.d/mcache.py"}], "after_files": [{"content": "# 3rd party\nimport memcache\n\n# project\nfrom checks import AgentCheck\n\n# Ref: http://code.sixapart.com/svn/memcached/trunk/server/doc/protocol.txt\n# Name              Type     Meaning\n# ----------------------------------\n# pid               32u      Process id of this server process\n# uptime            32u      Number of seconds this server has been running\n# time              32u      current UNIX time according to the server\n# version           string   Version string of this server\n# pointer_size      32       Default size of pointers on the host OS\n#                            (generally 32 or 64)\n# rusage_user       32u:32u  Accumulated user time for this process\n#                            (seconds:microseconds)\n# rusage_system     32u:32u  Accumulated system time for this process\n#                            (seconds:microseconds)\n# curr_items        32u      Current number of items stored by the server\n# total_items       32u      Total number of items stored by this server\n#                            ever since it started\n# bytes             64u      Current number of bytes used by this server\n#                            to store items\n# curr_connections  32u      Number of open connections\n# total_connections 32u      Total number of connections opened since\n#                            the server started running\n# connection_structures 32u  Number of connection structures allocated\n#                            by the server\n# cmd_get           64u      Cumulative number of retrieval requests\n# cmd_set           64u      Cumulative number of storage requests\n# get_hits          64u      Number of keys that have been requested and\n#                            found present\n# get_misses        64u      Number of items that have been requested\n#                            and not found\n# delete_misses     64u      Number of deletions reqs for missing keys\n# delete_hits       64u      Number of deletion reqs resulting in\n#                            an item being removed.\n# evictions         64u      Number of valid items removed from cache\n#                            to free memory for new items\n# bytes_read        64u      Total number of bytes read by this server\n#                            from network\n# bytes_written     64u      Total number of bytes sent by this server to\n#                            network\n# limit_maxbytes    32u      Number of bytes this server is allowed to\n#                            use for storage.\n# threads           32u      Number of worker threads requested.\n#                            (see doc/threads.txt)\n# listen_disabled_num 32u    How many times the server has reached maxconns\n#                            (see https://code.google.com/p/memcached/wiki/Timeouts)\n#     >>> mc.get_stats()\n# [('127.0.0.1:11211 (1)', {'pid': '2301', 'total_items': '2',\n# 'uptime': '80', 'listen_disabled_num': '0', 'version': '1.2.8',\n# 'limit_maxbytes': '67108864', 'rusage_user': '0.002532',\n# 'bytes_read': '51', 'accepting_conns': '1', 'rusage_system':\n# '0.007445', 'cmd_get': '0', 'curr_connections': '4', 'threads': '2',\n# 'total_connections': '5', 'cmd_set': '2', 'curr_items': '0',\n# 'get_misses': '0', 'cmd_flush': '0', 'evictions': '0', 'bytes': '0',\n# 'connection_structures': '5', 'bytes_written': '25', 'time':\n# '1306364220', 'pointer_size': '64', 'get_hits': '0'})]\n\n# For Membase it gets worse\n# http://www.couchbase.org/wiki/display/membase/Membase+Statistics\n# https://github.com/membase/ep-engine/blob/master/docs/stats.org\n\n\nclass Memcache(AgentCheck):\n\n    SOURCE_TYPE_NAME = 'memcached'\n\n    DEFAULT_PORT = 11211\n\n    GAUGES = [\n        \"total_items\",\n        \"curr_items\",\n        \"limit_maxbytes\",\n        \"uptime\",\n        \"bytes\",\n        \"curr_connections\",\n        \"connection_structures\",\n        \"threads\",\n        \"pointer_size\"\n    ]\n\n    RATES = [\n        \"rusage_user\",\n        \"rusage_system\",\n        \"cmd_get\",\n        \"cmd_set\",\n        \"cmd_flush\",\n        \"get_hits\",\n        \"get_misses\",\n        \"delete_misses\",\n        \"delete_hits\",\n        \"evictions\",\n        \"bytes_read\",\n        \"bytes_written\",\n        \"cas_misses\",\n        \"cas_hits\",\n        \"cas_badval\",\n        \"total_connections\",\n        \"listen_disabled_num\"\n    ]\n\n    SERVICE_CHECK = 'memcache.can_connect'\n\n    def get_library_versions(self):\n        return {\"memcache\": memcache.__version__}\n\n    def _get_metrics(self, server, port, tags):\n        mc = None  # client\n        service_check_tags = [\"host:%s\" % server, \"port:%s\" % port]\n        try:\n            self.log.debug(\"Connecting to %s:%s tags:%s\", server, port, tags)\n            mc = memcache.Client([\"%s:%s\" % (server, port)])\n            raw_stats = mc.get_stats()\n\n            assert len(raw_stats) == 1 and len(raw_stats[0]) == 2,\\\n                \"Malformed response: %s\" % raw_stats\n\n\n            # Access the dict\n            stats = raw_stats[0][1]\n            for metric in stats:\n                # Check if metric is a gauge or rate\n                if metric in self.GAUGES:\n                    our_metric = self.normalize(metric.lower(), 'memcache')\n                    self.gauge(our_metric, float(stats[metric]), tags=tags)\n\n                # Tweak the name if it's a rate so that we don't use the exact\n                # same metric name as the memcache documentation\n                if metric in self.RATES:\n                    our_metric = self.normalize(\n                        \"{0}_rate\".format(metric.lower()), 'memcache')\n                    self.rate(our_metric, float(stats[metric]), tags=tags)\n\n            # calculate some metrics based on other metrics.\n            # stats should be present, but wrap in try/except\n            # and log an exception just in case.\n            try:\n                self.gauge(\n                    \"memcache.get_hit_percent\",\n                    100.0 * float(stats[\"get_hits\"]) / float(stats[\"cmd_get\"]),\n                    tags=tags,\n                )\n            except ZeroDivisionError:\n                pass\n\n            try:\n                self.gauge(\n                    \"memcache.fill_percent\",\n                    100.0 * float(stats[\"bytes\"]) / float(stats[\"limit_maxbytes\"]),\n                    tags=tags,\n                )\n            except ZeroDivisionError:\n                pass\n\n            try:\n                self.gauge(\n                    \"memcache.avg_item_size\",\n                    float(stats[\"bytes\"]) / float(stats[\"curr_items\"]),\n                    tags=tags,\n                )\n            except ZeroDivisionError:\n                pass\n\n            uptime = stats.get(\"uptime\", 0)\n            self.service_check(\n                self.SERVICE_CHECK, AgentCheck.OK,\n                tags=service_check_tags,\n                message=\"Server has been up for %s seconds\" % uptime)\n        except AssertionError:\n            self.service_check(\n                self.SERVICE_CHECK, AgentCheck.CRITICAL,\n                tags=service_check_tags,\n                message=\"Unable to fetch stats from server\")\n            raise Exception(\n                \"Unable to retrieve stats from memcache instance: {0}:{1}.\"\n                \"Please check your configuration\".format(server, port))\n\n        if mc is not None:\n            mc.disconnect_all()\n            self.log.debug(\"Disconnected from memcached\")\n        del mc\n\n    def check(self, instance):\n        socket = instance.get('socket')\n        server = instance.get('url')\n        if not server and not socket:\n            raise Exception('Either \"url\" or \"socket\" must be configured')\n\n        if socket:\n            server = 'unix'\n            port = socket\n        else:\n            port = int(instance.get('port', self.DEFAULT_PORT))\n        custom_tags = instance.get('tags') or []\n\n        tags = [\"url:{0}:{1}\".format(server, port)] + custom_tags\n\n        self._get_metrics(server, port, tags)\n", "path": "checks.d/mcache.py"}]}