Emit various debugging information with the results of the fingerprinter

This commit is contained in:
Sean Chittenden
2016-05-09 12:21:51 -07:00
parent 32ade79a62
commit fd9bcabaa8
4 changed files with 6 additions and 2 deletions

View File

@@ -582,6 +582,7 @@ func (c *Client) reservePorts() {
func (c *Client) fingerprint() error {
whitelist := c.config.ReadStringListToMap("fingerprint.whitelist")
whitelistEnabled := len(whitelist) > 0
c.logger.Printf("[DEBUG] client: built-in fingerprints: %v", fingerprint.BuiltinFingerprints)
var applied []string
var skipped []string

View File

@@ -48,10 +48,12 @@ func (f *CPUFingerprint) Fingerprint(cfg *config.Config, node *structs.Node) (bo
if mhz > 0 {
node.Attributes["cpu.frequency"] = fmt.Sprintf("%.6f", mhz)
f.logger.Printf("[DEBUG] fingerprint.cpu: frequency: %02.1fMHz", mhz)
}
if numCores > 0 {
node.Attributes["cpu.numcores"] = fmt.Sprintf("%d", numCores)
f.logger.Printf("[DEBUG] fingerprint.cpu: core count: %d", numCores)
}
if mhz > 0 && numCores > 0 {

View File

@@ -77,6 +77,7 @@ func (f *NetworkFingerprint) Fingerprint(cfg *config.Config, node *structs.Node)
if throughput := f.linkSpeed(intf.Name); throughput > 0 {
newNetwork.MBits = throughput
f.logger.Printf("[DEBUG] fingerprint.network: link speed for %v set to %v", intf.Name, newNetwork.MBits)
} else {
f.logger.Printf("[DEBUG] fingerprint.network: Unable to read link speed; setting to default %v", cfg.NetworkSpeed)
newNetwork.MBits = cfg.NetworkSpeed

View File

@@ -16,14 +16,14 @@ func (f *NetworkFingerprint) linkSpeedSys(device string) int {
// Read contents of the device/speed file
content, err := ioutil.ReadFile(path)
if err != nil {
f.logger.Printf("[WARN] fingerprint.network: Unable to read link speed from %s", path)
f.logger.Printf("[DEBUG] fingerprint.network: Unable to read link speed from %s", path)
return 0
}
lines := strings.Split(string(content), "\n")
mbs, err := strconv.Atoi(lines[0])
if err != nil || mbs <= 0 {
f.logger.Printf("[WARN] fingerprint.network: Unable to parse link speed from %s", path)
f.logger.Printf("[DEBUG] fingerprint.network: Unable to parse link speed from %s", path)
return 0
}