Skip to content

Commit

Permalink
Add product name to the mix.
Browse files Browse the repository at this point in the history
  • Loading branch information
JonathanHenson committed Oct 5, 2023
1 parent 239260e commit 4dc4fc1
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions bin/system_info/print_system_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ int main(void) {

struct aws_byte_cursor virtualization_vendor = aws_system_environment_get_virtualization_vendor(env);
fprintf(stdout, " 'virtualization vendor': '" PRInSTR "'\n", (int)virtualization_vendor.len, virtualization_vendor.ptr);
struct aws_byte_cursor product_name = aws_system_environment_get_virtualization_product_name(env);
fprintf(stdout, " 'product name': '" PRInSTR "'\n", (int)product_name.len, product_name.ptr);
fprintf(stdout, " 'number of processors': '%lu'\n", (unsigned long)aws_system_environment_get_processor_count(env));
size_t numa_nodes = aws_system_environment_get_cpu_group_count(env);

Expand Down
2 changes: 2 additions & 0 deletions include/aws/common/private/system_info_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
struct aws_system_environment {
struct aws_allocator *allocator;
struct aws_byte_buf virtualization_vendor;
struct aws_byte_buf product_name;
enum aws_platform_os os;
size_t cpu_count;
size_t cpu_group_count;
Expand All @@ -23,5 +24,6 @@ void aws_system_environment_destroy_platform_impl(struct aws_system_environment


void aws_system_environment_load_virtualization_vendor_impl(struct aws_system_environment *env);
void aws_system_environment_load_virtualization_product_name_impl(struct aws_system_environment *env);

#endif /* AWS_COMMON_SYSTEM_INFO_PRIV_H */
3 changes: 3 additions & 0 deletions include/aws/common/system_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ void aws_system_environment_destroy(struct aws_system_environment *env);
AWS_COMMON_API
struct aws_byte_cursor aws_system_environment_get_virtualization_vendor(struct aws_system_environment *env);

AWS_COMMON_API
struct aws_byte_cursor aws_system_environment_get_virtualization_product_name(struct aws_system_environment *env);

AWS_COMMON_API
size_t aws_system_environment_get_processor_count(struct aws_system_environment *env);

Expand Down
4 changes: 4 additions & 0 deletions source/linux/system_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@ void aws_system_environment_destroy_platform_impl(struct aws_system_environment
void aws_system_environment_load_virtualization_vendor_impl(struct aws_system_environment *env) {
aws_byte_buf_init_from_file(&env->virtualization_vendor, env->allocator, "/sys/devices/virtual/dmi/id/sys_vendor");
}

void aws_system_environment_load_virtualization_product_name_impl(struct aws_system_environment *env) {
aws_byte_buf_init_from_file(&env->virtualization_vendor, env->allocator, "/sys/devices/virtual/dmi/id/product_name");
}
7 changes: 7 additions & 0 deletions source/system_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ struct aws_system_environment *aws_system_environment_load(struct aws_allocator
}

aws_system_environment_load_virtualization_vendor_impl(env);
aws_system_environment_load_virtualization_product_name_impl(env);

env->os = aws_get_platform_build_os();
env->cpu_count = aws_system_info_processor_count();
env->cpu_group_count = aws_get_cpu_group_count();
Expand All @@ -37,6 +39,11 @@ struct aws_byte_cursor aws_system_environment_get_virtualization_vendor(struct a
return aws_byte_cursor_trim_pred(&vendor_string, aws_char_is_space);
}

struct aws_byte_cursor aws_system_environment_get_virtualization_product_name(struct aws_system_environment *env) {
struct aws_byte_cursor product_name_str = aws_byte_cursor_from_buf(&env->product_name);
return aws_byte_cursor_trim_pred(&product_name_str, aws_char_is_space);
}

size_t aws_system_environment_get_processor_count(struct aws_system_environment *env) {
return env->cpu_count;
}
Expand Down

0 comments on commit 4dc4fc1

Please sign in to comment.