

It's a pure-Python CLI package including its couple of dependencies (no heavy Matplotlib), can potentially plot many metrics from procfs, JSONPath queries to the process tree, has basic decimation/aggregation (Ramer-Douglas-Peucker and moving average), filtering by time ranges and PIDs, and a couple of other things. Returning to the problem of process analysis frequently enough and not being satisfied with the solutions I described below originally, I decided to write my own. If available memory or the free+buffer+cache memory is too low.2020 update (Linux/procfs-only).


So actual memory used(which includes buffer & cache) = total memory – available memory.Available memory is the actual memory that is available to the user.Together we will call it YIELD_MEM(yield memory) since it can yield memory whenever a new process is started. Buffer and Cache memory contain metadata and actual contents from the disk so that the operations could be done quickly.Free memory is basically unused wasted memory.Do not be worried if free memory is close to 0. Linux tries to use unused RAM for disk caching to fasten up the operations.We will use bc to handle Floating-point arithmetic operations in bash.

We will use the free -m command coupled with awk to filter our unnecessary details so as to view the free memory, available memory, buffer, and cached memory and finally calculate Memory used percentage. #Total memory usage is Total Memory - Available MemoryĮcho "System is critically low on memory!"Įcho -e "\nMEMORY OK\n." TOTAL_USED_MEM=$(( $TOTAL_MEM - $AVAILABLE_MEM )) Step 3: Create memory_util function function memory_util ()īUFFCACHE_MEM=$(free -m | awk '/Mem/ ')
