Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Architecture and Uname variable #207

Closed
wants to merge 7 commits into from

Conversation

achawla2012
Copy link
Contributor

Proposed changes

Currently architecture is an empty string, and uname is uname -m

As part of this PR,

  • Fix to populate architecture as uname -m using host information and uname as uname -a.
  • Update tests to test changes.

Call-Out

I cannot find any supported wrapper/util in gopsutil or unix binary that would return Utsname struct variables in platform-agnostic manner.
So I have added GetUnixName function.

Checklist

Before creating a PR, run through this checklist and mark each as complete.

  • I have read the CONTRIBUTING document
  • If applicable, I have added tests that prove my fix is effective or that my feature works
  • If applicable, I have checked that any relevant tests pass after adding my changes
  • I have updated any relevant documentation (README.md)

@netlify
Copy link

netlify bot commented Feb 17, 2023

Deploy Preview for agent-public-docs canceled.

Name Link
🔨 Latest commit 433bf56
🔍 Latest deploy log https://app.netlify.com/sites/agent-public-docs/deploys/6406560be0fbc600083e358a

@github-actions github-actions bot added bug Something isn't working chore Pull requests for routine tasks labels Feb 17, 2023
@achawla2012 achawla2012 marked this pull request as ready for review February 17, 2023 21:00
@oliveromahony
Copy link
Contributor

Can you provide the output for 4 operating systems from our support matrix? https://github.com/nginx/agent/blob/main/Makefile#L12
Ubuntu 22, RHEL 8, SUSE 15 and FreeBSD 13 thanks

@oliveromahony
Copy link
Contributor

please address the unit test failures

@achawla2012
Copy link
Contributor Author

Can you provide the output for 4 operating systems from our support matrix? https://github.com/nginx/agent/blob/main/Makefile#L12 Ubuntu 22, RHEL 8, SUSE 15 and FreeBSD 13 thanks

Ubuntu 22

ubuntu@ip-172-16-0-4:~$ uname -a
Linux ip-172-16-0-4 5.15.0-1030-aws #34-Ubuntu SMP Mon Jan 23 20:13:32 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
ubuntu@ip-172-16-0-4:~$ uname -m
x86_64
ubuntu@ip-172-16-0-4:~$ 

//agent .log
"{\"agent\":\"\",\"boot\":1677788139,\"hostname\":\"ip-172-16-0-49\",\"display_name\":\"ip-172-16-0-49\",\"os-type\":\"linux\",\"uuid\":\"1325a622-f367-3f34-b907-a85d183844e8\",\"uname\":\"Linux ip-172-16-0-49 5.15.0-1030-aws #34-Ubuntu SMP Mon Jan 23 20:13:32 UTC 2023 x86_64\",\"disk_partitions\":[{\"mountpoint\":\"/\",\"device\":\"/dev/nvme0n1p1\",\"fstype\":\"ext4\"},{\"mountpoint\":\"/snap/amazon-ssm-agent/6312\",\"device\":\"/dev/loop0\",\"fstype\":\"squashfs\"},{\"mountpoint\":\"/snap/core20/1822\",\"device\":\"/dev/loop2\",\"fstype\":\"squashfs\"},{\"mountpoint\":\"/snap/snapd/18357\",\"device\":\"/dev/loop4\",\"fstype\":\"squashfs\"},{\"mountpoint\":\"/snap/lxd/24322\",\"device\":\"/dev/loop3\",\"fstype\":\"squashfs\"},{\"mountpoint\":\"/snap/core18/2679\",\"device\":\"/dev/loop1\",\"fstype\":\"squashfs\"},{\"mountpoint\":\"/boot/efi\",\"device\":\"/dev/nvme0n1p15\",\"fstype\":\"vfat\"},{\"mountpoint\":\"/snap/core18/2697\",\"device\":\"/dev/loop5\",\"fstype\":\"squashfs\"}],\"network\":{\"interfaces\":[{\"mac\":\"\",\"ipv6\":[{\"prefixlen\":128,\"netmask\":\"ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff\",\"address\":\"::1\"}],\"ipv4\":[{\"prefixlen\":8,\"netmask\":\"255.0.0.0\",\"address\":\"127.0.0.1\"}],\"name\":\"lo\"},{\"mac\":\"0a:2b:71:5b:33:33\",\"ipv6\":[{\"prefixlen\":128,\"netmask\":\"ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff\",\"address\":\"2600:1f13:a98:5701:a8ea:8a0e:327:a8b7\"},{\"prefixlen\":64,\"netmask\":\"ffff:ffff:ffff:ffff::\",\"address\":\"fe80::82b:71ff:fe5b:3333\"}],\"ipv4\":[{\"prefixlen\":24,\"netmask\":\"255.255.255.0\",\"address\":\"172.16.0.49\"}],\"name\":\"ens5\"},{\"mac\":\"02:42:af:f1:90:b4\",\"ipv6\":[],\"ipv4\":[{\"prefixlen\":24,\"netmask\":\"255.255.255.0\",\"address\":\"192.0.10.1\"}],\"name\":\"docker0\"}],\"default\":\"lo\"},\"processor\":[{\"model\":\"1\",\"cores\":1,\"architecture\":\"x86_64\",\"mhz\":2200,\"hypervisor\":\"\",\"cpus\":2,\"virtualization\":\"\",\"cache\":{\"Cacheline bytes:\":\"64\",\"Features:\":\"ADX,AESNI,AVX,AVX2,AVXSLOW,BMI1,BMI2,CLMUL,CLZERO,CMOV,CMPXCHG8,CX16,F16C,FMA3,FXSR,FXSROPT,HTT,HYPERVISOR,LAHF,LZCNT,MMX,MMXEXT,MOVBE,NX,OSXSAVE,POPCNT,RDRAND,RDSEED,RDTSCP,SCE,SHA,SSE,SSE2,SSE3,SSE4,SSE42,SSE4A,SSSE3,X87,XGETBV1,XSAVE,XSAVEC,XSAVEOPT\",\"L1d\":\"32 KiB (1 instance)\",\"L1i\":\"64 KiB (1 instance)\",\"L2\":\"512 KiB (1 instance)\",\"L3\":\"8 MiB (1 instance)\",\"SIMD 2:\":\"Streaming SIMD 2 Extensions\"}},{\"model\":\"1\",\"cores\":1,\"architecture\":\"x86_64\",\"mhz\":2200,\"hypervisor\":\"\",\"cpus\":2,\"virtualization\":\"\",\"cache\":{\"Cacheline bytes:\":\"64\",\"Features:\":\"ADX,AESNI,AVX,AVX2,AVXSLOW,BMI1,BMI2,CLMUL,CLZERO,CMOV,CMPXCHG8,CX16,F16C,FMA3,FXSR,FXSROPT,HTT,HYPERVISOR,LAHF,LZCNT,MMX,MMXEXT,MOVBE,NX,OSXSAVE,POPCNT,RDRAND,RDSEED,RDTSCP,SCE,SHA,SSE,SSE2,SSE3,SSE4,SSE42,SSE4A,SSSE3,X87,XGETBV1,XSAVE,XSAVEC,XSAVEOPT\",\"L1d\":\"32 KiB (1 instance)\",\"L1i\":\"64 KiB (1 instance)\",\"L2\":\"512 KiB (1 instance)\",\"L3\":\"8 MiB (1 instance)\",\"SIMD 2:\":\"Streaming SIMD 2 Extensions\"}}],\"release\":{\"codename\":\"jammy\",\"id\":\"ubuntu\",\"name\":\"Ubuntu\",\"version_id\":\"22.04\",\"version\":\"22.04.2 LTS (Jammy Jellyfish)\"},\"tags\":[],\"agent_accessible_dirs\":\"/etc/nginx:/usr/local/etc/nginx:/usr/share/nginx/modules:/etc/nms\"}"

RHEL

[ec2-user@ip-172-16-0-62 ~]$ uname -a
Linux ip-172-16-0-62.us-west-2.compute.internal 4.18.0-425.13.1.el8_7.x86_64 #1 SMP Thu Feb 2 13:01:45 EST 2023 x86_64 x86_64 x86_64 GNU/Linux
[ec2-user@ip-172-16-0-62 ~]$ uname -m
x86_64
[ec2-user@ip-172-16-0-62 ~]$ 
// Agent log.
"{\"agent\":\"\",\"boot\":1677651430,\"hostname\":\"ip-172-16-0-214.us-west-2.compute.internal\",\"display_name\":\"ip-172-16-0-214.us-west-2.compute.internal\",\"os-type\":\"linux\",\"uuid\":\"42721515-dc58-381e-b208-b806af379e51\",\"uname\":\"Linux ip-172-16-0-214.us-west-2.compute.internal 4.18.0-425.10.1.el8_7.x86_64 #1 SMP Wed Dec 14 16:00:01 EST 2022 x86_64\",\"disk_partitions\":[{\"mountpoint\":\"/\",\"device\":\"/dev/nvme0n1p2\",\"fstype\":\"xfs\"}],\"network\":{\"interfaces\":[{\"mac\":\"\",\"ipv6\":[{\"prefixlen\":128,\"netmask\":\"ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff\",\"address\":\"::1\"}],\"ipv4\":[{\"prefixlen\":8,\"netmask\":\"255.0.0.0\",\"address\":\"127.0.0.1\"}],\"name\":\"lo\"},{\"mac\":\"02:3d:1b:71:ac:af\",\"ipv6\":[{\"prefixlen\":128,\"netmask\":\"ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff\",\"address\":\"2600:1f13:553:8001:9426:65e7:ad32:c6b0\"},{\"prefixlen\":64,\"netmask\":\"ffff:ffff:ffff:ffff::\",\"address\":\"fe80::3d:1bff:fe71:acaf\"}],\"ipv4\":[{\"prefixlen\":24,\"netmask\":\"255.255.255.0\",\"address\":\"172.16.0.214\"}],\"name\":\"eth0\"}],\"default\":\"lo\"},\"processor\":[{\"model\":\"1\",\"cores\":1,\"architecture\":\"x86_64\",\"mhz\":2199.522,\"hypervisor\":\"\",\"cpus\":2,\"virtualization\":\"\",\"cache\":{\"Cacheline bytes:\":\"64\",\"Features:\":\"ADX,AESNI,AVX,AVX2,AVXSLOW,BMI1,BMI2,CLMUL,CLZERO,CMOV,CMPXCHG8,CX16,F16C,FMA3,FXSR,FXSROPT,HTT,HYPERVISOR,LAHF,LZCNT,MMX,MMXEXT,MOVBE,NX,OSXSAVE,POPCNT,RDRAND,RDSEED,RDTSCP,SCE,SHA,SSE,SSE2,SSE3,SSE4,SSE42,SSE4A,SSSE3,X87,XGETBV1,XSAVE,XSAVEC,XSAVEOPT\",\"L1d\":\"32K\",\"L1i\":\"64K\",\"L2\":\"512K\",\"L3\":\"8192K\",\"SIMD 2:\":\"Streaming SIMD 2 Extensions\"}},{\"model\":\"1\",\"cores\":1,\"architecture\":\"x86_64\",\"mhz\":2199.522,\"hypervisor\":\"\",\"cpus\":2,\"virtualization\":\"\",\"cache\":{\"Cacheline bytes:\":\"64\",\"Features:\":\"ADX,AESNI,AVX,AVX2,AVXSLOW,BMI1,BMI2,CLMUL,CLZERO,CMOV,CMPXCHG8,CX16,F16C,FMA3,FXSR,FXSROPT,HTT,HYPERVISOR,LAHF,LZCNT,MMX,MMXEXT,MOVBE,NX,OSXSAVE,POPCNT,RDRAND,RDSEED,RDTSCP,SCE,SHA,SSE,SSE2,SSE3,SSE4,SSE42,SSE4A,SSSE3,X87,XGETBV1,XSAVE,XSAVEC,XSAVEOPT\",\"L1d\":\"32K\",\"L1i\":\"64K\",\"L2\":\"512K\",\"L3\":\"8192K\",\"SIMD 2:\":\"Streaming SIMD 2 Extensions\"}}],\"release\":{\"codename\":\"linux\",\"id\":\"rhel\",\"name\":\"Red Hat Enterprise Linux\",\"version_id\":\"8.7\",\"version\":\"8.7 (Ootpa)\"},\"tags\":[],\"agent_accessible_dirs\":\"/etc/nginx:/usr/local/etc/nginx:/usr/share/nginx/modules:/etc/nms\"}" 

SUSE

Forum: https://forums.suse.com/categories/suse-public-cloud

Have a lot of fun... 
ec2-user@ip-172-16-0-112:~> uname -a
Linux ip-172-16-0-112 5.3.18-24.96-default #1 SMP Mon Nov 22 08:33:36 UTC 2021 (9a413cc) x86_64 x86_64 x86_64 GNU/Linux
ec2-user@ip-172-16-0-112:~> uname -m
x86_64
ec2-user@ip-172-16-0-112:~> 
//agent log
"{\"agent\":\"\",\"boot\":1677783989,\"hostname\":\"ip-172-16-0-207\",\"display_name\":\"ip-172-16-0-207\",\"os-type\":\"linux\",\"uuid\":\"d1af3bda-e1dd-351d-85e7-0784aa7f7fe0\",\"uname\":\"Linux ip-172-16-0-207 5.3.18-24.96-default #1 SMP Mon Nov 22 08:33:36 UTC 2021 (9a413cc) x86_64\",\"disk_partitions\":[{\"mountpoint\":\"/\",\"device\":\"/dev/nvme0n1p3\",\"fstype\":\"xfs\"},{\"mountpoint\":\"/boot/efi\",\"device\":\"/dev/nvme0n1p2\",\"fstype\":\"vfat\"}],\"network\":{\"interfaces\":[{\"mac\":\"\",\"ipv6\":[{\"prefixlen\":128,\"netmask\":\"ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff\",\"address\":\"::1\"}],\"ipv4\":[{\"prefixlen\":8,\"netmask\":\"255.0.0.0\",\"address\":\"127.0.0.1\"}],\"name\":\"lo\"},{\"mac\":\"02:21:3a:31:34:d5\",\"ipv6\":[{\"prefixlen\":64,\"netmask\":\"ffff:ffff:ffff:ffff::\",\"address\":\"2600:1f13:843:6101:9691:3ac9:6f9:5a2d\"},{\"prefixlen\":64,\"netmask\":\"ffff:ffff:ffff:ffff::\",\"address\":\"fe80::21:3aff:fe31:34d5\"}],\"ipv4\":[{\"prefixlen\":24,\"netmask\":\"255.255.255.0\",\"address\":\"172.16.0.207\"}],\"name\":\"eth0\"},{\"mac\":\"02:42:56:7e:ca:ca\",\"ipv6\":[],\"ipv4\":[{\"prefixlen\":24,\"netmask\":\"255.255.255.0\",\"address\":\"192.0.10.1\"}],\"name\":\"docker0\"}],\"default\":\"lo\"},\"processor\":[{\"model\":\"1\",\"cores\":1,\"architecture\":\"x86_64\",\"mhz\":2199.79,\"hypervisor\":\"\",\"cpus\":2,\"virtualization\":\"\",\"cache\":{\"Cacheline bytes:\":\"64\",\"Features:\":\"ADX,AESNI,AVX,AVX2,AVXSLOW,BMI1,BMI2,CLMUL,CLZERO,CMOV,CMPXCHG8,CX16,F16C,FMA3,FXSR,FXSROPT,HTT,HYPERVISOR,LAHF,LZCNT,MMX,MMXEXT,MOVBE,NX,OSXSAVE,POPCNT,RDRAND,RDSEED,RDTSCP,SCE,SHA,SSE,SSE2,SSE3,SSE4,SSE42,SSE4A,SSSE3,X87,XGETBV1,XSAVE,XSAVEC,XSAVEOPT\",\"L1d\":\"32K\",\"L1i\":\"64K\",\"L2\":\"512K\",\"L3\":\"8192K\",\"SIMD 2:\":\"Streaming SIMD 2 Extensions\"}},{\"model\":\"1\",\"cores\":1,\"architecture\":\"x86_64\",\"mhz\":2199.79,\"hypervisor\":\"\",\"cpus\":2,\"virtualization\":\"\",\"cache\":{\"Cacheline bytes:\":\"64\",\"Features:\":\"ADX,AESNI,AVX,AVX2,AVXSLOW,BMI1,BMI2,CLMUL,CLZERO,CMOV,CMPXCHG8,CX16,F16C,FMA3,FXSR,FXSROPT,HTT,HYPERVISOR,LAHF,LZCNT,MMX,MMXEXT,MOVBE,NX,OSXSAVE,POPCNT,RDRAND,RDSEED,RDTSCP,SCE,SHA,SSE,SSE2,SSE3,SSE4,SSE42,SSE4A,SSSE3,X87,XGETBV1,XSAVE,XSAVEC,XSAVEOPT\",\"L1d\":\"32K\",\"L1i\":\"64K\",\"L2\":\"512K\",\"L3\":\"8192K\",\"SIMD 2:\":\"Streaming SIMD 2 Extensions\"}}],\"release\":{\"codename\":\"linux\",\"id\":\"sles\",\"name\":\"SLES\",\"version_id\":\"15.2\",\"version\":\"15-SP2\"},\"tags\":[],\"agent_accessible_dirs\":\"/etc/nginx:/usr/local/etc/nginx:/usr/share/nginx/modules:/etc/nms\"}"

FREEBSD

FreeBSD directory layout:      man hier

...
ec2-user@ip-172-16-0-190:~ $ uname -m
amd64
ec2-user@ip-172-16-0-190:~ $ uname -a
FreeBSD ip-172-16-0-190.us-west-2.compute.internal 13.1-RELEASE-p6 FreeBSD 13.1-RELEASE-p6 GENERIC amd64

@oliveromahony
Copy link
Contributor

This PR looks good if you can provide the agent log for FreeBSD and run a make deps or rebase with main and run a make install-tools and commit any dependency changes, that would be great

@achawla2012
Copy link
Contributor Author

This PR looks good if you can provide the agent log for FreeBSD and run a make deps or rebase with main and run a make install-tools and commit any dependency changes, that would be great

 % make install-tools
fatal: No names found, cannot describe anything.
Getting Tools
go get github.com/alvaroloes/enumer
go get github.com/gogo/protobuf/protoc-gen-gogo
go get github.com/gogo/protobuf/protoc-gen-gogofast
go get github.com/golang/mock/mockgen
go get github.com/maxbrunsfeld/counterfeiter/v6
go get github.com/mwitkow/go-proto-validators/protoc-gen-govalidators
go get google.golang.org/grpc/cmd/protoc-gen-go-grpc
go get github.com/pseudomuto/protoc-gen-doc/cmd/protoc-gen-doc
go: module github.com/golang/protobuf is deprecated: Use the "google.golang.org/protobuf" module instead.
go get github.com/go-swagger/go-swagger/cmd/swagger
go get github.com/bufbuild/buf/cmd/buf
go get github.com/goreleaser/nfpm/v2/cmd/nfpm
go get github.com/evilmartians/lefthook
Installing Tools
go install github.com/alvaroloes/enumer
go install github.com/gogo/protobuf/protoc-gen-gogo
go install github.com/gogo/protobuf/protoc-gen-gogofast
go install github.com/golang/mock/mockgen
go install github.com/maxbrunsfeld/counterfeiter/v6
go install github.com/mwitkow/go-proto-validators/protoc-gen-govalidators
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc
go install github.com/pseudomuto/protoc-gen-doc/cmd/protoc-gen-doc
go install github.com/go-swagger/go-swagger/cmd/swagger
go install github.com/bufbuild/buf/cmd/buf
go install github.com/goreleaser/nfpm/v2/cmd/nfpm
go install github.com/evilmartians/lefthook

@achawla2012
Copy link
Contributor Author

@oliveromahony @ryepup messed up with rebase locally. I will close this PR.

I have cloned this to new one :- #239

@achawla2012 achawla2012 closed this Mar 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working chore Pull requests for routine tasks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Agent does not show up architecture and uname properly in the system
4 participants