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

  • SEARCH
  • Home
  • 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 7648813
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T10:48:41+00:00 2026-05-31T10:48:41+00:00

I want to convert the output of ifstat command into JSON and serve it

  • 0

I want to convert the output of ifstat command into JSON and serve it over http on the fly to be used for a javascript graph app. Are there any lightweight — sed or awk — command-line solutions which I can use? I do not want to store JSON output on the disk and it would be good if the web-server was a small lightweight command line tool into which I can pipe JSON output.

EDIT 1:

This is the live streaming chart library which will use the data. I’m not keen on a specific web server; any webserver that does the job would be fine.

  • 1 1 Answer
  • 0 Views
  • 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-31T10:48:43+00:00Added an answer on May 31, 2026 at 10:48 am

    This is what I have tried.

    Terminal #1

    ifstat -n | awk 'NR>2{print systime(),$0; fflush()}' | tee ifstat.log
    

    Terminal #2

    while :
    do
    { 
        echo -e "HTTP/1.1 200 OK"
        echo -e "Content-Type: application/json\n"
        tail -n1 ifstat.log | awk '{ printf("{\"time\":%s, \"in\":%s, \"out\":%s}\n", $1, $2, $3) }'
    } | nc -l 8000
    done
    

    firefox

    open: http://localhost:8000

    {"time":1332052321, "in":1.24, "out":2.62}
    

    I know little about JSON. Maybe the output is invalid. You should rewrite the awk command.

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

Sidebar

Related Questions

I want to convert the JSON output of the Shopify API call into an
I need to convert the output of an .aspx page into a JSON object
i want to convert my input Excel file into the Output XML file. If
I want to convert the output of any website got with curl into utf8
i have output from a server like [alex, \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd] i want to convert it
I want to convert all the URLs in a javascript string to links, in
I want to convert XML into binary data in Java? What is the fastest
I want to convert a binary number into a float number. Here's an example
I want to convert string Date into Timestamp in java. The following coding i
I seek a perl module to convert CppUnit output to TAP format. I want

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.