Sample Header Ad - 728x90

Get % used of zram in script

2 votes
1 answer
409 views
I've got a script that collects various bits of system data and reports this via MQTT to a central local server. I recently implemented zram with priority over swap to see if this offers a performance boost. As part of monitoring this I need to be able to workout the % used zram, so that it can be reported. I know that I can see basic stats for swap & zram with the following commands: cat /proc/swap or swapon -s Filename Type Size Used Priority /var/swap file 102396 0 -2 /dev/zram0 partition 5055516 170752 5 or zramctl NAME ALGORITHM DISKSIZE DATA COMPR TOTAL STREAMS MOUNTPOINT /dev/zram0 lz4 4.8G 165.5M 58.4M 62.8M 4 [SWAP] But these don't present a % used and in the case of the first 2 commands also report the standard swap. Is there a way to determine & output the % used zram and nothing else in a single-line command? edit: It looks like swapon -s offers the easiest results to use since it gives size and used values in the zram line. If anyone can offer a way to return just the %used I'd really appreciate it. Thanks.
Asked by Phill Healey (123 rep)
May 23, 2020, 08:23 PM
Last activity: Jan 3, 2022, 11:15 AM