8. amps-grep

amps-grep is a utility used to search AMPS error logs. The utility supports both literal search terms and regular expressions. The utility is aware of the structure of AMPS error messages, and returns the full text of a matching error rather than simply the line that matches.

The utility can search for a literal match, or use regular expressions. The regular expression dialect supported is the full set of regular expressions supported by the Python re module.

Options and Parameters

Option Description
The file or files to search.
–version Show the version number of the program and exit.
–help Show the help message and exit.
-e, –search_term=TERM Literal term to search.
-E, –extended_regex=REGEX Regular expression to search.
-n, –line-number Include line numbers in results.
-H, –with-filename Include filename in results.
-h, –no-filename Do not include filename in results
-i, –ignore-case Use case-insensitive matching.

Table 8.1: Parameters for amps_grep

tip amps-grep reads from the standard input if no filenames are provided.


The following examples shows the output of amps-grep. This example simply searches for any occurence of the term pubber, the name of a client, in the AMPS log.

$ amps-grep -e pubber trace.out

2017-09-28T16:57:49.8267470-07:00 [26] trace: 12-0010 client[AMPS-Sample-any-tcp-1-212373446269826439] logon command received: {"c":"logon","cid":"0","client_name":"pubber","mt":"nvfix","a":"processed","version":""}
2017-09-28T16:57:49.8269820-07:00 [45] info: 1F-0004 [AMPS-Sample-any-tcp-1-212373446269826439] AMPS client session logon for: pubber
client session info:
 client authid           = ''
 client name hash        = 7094790850998930143
 client version          =
 last acked client seq   = 0
 last txn log client seq = 0
 correlation id          =
2017-09-28T16:57:49.8270020-07:00 [45] trace: 17-0002 client[pubber] ack sent: {"c":"ack","cid":"0","s":0,"bm":"7094790850998930143|0|","client_name":"pubber","a":"processed","status":"success","reason":"authentication disabled","version":""}
2017-09-28T16:57:49.8272340-07:00 [26] trace: 12-0001 client[pubber] publish command received: {"c":"p","t":"test"}Data=0^A
2017-09-28T16:57:49.8281260-07:00 [26] trace: 12-0001 client[pubber] publish command received: {"c":"p","t":"test"}Data=5^A
2017-09-28T16:57:49.8281840-07:00 [26] info: 07-0013 client[pubber] disconnected.
2017-09-28T16:57:49.8282820-07:00 [26] info: 16-0004 client[pubber] 0 queued sow requests canceled.