---
# System prepended metadata

title: General Parser
tags: [output, tracer, code, pseudocode]

---

# General Parser
###### tags: `tracer` `code` `pseudocode` `output`

Source Code is here: https://github.com/Sheenam3/tcptracer-goparser/blob/master/genparser.go

Pseudocode:

```
main() {

#Goroutine 1: Tcptracer (Storing every new line)
            
#Goroutine 2: Tcpconnect (Storing every new line)

#main routine waits for 10 seconds

#Goroutine 1 and 2 stops after taking 10 lines

#Dump Data struct to show logs

}
```


# Output:

Struct n includes the following stored and parsed values:- 
1. One output line log
2. PID
3. Timestamp
4. probeName

Output n:- 
Normal command output displayed

```
2019/12/25 02:34:30 pid: 26286
2019/12/25 02:34:30 Probe Name: tcptracer
2019/12/25 02:34:30 pid: 26287
2019/12/25 02:34:30 Probe Name: tcpconnect
Struct 0  includes: {0.000    23196  coredns      4  127.0.0.1        127.0.0.1        8080 23196 0 tcpconnect}
Output 0: 0.000    23196  coredns      4  127.0.0.1        127.0.0.1        8080
 PID:23196      | TimeStamp:0    | ProbeName:tcpconnect 
Struct 1  includes: {0.331    22624  python       4  10.233.64.31     10.233.0.1       443  22624 0.331 tcpconnect}
Output 1: 0.331    22624  python       4  10.233.64.31     10.233.0.1       443 
 PID:22624      | TimeStamp:0.331        | ProbeName:tcpconnect 
Struct 2  includes: {0.437    22624  python       4  10.233.64.31     10.233.0.1       443  22624 0.437 tcpconnect}
Output 2: 0.437    22624  python       4  10.233.64.31     10.233.0.1       443 
 PID:22624      | TimeStamp:0.437        | ProbeName:tcpconnect 
Struct 3  includes: {0.983    27515  kubelet      4  10.233.64.1      10.233.64.36     8080 27515 0.983 tcpconnect}
Output 3: 0.983    27515  kubelet      4  10.233.64.1      10.233.64.36     8080
 PID:27515      | TimeStamp:0.983        | ProbeName:tcpconnect 
Struct 4  includes: {1.000    23196  coredns      4  127.0.0.1        127.0.0.1        8080 23196 1 tcpconnect}
Output 4: 1.000    23196  coredns      4  127.0.0.1        127.0.0.1        8080
 PID:23196      | TimeStamp:1    | ProbeName:tcpconnect 
Struct 5  includes: {1.362    27515  kubelet      4  10.233.64.1      10.233.64.37     44135 27515 1.362 tcpconnect}
Output 5: 1.362    27515  kubelet      4  10.233.64.1      10.233.64.37     44135
 PID:27515      | TimeStamp:1.362        | ProbeName:tcpconnect 
Struct 6  includes: {2.000    23196  coredns      4  127.0.0.1        127.0.0.1        8080 23196 2 tcpconnect}
Output 6: 2.000    23196  coredns      4  127.0.0.1        127.0.0.1        8080
 PID:23196      | TimeStamp:2    | ProbeName:tcpconnect 
Struct 7  includes: {2.289    27515  kubelet      4  127.0.0.1        127.0.0.1        10251 27515 2.289 tcpconnect}
Output 7: 2.289    27515  kubelet      4  127.0.0.1        127.0.0.1        10251
 PID:27515      | TimeStamp:2.289        | ProbeName:tcpconnect 
Struct 8  includes: {2.467    22794  python       4  10.233.64.31     10.233.0.1       443  22794 2.467 tcpconnect}
Output 8: 2.467    22794  python       4  10.233.64.31     10.233.0.1       443 
 PID:22794      | TimeStamp:2.467        | ProbeName:tcpconnect 
Struct 9  includes: {2.572    22794  python       4  10.233.64.31     10.233.0.1       443  22794 2.572 tcpconnect}
Output 9: 2.572    22794  python       4  10.233.64.31     10.233.0.1       443 
 PID:22794      | TimeStamp:2.572        | ProbeName:tcpconnect 
Struct 10  includes: {0.000    C  22624  python           4  10.233.64.31     10.233.0.1       60750  443    22624 0 tcptracer}
Output 10: 0.000    C  22624  python           4  10.233.64.31     10.233.0.1       60750  443   
 PID:22624      | TimeStamp:0    | ProbeName:tcptracer 
Struct 11  includes: {0.000    A  21278  kube-apiserver   6  [::]             [0:ffff:c0a8:a0f::] 0      65535  21278 0 tcptracer}
Output 11: 0.000    A  21278  kube-apiserver   6  [::]             [0:ffff:c0a8:a0f::] 0      65535 
 PID:21278      | TimeStamp:0    | ProbeName:tcptracer 
Struct 12  includes: {0.103    X  22624  python           4  10.233.64.31     10.233.0.1       60750  443    22624 0.103 tcptracer}
Output 12: 0.103    X  22624  python           4  10.233.64.31     10.233.0.1       60750  443   
 PID:22624      | TimeStamp:0.103        | ProbeName:tcptracer 
Struct 13  includes: {0.103    X  21278  kube-apiserver   6  [::]             [0:ffff:c0a8:a0f::] 0      65535  21278 0.103 tcptracer}
Output 13: 0.103    X  21278  kube-apiserver   6  [::]             [0:ffff:c0a8:a0f::] 0      65535 
 PID:21278      | TimeStamp:0.103        | ProbeName:tcptracer 
Struct 14  includes: {0.106    C  22624  python           4  10.233.64.31     10.233.0.1       60752  443    22624 0.106 tcptracer}
Output 14: 0.106    C  22624  python           4  10.233.64.31     10.233.0.1       60752  443   
 PID:22624      | TimeStamp:0.106        | ProbeName:tcptracer 
Struct 15  includes: {0.106    A  21278  kube-apiserver   6  [::]             [0:ffff:c0a8:a0f::] 0      65535  21278 0.106 tcptracer}
Output 15: 0.106    A  21278  kube-apiserver   6  [::]             [0:ffff:c0a8:a0f::] 0      65535 
 PID:21278      | TimeStamp:0.106        | ProbeName:tcptracer 
Struct 16  includes: {0.185    X  22624  python           4  10.233.64.31     10.233.0.1       60726  443    22624 0.185 tcptracer}
Output 16: 0.185    X  22624  python           4  10.233.64.31     10.233.0.1       60726  443   
 PID:22624      | TimeStamp:0.185        | ProbeName:tcptracer 
Struct 17  includes: {0.185    X  21278  kube-apiserver   6  [::]             [0:ffff:c0a8:a0f::] 0      65535  21278 0.185 tcptracer}
Output 17: 0.185    X  21278  kube-apiserver   6  [::]             [0:ffff:c0a8:a0f::] 0      65535 
 PID:21278      | TimeStamp:0.185        | ProbeName:tcptracer 
Struct 18  includes: {0.652    C  27515  kubelet          4  10.233.64.1      10.233.64.36     53978  8080   27515 0.652 tcptracer}
Output 18: 0.652    C  27515  kubelet          4  10.233.64.1      10.233.64.36     53978  8080  
 PID:27515      | TimeStamp:0.652        | ProbeName:tcptracer 
```

