Trying to get all lines starting with Status and 2nd column starts with conn

Status : conn:Get IPs

/^\sStatus/ {
if ($2 ~ /^conn/) {
state = 1
} else {
state = 0
}

I need to find all instances where $2 begins with conn.
It needs to match the following status for example:
conn:
conn:Get IPs
conn:idle

It needs to NOT match:
not-conn:
not-conn:idle

Thanks!

Hi, @Brad_Spilde

Can you please paste the whole input buffer that you need to parse?

<response status="success">
<result>
Agent: uid-server-01.domain.local(vsys: vsys1) Host: 172.18.80.101(172.18.80.101):5000
Status                                            : conn:Get IPs
Version                                           : 0x5
num of connection tried                           : 52908
num of connection succeeded                       : 21
num of connection failed                          : 52887
num of status msgs rcvd                           : 1243046
num of request of status msgs sent                : 1243076
num of request of ip mapping msgs sent            : 6589956
num of request of new ip mapping msgs sent        : 0
num of request of all ip mapping msgs sent        : 21
num of user ip mapping msgs rcvd                  : 2167016
num of ip msgs rcvd but failed to proc            : 0
num of user ip mapping add entries rcvd           : 13923156
num of user ip mapping del entries rcvd           : 1095453
num of request of group msgs sent                 : 0
num of group msgs rcvd                            : 0
num of group msgs recvd buf fail to proc          : 0
num of xml data msgs rcvd                         : 0
num of xml data msgs rcvd but failed to proc      : 0
num of sync digest messages sent                  : 0
num of sync digest messages received              : 0
num of sync group messages sent                   : 0
num of sync group messages received               : 0
num of sync users messages sent                   : 0
num of sync users messages received               : 0
num of bloomfilter requests sent                  : 1846
num of bloomfilter response received              : 1769
num of bloomfilter response failed to proc        : 0
num of bloomfilter resize requests sent           : 0
Last heard(seconds ago)                           : 1
Messages State:
  Job ID                                          : 0
  Sent messages                                   : 7834838
  Rcvd messages                                   : 3411867
  Rcvd rate(msgs/s)                               : 0
  Rcvd peak rate(msgs/s)                          : 21
  Lost messages                                   : 78
  Failed to send messages                         : 4
  Failed to enqueue messages                      : 0
  Queued sending msgs with priority 0             : 0
  Queued sending msgs with priority 1             : 0
  Queued rcvring msgs with priority 0             : 0
  Queued rcvring msgs with priority 1             : 0
Credential Enforcement Status : Disabled

Agent: uid-server-02.domain.local(vsys: vsys1) Host: 172.18.80.102(172.18.80.102):5000
Status                                            : conn:idle
Version                                           : 0x5
num of connection tried                           : 561
num of connection succeeded                       : 21
num of connection failed                          : 540
num of status msgs rcvd                           : 1294600
num of request of status msgs sent                : 1294644
num of request of ip mapping msgs sent            : 6860345
num of request of new ip mapping msgs sent        : 0
num of request of all ip mapping msgs sent        : 21
num of user ip mapping msgs rcvd                  : 2264419
num of ip msgs rcvd but failed to proc            : 0
num of user ip mapping add entries rcvd           : 14627105
num of user ip mapping del entries rcvd           : 1145735
num of request of group msgs sent                 : 0
num of group msgs rcvd                            : 0
num of group msgs recvd buf fail to proc          : 0
num of xml data msgs rcvd                         : 0
num of xml data msgs rcvd but failed to proc      : 0
num of sync digest messages sent                  : 0
num of sync digest messages received              : 0
num of sync group messages sent                   : 0
num of sync group messages received               : 0
num of sync users messages sent                   : 0
num of sync users messages received               : 0
num of bloomfilter requests sent                  : 1846
num of bloomfilter response received              : 1844
num of bloomfilter response failed to proc        : 0
num of bloomfilter resize requests sent           : 0
Last heard(seconds ago)                           : 0
Messages State:
  Job ID                                          : 0
  Sent messages                                   : 8156866
  Rcvd messages                                   : 3560900
  Rcvd rate(msgs/s)                               : 0
  Rcvd peak rate(msgs/s)                          : 21
  Lost messages                                   : 3
  Failed to send messages                         : 8
  Failed to enqueue messages                      : 0
  Queued sending msgs with priority 0             : 0
  Queued sending msgs with priority 1             : 0
  Queued rcvring msgs with priority 0             : 0
  Queued rcvring msgs with priority 1             : 0
Credential Enforcement Status : Disabled


</result>
</response>

Does this help:

awk  '/^Status/ && $3 ~ /^conn:/ {print}' brad.txt 
Status                                            : conn:Get IPs
Status                                            : conn:idle
1 Like

Looks like my issue was just that I was hitting the wrong column. I needed 3 not 2 as you pointed out to me. :slight_smile:

# 	Status                                            : not-conn:idle(Error: Failed to connect to User-ID-Agent at          1.1.1.1(1.1.1.1):222
# OR
# 	Status                                            : conn:Get IPs
/^\sStatus/ {
if ($3 ~ /^conn/) {
	state = 1
} else {
	state = 0
}

The " : " in the middle sneaks in another column :slight_smile:

I don’t think that you need to take this much further but if this
was a more complicated case than you could have tried to define ‘:’
as a field separator.

1 Like