File tree Expand file tree Collapse file tree 1 file changed +18
-4
lines changed Expand file tree Collapse file tree 1 file changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -19,22 +19,36 @@ import (
19
19
"github.com/aws/aws-sdk-go/aws/ec2metadata"
20
20
"github.com/aws/aws-sdk-go/aws/session"
21
21
"io/ioutil"
22
+ "os"
22
23
"strings"
23
24
24
25
info "github.com/google/cadvisor/info/v1"
25
26
)
26
27
27
28
const (
28
29
ProductVerFileName = "/sys/class/dmi/id/product_version"
30
+ BiosVerFileName = "/sys/class/dmi/id/bios_vendor"
29
31
Amazon = "amazon"
30
32
)
31
33
32
34
func onAWS () bool {
33
- data , err := ioutil .ReadFile (ProductVerFileName )
34
- if err != nil {
35
- return false
35
+ var dataProduct []byte
36
+ var dataBios []byte
37
+ if _ , err := os .Stat (ProductVerFileName ); err == nil {
38
+ dataProduct , err = ioutil .ReadFile (ProductVerFileName )
39
+ if err != nil {
40
+ return false
41
+ }
42
+ }
43
+
44
+ if _ , err := os .Stat (BiosVerFileName ); err == nil {
45
+ dataBios , err = ioutil .ReadFile (BiosVerFileName )
46
+ if err != nil {
47
+ return false
48
+ }
36
49
}
37
- return strings .Contains (string (data ), Amazon )
50
+
51
+ return strings .Contains (string (dataProduct ), Amazon ) || strings .Contains (strings .ToLower (string (dataBios )), Amazon )
38
52
}
39
53
40
54
func getAwsMetadata (name string ) string {
You can’t perform that action at this time.
0 commit comments