本文整理匯總了Golang中github.com/cloudfoundry/gosigar.FileSystemUsage.UsePercent方法的典型用法代碼示例。如果您正苦於以下問題:Golang FileSystemUsage.UsePercent方法的具體用法?Golang FileSystemUsage.UsePercent怎麽用?Golang FileSystemUsage.UsePercent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/cloudfoundry/gosigar.FileSystemUsage
的用法示例。
在下文中一共展示了FileSystemUsage.UsePercent方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: GetFileSystemList75
func GetFileSystemList75() []string {
result := []string{}
volumes := []sigar.FileSystem{}
if runtime.GOOS == "windows" {
volumes = getWindowsDrives()
} else {
fslist := sigar.FileSystemList{}
fslist.Get()
volumes = fslist.List
}
for _, volume := range volumes {
dirName := volume.DirName
usage := sigar.FileSystemUsage{}
usage.Get(dirName)
if usage.UsePercent() >= 75 {
result = append(result, fmt.Sprintf("%s (%s)",
dirName,
sigar.FormatPercent(usage.UsePercent())))
}
}
return result
}
示例2: postMetrics
func postMetrics() error {
var metrics = make(map[string]interface{})
// Runtime Info
metrics["agent.runtime.numcpu"] = runtime.NumCPU()
metrics["agent.runtime.numgoroutine"] = runtime.NumGoroutine()
// System Info
avg := sigar.LoadAverage{}
mem := sigar.Mem{}
swap := sigar.Swap{}
avg.Get()
mem.Get()
swap.Get()
metrics["agent.system.loadavg.one"] = avg.One
metrics["agent.system.loadavg.five"] = avg.Five
metrics["agent.system.loadavg.fifteen"] = avg.Fifteen
metrics["agent.system.mem.total"] = mem.Total
metrics["agent.system.mem.used"] = mem.Used
metrics["agent.system.mem.free"] = mem.Free
metrics["agent.system.mem.actual_used"] = mem.ActualUsed
metrics["agent.system.mem.actual_free"] = mem.ActualFree
metrics["agent.system.swap.total"] = swap.Total
metrics["agent.system.swap.used"] = swap.Used
metrics["agent.system.swap.free"] = swap.Free
// Disk Info
fslist := sigar.FileSystemList{}
fslist.Get()
for _, fs := range fslist.List {
if strings.HasPrefix(fs.DevName, "/") {
dirname := fs.DirName
usage := sigar.FileSystemUsage{}
usage.Get(dirname)
metrics[fmt.Sprintf("agent.disk.%s.total", dirname)] = usage.Total
metrics[fmt.Sprintf("agent.disk.%s.used", dirname)] = usage.Used
metrics[fmt.Sprintf("agent.disk.%s.avail", dirname)] = usage.Avail
metrics[fmt.Sprintf("agent.disk.%s.used_percent", dirname)] = usage.UsePercent()
}
}
if client, err := models.NewCounterClient(nil); err != nil {
return err
} else {
return client.PostMany("statsd", metrics)
}
}