2022-09-27 00:15:49 +00:00
|
|
|
package pprofweb
|
|
|
|
|
|
|
|
import (
|
|
|
|
"log"
|
|
|
|
"net/http"
|
|
|
|
)
|
|
|
|
|
|
|
|
const rootTemplate = `<!doctype html>
|
|
|
|
<html>
|
|
|
|
<head><title>PProf Web Interface</title></head>
|
|
|
|
<body>
|
2022-09-29 16:55:50 +00:00
|
|
|
<p>Upload a file to explore it using the <a href="https://github.com/google/pprof">Pprof</a> web interface.</p>
|
2022-09-27 00:15:49 +00:00
|
|
|
|
2022-09-29 16:55:50 +00:00
|
|
|
<p>
|
2023-01-24 23:29:44 +00:00
|
|
|
the source code <a href="https://tuxpa.in/a/pprofweb">over here </a>.
|
2022-09-29 16:55:50 +00:00
|
|
|
</p>
|
2022-09-27 00:15:49 +00:00
|
|
|
|
2022-09-29 16:55:50 +00:00
|
|
|
<p>
|
2022-09-27 00:15:49 +00:00
|
|
|
code is based off <a href="https://github.com/evanj/pprofweb">this project</a>.
|
|
|
|
</p>
|
|
|
|
<p>
|
|
|
|
when you upload data, you get a unique url. you can share that url with other people!
|
2022-09-27 00:31:58 +00:00
|
|
|
</p>
|
|
|
|
<p>
|
2022-09-27 00:15:49 +00:00
|
|
|
i currently have it set to save forever, but that might not always be true. assume that things can be lost at any time!
|
2022-09-27 00:31:58 +00:00
|
|
|
</p>
|
2022-09-27 00:15:49 +00:00
|
|
|
|
2022-09-27 00:31:58 +00:00
|
|
|
<p>
|
2023-03-07 19:39:39 +00:00
|
|
|
also assume that things are not private. i am using xid to generate, which i believe is not secure? its also just on a random pvc
|
2022-09-27 00:31:58 +00:00
|
|
|
</p>
|
2022-09-27 00:15:49 +00:00
|
|
|
|
2022-09-27 00:31:58 +00:00
|
|
|
<p>
|
2022-09-27 00:45:40 +00:00
|
|
|
anyhow, just upload your profile here!
|
2022-09-27 00:31:58 +00:00
|
|
|
</p>
|
2022-09-27 00:15:49 +00:00
|
|
|
|
2022-09-27 00:31:58 +00:00
|
|
|
<p>
|
2022-09-27 00:15:49 +00:00
|
|
|
go tool pprof [binary] profile.pb.gz
|
2022-09-27 00:31:58 +00:00
|
|
|
</p>
|
2022-09-27 00:15:49 +00:00
|
|
|
|
2022-09-27 00:31:58 +00:00
|
|
|
<p>
|
|
|
|
works with whatever works in the command line (it just runs go tool pprof in the background anyways)
|
2022-09-27 00:15:49 +00:00
|
|
|
</p>
|
|
|
|
|
|
|
|
<form method="post" action="/upload" enctype="multipart/form-data">
|
|
|
|
<p>Upload file: <input type="file" name="file"> <input type="submit" value="Upload"></p>
|
|
|
|
</form>
|
2022-09-29 16:55:50 +00:00
|
|
|
|
|
|
|
|
|
|
|
<p>
|
|
|
|
u can also use curl! basically it checks if your Accept headers have "http", and if not, then it will not redirect, and will send the id instead
|
2023-03-07 19:39:39 +00:00
|
|
|
curl -F file=@<filename> https://pprof.tuxpa.in/upload
|
2023-05-03 05:47:57 +00:00
|
|
|
</p>
|
2022-09-29 16:55:50 +00:00
|
|
|
|
2023-05-03 05:47:57 +00:00
|
|
|
<p>
|
|
|
|
i also made a simple cli
|
|
|
|
you can download it by doing
|
2022-09-29 16:55:50 +00:00
|
|
|
</p>
|
2023-05-03 05:47:57 +00:00
|
|
|
<p>
|
|
|
|
go install tuxpa.in/a/pprofweb
|
|
|
|
</p>
|
|
|
|
|
2022-09-27 00:15:49 +00:00
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
`
|
|
|
|
|
|
|
|
func rootHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
|
log.Printf("rootHandler %s %s", r.Method, r.URL.String())
|
|
|
|
if r.Method != http.MethodGet {
|
|
|
|
http.Error(w, "wrong method", http.StatusMethodNotAllowed)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if r.URL.Path != "/" {
|
|
|
|
http.Error(w, "not found", http.StatusNotFound)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
w.Write([]byte(rootTemplate))
|
|
|
|
}
|