3

I am trying to monitor the swapping activity in a Linux Server in the last, say, 1, 5 or 15 minutes.

One way is to run vmstat and keep watching si and so counters during these intervals.

However how can I check as a "one-shot" action (e.g. through a Nagios plugin) for a value showing the swapping activity during the aforementioned intervals?

In other words I need a way to instantly check whether my Server is actively swapping.

1 Answer 1

1

Believe you could use /proc/vmstat output, say with

cat /proc/vmstat | grep pswp 

command.

This will show you swap in and swap out counters.

Or:

only si:

vmstat 1 1 | awk 'NR == 1 {next} NR == 2 {for (i = 1; i <= NF; i++) fields[$i] = i; next} {split($0, data); item = data[fields["si"]]; print item; totals[fields["si"]] += item} NR >= 6 + 2 {exit}' 

only so:

vmstat 1 1 | awk 'NR == 1 {next} NR == 2 {for (i = 1; i <= NF; i++) fields[$i] = i; next} {split($0, data); item = data[fields["si"]]; print item; totals[fields["so"]] += item} NR >= 6 + 2 {exit}' 
1

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.