mirror of
https://github.com/davidallendj/magellan.git
synced 2025-12-20 03:27:03 -07:00
Added more output for debugging
This commit is contained in:
parent
a75530e96b
commit
e93f49eb82
3 changed files with 21 additions and 8 deletions
|
|
@ -125,7 +125,10 @@ func CollectAll(probeStates *[]ScannedResult, l *log.Logger, q *QueryParams) err
|
|||
l.Log.Errorf("failed to query chassis: %v", err)
|
||||
continue
|
||||
}
|
||||
json.Unmarshal(chassis, &rm)
|
||||
err = json.Unmarshal(chassis, &rm)
|
||||
if err != nil {
|
||||
l.Log.Errorf("failed to unmarshal chassis JSON: %v", err)
|
||||
}
|
||||
data["Chassis"] = rm["Chassis"]
|
||||
|
||||
// systems
|
||||
|
|
@ -133,7 +136,10 @@ func CollectAll(probeStates *[]ScannedResult, l *log.Logger, q *QueryParams) err
|
|||
if err != nil {
|
||||
l.Log.Errorf("failed to query systems: %v", err)
|
||||
}
|
||||
json.Unmarshal(systems, &rm)
|
||||
err = json.Unmarshal(systems, &rm)
|
||||
if err != nil {
|
||||
l.Log.Errorf("failed to unmarshal system JSON: %v", err)
|
||||
}
|
||||
data["Systems"] = rm["Systems"]
|
||||
|
||||
// add other fields from systems
|
||||
|
|
|
|||
|
|
@ -95,11 +95,12 @@ func generateHosts(ip *net.IP, mask *net.IPMask) []string {
|
|||
return hosts
|
||||
}
|
||||
|
||||
func ScanForAssets(hosts []string, ports []int, threads int, timeout int, disableProbing bool) []ScannedResult {
|
||||
results := make([]ScannedResult, 0, len(hosts))
|
||||
done := make(chan struct{}, threads+1)
|
||||
chanHost := make(chan string, threads+1)
|
||||
// chanPort := make(chan int, threads+1)
|
||||
func ScanForAssets(hosts []string, ports []int, threads int, timeout int, disableProbing bool, verbose bool) []ScannedResult {
|
||||
var (
|
||||
results = make([]ScannedResult, 0, len(hosts))
|
||||
done = make(chan struct{}, threads+1)
|
||||
chanHost = make(chan string, threads+1)
|
||||
)
|
||||
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(threads)
|
||||
|
|
@ -118,8 +119,14 @@ func ScanForAssets(hosts []string, ports []int, threads int, timeout int, disabl
|
|||
url := fmt.Sprintf("https://%s:%d/redfish/v1/", result.Host, result.Port)
|
||||
res, _, err := util.MakeRequest(nil, url, "GET", nil, nil)
|
||||
if err != nil || res == nil {
|
||||
if verbose {
|
||||
fmt.Printf("failed to make request: %v\n", err)
|
||||
}
|
||||
continue
|
||||
} else if res.StatusCode != http.StatusOK {
|
||||
if verbose {
|
||||
fmt.Printf("request returned code: %v\n", res.StatusCode)
|
||||
}
|
||||
continue
|
||||
} else {
|
||||
probeResults = append(probeResults, result)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue