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 #239

Merged
merged 4 commits into from
Mar 15, 2023
Merged

Conversation

achawla2012
Copy link
Contributor

@achawla2012 achawla2012 commented Mar 7, 2023

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)

Test

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

Agent log

time="2023-03-14T15:00:50Z" level=trace msg="HostInfo created: boot:1678725802 hostname:\"ip-172-16-0-163.eu-central-1.compute.internal\" display_name:\"ip-172-16-0-163.eu-central-1.compute.internal\" os_type:\"freebsd\" uuid:\"80726cf1-f310-3136-9438-f707908a74ef\" uname:\"FreeBSD ip-172-16-0-163.eu-central-1.compute.internal 13.1-RELEASE-p6 FreeBSD 13.1-RELEASE-p6 GENERIC  amd64\" partitons:<mount_point:\"/\" device:\"/dev/gpt/rootfs\" fs_type:\"ufs\" > partitons:<mount_point:\"/dev\" device:\"devfs\" fs_type:\"devfs\" > partitons:<mount_point:\"/boot/efi\" device:\"/dev/gpt/efiesp\" fs_type:\"msdosfs\" > network:<interfaces:<mac:\"06:a2:78:8e:a5:a8\" ipv6:<prefixlen:64 netmask:\"ffff:ffff:ffff:ffff::\" address:\"fe80::4a2:78ff:fe8e:a5a8\" > ipv4:<prefixlen:24 netmask:\"255.255.255.0\" address:\"172.16.0.163\" > name:\"ena0\" > interfaces:<ipv6:<prefixlen:128 netmask:\"ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff\" address:\"::1\" > ipv6:<prefixlen:64 netmask:\"ffff:ffff:ffff:ffff::\" address:\"fe80::1\" > ipv4:<prefixlen:8 netmask:\"255.0.0.0\" address:\"127.0.0.1\" > name:\"lo0\" > default:\"ena0\" > processor:<cores:2 architecture:\"amd64\" mhz:2500 cpus:1 virtualization:\"host\" cache:<key:\"Cacheline bytes:\" value:\"64\" > cache:<key:\"Features:\" value:\"ADX,AESNI,AVX,AVX2,AVX512BW,AVX512CD,AVX512DQ,AVX512F,AVX512VL,BMI1,BMI2,CLMUL,CMOV,CMPXCHG8,CX16,ERMS,F16C,FMA3,FXSR,FXSROPT,HTT,HYPERVISOR,LAHF,LZCNT,MMX,MOVBE,MPX,NX,OSXSAVE,POPCNT,RDRAND,RDSEED,RDTSCP,SCE,SSE,SSE2,SSE3,SSE4,SSE42,SSSE3,X87,XGETBV1,XSAVE,XSAVEC,XSAVEOPT,XSAVES\" > cache:<key:\"L1d\" value:\"32768\" > cache:<key:\"L1i\" value:\"32768\" > cache:<key:\"L2\" value:\"1048576\" > cache:<key:\"L3\" value:\"37486592\" > cache:<key:\"SIMD 2:\" value:\"Streaming SIMD 2 Extensions\" > > release:<codename:\"freebsd\" id:\"freebsd\" version_id:\"13.1-release-p6\" version:\"13.1-release-p6\" > agent_accessible_dirs:\"/etc/nginx:/usr/local/etc/nginx:/usr/share/nginx/modules:/etc/nms\" "

@netlify
Copy link

netlify bot commented Mar 7, 2023

Deploy Preview for agent-public-docs ready!

Name Link
🔨 Latest commit e9fcf6b
🔍 Latest deploy log https://app.netlify.com/sites/agent-public-docs/deploys/640b8f35d5c2be0008ed3330
😎 Deploy Preview https://deploy-preview-239--agent-public-docs.netlify.app/nginx-agent/overview
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@github-actions github-actions bot added bug Something isn't working chore Pull requests for routine tasks labels Mar 7, 2023
@achawla2012 achawla2012 marked this pull request as ready for review March 7, 2023 23:38
@achawla2012
Copy link
Contributor Author

@oliveromahony

@ryepup
Copy link
Contributor

ryepup commented Mar 8, 2023

LGTM, going to defer to the agent team for the official approval.

@github-actions github-actions bot added dependencies documentation Improvements or additions to documentation labels Mar 9, 2023
@dhurley dhurley merged commit 34f8052 into nginx:main Mar 15, 2023
@dhurley dhurley linked an issue Mar 16, 2023 that may be closed by this pull request
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 dependencies documentation Improvements or additions to documentation
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