MCPcopy Index your code
hub / github.com/docker/docker-py / stats

Method stats

docker/api/container.py:1139–1184  ·  view source on GitHub ↗

Stream statistics for a specific container. Similar to the ``docker stats`` command. Args: container (str): The container to stream statistics from decode (bool): If set to true, stream will be decoded into dicts on the fly. Only appl

(self, container, decode=None, stream=True, one_shot=None)

Source from the content-addressed store, hash-verified

1137
1138 @utils.check_resource('container')
1139 def stats(self, container, decode=None, stream=True, one_shot=None):
1140 """
1141 Stream statistics for a specific container. Similar to the
1142 ``docker stats`` command.
1143
1144 Args:
1145 container (str): The container to stream statistics from
1146 decode (bool): If set to true, stream will be decoded into dicts
1147 on the fly. Only applicable if ``stream`` is True.
1148 False by default.
1149 stream (bool): If set to false, only the current stats will be
1150 returned instead of a stream. True by default.
1151 one_shot (bool): If set to true, Only get a single stat instead of
1152 waiting for 2 cycles. Must be used with stream=false. False by
1153 default.
1154
1155 Raises:
1156 :py:class:`docker.errors.APIError`
1157 If the server returns an error.
1158
1159 """
1160 url = self._url("/containers/{0}/stats", container)
1161 params = {
1162 'stream': stream
1163 }
1164 if one_shot is not None:
1165 if utils.version_lt(self._version, '1.41'):
1166 raise errors.InvalidVersion(
1167 'one_shot is not supported for API version < 1.41'
1168 )
1169 params['one-shot'] = one_shot
1170 if stream:
1171 if one_shot:
1172 raise errors.InvalidArgument(
1173 'one_shot is only available in conjunction with '
1174 'stream=False'
1175 )
1176 return self._stream_helper(
1177 self._get(url, stream=True, params=params), decode=decode
1178 )
1179 else:
1180 if decode:
1181 raise errors.InvalidArgument(
1182 "decode is only available in conjunction with stream=True"
1183 )
1184 return self._result(self._get(url, params=params), json=True)
1185
1186 @utils.check_resource('container')
1187 def stop(self, container, timeout=None):

Callers

nothing calls this directly

Calls 4

_urlMethod · 0.80
_stream_helperMethod · 0.80
_getMethod · 0.80
_resultMethod · 0.80

Tested by

no test coverage detected