Skip to content

Commit

Permalink
Adds ability to organize by a particular column value
Browse files Browse the repository at this point in the history
  • Loading branch information
eskibars committed Apr 30, 2016

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent afb8e62 commit e5be463
Showing 5 changed files with 27 additions and 5 deletions.
26 changes: 23 additions & 3 deletions beater/wmibeat.go
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@ import (
"time"
"strings"
"bytes"
"strconv"

"github.com/elastic/beats/libbeat/beat"
"github.com/elastic/beats/libbeat/cfgfile"
@@ -114,7 +115,13 @@ func (bt *Wmibeat) Run(b *beat.Beat) error {
count := int(countObj.Val)
defer countObj.Clear()

var classValues []common.MapStr
var classValues interface {} = nil

if (class.ObjectTitle != "") {
classValues = common.MapStr{}
} else {
classValues = []common.MapStr{}
}
for i :=0; i < count; i++ {
rowObj, err := oleutil.CallMethod(result, "ItemIndex", i)
if err != nil {
@@ -123,17 +130,30 @@ func (bt *Wmibeat) Run(b *beat.Beat) error {
row := rowObj.ToIDispatch()
defer rowObj.Clear()
var rowValues common.MapStr
var objectTitle = ""
for _, j := range wmiFields {
wmiObj, err := oleutil.GetProperty(row, j)

if err != nil {
return err
}
rowValues = common.MapStrUnion(rowValues, common.MapStr { j: wmiObj.Value() } )
var objValue = wmiObj.Value()
if (class.ObjectTitle == j) {
objectTitle = objValue.(string)
}
rowValues = common.MapStrUnion(rowValues, common.MapStr { j: objValue } )
defer wmiObj.Clear()

}
classValues = append(classValues, rowValues)
if (class.ObjectTitle != "") {
if (objectTitle != "") {
classValues = common.MapStrUnion(classValues.(common.MapStr), common.MapStr { objectTitle: rowValues })
} else {
classValues = common.MapStrUnion(classValues.(common.MapStr), common.MapStr { strconv.Itoa(i): rowValues })
}
} else {
classValues = append(classValues.([]common.MapStr), rowValues)
}
rowValues = nil
}
allValues = append(allValues, common.MapStr { class.Class: classValues })
1 change: 1 addition & 0 deletions config/config.go
Original file line number Diff line number Diff line change
@@ -16,4 +16,5 @@ type ClassConfig struct {
Class string `config:"class"`
Fields []string `config:"fields"`
WhereClause string `config:"whereclause"`
ObjectTitle string `config:"objecttitlecolumn"`
}
2 changes: 1 addition & 1 deletion etc/fields.yml
Original file line number Diff line number Diff line change
@@ -56,5 +56,5 @@ wmibeat:
sections:
- ["env", "Common"]
- ["wmibeat", "Wmibeat"]
- ["wmibeat", "WMIbeat"]

2 changes: 1 addition & 1 deletion tests/system/test_base.py
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ class Test(BaseTest):

def test_base(self):
"""
Basic test with exiting Wmibeat normally
Basic test with exiting WMIbeat normally
"""
self.render_config_template(
path=os.path.abspath(self.working_dir) + "/log/*"
1 change: 1 addition & 0 deletions wmibeat.yml
Original file line number Diff line number Diff line change
@@ -27,6 +27,7 @@ wmibeat:
- PercentDiskWriteTime
- PercentDiskTime
whereclause: Name != "_Total"
objecttitlecolumn: Name
- class: Win32_PerfFormattedData_PerfOS_Memory
fields:
- CommittedBytes

0 comments on commit e5be463

Please sign in to comment.