Regarding Swap memory usahe monitot via shell script
Linux - NewbieThis 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.
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.
Has it not occurred to you that they are at every line where you've placed a test against a percentage?
Therefore you could search for information about how to compare numbers in bash.
Percentages are not valid, at least not with these types of comparisons, instead you'd compare strings. But if you don't need to, then instead remove the percent sign and just compare the integers.
This all depends on what is in the variable swap.
This also appears to not be the code where you've seen the errors, there are not 3 repetitions of the string "40%" in lines which are 4 apart from each other.
Anyways, that's a fundamental problem with your script, your compares. Suggest you print out the variable $swap to see what it contains as a debug before you code your comparisons.
My additional point being, if you just take one piece of information where I say remove the percent sign in your compares, that is not necessarily the solution, in fact may be very unlikely. It's not helpful if you do just that and then reply "it didn't work", so that point is to debug the script so you know what comparison works correctly.
There are a few things you can change for your awk statement to make your life easier.
As script was testing at "OK" threshold before. but now one of the host crossed ok and reached "warning" level. but still getting ok status as below.
[test ~]$ ./swap_memory_health_check.sh
OK - Swap Memory at 25.40%
Code used is below. seems good with if loop but not sure where am doing wrong.
Almost the same problem, just with a different script. And again, we aren't on your 'team'...we are not your co-workers, but volunteers who try to help others. We're happy to do so, but you have to show that you're applying what you're getting told and taking the advice offered. Otherwise, we're just doing all your debugging work for you.
I would suggest you yo use www.shellcheck.net to check your script. (it will also help you to solve the problems found).
Quote:
Originally Posted by JeremyBoden
Anyway, why not try running a program such as (for example) glances in a terminal screen.
It will monitor your swap and a host of other things...
Hi
thanks for the suggestion. we are in restricted environment where third party application/software cant be installed.
or else would have been tried.
thanks for advice,will be try using it in other environment.
Almost the same problem, just with a different script. And again, we aren't on your 'team'...we are not your co-workers, but volunteers who try to help others. We're happy to do so, but you have to show that you're applying what you're getting told and taking the advice offered. Otherwise, we're just doing all your debugging work for you.
Hi New to forum and Linux too..and was not knowing that i can show gratitude by clicking on green button. So was marking it as helpful.
Thanks for the suggestion.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.