#!/bin/bash SLABVERSION=$(head -1 /proc/slabinfo | cut -f2 -d: | awk '{print $1;}') echo /proc/slabinfo has version $SLABVERSION [ $(echo $SLABVERSION*1000 | bc | cut -f1 -d.) -lt 1100 ] && echo Warning at least version 1.1 is required tail -n +2 /proc/slabinfo | ( LINE=---------------------------------------- PAGESIZE=4 TOTALPAGES=0 printf "%s\nName Memory usage\n$LINE\n" "$LINE" while read NAME USEDENTRIES ALLOCATEDENTRIES ENTRYSIZE USEDSLABS ALLOCATEDSLABS SLABSIZE REST do SIZE=$(($ALLOCATEDSLABS*$SLABSIZE)) printf '%-17s %6d pages %6d KB\n' $NAME $SIZE $(($SIZE*$PAGESIZE)) TOTALPAGES=$(($TOTALPAGES+$SIZE)) done printf -- "$LINE\n%-17s %6d pages %6d KB\n$LINE\n" Total $TOTALPAGES $(($TOTALPAGES*$PAGESIZE)) )