Erhalten Sie Docker Container CPU-Auslastung als Prozentsatz

Docker bietet eine interaktive stats Befehl docker stats [cid] gibt aktuelle Informationen über die CPU-Auslastung, etwa so:

CONTAINER      CPU %          MEM USAGE/LIMIT       MEM %       NET I/O
36e8a65d       0.03%          4.086 MiB/7.798 GiB   0.05%       281.3 MiB/288.3 MiB

Ich versuche die CPU-Auslastung als Prozentsatz in ein verdauliches format zu tun einige Analyse.

Ich gesehen habe, die stats in /sys/fs, die wohl ähnliche Werte wie die Docker Remote APIdie gibt mir diese JSON-blob:

{
    "cpu_usage": {
        "usage_in_usermode": 345230000000, 
        "total_usage": 430576697133, 
        "percpu_usage": [
            112999686856, 
            106377031910, 
            113291361597, 
            97908616770
        ], 
        "usage_in_kernelmode": 80670000000
    }, 
    "system_cpu_usage": 440576670000000, 
    "throttling_data": {
        "throttled_time": 0, 
        "periods": 0, 
        "throttled_periods": 0
    }
}

Aber ich bin mir nicht sicher, wie genau die CPU-Auslastung als Prozentsatz aus.

Irgendwelche Ideen?

InformationsquelleAutor der Frage Dan LaManna | 2015-05-16

Schreibe einen Kommentar