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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
07-23-2012, 11:27 AM
|
#1
|
LQ Newbie
Registered: Jul 2012
Posts: 3
Rep:
|
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.
|
|
|
07-23-2012, 12:01 PM
|
#2
|
LQ Guru
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 27,245
|
Quote:
Originally Posted by JKimbrell
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.
|
|
|
07-23-2012, 12:15 PM
|
#3
|
LQ Newbie
Registered: Jul 2012
Posts: 3
Original Poster
Rep:
|
That's nice TBone, however, I need more that this..
Appreciate you looking however.
|
|
|
07-23-2012, 12:39 PM
|
#4
|
LQ Guru
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 27,245
|
Quote:
Originally Posted by JKimbrell
That's nice TBone, however, I need more that this..
Appreciate you looking however.
|
More than what??? What's missing?
|
|
|
07-23-2012, 01:18 PM
|
#5
|
LQ Newbie
Registered: Jul 2012
Posts: 3
Original Poster
Rep:
|
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.
|
|
|
07-23-2012, 01:22 PM
|
#6
|
LQ Guru
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 27,245
|
Quote:
Originally Posted by JKimbrell
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.
|
All times are GMT -5. The time now is 07:28 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|