Sponsored Content
Full Discussion: simple awk problem
Top Forums Shell Programming and Scripting simple awk problem Post 302438794 by arch12 on Tuesday 20th of July 2010 10:26:04 PM
Old 07-20-2010
simple awk problem

Code:
pcn linus> ntpq -p
     remote           refid      st t when poll reach   delay   offset    disp
==============================================================================
+smpnn01         ntpsrv1          2 u  829 1024  377     1.46    0.793    0.85
*smpnn02         ntpsrv1          2 u  365 1024  377     2.40    0.046    0.27
 LOCAL(0)        LOCAL(0)         3 l   51   64  377     0.00    0.000   10.01
 
ntpq -p | awk '{if ( $8 < 5 ) { print "   "  } else { print $NF, " has high delay " } }'
disp  has high delay

need to print the O/p like smpnn01 has high delay( value of the delay)

could somebody help me print this

Last edited by Scott; 07-28-2010 at 04:39 AM.. Reason: Code tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Simple Scripting Problem

Hi there, I was trying to add a line of text in the middle line of a file. I have counted the lines in the file, and then I divide it into 2, after that I am stuck on how am I suppose to append the line on that file? When I tried to use this command 'second line >> filename' it appends it at... (3 Replies)
Discussion started by: felixwhoals
3 Replies

2. Shell Programming and Scripting

Simple AWK script problem.

Hi all, I have set up a simple awk script to calculate the average of values that are printed out a number of times per second (the number of time the printing occurs varies). The data is of the format shown below: 1 4.43 1 3.65 1 2.45 2 7.65 2 8.23 2 5.65 3 4.65 3 6.21 .. .. 120... (4 Replies)
Discussion started by: omnomtac
4 Replies

3. Shell Programming and Scripting

awk gsub simple problem

Hi New to shell script and awk and need assistance on this problem. I need to use a variable to substitute a string in an external file and write the changed info to another file. At first I did not know if you could use a variable as the sub value but the following showed me that I can. ... (3 Replies)
Discussion started by: hukcjv
3 Replies

4. Shell Programming and Scripting

Please help me with a simple problem

Hi, I have a very simple script like below: for n in 10 20 30 do for a in 30 40 50 60 70 80 do for r in 2 3 4 5 6 7 do m=$((r*a)) count=1 while do echo "a = " $a ", m = " $m ", n = " $n ... (2 Replies)
Discussion started by: Dark2Bright
2 Replies

5. Shell Programming and Scripting

simple awk problem

Hello; I have the following log file: 10/11/11 10:42:02 LOCK Q Userid:284 Username=root UserPID:23158 Device:marlin batch 10/11/11 10:42:02 TableNr:226 TableName:iatkn RecId:116290398 Flags:X Q H 10/11/11 10:42:02 LOCK CONTENTION X 10/11/11 10:42:02 ... (3 Replies)
Discussion started by: delphys
3 Replies

6. Shell Programming and Scripting

Simple awk problem II

Hello; Trying to figure out how to keep just the contents between the two search lines: awk '/regexp_1/ ,/regexp_2/' I do not want lines containing regexp_1 and regexp_2 in the output. Thank you for any ideas Video tutorial on how to use code tags in The UNIX and Linux Forums. (5 Replies)
Discussion started by: delphys
5 Replies

7. Shell Programming and Scripting

another simple awk problem

Hello; I need to print two previous lines after searching for a reg exp: awk '/haywood/' should produce the following =================== p9J46THe020804 89922 Tue Oct 18 21:06 MAILER-DAEMON (host map: lookup (haywood.com): deferred) ... (1 Reply)
Discussion started by: delphys
1 Replies

8. Shell Programming and Scripting

simple awk sort problem

Hello folks I have the following output UNIX95=1 ps -ef -o pcpu,user,pid,args |more %CPU USER PID COMMAND 0.03 root 0 swapper 0.08 root 1 init 0.00 root 13 net_str_cached 0.00 root 12 usbhubd 0.00 root 11 escsid 0.00 root 10... (3 Replies)
Discussion started by: delphys
3 Replies

9. Shell Programming and Scripting

simple wc problem

Hi there, Im sure there is a simple explanation for this but I have a file like this with no balnk lines peter paul john I run the command # var=`grep paul file.txt` # echo $var paul # echo $var | wc -l 1 but when I grep for a value that isnt in the file, i still... (4 Replies)
Discussion started by: rethink
4 Replies

10. Shell Programming and Scripting

Simple awk search problem

Hello; we have : awk '/reg_exp/,0/ prints every line after the first occurrence of "reg_exp" But if I want to print rest of the lines AFTER the last occurrence of "reg_exp", how would I do it ?? Tried : awk ' ! (/reg_exp/,0)' But it errored... Thank you for any... (5 Replies)
Discussion started by: delphys
5 Replies
ntpdc(8)						      System Manager's Manual							  ntpdc(8)

Name
       ntpdc - monitor operation of the NTP daemon, ntpd

Syntax
       /usr/etc/ntpdc [ -n ][ -v ] host1 | IPaddress1 ...

Description
       The  command sends a query to the daemon running on each of the hosts listed on the command line.  The daemon on each responding host sends
       information about the current calculated offset between its time and the time of each of its NTP servers or peers.  The command formats the
       information on the standard output.

       You  can specify hosts by either host name or Internet address.	The hosts that you specify must either exist in the file, or in the master
       database, if the database is being served to your system by BIND/Hesiod or Yellow Pages.  The command by default generates a terse,  table-
       style report.  If you specify the option, the command generates a verbose report.

Options
       -n     Prints  Internet	addresses,  instead  of host names, of the servers or peers.  By default, the Internet addresses of the responding
	      hosts and the names of their servers or peers are printed.

       -v     Prints a verbose report for each of the servers or peers of the responding host.

Examples
   Terse Report:
       The following is a typical terse report generated in response to the command:
       % /usr/etc/ntpdc 555.5.55.55
       The host 555.5.55.55  is  an  NTP  client,  with  the  servers  and  specified  in  its	file.	The  information  returned  is	about  and
	    Address	      Strat  Poll Reach Delay  Offset  Disp
       (rem)	 (lcl)
       .server1  555.5.55.55  1      64   377	53.0   -65.0   5.0
       *server2  555.5.55.55  1      256  377	155.0  -4.0    16.0
       +server3  555.5.55.55  2      64   377	16.0   -61.0   3.0

       The fields are interpreted as follows:

       - , + , . or *
	      A  minus	sign  (-), plus sign (+), or dot (.) indicates a pre-configured peer (see the reference page).	The asterisk (*) indicates
	      which pre-configured peer (if any) is currently being used for synchronization.

       (rem)  The remote host name or Internet address of a peer or server of the responding host.

       (lcl)  The Internet address of the responding host that was specified on the command line.

       Strat  The current operating stratum level of the peer or server.  Since the NTP hierarchy can change dynamically the  stratum  levels  may
	      change.  Lower stratum levels correspond to higher accuracy.

       Poll   Current polling interval in seconds for this peer or server.  Polling intervals change dynamically.

       Reach  Reachability in response to the last 8 polls (value of 8-bit shift register with bits entering from the end furthest to the right).

       Delay  The estimated round-trip delay in milliseconds for NTP message exchanges between the responding host and this peer or server.  Delay
	      is calculated from the previous 8 polls.

       Offset The estimated offset between the peer or server's time and the responding host's time in milliseconds.   This  value  is	calculated
	      from the previous 8 polls.

       Disp   The current estimated value of dispersion in milliseconds for this peer's offset/delay pair.

	      Dispersion  is  used by the daemon in the clock selection algorithm.  Increasing values of dispersion are associated with decreasing
	      quality of the estimate.

   Verbose Report:
       When the option is given, a verbose report for each of the servers or peers of each of the hosts specified on the command  line	is  gener-
       ated.

       The following is a typical verbose report generated in response to the following command line:
       % /usr/etc/ntpdc -v 111.11.111.11

       Neighbor address 555.55.5.55 port:123  local address 111.11.1.11
       Reach: 0377 stratum: 2, precision: -7
       dispersion: 2.000000, flags: 1301, leap: 0
       Reference clock ID: [22.22.2.22] timestamp: 7e5aa1a9.2add5d0b
       hpoll: 10, ppoll: 10, timer: 1024, sent: 85 received: 90
       Delay(ms)   20.00  20.00  28.00	29.00  20.00  39.00  29.00  28.00
       Offset(ms)   5.00   6.00   5.00	-1.00  -2.00   0.00   3.00   5.00

	       delay: 20.000000 offset: 5.000000 dsp 2.000000
       --------------------------------------------------------------------

       The fields are interpreted as follows:

       Neighbor address
	      The address and port number of one NTP server, followed by the Internet address of the responding host (local address).

       Reach: Reachability in response to the last 8 polls (value of 8-bit shift register with bits entering from the end furthest to the right).

       stratum:
	      The  current  operating  stratum level of the peer or server.  Since the NTP hierarchy can change dynamically the stratum levels may
	      change.  Lower stratum levels correspond to higher accuracy.

       precision:
	      The precision of this clock, given in seconds as a power of 2.  If precision is equal to -7, that means that the precision is 2**-7,
	      or 1/128 seconds.  The daemon automatically determines the precision of each clock based on the kernel variable

       disp:  The  current  estimated  value of dispersion in milliseconds for this peer's offset/delay pair.  Dispersion is used by the daemon in
	      the clock selection algorithm.  Increasing values of dispersion are associated with decreasing quality of the estimate.

       flags: nn
	      The parameter is used by the daemon clock selection process.

       leap: flag
	      The leap second indicator.  Non-zero if there is to be a leap second inserted in the NTP timescale.  The bits are set  before  23:59
	      on the day of insertion and reset after 00:00 on the following day.

       Reference clock ID: address
	      If  the NTP server is synchronized by a radio/satellite timecode receiver, this field is or If the NTP server is the local reference
	      clock, this field is Finally, this field can be the of the most accurate NTP server currently serving the responding host.

       timestamp: nn
	      The local time, in hex-timestamp format, when the local clock of the server was last updated.

       hpoll: n
	      The host poll interval which is the maximum interval between messages transmitted to the server, in seconds as a power  of  2.   For
	      example, a value of 6 indicates an interval of 64 seconds.

       ppoll: n
	      The  peer poll interval which is the maximum interval between messages sent by the server, in seconds as a power of 2.  For example,
	      a value of 6 indicates an interval of 64 seconds.

       timer: nn
	      The current poll rate in seconds.

       sent: nn
	      The number of NTP packets sent to this server by the responding host.

       received: nn
	      The number of NTP packets received from this server by the responding host.

       Delay and Offset
	      The round-trip delay and estimated clock offset for the last eight NTP packet exchanges.	If there are fewer than eight  valid  sam-
	      ples, the delay field will be zero.

       delay: est-delay offset: est-offset dsp: n
	      Estimated delay, offset, and dispersion calculated from the above 8 samples.  See RFC 1129 for how to calculate the estimated delay,
	      offset, and dispersion.

Diagnostics
       host1: connection refused
       Check whether the daemon is running on

       host2: unknown
       The command cannot resolve the host name Check that exists in the file, or that it exists in the master database, if the database is  being
       served by BIND/Hesiod or Yellow Pages.

       If  a server is listed in the host's file, but does not appear in the report, it is possible that the daemon on the responding host can not
       resolve the server names in the file.  Check that the server exists in the responding host's file or in the master database, if	the  data-
       base is being served to the responding host by BIND/Hesiod or Yellow Pages.

See Also
       ntp.conf(5), ntp(8), ntpd(8)
       RFC 1129--Internet Time Synchronization:  the Network Time Protocol
       Introduction to Networking and Distributed System Services

																	  ntpdc(8)
All times are GMT -4. The time now is 11:31 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy