ignore loop devices as well

This commit is contained in:
wh1te909 2024-01-27 20:24:56 +00:00
parent ff9c271c76
commit cfbbdc89e7
2 changed files with 11 additions and 1 deletions

View File

@ -395,11 +395,12 @@ func (a *Agent) GetWMIInfo() map[string]interface{} {
// disks
block, err := ghw.Block(ghw.WithDisableWarnings())
ignore := []string{"ram", "loop"}
if err != nil {
a.Logger.Errorln("ghw.Block()", err)
} else {
for _, disk := range block.Disks {
if disk.IsRemovable || strings.Contains(disk.Name, "ram") {
if disk.IsRemovable || contains(disk.Name, ignore) {
continue
}
ret := fmt.Sprintf("%s %s %s %s %s %s", disk.Vendor, disk.Model, disk.StorageController, disk.DriveType, disk.Name, ByteCountSI(disk.SizeBytes))

View File

@ -311,6 +311,15 @@ func removeNewlines(s string) string {
return strings.ReplaceAll(s, "\n", "")
}
func contains(s string, substrs []string) bool {
for _, substr := range substrs {
if strings.Contains(s, substr) {
return true
}
}
return false
}
func stringInSlice(a string, list []string) bool {
for _, b := range list {
if b == a {