LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-23-2012, 11:27 AM   #1
JKimbrell
LQ Newbie
 
Registered: Jul 2012
Posts: 3

Rep: Reputation: Disabled
Need "percentage" from vmstat


Hello All,
Hopefully, someone can help with this.
We have an in house monitoring solution, and I need to return a percentage of usage from the "swpd" in vmstat instead of just a number.

procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------
r b swpd free buff cache si so bi bo in cs us sy id wa st
0 0 488 162276 841144 30837840 0 0 628 29 4 9 6 2 90 2 0


Any ideas?
J.
 
Old 07-23-2012, 12:01 PM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 27,245

Rep: Reputation: 8077Reputation: 8077Reputation: 8077Reputation: 8077Reputation: 8077Reputation: 8077Reputation: 8077Reputation: 8077Reputation: 8077Reputation: 8077Reputation: 8077
Quote:
Originally Posted by JKimbrell View Post
Hello All,
Hopefully, someone can help with this.
We have an in house monitoring solution, and I need to return a percentage of usage from the "swpd" in vmstat instead of just a number.

procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------
r b swpd free buff cache si so bi bo in cs us sy id wa st
0 0 488 162276 841144 30837840 0 0 628 29 4 9 6 2 90 2 0
If you're looking for the percentage of the swap memory, you should start with the output of the "free" command instead. It'll give you the total, used, and free amounts. From there, calculating a percentage in bash is fairly simple:
http://www.ukdragon.com/blog/index.p...ntages_in_bash

So grab the free output into variables like:
Code:
$total = `free | grep Swap | awk {'print $2'}`
$used = `free | grep Swap | awk {'print $3'}`
$free  = `free | grep Swap | awk {'print $4'}`
(note: TOTALLY untested and unchecked).

That'll give you variables, run your percentage from there.
 
Old 07-23-2012, 12:15 PM   #3
JKimbrell
LQ Newbie
 
Registered: Jul 2012
Posts: 3

Original Poster
Rep: Reputation: Disabled
That's nice TBone, however, I need more that this..
Appreciate you looking however.
 
Old 07-23-2012, 12:39 PM   #4
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 27,245

Rep: Reputation: 8077Reputation: 8077Reputation: 8077Reputation: 8077Reputation: 8077Reputation: 8077Reputation: 8077Reputation: 8077Reputation: 8077Reputation: 8077Reputation: 8077
Quote:
Originally Posted by JKimbrell View Post
That's nice TBone, however, I need more that this..
Appreciate you looking however.
More than what??? What's missing?
 
Old 07-23-2012, 01:18 PM   #5
JKimbrell
LQ Newbie
 
Registered: Jul 2012
Posts: 3

Original Poster
Rep: Reputation: Disabled
Don't need to get worked up, I don't like the answer, I need more of a complete answer.
Not an untested line of syntax and a URL.
 
Old 07-23-2012, 01:22 PM   #6
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 27,245

Rep: Reputation: 8077Reputation: 8077Reputation: 8077Reputation: 8077Reputation: 8077Reputation: 8077Reputation: 8077Reputation: 8077Reputation: 8077Reputation: 8077Reputation: 8077
Quote:
Originally Posted by JKimbrell View Post
Don't need to get worked up, I don't like the answer, I need more of a complete answer.
Not an untested line of syntax and a URL.
Wasn't worked up, was asking what was missing. The answer is "nothing". The only 'untested' part is how to CALL the command to build a variable in bash. I think it's correct, but (since YOU are going to write the script), I left it to you to research. I even gave you a link to a tutorial showing you how to figure percentages in bash, so you could use what you were given.

You don't like it, feel free to figure it out on your own...you asked for ideas. I pointed you to the right system utility to use, gave you three lines of variable-producing code from which (if you put any effort into it), you could have easily written your own script.

I'm guessing what you wanted was someone to write it for you, and hand you something tested and debugged. No, thanks....you were given ideas, direction, and instructions to take it further. If you don't want to, then tell someone else at your company to write it.

Last edited by TB0ne; 07-23-2012 at 01:42 PM.
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
unpredictable "delete" "move to trash" or "cut" file menu option dorianrenato Linux - General 3 11-28-2011 07:41 PM
Squid "increase Hit percentage" nima0102 Linux - Server 4 02-12-2009 05:51 AM
net working eth0 eth1 wlan0 "no connection" "no LAN" "no wi-fi" Cayitano Linux - Newbie 5 12-09-2007 08:11 PM
Standard commands give "-bash: open: command not found" even in "su -" and "su root" mibo12 Linux - General 4 11-11-2007 11:18 PM
LXer: Displaying "MyComputer", "Trash", "Network Servers" Icons On A GNOME Desktop LXer Syndicated Linux News 0 04-02-2007 09:31 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:28 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration