Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

🥵 Pressure Stall Informations (PSI) and starvation notifier

License

NotificationsYou must be signed in to change notification settings

samber/go-psi

Repository files navigation

tagGo VersionGoDocBuild StatusGo reportCoverageContributorsLicense

A few readings to getting started with PSI:

🚀 Install

go get github.com/samber/go-psi

This library is v1 and follows SemVer strictly. No breaking changes will be made to exported APIs before v2.0.0.

Requires Linux kernel >= 4.20.

💡 Usage

GoDoc:https://pkg.go.dev/github.com/samber/go-psi

Retrieve current PSI state

import"github.com/samber/go-psi"// Get PSI for a single resource: psi.Memory or psi.CPU or psi.IO.stats,err:=psi.PSIStatsForResource(psi.Memory)// Get all PSI stats.all,err:=psi.AllPSIStats()

Get PSI change notifications

import"github.com/samber/go-psi"onChange,done,err:=psi.Notify(psi.Memory)for {last,_:=<-onChangefmt.Printf("\nMemory:\n%s\n",last)}// when you're done, just stop the notifierdone<-struct{}{}

Get PSI starvation alerts

import"github.com/samber/go-psi"// Alert starts when CPU 10s average go further 90% and stops when CPU goes below 70%.onAlert,done,err:=psi.NotifyStarvation(psi.CPU,psi.Avg10,70,90)for {alert,_:=<-onAlertfmt.Printf("\nALERT %t\nCPU: %f%%\n",alert.Starved,alert.Current)}// when you're done, just stop the notifierdone<-struct{}{}

🤝 Contributing

Don't hesitate ;)

# Install some dev dependenciesmake tools# Run testsmaketest# ormake watch-test

👤 Contributors

Contributors

💫 Show your support

Give a ⭐️ if this project helped you!

GitHub Sponsors

📝 License

Copyright © 2023Samuel Berthe.

This project isMIT licensed.


[8]ページ先頭

©2009-2025 Movatter.jp