I`m trying to write a shell script to get free, used and total memory on our linux servers.
It's working great, but i need follow some standards to make it a real nagios plugin.
It's pretty simple, you just type two parameters to the script, check_ram -w 80 -c 90 #just an exemple.
I don't want that it displays the amount of memory if no parameters was passed to the script.
#exemple: check_ram -w -c should give error and call the function HELP without show used and free memory. But it keeping ignoring the breaks and showing the used and free memory.
w and c need have values to let script continue.
Thank you anyway.
Put the calculation of the memory into a function too. Call it only when needed - currently you call it all the time, makes no sense. It will be executed no matter what happens in the case/esac-block.
Second thing is, if you iterate through arguments with $# -gt 0 it will always be the same. You miss the shift.
Third, have the exit 0 at the very end of the script since this is, if not aborted earlier, the good exit code you want to have.
Thx for replay Mr Zaxxon, i changed my code.
I'm just confused how to call MEMCAL function only if user type 2 int parameters like check_ram -w 80 -c 90.
how can i check if the two parameters has int values and only after check it call the function?
I'm still trying but i can't find a solution.
Hi
I am trying to calculate memory used by Linux System
free -m
total used free shared buffers cached
Mem: 32109 31010 1099 0 3600 7287
-/+ buffers/cache: 20121 11987
Swap: 10239 1282 8957
Now according to my requirement Im calculating memory using below cmd
free -m | awk 'NR==3{printf... (2 Replies)
good morning,
how I can know how much total and free memory I have in my AIX 5.3 server, and this is shown in megabytes or gigabytes?
Thank you very much. (4 Replies)
I was running a program and it stopped and showed "Out of Memory!". at that time, the RAM used by this process is around 4G and the free memory size of the machine is around 30G. Does anybody know what maybe the reason? this program is written with Perl. the OS of the machine is Solaris U8. And I... (1 Reply)
Hi,
I have a strange issue where the total memory on the server is showing low.
At the moment 8 GB of memory is installed and only 3 GB is showing on the shell prompt. I am using the commands free -m and vmstat to check the memory. Please help me out in identifying the issue.
With regards... (3 Replies)
Good afternoon! Im new at scripting and Im trying to write a script to
calculate total space, total used space and total free space in filesystem names matching a keyword (in this one we will use keyword virginia). Please dont be mean or harsh, like I said Im new and trying my best. Scripting... (4 Replies)
Hi all,
Could please let me know how to get the more memory free space (not added the RAM) in local zone.
-bash-3.00# vmstat 2 5
kthr memory page disk faults cpu
r b w swap free re mf pi po fr de sr s0 s1 s1 s1 in sy cs us sy... (3 Replies)
Hi,
Im working on Solaris 9 on SPARC-32 bit running on an Ultra-80, and I have to find out the following:-
1. Total Physical Memory in the system(total RAM).
2. Available Physical Memory(i.e. RAM Usage)
3. Total (Logical) Memory in the system
4. Available (Logical) Memory.
I know... (4 Replies)
Friends , i have a question how to check the total memomry and free memory in AIX, We have vmstat ,svmon and topas commands.Which command among the will give the true figure. (6 Replies)
I need to put a program together to determine the total, available memory and total and available swap on unix machines. I have been searching for weeks and I seem to run into dead ends. Every unix platform I look at has a different way to determine memory info.
Any sugggestions or new... (4 Replies)