Skip to content

Commit

Permalink
iptables lister未初始化问题 (#995)
Browse files Browse the repository at this point in the history
* iptables插件

* 添加注册

* pushgateway接口支持用户指定值置换agent_hostname

* pushgateway接口支持用户指定值置换agent_hostname

* 修改命名

* Update iptables.go

修复未初始化问题 #994
  • Loading branch information
tianyanli authored Jul 5, 2024
1 parent 1211e88 commit e3313a6
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions inputs/iptables/iptables.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ func (ins *Instance) Init() error {
log.Println("W! Table or Chains is empty")
return types.ErrInstancesEmpty
}
if ins.lister == nil {
ins.lister = ins.chainList
}
return nil
}

Expand All @@ -71,6 +74,10 @@ func (ins *Instance) Gather(slist *types.SampleList) {
log.Println("W! Table or Chains is empty")
return
}
if ins.lister == nil {
log.Println("E! Lister is empty or not initialized")
return
}
// best effort : we continue through the chains even if an error is encountered,
// but we keep track of the last error.
for _, chain := range ins.Chains {
Expand Down

0 comments on commit e3313a6

Please sign in to comment.