Commit Graph

251 Commits

Author SHA1 Message Date
Sean Chittenden 2dcb591cd8
Warn when we're unable to fingerprint the CPU Mhz 2016-06-16 23:07:13 -07:00
Sean Chittenden b8e63411c0
Explicitly call `cpu.Counts()` to determine the CPU core count
Much safer than counting the number of InfoStat structs returned.
2016-06-16 23:07:13 -07:00
Sean Chittenden ec77a1869e
Test for errors 2016-06-16 14:43:46 -07:00
Sean Chittenden bcbec34937
Only actively test Consul when env `CONSUL_HTTP_ADDR` is set 2016-06-10 15:50:11 -04:00
Sean Chittenden 6fdf9135cb
Provide a default ConsulConfig for client/config.DefaultConfig()
Change the unit test to only test if the consul link exists, not the
value of the link.  The old test was hostname specific and therefore
would always be different based on the environment running the tests.
2016-06-10 15:50:11 -04:00
Sean Chittenden bff57a0dce
Reconcile, clean up, and centralize API version numbers (major and minor).
Reduce future confusion by introducing a minor version that is gossiped out
via the `mvn` Serf tag (Minor Version Number, `vsn` is already being used for
to communicate `Major Version Number`).

Background: hashicorp/consul/issues/1346#issuecomment-151663152
2016-06-10 15:50:11 -04:00
Sean Chittenden e727fd8c3c
Centralize the creation of a consul/api.Config struct.
While documented, the consul.timeout parameter wasn't ever set
except one-off in the Consul fingerprinter.
2016-06-10 15:50:11 -04:00
Diptanu Choudhury 15d867d5f1 Updated gopsutil 2016-05-28 19:42:34 -07:00
Sean Chittenden dc28ab0cb5
Speling police 2016-05-15 09:41:34 -07:00
Sean Chittenden 9fd4b82390
Establish a floor of one core for the number of cores.
In most cases the upstream library [shirou/gopsutil](https://github.com/shirou/gopsutil)
needs to be fixed.
2016-05-09 12:22:40 -07:00
Sean Chittenden 53d4681b61
Emit various debugging information with the results of the fingerprinter 2016-05-09 12:21:51 -07:00
Sean Chittenden a2b71983c0
cgroups are a decidedly Linux-only feature. Build and test as such. 2016-05-09 11:56:35 -07:00
Sean Chittenden 8e88b11596
Decrease the log-level from WARN to DEBUG when fingerprinting GCE
This brings the logging here inline with the remaining fingerprinting code
2016-05-09 11:56:35 -07:00
Sean Chittenden 2ff8b10e05
Rename cgroup_universal.go to cgroup_default.go
Universal implies it is applicable to Linux, whereas default implies
the fallthrough for the non-Linux build targets.
2016-05-09 11:56:35 -07:00
Sean Chittenden f8e9a759d3
Move network detection code to Linux-specific build
Non-Linux build targets get the current default of 0.  This will allow
platform specific fingerprinting for network capabilities.
2016-05-09 11:56:35 -07:00
Sean Chittenden f2e01f0eab
Stub out FreeBSD support for Nomad
Compiles, but is not functional (yet).
2016-05-09 11:56:35 -07:00
Troy Swanson f16468c27a Make logging more consistent 2016-04-15 15:42:57 -05:00
Alex Dadgar aefa4b9207 add nomad fingerprinter 2016-03-22 17:12:30 -07:00
Alex Dadgar 4ce455be31 Merge pull request #712 from iverberk/f-cgroup-finterprinter
Add periodic cgroup fingerprinter
2016-01-29 08:50:43 -08:00
Ivo Verberk 22fef1766b Add comments and small improvements to cgroup fingerprinter 2016-01-29 14:34:29 +01:00
Ivo Verberk 2921cf0d92 Fix comment 2016-01-27 10:56:35 +01:00
Ivo Verberk 5f86e28974 Add a periodic cgroup fingerprinter 2016-01-27 07:22:25 +01:00
Alex Dadgar a85800188c Respond to comments 2016-01-26 14:55:38 -08:00
Alex Dadgar d5c77cd4a4 Update client fingerprinters 2016-01-26 10:08:01 -08:00
Abhishek Chanda cd51ee6430 Handle non 200 codes while getting env metadata 2015-12-22 05:23:32 +00:00
Alex Dadgar b943c6e278 Remove all calls to the default logger 2015-12-11 15:02:13 -08:00
Diptanu Choudhury 7bbf3b6497 Renaming constants 2015-12-11 13:47:35 -08:00
Diptanu Choudhury 6b43aa6753 Renaming constants 2015-12-11 13:18:04 -08:00
Diptanu Choudhury 7d6a687b95 Changed the log line in consul fingerprinter 2015-12-11 09:10:21 -08:00
Diptanu Choudhury 49d9d04025 Print consul debug messages only when the consul agent is available 2015-12-11 09:06:03 -08:00
Chris Hines 53ecc03022 Improve error messages. 2015-12-09 16:34:18 -05:00
Chris Hines 6697980331 Use GetDiskFreeSpaceEx instead of parsing output of fsutil on Windows. 2015-11-30 16:43:25 -05:00
Alex Dadgar b2daa5e2e6 Standardize log messages in fingerprinters to DEBUG 2015-11-24 11:06:51 -08:00
Alex Dadgar 6e59527a97 Clear consul attributes if consul couldn't be fingerprinted 2015-11-22 13:51:10 -08:00
Alex Dadgar 77d86d5bb0 Fingerprinter only creates one consul client 2015-11-22 13:42:06 -08:00
Alex Dadgar a352c0fc69 Fix network fingerprint test 2015-11-19 09:22:32 -08:00
Alex Dadgar cf4a44352f Allow no interfaces in network fingerprinter 2015-11-18 19:01:39 -08:00
Guillaume Jacquet 4a3e709eef Fix AWS metadata url
Fix URL. It was printing an error message on startup:
```
2015/11/13 15:49:21 [ERR] fingerprint.env_aws: Error querying AWS Metadata URL, skipping
```

By the way is it safe to use latest? Is there a chance that Amazon decides to change the format of the metadata? It could be safer to use something like `http://169.254.169.254/2014-11-05/meta-data`
2015-11-13 11:03:05 -05:00
Alex Dadgar 7c6b80a8fd Merge pull request #400 from nak3/fingerprint-test
Update fingerprint test codes
2015-11-10 17:06:16 -08:00
Kenjiro Nakayama 658118ed5f Update fingerprint test codes 2015-11-07 23:16:43 +09:00
Chris Bednarski 2719c4ffd7 Merge branch 'master' into f-windows-networking 2015-11-06 13:32:28 -08:00
Alex Dadgar 5f1b6e70b0 Client handles periodic fingerprinters 2015-11-05 13:46:17 -08:00
Alex Dadgar 5f84878ffb Add consul fingerprinter to builtin list; sort list; fix bad error in consul fingerprinter 2015-11-05 13:46:16 -08:00
Alex Dadgar f9fd83c696 Merge fix 2015-11-05 13:46:02 -08:00
Kenjiro Nakayama 21f537339e Use const value for AWS metadata URL 2015-11-04 00:06:14 +09:00
Chris Bednarski a67a78a2d9 Use the same network fingerprinter for *nix and windows 2015-10-30 16:48:02 -07:00
Diptanu Choudhury e55bbe5f2c Refactored code 2015-10-29 16:16:10 -07:00
Diptanu Choudhury 17d430e46c Renamed BasicNetworkInterfaceDetector to DefaultNetworkInterfaceDetector 2015-10-29 15:55:49 -07:00
Diptanu Choudhury 1360f8c6fa Fixed a debug message 2015-10-29 15:17:40 -07:00
Diptanu Choudhury d31f567484 Fixed style of a debug log 2015-10-29 15:15:44 -07:00
Diptanu Choudhury 08302d43ee Added a test to ensure we are not selecting devices which are not marked as UP or loopback and have no IP addresses 2015-10-29 15:14:13 -07:00
Diptanu Choudhury b048919b63 Added some coments 2015-10-29 11:05:58 -07:00
Diptanu Choudhury 6400273cf8 Added tests for testing detecting default device 2015-10-29 11:01:15 -07:00
Diptanu Choudhury b78c00f255 Introduced an interface to detect network devices so that we can mock it for tests 2015-10-28 15:58:40 -07:00
Diptanu Choudhury f0e445d8f5 Refactored the findInterfaces method to make it more clear 2015-10-28 15:48:08 -07:00
Diptanu Choudhury a3d79ec589 Some coding style changes 2015-10-28 15:03:11 -07:00
Diptanu Choudhury 9b86b2313f We don't want lo and PPP in production 2015-10-28 14:44:46 -07:00
Diptanu Choudhury df5efd1e24 Added more information to log 2015-10-28 14:41:13 -07:00
Diptanu Choudhury 58bf6047a7 Adding more information to errors 2015-10-28 14:32:13 -07:00
Diptanu Choudhury 2464789b73 Added more comments 2015-10-28 14:03:33 -07:00
Diptanu Choudhury 915be5e86c Selecting the ipv4 address if there are ipv4 and ipv6 addresses configured for an interface 2015-10-28 13:38:28 -07:00
Diptanu Choudhury fffb0ed5ae Exctracted a method to detect network interface 2015-10-28 11:11:13 -07:00
Diptanu Choudhury 7a15cf0e45 Fix merge conflicts 2015-10-28 08:54:29 -07:00
Kenjiro Nakayama a79ae3c546 Assign IP when network device is specified 2015-10-28 21:19:06 +09:00
Diptanu Choudhury 809f360743 Using the Go stdlib APIs to detect IP Address of a device 2015-10-27 14:14:25 -07:00
Kenjiro Nakayama e688dc3826 Set default network interface rather than eth0 for non-dev mode, and use loopback device for dev mode by default 2015-10-28 02:03:48 +09:00
Kenjiro Nakayama fa005d75fa Set default network interface rather than eth0 2015-10-25 23:32:54 +09:00
Jeff Mitchell 959c175ca1 Update the location of cleanhttp 2015-10-22 14:21:07 -04:00
Jeff Mitchell cea5fd9081 Use cleanhttp for truly clean clients and transports. 2015-10-22 10:58:23 -04:00
Alex Dadgar 1d15f6eda6 Bind alloc dir and task local dir to docker containers and parse args correctly 2015-10-15 16:40:07 -07:00
Abhishek Chanda 953bd8b53f Trim extra newline from kernel version 2015-10-15 00:54:21 -07:00
Alex Dadgar 76ec48bfce Merge pull request #215 from Carevoyance/gce_fingerprint
Add GCE fingerprinting functionality
2015-10-12 16:14:32 -07:00
Daniel Imfeld c9c8dee48e More syntax cleanup 2015-10-12 17:57:45 -05:00
Daniel Imfeld 9730df8411 Fix old comments and other syntax cleanup 2015-10-12 16:56:33 -05:00
Daniel Imfeld 9f58d85762 GCE fingerprinter no longer updates network resources
It has nothing to add that the generic fingerprinters aren't
finding on their own already.
2015-10-09 18:34:57 -05:00
Daniel Imfeld cbe349b8b4 Add a few more GCE-specific attributes:
* cpu-platform
* scheduling.automatic-restart
* scheduling.on-host-maintenance
* network.NETWORKNAME=true
2015-10-09 09:10:40 -05:00
Alex Dadgar 8130510a5a Fix AWS Networking Fingerprint tests failing when actually on AWS 2015-10-08 12:49:43 -07:00
Daniel Imfeld d66e78c5ca Parse information for all GCE network interface.
* No longer setting Device name in the network interface since we can't
match up the info here with real device names.
* Add attributes for all external IPs if more than one exists.
2015-10-07 13:35:20 -05:00
Daniel Imfeld 70350aead9 Compact tags and attribute reading code. 2015-10-07 12:39:23 -05:00
Ivo Verberk c6e1b13b51 Fix vet warnings 2015-10-07 12:26:58 +02:00
Daniel Imfeld dc1c8e5273 TestNetworkFingerprint_notAWS passes even when actually on AWS 2015-10-06 21:21:42 -05:00
Daniel Imfeld 892cad6775 NonXXX tests should pass when actually running in their respective environments.
Fixes #224
2015-10-06 21:16:28 -05:00
Daniel Imfeld 32d5c61779 Consolidate GCEMetadataClient into EnvGCEFingerprint
This allows easier reuse of the same client across multiple functions.
2015-10-05 13:13:25 -05:00
Daniel Imfeld a85dda68fe And add a comment to the constant. 2015-10-05 12:59:02 -05:00
Daniel Imfeld adbb23e267 Use a constant for the default GCE metadata URL 2015-10-05 12:57:45 -05:00
Daniel Imfeld 46bbfc3549 isAWS should return false on GCE
GCE and AWS both expose metadata servers, and GCE's 404 response
includes the URL in the content, which maatches the regex. So,
check the response code as well and if a 4xx code comes back,
take that to meanit's not AWS.
2015-10-05 00:42:34 -05:00
Daniel Imfeld a43a262e66 Fingerprinting code for GCE nodes
This reads the following:

* hostname
* instance id
* machine-type
* zone
* internal IP
* external IP (if any)
* tags
* attributes

Atributes are placed under the platform.gce.attr.* hierarchy.

Tags are set up as platform.gce.tag.TagName=true.
2015-10-05 00:40:43 -05:00
Alex Dadgar e60e6ff8f5 Add debug line when setting link speed to default 2015-10-02 17:32:17 -07:00
Alex Dadgar 4cc8588cb5 Merges 2015-10-02 17:32:11 -07:00
Antoine POPINEAU f35ebe14ad Merge branch 'master' into dev/net-fingerprint 2015-10-02 09:38:35 +02:00
Antoine POPINEAU 36daef1625 Renamed all instances of `Iface` to `NetworkInterface`. 2015-10-02 09:29:18 +02:00
Antoine POPINEAU 3a4b304a53 Refactored code. 2015-10-01 21:16:39 +02:00
Antoine POPINEAU 2e1488fb04 Comment some undocumented code. 2015-10-01 20:39:10 +02:00
Ryan Uber 836fd8a015 Merge pull request #153 from aldergren/master
Prevent df on linux from adding line breaks to output
2015-10-01 11:21:02 -07:00
Antoine POPINEAU b01912abdc Forgot some error checking. 2015-10-01 17:33:40 +02:00
Antoine POPINEAU 70d34da1bc Client config param added to specify net iface to use for fingerprinting. Added a Golang-native method for determining the interface IP address. 2015-10-01 17:31:47 +02:00
Orivej Desh 443d2deb32 Update obsolete comments 2015-09-29 20:33:11 +00:00
Orivej Desh d844997661 Fix "ifconfig not found" warning 2015-09-29 20:06:37 +00:00
Niklas Aldergren 9145d8ffb9 Prevent df on linux from adding line breaks to output 2015-09-29 13:23:41 +02:00
Orivej Desh 4ecf7a0f74 Improve link speed fingerprint error reporting
With disconnected eth0 log output now looks like:

[WARN] fingerprint.network: Unable to parse IP in output of '/bin/ifconfig eth0'
[WARN] fingerprint.network: Unable to parse Speed in output of '/usr/sbin/ethtool eth0'

In a virtual machine:

[WARN] fingerprint.network: Unable to parse Speed in output of '/sbin/ethtool eth0'
[WARN] fingerprint.network: Unable to read link speed from /sys/class/net/eth0/speed
2015-09-28 23:34:25 +00:00
Mitchell Hashimoto 690634d245 client: fix windows build errors 2015-09-27 23:53:25 -07:00
Armon Dadgar 8aa2c292a0 Merge pull request #77 from hashicorp/f-network-fingerprint
Network Fingerprinting
2015-09-23 14:36:29 -07:00
Clint Shryock 491f2d927f clean up some log formatting 2015-09-23 14:09:55 -05:00
Armon Dadgar b213462cb4 Change CPU from float64 to int 2015-09-23 11:14:32 -07:00
Clint Shryock 8c0542a9af Refactor network fingerprinting to be generic, use build flags 2015-09-23 10:12:56 -05:00
Clint Shryock 61d695b7d4 prefix warn/error messages 2015-09-23 10:03:35 -05:00
Clint Shryock e4a8565f00 fix casing for ERR logs 2015-09-23 10:00:06 -05:00
Clint Shryock c84d51a9d1 don't re-convert mbits 2015-09-22 23:57:24 -05:00
Clint Shryock f876ed6673 refactoring, docs 2015-09-22 23:51:56 -05:00
Clint Shryock f60bbbfd15 populate node network resource 2015-09-22 23:22:23 -05:00
Clint Shryock e3c8ca8462 Update code for parsing IP address 2015-09-22 22:56:31 -05:00
Clint Shryock c615c560d2 Move ec2InstanceSpeed to a package variable, convert to string:int map 2015-09-22 22:04:20 -05:00
Clint Shryock 5c749e1ffb Consolidate the AWS fingerprinters 2015-09-22 16:56:04 -05:00
Clint Shryock 2bbf080666 Refactor some AWS things, removing fingerprint/network.go
- move isAWS to env, use in other places
- fingerprint/network.go is no empty; removed
2015-09-22 16:31:57 -05:00
Clint Shryock b44c911996 change the naming 2015-09-22 16:01:29 -05:00
Clint Shryock a9cf7381ca Refactor the Network Fingerprinters 2015-09-22 15:59:00 -05:00
Clint Shryock f048326300 Rework client/fingerprint/fingerprint.go to use a slice and enforce ordering 2015-09-22 14:23:48 -05:00
Clint Shryock d11bd582f7 Basic network fingerprinting for Unix type, AWS systems 2015-09-22 11:44:53 -05:00
Armon Dadgar c7773feced nomad: improve error messages at start for dev mode 2015-09-06 20:18:47 -07:00
Chris Bednarski d9d78d6b2c Add working test for consul fingerprinter 2015-08-31 19:56:38 -07:00
Chris Bednarski ab0deab3e5 Made consul fingerprinter configurable 2015-08-31 19:56:25 -07:00
Chris Bednarski ff5266ad8f Add consul data to node.Links 2015-08-31 16:04:48 -07:00
Chris Bednarski a033bedbaf Added basic consul functionality; currently hard-coded to a test instance 2015-08-31 16:04:48 -07:00
Clint Shryock 1e652cc4e9 fingerprint/env_aws: Rename ec2-instance link to aws.ec2, drop ami link 2015-08-31 15:02:31 -05:00
Clint Shryock 416e7de06d fingerprint/aws: Add 2 basic links, rename 'env' to 'platform' 2015-08-31 14:18:40 -05:00
Clint Shryock ae1142ad33 cleanups 2015-08-28 13:09:21 -05:00
Clint Shryock dc217da84a spike on AWS ENV fingerprint 2015-08-28 11:33:41 -05:00
Chris Bednarski 9b8fc07bbe Drop os fingerprint since this is redundant with host 2015-08-27 17:37:56 -07:00
Chris Bednarski 94235e3448 Change 'os' to 'kernel.name'; add 'kernel.version' for *nix* 2015-08-27 17:37:37 -07:00
Chris Bednarski ced2f647c6 Add guard to storage fingerprint so CWD will be used if AllocDir is not specified -- fixes windows tests 2015-08-27 16:03:09 -07:00
Chris Bednarski d0a091c952 Add the storage fingerprinter to the list of built-ins 2015-08-27 14:30:41 -07:00
Chris Bednarski 0437a02fd7 Change column constraint so this is compatible with darwin and linux 2015-08-27 14:30:20 -07:00
Clint c6cdf014fd Merge pull request #7 from hashicorp/memory-fingerprint
Add a memory fingerprint
2015-08-27 16:11:44 -05:00
Clint Shryock b223278b6f convert to MB for MemoryMB, and update test 2015-08-27 16:01:47 -05:00
Chris Bednarski 6123ba8b83 Get average frequency of all CPUs so we can do average frequency * cores for total compute 2015-08-27 13:35:54 -07:00
Clint Shryock 759d3131f2 Merge remote-tracking branch 'upstream/master' into memory-fingerprint
* upstream/master:
  Prevent a panic if the df tool output is not in the expected format
  Change 'available' to 'free' because it's shorter; also initialize node.Resources.DiskMB as total disk instead of available disk
  Changed logs to errors; added data to node.Resources.DiskMB
  populate CPU in Node Resources
  Fix arity in log call for TCP resolution failure
  Add storage fingerprinter
2015-08-27 15:30:00 -05:00
Clint e3348ad809 Merge pull request #6 from hashicorp/cpu-resources
populate CPU in Node Resources
2015-08-27 15:26:00 -05:00
Clint Shryock 83a792593e Add a memory fingerprint, just grabs memory 2015-08-27 15:19:19 -05:00
Chris Bednarski 78767f0ff4 Merge pull request #4 from hashicorp/f-storage-fingerprint
Add storage fingerprinter
2015-08-27 12:43:18 -07:00
Chris Bednarski 8e544e0969 Prevent a panic if the df tool output is not in the expected format 2015-08-27 12:42:58 -07:00
Chris Bednarski 66b518cd6c Change 'available' to 'free' because it's shorter; also initialize node.Resources.DiskMB as total disk instead of available disk 2015-08-27 12:37:05 -07:00
Chris Bednarski d17c6128c8 Changed logs to errors; added data to node.Resources.DiskMB 2015-08-27 12:23:17 -07:00
Clint Shryock 58be8ba139 populate CPU in Node Resources 2015-08-27 14:15:56 -05:00
Clint Shryock cacb8074d3 Add cpu.frequency, cpu.totalcompute 2015-08-27 09:19:53 -05:00
Chris Bednarski edea3700a4 Add storage fingerprinter
Breaking change: Added ID() to Fingerprint interface. This allows us to assign
each fingerprint implementation a unique ID, identify which fingerprinters have
been run, and also self-identify in log messages.

- Added storage fingerprinter for Windows and *nix
- Added storage tests under storage_test.go
- Added test helper functions under fingerprint/fingerprint_test.go
- Added ID() to existing finterprinters and drivers
- Added Fingerprint.ID() to log messages via log.SetPrefix()
2015-08-26 17:17:08 -07:00
Clint Shryock 9a92383b69 refactor into multiple fingerprints 2015-08-26 16:29:18 -05:00
Clint Shryock 8ab31da8b0 update fingerprint with more cpu, some host info 2015-08-26 15:20:07 -05:00
Clint Shryock d2318f71f1 Fingerprint CPU model name, count of cores 2015-08-26 11:32:30 -05:00
Chris Bednarski 0b255c6af6 Pass config to fingerprints; update tests 2015-08-25 16:21:29 -07:00
Armon Dadgar 88438619c8 fingerprint: adding arch fingerprint 2015-08-20 16:29:19 -07:00