本文整理汇总了Golang中github.com/shirou/gopsutil/process.Process.Name方法的典型用法代码示例。如果您正苦于以下问题:Golang Process.Name方法的具体用法?Golang Process.Name怎么用?Golang Process.Name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/shirou/gopsutil/process.Process
的用法示例。
在下文中一共展示了Process.Name方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: NewSpecProcessor
func NewSpecProcessor(
processName string,
prefix string,
pid int32,
acc telegraf.Accumulator,
p *process.Process,
tags map[string]string,
) *SpecProcessor {
if processName != "" {
tags["process_name"] = processName
} else {
name, err := p.Name()
if err == nil {
tags["process_name"] = name
}
}
return &SpecProcessor{
Prefix: prefix,
pid: pid,
tags: tags,
fields: make(map[string]interface{}),
acc: acc,
proc: p,
}
}
示例2: NewSpecProcessor
func NewSpecProcessor(
prefix string,
acc plugins.Accumulator,
p *process.Process,
) *SpecProcessor {
tags := make(map[string]string)
tags["pid"] = fmt.Sprintf("%v", p.Pid)
if name, err := p.Name(); err == nil {
tags["name"] = name
}
return &SpecProcessor{
Prefix: prefix,
tags: tags,
acc: acc,
proc: p,
}
}
示例3: NewSpecProcessor
func NewSpecProcessor(
prefix string,
acc telegraf.Accumulator,
p *process.Process,
tags map[string]string,
) *SpecProcessor {
if name, err := p.Name(); err == nil {
tags["process_name"] = name
}
return &SpecProcessor{
Prefix: prefix,
tags: tags,
fields: make(map[string]interface{}),
acc: acc,
proc: p,
}
}
示例4: getProcStatus
func getProcStatus(p *process.Process) (*ProcessStatus, error) {
n, err := p.Name()
if err != nil {
return nil, err
}
c, err := p.Percent(0)
if err != nil {
return nil, err
}
m, err := p.MemoryInfo()
if err != nil {
return nil, err
}
return &ProcessStatus{
Pid: p.Pid,
Name: n,
CPU: c,
VMS: m.VMS,
RSS: m.RSS,
Swap: m.Swap,
}, nil
}