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O,UAAU,kBAAoB,EAAM,UAAU,iBACrD,EAAO,aAAa,WAAa,EAAM,aAAa,UACpD,EAAO,aAAa,OAAS,EAAM,aAAa,MAChD,GACJ,CAAE,MAAO,GACL,EAAK,EACT,CACJ,GACJ,IAAG,SAAU,GACT,OAAO,EAAG,EAAO,EACrB,GACJ,GACJ,EACA,cAAc,UAAU,SAAW,SAAU,GAC9B,KACN,QAAO,SAAU,EAAO,GACzB,GAAI,EACA,OAAO,EAAG,GAEd,IACI,IAAK,IAAI,KAAQ,EACb,GAA4B,iBAAjB,EAAO,GACd,IAAK,IAAI,KAAQ,EAAO,GACpB,GAAkC,iBAAvB,EAAO,GAAM,GACpB,IAAK,IAAI,KAAQ,EAAO,GAAM,GAC1B,EAAO,GAAM,GAAM,GAAQ,EAAO,GAAM,GAAM,GAAQ,EAAO,gBAGjE,EAAO,GAAM,GAAQ,EAAO,GAAM,GAAQ,EAAO,eAI7C,cAAR,IACA,EAAO,GAAQ,EAAO,GAAQ,EAAO,WAIrD,CAAE,MAAO,GACL,OAAO,EAAG,EACd,CACA,OAAO,EAAG,KAAM,EACpB,GACJ,EACA,OAAO,QAAU","file":"/npm/docker-utility@1.0.1/lib/dockerUtility.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/docker-utility@1.0.1/lib/dockerUtility.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","var duckemodem = require('ducke-modem');\nvar async = require('async');\nvar DockerUtility = function (options) {\n    var self = this;\n    var options = options || duckemodem.Parameters();\n    self.modem = new duckemodem.API(options);\n}\nDockerUtility.prototype.stats = function (id, cb) {\n    var self = this;\n    self.modem.get('/containers/' + id + '/stats?stream=false').result(cb);\n}\nDockerUtility.prototype.container = function (id, cb) {\n    var self = this;\n    self.modem.get('/containers/'+id+'/json').result(cb);\n}\nDockerUtility.prototype.containers = function (cb) {\n    var self = this;\n    self.modem.get('/containers/json?all=1').result(cb);\n}\nDockerUtility.prototype.totals = function (cb) {\n    var self = this;\n    var totals = {\n        containers: 0,\n        precpu_stats: {\n            cpu_usage: {\n                total_usage: 0,\n                usage_in_kernelmode: 0,\n                usage_in_usermode: 0\n            }\n        },\n        cpu_stats: {\n            cpu_usage: {\n                total_usage: 0,\n                usage_in_kernelmode: 0,\n                usage_in_usermode: 0,\n            },\n            system_cpu_usage: 0\n        },\n        memory_stats: {\n            usage: 0,\n            max_usage: 0\n        }\n    };\n    self.containers(function (error, containers) {\n        if (error) {\n            return cb(error)\n        }\n        totals.containers = containers.length;\n        async.eachLimit(containers, 1, function (container, next) {\n            self.stats(container.Id, function (error, stats) {\n                try {\n                    totals.precpu_stats.cpu_usage.total_usage += stats.precpu_stats.cpu_usage.total_usage;\n                    totals.precpu_stats.cpu_usage.usage_in_kernelmode += stats.precpu_stats.cpu_usage.usage_in_kernelmode;\n                    totals.precpu_stats.cpu_usage.usage_in_usermode += stats.precpu_stats.cpu_usage.usage_in_usermode;\n                    totals.cpu_stats.cpu_usage.total_usage += stats.cpu_stats.cpu_usage.total_usage;\n                    totals.cpu_stats.cpu_usage.usage_in_usermode += stats.cpu_stats.cpu_usage.usage_in_usermode;\n                    totals.cpu_stats.cpu_usage.usage_in_kernelmode += stats.cpu_stats.cpu_usage.usage_in_kernelmode;\n                    totals.cpu_stats.system_cpu_usage += stats.cpu_stats.system_cpu_usage;\n                    totals.memory_stats.max_usage += stats.memory_stats.max_usage;\n                    totals.memory_stats.usage += stats.memory_stats.usage;\n                    next();\n                } catch (e) {\n                    next(e)\n                }\n            });\n        }, function (error) {\n            return cb(error, totals);\n        })\n    })\n}\nDockerUtility.prototype.averages = function (cb) {\n    var self = this;\n    self.totals(function (error, totals) {\n        if (error) {\n            return cb(error);\n        }\n        try {\n            for (var key1 in totals) {\n                if (typeof totals[key1] === 'object') {\n                    for (var key2 in totals[key1]) {\n                        if (typeof totals[key1][key2] === 'object') {\n                            for (var key3 in totals[key1][key2]) {\n                                totals[key1][key2][key3] = totals[key1][key2][key3] / totals.containers\n                            }\n                        } else {\n                            totals[key1][key2] = totals[key1][key2] / totals.containers\n                        }\n                    }\n                } else {\n                    if (key1 != \"containers\") {\n                        totals[key1] = totals[key1] / totals.containers\n                    }\n                }\n            }\n        } catch (e) {\n            return cb(e);\n        }\n        return cb(null, totals);\n    });\n};\nmodule.exports = DockerUtility;\n\n\n"]}