-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #108 from mfreeman451/99-feat-sparkgraphs-in-grid-…
…mode 99 feat sparkgraphs in grid mode
- Loading branch information
Showing
27 changed files
with
1,128 additions
and
477 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#!/bin/bash | ||
|
||
VERSION=${VERSION:-1.0.5} | ||
VERSION=${VERSION:-1.0.6} | ||
|
||
|
||
./setup-deb-poller.sh | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// Package agent pkg/agent/icmp_checker.go | ||
package agent | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"time" | ||
|
||
"github.com/mfreeman451/serviceradar/pkg/models" | ||
"github.com/mfreeman451/serviceradar/pkg/scan" | ||
) | ||
|
||
type ICMPChecker struct { | ||
Host string | ||
Count int | ||
} | ||
|
||
const ( | ||
defaultICMPCount = 3 | ||
defaultConcurrent = 1 | ||
) | ||
|
||
func (p *ICMPChecker) Check(ctx context.Context) (isDown bool, results string) { | ||
scanner := scan.NewCombinedScanner(defaultICMPCount*time.Second, defaultConcurrent, p.Count) | ||
|
||
target := models.Target{ | ||
Host: p.Host, | ||
Mode: models.ModeICMP, | ||
} | ||
|
||
resultChan, err := scanner.Scan(ctx, []models.Target{target}) | ||
if err != nil { | ||
return false, fmt.Sprintf("ICMP check failed: %v", err) | ||
} | ||
|
||
var totalResponseTime time.Duration | ||
|
||
var successfulPings int | ||
|
||
for result := range resultChan { | ||
if result.Error != nil { | ||
return false, result.Error.Error() | ||
} | ||
|
||
if result.Available { | ||
totalResponseTime += result.RespTime | ||
successfulPings++ | ||
} | ||
} | ||
|
||
if successfulPings == 0 { | ||
return false, "No successful ICMP replies" | ||
} | ||
|
||
avgResponseTime := totalResponseTime / time.Duration(successfulPings) | ||
|
||
return true, fmt.Sprintf("%d", avgResponseTime) | ||
} |
Oops, something went wrong.