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 569099
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T13:15:32+00:00 2026-05-13T13:15:32+00:00

I have a text file and the last 2 lines look like this… Uptime:

  • 0

I have a text file and the last 2 lines look like this…

Uptime: 822832  Threads: 32  Questions: 13591705  Slow queries: 722  Opens: 81551  Flush tables: 59  Open tables: 64  Queries per second avg: 16.518
Uptime: 822893  Threads: 31  Questions: 13592768  Slow queries: 732  Opens: 81551  Flush tables: 59  Open tables: 64  Queries per second avg: 16.618

How do I find the difference between the two values of each parameter?
The expected output is:

61 -1 1063 10 0 0 0 0.1

In other words I will like to deduct the current uptime value from the earlier uptime.
Find the difference between the threads and Questions and so on.

The purpose of this exercise is to watch this file and alert the user when the difference is too high. For e.g. if the slow queries are more than 500 or the “Questions” parameter is too low (<100)

(It is the MySQL status but has nothing to do with it, so mysql tag does not apply)

  • 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-13T13:15:32+00:00Added an answer on May 13, 2026 at 1:15 pm

    here’s one way. tail is used to get the last 2 lines, especially useful in terms of efficiency if you have a big file.

    tail -2 file | awk '
    {
     gsub(/[a-zA-Z: ]+/," ")
     m=split($0,a," ")
     if (f) {
       for (i=1;i<=m;i++){
            print -(b[i]-a[i])
        }
       # to check for Questions, slow queries etc
       if (  -(b[3]-a[3])  < 100 ){
          print "Questions parameter too low"
       }else if ( -(b[4]-a[4]) > 500 ){
          print "Slow queries more than 500"
       }else if ( a[1] - b[1] < 0 ){
          print "mysql ...... "
       }
        exit
     }
     for(i=1;i<=m;i++ ){ b[i]=a[i] ;f=1 }
    } '
    

    output

    $ ./shell.sh
    61
    -1
    1063
    10
    0
    0
    0
    0.1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a log file that has lines that look like this: 1,2546857-23541,f_last,user,4:19 P.M.,11/02/2009,START,27,27,3,c2546857-23541,
I have text file with a row like this: SendersTimeSeriesIdentification: COMPANY_A/COMPANY_B/REF_7/20090505 I'd like to
Possible Duplicate: Reading the last n lines from a huge text file I have
I have text file with some stuff that i would like to put into
I have text file with something like first line line nr 2 line three
I have text file, like FILED AS OF DATE: 20090209 DATE AS OF CHANGE:
I have text file with some text information and i need to split this
I have text file with entries like 123 112 3333 44 2 How to
I have a text file of this format: L O A D C A
I have text file, names.txt, with every row containing a last name: Smith Johnson

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.