On a Linux box - If you would like to see a metric with percentage memory and swap used, it's as simple as adding another 4 lines to the vm.sh file in /opt/circonus/etc/node-agent.d/linux

Below is the default vm.sh file with the following additions:

  1. let MEM_PERC=100*$MEM_USED/$MEM_TOTAL
  2. let SWAP_PERC=100*${SWAP[2]}/${SWAP[1]}

and then 2 print statements:

  1. print_vm memory perc $MEM_PERC
  2. print_vm swap perc $SWAP_PERC
  1. #!/bin/bash
  2. print_vm() {
  3. printf "%s`%s\tL\t%s\n" $1 $2 $3
  4. }
  5. MEM=($(free -b | grep ^Mem:))
  6. MEM_TOTAL=${MEM[1]}
  7. # For consistency across platforms, count cache as free, not used
  8. let MEM_USED=${MEM[1]}-${MEM[3]}-${MEM[5]}-${MEM[6]}
  9. let MEM_FREE=${MEM[3]}+${MEM[5]}+${MEM[6]}
  10. let MEM_PERC=100*$MEM_USED/$MEM_TOTAL
  11. SWAP=($(free -b | grep ^Swap:))
  12. SWAP_TOTAL=${SWAP[1]}
  13. SWAP_USED=${SWAP[2]}
  14. SWAP_FREE=${SWAP[3]}
  15. let SWAP_PERC=100*${SWAP[2]}/${SWAP[1]}
  16. # pgfault is min+maj
  17. PG_FAULTS=$(grep ^pgfault /proc/vmstat | awk '{ print $2 }')
  18. PG_MAJFAULTS=$(grep ^pgmajfault /proc/vmstat | awk '{ print $2 }')
  19. let PG_MINFAULTS=$PG_FAULTS-$PG_MAJFAULTS
  20. print_vm memory total $MEM_TOTAL
  21. print_vm memory used $MEM_USED
  22. print_vm memory free $MEM_FREE
  23. print_vm memory perc $MEM_PERC
  24. print_vm swap total $SWAP_TOTAL
  25. print_vm swap used $SWAP_USED
  26. print_vm swap free $SWAP_FREE
  27. print_vm swap perc $SWAP_PERC
  28. print_vm info page_fault $PG_FAULTS
  29. print_vm info page_fault`minor $PG_MINFAULTS
  30. print_vm info page_fault`major $PG_MAJFAULTS

Just remember to restart nad (sudo /etc/init.d/nad restart), then go to the existing check and enable the 2 new metrics!

You can also change the 100 to 10,000 above, turning the resulting %age into a 4 digit number, then apply =VAL/100 to the metric in the graph to get XX.XX% for more precision.