Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1058365
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T18:01:00+00:00 2026-05-16T18:01:00+00:00

I have collected vmstat data in a file . It gives details about free,

  • 0

I have collected vmstat data in a file . It gives details about free, buffer and cache .
SInce i’m interested in finding the memory usage , I should do the following computation for each line of vmstat output — USED=TOTAL – (FREE+BUFFER+CACHE) where TOTAL is the total RAM memory and USED is the instantaneous memory value.
TOTAL memory = 4042928 (4 GB)

My code is here

grep -v procs $1 | grep -v free | awk '{USED=4042928-$4-$5-$6;print $USED}' > test.dat
awk: program limit exceeded: maximum number of fields size=32767
        FILENAME="-" FNR=1 NR=1
  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T18:01:01+00:00Added an answer on May 16, 2026 at 6:01 pm

    You should not be printing $USED for a start, the variable in awk is USED:

    pax> vmstat
    procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu----
     r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa
     0  0      0 1402804 258392 2159316    0    0    54    79  197  479  1  2 93  3
    
    pax> vmstat | egrep -v 'procs|free' | awk '{USED=4042928-$4-$5-$6;print USED}'
    222780
    

    What is most likely to be happening in your case is that you’re using an awk with that limitation of about 32000 fields per record.

    Because your fields 4, 5 and 6 are respectively 25172, 664 and 8520 (from one of your comments), your USED value becomes 4042928-25172-664-8520 or 4008572.

    If you tried to print USED, that’s what you’d get but, because you’re trying to print $USED, it thinks you want $4008572 (field number 4008572) which is just a little bit beyond the 32000 range.

    Interestingly, if you have a lot more free memory, you wouldn’t get the error but you’d still get an erroneous value 🙂

    By the way, gawk doesn’t have this limitation, it simply prints an empty field (see, for example, section 11.9 here).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have connected to a server via SFTP using FileZilla and accepted adding the
I have successfully connected to an Oracle database (10g) from C# (Visual Studio 2008)
I have two keyboards connected to my PC, is there any way to know
( .NET 2.0, System.Windows.FormsDataGridView and DataTable ) I have 1 datagrid connected to 1
I have some code which collects points (consed integers) from a loop which looks
I have a GSM modem connected via USB. The modem creates 2 serial ports.
I have an ASP .NET 2.0 website connected to a SQL Server 2005 database.
I have a set of WCF web services connected to dynamically by a desktop
I have a .net client application which is connected to a remote database. Is
I have a java application that is connected to a view on a remote

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.