mirror of
https://github.com/fankes/komari-agent.git
synced 2025-10-19 19:19:23 +08:00
feat: 启动时输出监控的文件夹和网卡名
This commit is contained in:
@@ -321,3 +321,30 @@ func shouldInclude(nicName string, includeNics, excludeNics map[string]struct{})
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func InterfaceList() ([]string, error) {
|
||||
includeNics := parseNics(flags.IncludeNics)
|
||||
excludeNics := parseNics(flags.ExcludeNics)
|
||||
interfaces := []string{}
|
||||
if flags.MonthRotate != 0 {
|
||||
vnstatData, err := getVnstatData()
|
||||
if err == nil {
|
||||
for interfaceName := range vnstatData {
|
||||
if shouldInclude(interfaceName, includeNics, excludeNics) {
|
||||
interfaces = append(interfaces, interfaceName)
|
||||
}
|
||||
}
|
||||
return interfaces, nil
|
||||
}
|
||||
}
|
||||
ioCounters, err := net.IOCounters(true)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for _, interfaceStats := range ioCounters {
|
||||
if shouldInclude(interfaceStats.Name, includeNics, excludeNics) {
|
||||
interfaces = append(interfaces, interfaceStats.Name)
|
||||
}
|
||||
}
|
||||
return interfaces, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user