Skip to content

Commit e83e088

Browse files
tamilmani1989sharmasushant
authored andcommitted
VSTS#1748724 Minimal Support for Windows Telemetry (#88)
* VSTS#1748724 Made minor changes for windows telemetry to work * Spellchecked Orchestrator and corrected MB value
1 parent 6dd6eb8 commit e83e088

File tree

3 files changed

+19
-18
lines changed

3 files changed

+19
-18
lines changed

telemetry/telemetry.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"strings"
1919

2020
"github.com/Azure/azure-container-networking/common"
21+
"github.com/Azure/azure-container-networking/platform"
2122
)
2223

2324
// OS Details structure.
@@ -60,7 +61,7 @@ type BridgeInfo struct {
6061
}
6162

6263
// Orchestrator Details structure.
63-
type OrchsestratorInfo struct {
64+
type OrchestratorInfo struct {
6465
OrchestratorName string
6566
OrchestratorVersion string
6667
ErrorMessage string
@@ -75,7 +76,7 @@ type Report struct {
7576
Context string
7677
SubContext string
7778
VnetAddressSpace []string
78-
OrchestratorDetails *OrchsestratorInfo
79+
OrchestratorDetails *OrchestratorInfo
7980
OSDetails *OSInfo
8081
SystemDetails *SystemInfo
8182
InterfaceDetails *InterfaceInfo
@@ -90,6 +91,11 @@ type ReportManager struct {
9091
Report *Report
9192
}
9293

94+
const (
95+
// TelemetryFile Path.
96+
TelemetryFile = platform.RuntimePath + "AzureCNITelemetry.json"
97+
)
98+
9399
// Read file line by line and return array of lines.
94100
func ReadFileByLines(filename string) ([]string, error) {
95101
var (
@@ -295,14 +301,14 @@ func (report *Report) GetInterfaceDetails(queryUrl string) {
295301
func (report *Report) GetOrchestratorDetails() {
296302
out, err := exec.Command("kubectl", "--version").Output()
297303
if err != nil {
298-
report.OrchestratorDetails = &OrchsestratorInfo{}
304+
report.OrchestratorDetails = &OrchestratorInfo{}
299305
report.OrchestratorDetails.ErrorMessage = "kubectl command failed due to " + err.Error()
300306
return
301307
}
302308

303309
outStr := string(out)
304310
outStr = strings.TrimLeft(outStr, " ")
305-
report.OrchestratorDetails = &OrchsestratorInfo{}
311+
report.OrchestratorDetails = &OrchestratorInfo{}
306312

307313
resultArray := strings.Split(outStr, " ")
308314
if len(resultArray) >= 2 {

telemetry/telemetry_linux.go

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,8 @@ type DiskInfo struct {
2424
}
2525

2626
const (
27-
TelemetryFile = "/var/run/AzureCNITelemetry.json"
28-
MB = 1048576
29-
KB = 1024
27+
MB = 1048576
28+
KB = 1024
3029
)
3130

3231
// This function retrieves VMs memory usage.
@@ -89,12 +88,9 @@ func (report *Report) GetSystemDetails() {
8988

9089
// This function creates a report with os details(ostype, version).
9190
func (report *Report) GetOSDetails() {
92-
93-
osType := "Linux"
94-
9591
linesArr, err := ReadFileByLines("/etc/issue")
9692
if err != nil || len(linesArr) <= 0 {
97-
report.OSDetails = &OSInfo{OSType: "Linux"}
93+
report.OSDetails = &OSInfo{OSType: runtime.GOOS}
9894
report.OSDetails.ErrorMessage = "reading /etc/issue failed with" + err.Error()
9995
return
10096
}
@@ -103,7 +99,7 @@ func (report *Report) GetOSDetails() {
10399

104100
out, err := exec.Command("uname", "-r").Output()
105101
if err != nil {
106-
report.OSDetails = &OSInfo{OSType: "Linux"}
102+
report.OSDetails = &OSInfo{OSType: runtime.GOOS}
107103
report.OSDetails.ErrorMessage = "uname -r failed with " + err.Error()
108104
return
109105
}
@@ -112,7 +108,7 @@ func (report *Report) GetOSDetails() {
112108
kernelVersion = strings.TrimSuffix(kernelVersion, "\n")
113109

114110
report.OSDetails = &OSInfo{
115-
OSType: osType,
111+
OSType: runtime.GOOS,
116112
OSVersion: osInfoArr[1],
117113
KernelVersion: kernelVersion,
118114
OSDistribution: osInfoArr[0],

telemetry/telemetry_windows.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
package telemetry
55

6+
import "runtime"
7+
68
type MemInfo struct {
79
MemTotal uint64
810
MemFree uint64
@@ -13,10 +15,6 @@ type DiskInfo struct {
1315
DiskFree uint64
1416
}
1517

16-
const (
17-
TelemetryFile = "c:\\AzureCNITelemetry"
18-
)
19-
2018
func getMemInfo() (*MemInfo, error) {
2119

2220
return nil, nil
@@ -29,8 +27,9 @@ func getDiskInfo(path string) (*DiskInfo, error) {
2927

3028
func (report *Report) GetSystemDetails() {
3129

30+
report.SystemDetails = &SystemInfo{}
3231
}
3332

3433
func (report *Report) GetOSDetails() {
35-
34+
report.OSDetails = &OSInfo{OSType: runtime.GOOS}
3635
}

0 commit comments

Comments
 (0)