2021-08-17 12:39:36 +00:00
|
|
|
package modules
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/filecoin-project/lotus/journal/alerting"
|
|
|
|
"github.com/filecoin-project/lotus/lib/ulimit"
|
|
|
|
)
|
|
|
|
|
|
|
|
func CheckFdLimit(min uint64) func(al *alerting.Alerting) {
|
|
|
|
return func(al *alerting.Alerting) {
|
2021-08-26 13:59:54 +00:00
|
|
|
soft, _, err := ulimit.GetLimit()
|
|
|
|
|
|
|
|
if err == ulimit.ErrUnsupported {
|
|
|
|
log.Warn("FD limit monitoring not available")
|
2021-08-17 12:39:36 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
alert := al.AddAlertType("process", "fd-limit")
|
|
|
|
if err != nil {
|
|
|
|
al.Raise(alert, map[string]string{
|
|
|
|
"message": "failed to get FD limit",
|
|
|
|
"error": err.Error(),
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
if soft < min {
|
|
|
|
al.Raise(alert, map[string]interface{}{
|
|
|
|
"message": "soft FD limit is low",
|
|
|
|
"soft_limit": soft,
|
|
|
|
"recommended_min": min,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: More things:
|
|
|
|
// * Space in repo dirs (taking into account mounts)
|
|
|
|
// * Miner
|
|
|
|
// * Faulted partitions
|
|
|
|
// * Low balances
|
|
|
|
// * Market provider
|
|
|
|
// * Reachability
|
|
|
|
// * on-chain config
|
|
|
|
// * Low memory (maybe)
|
|
|
|
// * Network / sync issues
|