13 Star 50 Fork 0

Gitee 极速下载/etcd

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/coreos/etcd
克隆/下载
proc_io.go 1.10 KB
一键复制 编辑 原始数据 按行查看 历史
Eric Paris 提交于 2015-05-30 18:08 . Fix godeps to be usable
package procfs
import (
"fmt"
"io/ioutil"
)
// ProcIO models the content of /proc/<pid>/io.
type ProcIO struct {
// Chars read.
RChar uint64
// Chars written.
WChar uint64
// Read syscalls.
SyscR uint64
// Write syscalls.
SyscW uint64
// Bytes read.
ReadBytes uint64
// Bytes written.
WriteBytes uint64
// Bytes written, but taking into account truncation. See
// Documentation/filesystems/proc.txt in the kernel sources for
// detailed explanation.
CancelledWriteBytes int64
}
// NewIO creates a new ProcIO instance from a given Proc instance.
func (p Proc) NewIO() (ProcIO, error) {
pio := ProcIO{}
f, err := p.open("io")
if err != nil {
return pio, err
}
defer f.Close()
data, err := ioutil.ReadAll(f)
if err != nil {
return pio, err
}
ioFormat := "rchar: %d\nwchar: %d\nsyscr: %d\nsyscw: %d\n" +
"read_bytes: %d\nwrite_bytes: %d\n" +
"cancelled_write_bytes: %d\n"
_, err = fmt.Sscanf(string(data), ioFormat, &pio.RChar, &pio.WChar, &pio.SyscR,
&pio.SyscW, &pio.ReadBytes, &pio.WriteBytes, &pio.CancelledWriteBytes)
if err != nil {
return pio, err
}
return pio, nil
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/mirrors/etcd.git
git@gitee.com:mirrors/etcd.git
mirrors
etcd
etcd
v2.2.5

搜索帮助

A270a887 8829481 3d7a4017 8829481