projectdiscovery / utils

Helper Libraries
MIT License
108 stars 33 forks source link

Create a Embeddable package to monitor and profile go tools/apps #344

Open tarunKoyalwar opened 8 months ago

tarunKoyalwar commented 8 months ago

Proposed Changes

### Tasks
- [ ] Env Based Input ( we can reuse existing logic in pprof package but cpuprofile might need to be improved)
- [ ] When this package is embedded it should launch a seperate process ( with appropriate syscall attributes to make it completely indedepent of current process ) and monitor/profile and save resulting data in cache directory . similar to screen command (Ref: https://github.com/projectdiscovery/utils/issues/346)
- [ ] Detection logic should be based on below logic 
- [ ] Add Endpoint in PDTM API to support uploading and generating uuid of these profiles for effective sharing and ease of analysis

Detection Logic ( Task 3)

References

stan-threatmate commented 8 months ago

What worked for me while debugging nuclei is this approach. It will dump the goroutines stack trace and memory allocations on a regular interval until stopped.

Running these on an interval will create a new dump file every X minutes which might be what you need. You can then inspect the memory and goroutine stack trace using go tool pprof file.dump