Linux RAM (random access memory) is divided into chunks called pages. Swapping is the process by which Linux moves pages of memory from RAM into disk to free up memory. The combined size of physical memory and swap space is how much virtual memory a system has available.

Swapping is used because it allows a system to use more memory than physically available. This allows users to run more active applications than their computer hardware would be able to support without memory paging. The potential downside of this type of memory management is that disk is far slower than RAM, which means that if swapping isn’t done efficiently, the performance of the application will drop massively as the computer waits for memory to move from disk back into RAM. A computer constantly swapping memory is said to be thrashing and will be very slow. Thrashing will continue until the user closes some of the open applications or the operating system itself shuts down the processes.

Why use a Telegraf plugin for Swap?

The Telegraf plugin for Swap makes it easy to monitor what is happening with Swap Memory on your Linux system. You can then use Telegraf to output your metric data to 40 different data stores for long-term storage and analysis. These metrics could be used to optimize the memory usage of your application and improve user experience. This generally involves finding ways to break up huge data structures stored in memory.

How to monitor Swap using the Telegraf plugin

The Telegraf plugin for Linux Swap Memory doesn’t require any configuration beyond just putting the input plugin into your configuration file like below:

# Read metrics about swap memory usage
[[inputs.swap]]
  # no configuration

Key Swap metrics to use for monitoring

Some of the important Swap metrics that you should proactively monitor include:

  • free (int, bytes): free swap memory
  • total (int, bytes): total swap memory
  • used (int, bytes): used swap memory
  • used_percent (float, percent): percentage of swap memory used
  • in (int, bytes): data swapped in since last boot calculated from page number
  • out (int, bytes): data swapped out since last boot calculated from page number

For more information, please check out the documentation.

Project URL   Documentation

Related resources

Linux Monitoring Template

Template for InfluxDB Cloud to quickly set up dashboards and monitoring for Linux

Disk Usage Telegraf Plugin

Telegraf plugin to get metrics for disk utilization

CPU Usage Telegraf Plugin

Telegraf plugin to get metrics for CPU utilization

Scroll to Top