Source File
proc_fdinfo.go
Belonging Package
github.com/prometheus/procfs
package procfs
import (
)
var (
rPos = regexp.MustCompile(`^pos:\s+(\d+)$`)
rFlags = regexp.MustCompile(`^flags:\s+(\d+)$`)
rMntID = regexp.MustCompile(`^mnt_id:\s+(\d+)$`)
rInotify = regexp.MustCompile(`^inotify`)
)
func ( Proc) ( string) (*ProcFDInfo, error) {
, := util.ReadFileNoStat(.path("fdinfo", ))
if != nil {
return nil,
}
var , , , string
var []InotifyInfo
:= bufio.NewScanner(bytes.NewReader())
for .Scan() {
= .Text()
if rPos.MatchString() {
= rPos.FindStringSubmatch()[1]
} else if rFlags.MatchString() {
= rFlags.FindStringSubmatch()[1]
} else if rMntID.MatchString() {
= rMntID.FindStringSubmatch()[1]
} else if rInotify.MatchString() {
, := parseInotifyInfo()
if != nil {
return nil,
}
= append(, *)
}
}
:= &ProcFDInfo{
FD: ,
Pos: ,
Flags: ,
MntID: ,
InotifyInfos: ,
}
return , nil
}
func ( string) (*InotifyInfo, error) {
:= regexp.MustCompile(`^inotify\s+wd:([0-9a-f]+)\s+ino:([0-9a-f]+)\s+sdev:([0-9a-f]+)\s+mask:([0-9a-f]+)`)
:= .FindStringSubmatch()
:= &InotifyInfo{
WD: [1],
Ino: [2],
Sdev: [3],
Mask: [4],
}
return , nil
}
type ProcFDInfos []ProcFDInfo
func ( ProcFDInfos) () int { return len() }
func ( ProcFDInfos) (, int) { [], [] = [], [] }
func ( ProcFDInfos) (, int) bool { return [].FD < [].FD }
func ( ProcFDInfos) () (int, error) {
:= 0
for , := range {
+= len(.InotifyInfos)
}
return , nil
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |