gomplate icon indicating copy to clipboard operation
gomplate copied to clipboard

Any thought to shirou/gopsutils support?

Open sean- opened this issue 5 years ago • 5 comments

TL;DR: I need to scale the capabilities of an EC2 instance (in an ASG) based on the instance's size and machine type and gomplate seemed like a reasonable place to solve this.


Has there been any consideration to adding https://github.com/shirou/gopsutil under a generic namespace, like host? I just ran into a situation where I need to know the number of physical cores (excluding its hyperthreads), and then perform some math using some data that's present in an instance's EC2 user-data to set the level of concurrency for a cluster of EC2 instances processing requests.

This is still solvable without gomplate, but the convenience factor prompted this inquiry/feature request. I don't think it would be appropriate to expose all of gopsutil, but there are certainly a number of useful bits that it exposes in a useful and cross-platform way.

PS Thanks for https://github.com/hairyhenderson/gomplate/pull/271, which came in handy in a pinch and worked like a treat. Cheers!

sean- avatar Nov 06 '19 07:11 sean-

Hi @sean-! Thanks for this - I'd not seen gopsutil before, it looks interesting!

Looking through the code, it seems it does a lot of invoking of commands to get the information. That's going to be a problem for environments where those commands aren't available (like when running the FROM scratch Docker container, for example). Though I'm now realizing that there's precedent in the sockaddr functions 😂.

In general I do like this idea, and I think host would be a great namespace for this. It'd be nice to do it with a little less os/exec, but that's more of a nice-to-have.

hairyhenderson avatar Nov 06 '19 19:11 hairyhenderson

@hairyhenderson any plans on taking on this Issue? We have a similar use case with AWS ASG & Getting physical cores.

anjo-swe avatar Feb 26 '20 21:02 anjo-swe

@anjo-swe can you elaborate? If you're on an EC2 instance in AWS you might be able to use aws.EC2Meta to get that information, though I'm not sure if it's available directly - you may need to get the instance type and infer from there.

To be totally honest, I'm on the fence about this particular feature. I think having a host namespace is a great idea. I would prefer to have the functionality implemented natively as much as possible, avoiding all the os/exec calls in gopsutil.

Something like https://github.com/prometheus/procfs may be useful to help in some of this, but it's not very cross-platform.

hairyhenderson avatar Feb 27 '20 22:02 hairyhenderson

@hairyhenderson correct, I could grab the instance type and then do a lookup to the against all the instance types (e.g. boto3 - describe_instance_types).

Felt nice to do it inside some tool (e.g. gomplate) and only require a single call but it's not a blocker on our end.

anjo-swe avatar Feb 28 '20 10:02 anjo-swe

@anjo-swe ok thanks - that makes total sense!

hairyhenderson avatar Mar 06 '20 01:03 hairyhenderson

This issue is stale because it has been open for 60 days with no activity. Remove stale label or comment or this will be automatically closed in a few days.

github-actions[bot] avatar Apr 24 '23 04:04 github-actions[bot]