Slide 39
Slide 39 text
⑤ データ取得・転送ロジックを実装
3. Run(詳細は割愛)
設定ファイルで指定した間隔でループ処理
eventオブジェクトにデータを設定し、PublishEventで送信
39
func (bt *Winappbeat) Run(b *beat.Beat) error {
ticker := time.NewTicker(bt.period)
for {
select {
case <-bt.done:
return nil
case <-ticker.C:
}
list := listWindows(win.HWND(0))
for _, w := range list {
if bt.onlyNotEmpty && w.name == "" {
continue
}
if bt.onlyVisible && !w.visible {
continue
}
event := common.MapStr{
"@timestamp": common.Time(time.Now()),
"type": b.Name,
"windowname": w.name,
"windowcategory": w.nameCategory,
"windowclass": w.class,
}
b.Events.PublishEvent(event)
}
}
}
beater/winappbeat.go