added ping raw string
This commit is contained in:
parent
54f395b764
commit
56b9d39ba9
|
@ -31,6 +31,7 @@ type Summary interface {
|
||||||
type Result interface {
|
type Result interface {
|
||||||
GetResponses() map[int]Response
|
GetResponses() map[int]Response
|
||||||
GetSummary() Summary
|
GetSummary() Summary
|
||||||
|
GetRaw() []string
|
||||||
}
|
}
|
||||||
|
|
||||||
type PingOption struct {
|
type PingOption struct {
|
||||||
|
@ -107,6 +108,7 @@ func (s *PingSummary) GetAvgTime() float32 {
|
||||||
type PingResult struct {
|
type PingResult struct {
|
||||||
Responses map[int]Response `json:"responses,omitempty"`
|
Responses map[int]Response `json:"responses,omitempty"`
|
||||||
Summary Summary `json:"summary,omitempty"`
|
Summary Summary `json:"summary,omitempty"`
|
||||||
|
Raw []string `json:"raw,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *PingResult) GetResponses() map[int]Response {
|
func (r *PingResult) GetResponses() map[int]Response {
|
||||||
|
@ -115,6 +117,9 @@ func (r *PingResult) GetResponses() map[int]Response {
|
||||||
func (r *PingResult) GetSummary() Summary {
|
func (r *PingResult) GetSummary() Summary {
|
||||||
return r.Summary
|
return r.Summary
|
||||||
}
|
}
|
||||||
|
func (r *PingResult) GetRaw() []string {
|
||||||
|
return r.Raw
|
||||||
|
}
|
||||||
|
|
||||||
// $ ping 192.168.1.1 -c 7 -i 1 -w 0.3
|
// $ ping 192.168.1.1 -c 7 -i 1 -w 0.3
|
||||||
// PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
|
// PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
|
||||||
|
@ -131,11 +136,13 @@ func parseLinuxPing(output []byte) (Result, error) {
|
||||||
result := &PingResult{
|
result := &PingResult{
|
||||||
Responses: make(map[int]Response, 0),
|
Responses: make(map[int]Response, 0),
|
||||||
Summary: &PingSummary{},
|
Summary: &PingSummary{},
|
||||||
|
Raw: make([]string, 0),
|
||||||
}
|
}
|
||||||
lines := strings.Split(string(output), "\n")
|
lines := strings.Split(string(output), "\n")
|
||||||
|
|
||||||
LOOP:
|
LOOP:
|
||||||
for _, line := range lines {
|
for _, line := range lines {
|
||||||
|
result.Raw = append(result.Raw, line)
|
||||||
fields := strings.Fields(line)
|
fields := strings.Fields(line)
|
||||||
switch len(fields) {
|
switch len(fields) {
|
||||||
case 5:
|
case 5:
|
||||||
|
@ -255,12 +262,14 @@ func parseWindowsPing(output []byte) (Result, error) {
|
||||||
result := &PingResult{
|
result := &PingResult{
|
||||||
Responses: make(map[int]Response, 0),
|
Responses: make(map[int]Response, 0),
|
||||||
Summary: &PingSummary{},
|
Summary: &PingSummary{},
|
||||||
|
Raw: make([]string, 0),
|
||||||
}
|
}
|
||||||
lines := strings.Split(string(output), "\n")
|
lines := strings.Split(string(output), "\n")
|
||||||
|
|
||||||
seq := 1
|
seq := 1
|
||||||
LOOP:
|
LOOP:
|
||||||
for _, line := range lines {
|
for _, line := range lines {
|
||||||
|
result.Raw = append(result.Raw, line)
|
||||||
fields := strings.Fields(line)
|
fields := strings.Fields(line)
|
||||||
switch len(fields) {
|
switch len(fields) {
|
||||||
case 3:
|
case 3:
|
||||||
|
@ -374,11 +383,13 @@ func parseDarwinPing(output []byte) (Result, error) {
|
||||||
result := &PingResult{
|
result := &PingResult{
|
||||||
Responses: make(map[int]Response, 0),
|
Responses: make(map[int]Response, 0),
|
||||||
Summary: &PingSummary{},
|
Summary: &PingSummary{},
|
||||||
|
Raw: make([]string, 0),
|
||||||
}
|
}
|
||||||
lines := strings.Split(string(output), "\n")
|
lines := strings.Split(string(output), "\n")
|
||||||
|
|
||||||
LOOP:
|
LOOP:
|
||||||
for _, line := range lines {
|
for _, line := range lines {
|
||||||
|
result.Raw = append(result.Raw, line)
|
||||||
fields := strings.Fields(line)
|
fields := strings.Fields(line)
|
||||||
switch len(fields) {
|
switch len(fields) {
|
||||||
case 5:
|
case 5:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user