-
Notifications
You must be signed in to change notification settings - Fork 33
Division through zero #4
Copy link
Copy link
Open
Description
If you don't have any swap / your swap is zero byte you get an division by zero error ($2)
free -b | awk '$ 1 == "Swap:" {total=$ 2; used=$ 3; free=$ 4; pfree=($ 4*100/$ 2); pused=($ 3*100/$ 2); if("$1" == "") {printf("%.0f", free )} else {printf("%.0f", $1 "" )} }'
awk: cmd. line:1: (FILENAME=- FNR=3) fatal: division by zero attemptedfree -h
total used free shared buff/cache available
Mem: ....
Swap: 0B 0B 0BReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels