Sponsored Content
Top Forums Shell Programming and Scripting Calculate total memory using free -m Post 303000544 by sam@sam on Friday 14th of July 2017 12:54:14 AM
Old 07-14-2017
Calculate total memory using free -m

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
Code:
free -m | awk 'NR==3{printf "Memory Usage: (%.2f%%)\n", $3*100/32109 }'

But in the above code 32109 is hard coded(Which is total memory highlighted in red color) now I want to make this as generic, how do I pass that value 32109 as a variable in code. How can this be achieved

Last edited by sam@sam; 07-14-2017 at 02:30 AM..
 

9 More Discussions You Might Find Interesting

1. AIX

How to check free/total Memory in AIX

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)
Discussion started by: vimalbhan
6 Replies

2. Shell Programming and Scripting

Awk help needed to calculate total

Hi all, I have a flat file like 10 steven 25 mike 47 Charles 127 Nancy 34 steven 23 mike 67 Charles 7761 Nancy 8 steven 54 mike 88 Charles 1267 Nancy I need to calculate the total of steven and all the members , for this I am using like grep "`sed -n 1p patterns.txt`"... (7 Replies)
Discussion started by: senthilkumar_ak
7 Replies

3. Solaris

How to find Total and Free Physical Memory and Logical Memory in SOLARIS 9

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)
Discussion started by: 0ktalmagik
4 Replies

4. Solaris

how to get the more memory free space (see memory free column)

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)
Discussion started by: murthy76
3 Replies

5. Shell Programming and Scripting

Calculate total space, total used space and total free space in filesystem names matching keyword

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)
Discussion started by: bigben1220
4 Replies

6. AIX

How much total and free memory I have in my aix 5.3 server?

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)
Discussion started by: systemoper
4 Replies

7. Shell Programming and Scripting

Calculate total value from a row

HI I have a file # cat marks.txt MARKS LIST 2013 Name english french chinese latin total_marks wer 34 45 67 23 wqa 12 39 10 56 wsy 23 90 23 78 Now i need to find the total marks of each student using... (11 Replies)
Discussion started by: Priya Amaresh
11 Replies

8. Shell Programming and Scripting

Nagios script to get total and free memory

Hi Experts, need some help. 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... (4 Replies)
Discussion started by: berveglieri
4 Replies

9. Shell Programming and Scripting

Calculate the total

Hi All , I have the following script as below , I tried to modify to meet the requirement , could someone help ? very thanks ================================================================================================ while read STR NAME; do Total=0 MyString="$STR" GetData () {... (18 Replies)
Discussion started by: ust3
18 Replies
FREE(1) 							Linux User's Manual							   FREE(1)

NAME
free - Display amount of free and used memory in the system SYNOPSIS
free [-b|-k|-m|-g] [-c count] [-l] [-o] [-t] [-s delay] [-V] DESCRIPTION
free displays the total amount of free and used physical and swap memory in the system, as well as the buffers used by the kernel. The shared memory column should be ignored; it is obsolete. OPTIONS -b Display the amount of memory in bytes. -c count Display the result count times. Requires the -s option. -g Display the amount of memory in gigabytes. -k Display the amount of memory in kilobytes. This is the default. -l Show detailed low and high memory statistics. -m Display the amount of memory in megabytes. -o Display the output in old format, the only difference being this option will disable the display of the "buffer adjusted" line. -s Continuously display the result delay seconds apart. You may actually specify any floating point number for delay, usleep(3) is used for microsecond resolution delay times. -t Display a line showing the column totals. -V Display version information. FILES
/proc/meminfo memory information AUTHORS
Written by Brian Edmonds. Send bug reports to <albert@users.sf.net> SEE ALSO
ps(1), slabtop(1), top(1), vmstat(8). Cohesive Systems 5 Oct 2009 FREE(1)
All times are GMT -4. The time now is 05:00 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy