-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
152 additions
and
44 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
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,7 @@ | ||
package hostcollector | ||
|
||
import "github.com/cha87de/kvmtop/models" | ||
|
||
func domainCollect(domain *models.Domain) { | ||
// nothing to do at present | ||
} |
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,16 @@ | ||
package hostcollector | ||
|
||
import ( | ||
"os" | ||
|
||
"github.com/cha87de/kvmtop/models" | ||
libvirt "github.com/libvirt/libvirt-go" | ||
) | ||
|
||
func domainLookup(domain *models.Domain, libvirtDomain libvirt.Domain) { | ||
name, err := os.Hostname() | ||
if err != nil { | ||
panic(err) | ||
} | ||
domain.AddMetricMeasurement("host_name", models.CreateMeasurement(name)) | ||
} |
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,12 @@ | ||
package hostcollector | ||
|
||
import ( | ||
"github.com/cha87de/kvmtop/collectors" | ||
"github.com/cha87de/kvmtop/models" | ||
) | ||
|
||
func domainPrint(domain *models.Domain) []string { | ||
host := collectors.GetMetricString(domain.Measurable, "host_name", 0) | ||
result := append([]string{host}) | ||
return result | ||
} |
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,7 @@ | ||
package hostcollector | ||
|
||
import "github.com/cha87de/kvmtop/models" | ||
|
||
func hostCollect(host *models.Host) { | ||
// nothing to do | ||
} |
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,22 @@ | ||
package hostcollector | ||
|
||
import ( | ||
"os" | ||
|
||
"github.com/cha87de/kvmtop/config" | ||
"github.com/cha87de/kvmtop/models" | ||
"github.com/cha87de/kvmtop/util" | ||
) | ||
|
||
func hostLookup(host *models.Host) { | ||
name, err := os.Hostname() | ||
if err != nil { | ||
panic(err) | ||
} | ||
host.AddMetricMeasurement("host_name", models.CreateMeasurement(name)) | ||
|
||
if config.Options.Verbose { | ||
uuid := util.GetSysDmiUUID() | ||
host.AddMetricMeasurement("host_uuid", models.CreateMeasurement(uuid.Value)) | ||
} | ||
} |
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,18 @@ | ||
package hostcollector | ||
|
||
import ( | ||
"github.com/cha87de/kvmtop/collectors" | ||
"github.com/cha87de/kvmtop/config" | ||
"github.com/cha87de/kvmtop/models" | ||
) | ||
|
||
func hostPrint(host *models.Host) []string { | ||
hostname := collectors.GetMetricString(host.Measurable, "host_name", 0) | ||
result := []string{hostname} | ||
|
||
if config.Options.Verbose { | ||
hostUUID := collectors.GetMetricString(host.Measurable, "host_uuid", 0) | ||
result = append(result, hostUUID) | ||
} | ||
return result | ||
} |
This file was deleted.
Oops, something went wrong.
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,25 @@ | ||
package util | ||
|
||
import ( | ||
"bytes" | ||
"fmt" | ||
"io/ioutil" | ||
) | ||
|
||
// SysDmiUUID reflects the systems UUID from /sys/devices/virtual/dmi/id/product_uuid | ||
type SysDmiUUID struct { | ||
Value string | ||
} | ||
|
||
// GetSysDmiUUID reads the hosts DMI UUID from /sys/devices/virtual/dmi/id/product_uuid | ||
// Please Note: root privileges are required to read the file | ||
func GetSysDmiUUID() SysDmiUUID { | ||
stat := SysDmiUUID{} | ||
filepath := fmt.Sprint("/sys/devices/virtual/dmi/id/product_uuid") | ||
filecontent, _ := ioutil.ReadFile(filepath) | ||
fmt.Fscan( | ||
bytes.NewBuffer(filecontent), | ||
&stat.Value, | ||
) | ||
return stat | ||
} |