Friday, 18 November 2016

Quick one liner to get swap usage in Solaris 10

Calculating swap usage is Solaris without top or prstat isn't easy since the output of 'swap -s' doesn't exactly paint an easily decipherable picture.

So what do we do?

We do some piping, some translation with tr & finally awk!

Take this example of the 'swap -s' output from a Solaris 10 server.

root@localhost:/# swap -s
total: 11454880k bytes allocated + 0k reserved = 11454880k used, 55653984k available
root@localhost:/#

To make it really easy to interpret, I did this:

root@localhost:/# swap -s | tr -d "k$" | awk '{total= $9 + $11;} {print 100 * $9 / total, "% swap is used"}'
17.0699 % swap is used
root@localhost:/#

That's it!

No comments:

Post a Comment

Using capture groups in grep in Linux

Introduction Let me start by saying that this article isn't about capture groups in grep per se. What we are going to do here with gr...