Hi, I’m trying to implement ha dockermon and have configured one of my containers as a switch but I’d also like to get stats for the container but have no idea where to start with this? I’ve read through the documentation but would appreciate any guidance?
Thanks,
Matt
I’ve had some help and can now get memory stats but was hoping for CPU stats as well? If I do a GET request, these are the stats but unsure how to pull CPU and the JSON to use?
{"read":"2020-06-07T19:54:09.878244664Z","preread":"2020-06-07T19:54:08.87428150 8Z","pids_stats":{"current":18},"blkio_stats":{"io_service_bytes_recursive":[{"m ajor":8,"minor":0,"op":"Read","value":51134464},{"major":8,"minor":0,"op":"Write ","value":8192},{"major":8,"minor":0,"op":"Sync","value":51142656},{"major":8,"m inor":0,"op":"Async","value":0},{"major":8,"minor":0,"op":"Total","value":511426 56}],"io_serviced_recursive":[{"major":8,"minor":0,"op":"Read","value":4739},{"m ajor":8,"minor":0,"op":"Write","value":2},{"major":8,"minor":0,"op":"Sync","valu e":4741},{"major":8,"minor":0,"op":"Async","value":0},{"major":8,"minor":0,"op": "Total","value":4741}],"io_queue_recursive":[{"major":8,"minor":0,"op":"Read","v alue":0},{"major":8,"minor":0,"op":"Write","value":0},{"major":8,"minor":0,"op": "Sync","value":0},{"major":8,"minor":0,"op":"Async","value":0},{"major":8,"minor ":0,"op":"Total","value":0}],"io_service_time_recursive":[{"major":8,"minor":0," op":"Read","value":21597986312},{"major":8,"minor":0,"op":"Write","value":262063 },{"major":8,"minor":0,"op":"Sync","value":21598248375},{"major":8,"minor":0,"op ":"Async","value":0},{"major":8,"minor":0,"op":"Total","value":21598248375}],"io _wait_time_recursive":[{"major":8,"minor":0,"op":"Read","value":176544363570},{" major":8,"minor":0,"op":"Write","value":546605554},{"major":8,"minor":0,"op":"Sy nc","value":177090969124},{"major":8,"minor":0,"op":"Async","value":0},{"major": 8,"minor":0,"op":"Total","value":177090969124}],"io_merged_recursive":[{"major": 8,"minor":0,"op":"Read","value":1009},{"major":8,"minor":0,"op":"Write","value": 0},{"major":8,"minor":0,"op":"Sync","value":1009},{"major":8,"minor":0,"op":"Asy nc","value":0},{"major":8,"minor":0,"op":"Total","value":1009}],"io_time_recursi ve":[{"major":8,"minor":0,"op":"","value":10935904844}],"sectors_recursive":[{"m ajor":8,"minor":0,"op":"","value":99888}]},"num_procs":0,"storage_stats":{},"cpu _stats":{"cpu_usage":{"total_usage":277677383654,"percpu_usage":[66939164880,669 98562169,71832983788,71906672817],"usage_in_kernelmode":70810000000,"usage_in_us ermode":206730000000},"system_cpu_usage":1150416890000000,"online_cpus":4,"throt tling_data":{"periods":0,"throttled_periods":0,"throttled_time":0}},"precpu_stat s":{"cpu_usage":{"total_usage":277677383654,"percpu_usage":[66939164880,66998562 169,71832983788,71906672817],"usage_in_kernelmode":70810000000,"usage_in_usermod e":206730000000},"system_cpu_usage":1150412920000000,"online_cpus":4,"throttling _data":{"periods":0,"throttled_periods":0,"throttled_time":0}},"memory_stats":{" usage":55291904,"max_usage":100745216,"stats":{"active_anon":19288064,"active_fi le":4198400,"cache":8892416,"dirty":0,"hierarchical_memory_limit":92233720368547 72000,"hierarchical_memsw_limit":0,"inactive_anon":20271104,"inactive_file":4694 016,"mapped_file":7741440,"pgfault":3866376,"pgmajfault":1450,"pgpgin":3872717," pgpgout":3860888,"rss":39559168,"rss_huge":0,"total_active_anon":19288064,"total _active_file":4198400,"total_cache":8892416,"total_dirty":0,"total_inactive_anon ":20271104,"total_inactive_file":4694016,"total_mapped_file":7741440,"total_pgfa ult":3866376,"total_pgmajfault":1450,"total_pgpgin":3872717,"total_pgpgout":3860 888,"total_rss":39559168,"total_rss_huge":0,"total_unevictable":0,"total_writeba ck":0,"unevictable":0,"writeback":0},"limit":16690458624},"name":"/ha_dockermon" ,"id":"28edad2d3fe83e03308525a27be30825658d23b5347cee732f00f5a313d826b7","networ ks":{"eth0":{"rx_bytes":156678050,"rx_packets":1593124,"rx_errors":0,"rx_dropped ":0,"tx_bytes":162965844,"tx_packets":1306802,"tx_errors":0,"tx_dropped":0}}}mat
This is the sensor I am using for memory stats
- platform: rest
resource:
http://192.168.68.110:7777/container/ha_dockermon/stats
name: HA Dockermon Memory
scan_interval: 900
value_template: '{{ (value_json.memory_stats.usage /1024/1024) |round(2) }}'
unit_of_measurement: 'MB'
Hi,
This is how you get the CPU usage for Plex:
- platform: rest
resource: http://192.168.86.102:8126/container/plex-server/stats
name: Docker Plex-Server CPU
scan_interval: 15
value_template: '{{ ( ( (value_json.cpu_stats.cpu_usage.total_usage-value_json.precpu_stats.cpu_usage.total_usage)/(value_json.cpu_stats.system_cpu_usage-value_json.precpu_stats.system_cpu_usage) )*100*value_json.cpu_stats.online_cpus) |round(2) }}'
unit_of_measurement: '%'