Skip to content
This repository has been archived by the owner on Nov 8, 2022. It is now read-only.

Commit

Permalink
Merge pull request #25 from kindermoumoute/fix_performances
Browse files Browse the repository at this point in the history
Update namespace to /intel/iostat
  • Loading branch information
jcooklin authored Dec 22, 2016
2 parents 5253416 + e6a78c9 commit 1225bc6
Show file tree
Hide file tree
Showing 6 changed files with 225 additions and 226 deletions.
86 changes: 43 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ This plugin has the ability to gather the following metrics:

* **CPU statistic**

Metric namespace prefix: /intel/linux/iostat/avg-cpu/
Metric namespace prefix: /intel/iostat/avg-cpu/

Namespace | Description
------------ | -------------
Expand All @@ -97,7 +97,7 @@ Namespace | Description

* **Device statistics**

Metric namespace prefix: /intel/linux/iostat/device/{disk_or_partition}
Metric namespace prefix: /intel/iostat/device/{disk_or_partition}

Name | Description
------------ | -------------
Expand Down Expand Up @@ -164,47 +164,47 @@ $ snaptel task watch 02dd7ff4-8106-47e9-8b86-70067cd0a850
Watching Task (02dd7ff4-8106-47e9-8b86-70067cd0a850):
NAMESPACE DATA TIMESTAMP SOURCE
/intel/linux/iostat/avg-cpu/%idle 97.62 2015-12-01 05:39:57.79589855 -0500 EST gklab-108-109-110-111
/intel/linux/iostat/avg-cpu/%iowait 1.13 2015-12-01 05:39:57.79589855 -0500 EST gklab-108-109-110-111
/intel/linux/iostat/avg-cpu/%nice 0 2015-12-01 05:39:57.79589855 -0500 EST gklab-108-109-110-111
/intel/linux/iostat/avg-cpu/%steal 0 2015-12-01 05:39:57.79589855 -0500 EST gklab-108-109-110-111
/intel/linux/iostat/avg-cpu/%system 0.5 2015-12-01 05:39:57.79589855 -0500 EST gklab-108-109-110-111
/intel/linux/iostat/avg-cpu/%user 0.75 2015-12-01 05:39:57.79589855 -0500 EST gklab-108-109-110-111
/intel/linux/iostat/device/ALL/%util 1.69 2015-12-01 05:39:57.79589855 -0500 EST gklab-108-109-110-111
/intel/linux/iostat/device/ALL/r_per_sec 0 2015-12-01 05:39:57.79589855 -0500 EST gklab-108-109-110-111
/intel/linux/iostat/device/ALL/rkB_per_sec 0 2015-12-01 05:39:57.79589855 -0500 EST gklab-108-109-110-111
/intel/linux/iostat/device/ALL/rrqm_per_sec 0 2015-12-01 05:39:57.79589855 -0500 EST gklab-108-109-110-111
/intel/linux/iostat/device/ALL/w_per_sec 133 2015-12-01 05:39:57.79589855 -0500 EST gklab-108-109-110-111
/intel/linux/iostat/device/ALL/wkB_per_sec 50672 2015-12-01 05:39:57.79589855 -0500 EST gklab-108-109-110-111
/intel/linux/iostat/device/ALL/wrqm_per_sec 326 2015-12-01 05:39:57.79589855 -0500 EST gklab-108-109-110-111
/intel/linux/iostat/device/sda1/%util 0 2015-12-01 05:39:57.79589855 -0500 EST gklab-108-109-110-111
/intel/linux/iostat/device/sda1/r_per_sec 0 2015-12-01 05:39:57.79589855 -0500 EST gklab-108-109-110-111
/intel/linux/iostat/device/sda1/rkB_per_sec 0 2015-12-01 05:39:57.79589855 -0500 EST gklab-108-109-110-111
/intel/linux/iostat/device/sda1/rrqm_per_sec 0 2015-12-01 05:39:57.79589855 -0500 EST gklab-108-109-110-111
/intel/linux/iostat/device/sda1/w_per_sec 0 2015-12-01 05:39:57.79589855 -0500 EST gklab-108-109-110-111
/intel/linux/iostat/device/sda1/wkB_per_sec 0 2015-12-01 05:39:57.79589855 -0500 EST gklab-108-109-110-111
/intel/linux/iostat/device/sda1/wrqm_per_sec 0 2015-12-01 05:39:57.79589855 -0500 EST gklab-108-109-110-111
/intel/linux/iostat/device/sdb/%util 6.8 2015-12-01 05:39:57.79589855 -0500 EST gklab-108-109-110-111
/intel/linux/iostat/device/sdb/r_per_sec 0 2015-12-01 05:39:57.79589855 -0500 EST gklab-108-109-110-111
/intel/linux/iostat/device/sdb/rkB_per_sec 0 2015-12-01 05:39:57.79589855 -0500 EST gklab-108-109-110-111
/intel/linux/iostat/device/sdb/rrqm_per_sec 0 2015-12-01 05:39:57.79589855 -0500 EST gklab-108-109-110-111
/intel/linux/iostat/device/sdb/w_per_sec 68 2015-12-01 05:39:57.79589855 -0500 EST gklab-108-109-110-111
/intel/linux/iostat/device/sdb/wkB_per_sec 25336 2015-12-01 05:39:57.79589855 -0500 EST gklab-108-109-110-111
/intel/linux/iostat/device/sdb/wrqm_per_sec 163 2015-12-01 05:39:57.79589855 -0500 EST gklab-108-109-110-111
/intel/linux/iostat/device/sdb1/%util 6.7 2015-12-01 05:39:57.79589855 -0500 EST gklab-108-109-110-111
/intel/linux/iostat/device/sdb1/r_per_sec 0 2015-12-01 05:39:57.79589855 -0500 EST gklab-108-109-110-111
/intel/linux/iostat/device/sdb1/rkB_per_sec 0 2015-12-01 05:39:57.79589855 -0500 EST gklab-108-109-110-111
/intel/linux/iostat/device/sdb1/rrqm_per_sec 0 2015-12-01 05:39:57.79589855 -0500 EST gklab-108-109-110-111
/intel/linux/iostat/device/sdb1/w_per_sec 65 2015-12-01 05:39:57.79589855 -0500 EST gklab-108-109-110-111
/intel/linux/iostat/device/sdb1/wkB_per_sec 25336 2015-12-01 05:39:57.79589855 -0500 EST gklab-108-109-110-111
/intel/linux/iostat/device/sdb1/wrqm_per_sec 163 2015-12-01 05:39:57.79589855 -0500 EST gklab-108-109-110-111
/intel/linux/iostat/device/sdb2/%util 0 2015-12-01 05:39:57.79589855 -0500 EST gklab-108-109-110-111
/intel/linux/iostat/device/sdb2/r_per_sec 0 2015-12-01 05:39:57.79589855 -0500 EST gklab-108-109-110-111
/intel/linux/iostat/device/sdb2/rkB_per_sec 0 2015-12-01 05:39:57.79589855 -0500 EST gklab-108-109-110-111
/intel/linux/iostat/device/sdb2/rrqm_per_sec 0 2015-12-01 05:39:57.79589855 -0500 EST gklab-108-109-110-111
/intel/linux/iostat/device/sdb2/w_per_sec 0 2015-12-01 05:39:57.79589855 -0500 EST gklab-108-109-110-111
/intel/linux/iostat/device/sdb2/wkB_per_sec 0 2015-12-01 05:39:57.79589855 -0500 EST gklab-108-109-110-111
/intel/linux/iostat/device/sdb2/wrqm_per_sec 0 2015-12-01 05:39:57.79589855 -0500 EST gklab-108-109-110-111
/intel/iostat/avg-cpu/%idle 97.62 2015-12-01 05:39:57.79589855 -0500 EST gklab-108-109-110-111
/intel/iostat/avg-cpu/%iowait 1.13 2015-12-01 05:39:57.79589855 -0500 EST gklab-108-109-110-111
/intel/iostat/avg-cpu/%nice 0 2015-12-01 05:39:57.79589855 -0500 EST gklab-108-109-110-111
/intel/iostat/avg-cpu/%steal 0 2015-12-01 05:39:57.79589855 -0500 EST gklab-108-109-110-111
/intel/iostat/avg-cpu/%system 0.5 2015-12-01 05:39:57.79589855 -0500 EST gklab-108-109-110-111
/intel/iostat/avg-cpu/%user 0.75 2015-12-01 05:39:57.79589855 -0500 EST gklab-108-109-110-111
/intel/iostat/device/ALL/%util 1.69 2015-12-01 05:39:57.79589855 -0500 EST gklab-108-109-110-111
/intel/iostat/device/ALL/r_per_sec 0 2015-12-01 05:39:57.79589855 -0500 EST gklab-108-109-110-111
/intel/iostat/device/ALL/rkB_per_sec 0 2015-12-01 05:39:57.79589855 -0500 EST gklab-108-109-110-111
/intel/iostat/device/ALL/rrqm_per_sec 0 2015-12-01 05:39:57.79589855 -0500 EST gklab-108-109-110-111
/intel/iostat/device/ALL/w_per_sec 133 2015-12-01 05:39:57.79589855 -0500 EST gklab-108-109-110-111
/intel/iostat/device/ALL/wkB_per_sec 50672 2015-12-01 05:39:57.79589855 -0500 EST gklab-108-109-110-111
/intel/iostat/device/ALL/wrqm_per_sec 326 2015-12-01 05:39:57.79589855 -0500 EST gklab-108-109-110-111
/intel/iostat/device/sda1/%util 0 2015-12-01 05:39:57.79589855 -0500 EST gklab-108-109-110-111
/intel/iostat/device/sda1/r_per_sec 0 2015-12-01 05:39:57.79589855 -0500 EST gklab-108-109-110-111
/intel/iostat/device/sda1/rkB_per_sec 0 2015-12-01 05:39:57.79589855 -0500 EST gklab-108-109-110-111
/intel/iostat/device/sda1/rrqm_per_sec 0 2015-12-01 05:39:57.79589855 -0500 EST gklab-108-109-110-111
/intel/iostat/device/sda1/w_per_sec 0 2015-12-01 05:39:57.79589855 -0500 EST gklab-108-109-110-111
/intel/iostat/device/sda1/wkB_per_sec 0 2015-12-01 05:39:57.79589855 -0500 EST gklab-108-109-110-111
/intel/iostat/device/sda1/wrqm_per_sec 0 2015-12-01 05:39:57.79589855 -0500 EST gklab-108-109-110-111
/intel/iostat/device/sdb/%util 6.8 2015-12-01 05:39:57.79589855 -0500 EST gklab-108-109-110-111
/intel/iostat/device/sdb/r_per_sec 0 2015-12-01 05:39:57.79589855 -0500 EST gklab-108-109-110-111
/intel/iostat/device/sdb/rkB_per_sec 0 2015-12-01 05:39:57.79589855 -0500 EST gklab-108-109-110-111
/intel/iostat/device/sdb/rrqm_per_sec 0 2015-12-01 05:39:57.79589855 -0500 EST gklab-108-109-110-111
/intel/iostat/device/sdb/w_per_sec 68 2015-12-01 05:39:57.79589855 -0500 EST gklab-108-109-110-111
/intel/iostat/device/sdb/wkB_per_sec 25336 2015-12-01 05:39:57.79589855 -0500 EST gklab-108-109-110-111
/intel/iostat/device/sdb/wrqm_per_sec 163 2015-12-01 05:39:57.79589855 -0500 EST gklab-108-109-110-111
/intel/iostat/device/sdb1/%util 6.7 2015-12-01 05:39:57.79589855 -0500 EST gklab-108-109-110-111
/intel/iostat/device/sdb1/r_per_sec 0 2015-12-01 05:39:57.79589855 -0500 EST gklab-108-109-110-111
/intel/iostat/device/sdb1/rkB_per_sec 0 2015-12-01 05:39:57.79589855 -0500 EST gklab-108-109-110-111
/intel/iostat/device/sdb1/rrqm_per_sec 0 2015-12-01 05:39:57.79589855 -0500 EST gklab-108-109-110-111
/intel/iostat/device/sdb1/w_per_sec 65 2015-12-01 05:39:57.79589855 -0500 EST gklab-108-109-110-111
/intel/iostat/device/sdb1/wkB_per_sec 25336 2015-12-01 05:39:57.79589855 -0500 EST gklab-108-109-110-111
/intel/iostat/device/sdb1/wrqm_per_sec 163 2015-12-01 05:39:57.79589855 -0500 EST gklab-108-109-110-111
/intel/iostat/device/sdb2/%util 0 2015-12-01 05:39:57.79589855 -0500 EST gklab-108-109-110-111
/intel/iostat/device/sdb2/r_per_sec 0 2015-12-01 05:39:57.79589855 -0500 EST gklab-108-109-110-111
/intel/iostat/device/sdb2/rkB_per_sec 0 2015-12-01 05:39:57.79589855 -0500 EST gklab-108-109-110-111
/intel/iostat/device/sdb2/rrqm_per_sec 0 2015-12-01 05:39:57.79589855 -0500 EST gklab-108-109-110-111
/intel/iostat/device/sdb2/w_per_sec 0 2015-12-01 05:39:57.79589855 -0500 EST gklab-108-109-110-111
/intel/iostat/device/sdb2/wkB_per_sec 0 2015-12-01 05:39:57.79589855 -0500 EST gklab-108-109-110-111
/intel/iostat/device/sdb2/wrqm_per_sec 0 2015-12-01 05:39:57.79589855 -0500 EST gklab-108-109-110-111
```

Stop task:
Expand Down
42 changes: 21 additions & 21 deletions examples/tasks/iostat-file.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,29 @@
"workflow": {
"collect": {
"metrics": {
"/intel/linux/iostat/avg-cpu/%user": {},
"/intel/linux/iostat/avg-cpu/%system": {},
"/intel/linux/iostat/avg-cpu/%idle": {},
"/intel/linux/iostat/avg-cpu/%iowait": {},
"/intel/linux/iostat/avg-cpu/%nice": {},
"/intel/linux/iostat/avg-cpu/%steal": {},
"/intel/linux/iostat/device/sda1/rrqm_per_sec": {},
"/intel/linux/iostat/device/sda1/wrqm_per_sec": {},
"/intel/linux/iostat/device/sda1/r_per_sec": {},
"/intel/linux/iostat/device/sda1/w_per_sec": {},
"/intel/linux/iostat/device/sda1/rkB_per_sec": {},
"/intel/linux/iostat/device/sda1/wkB_per_sec": {},
"/intel/linux/iostat/device/sda1/%util": {},
"/intel/linux/iostat/device/ALL/rrqm_per_sec": {},
"/intel/linux/iostat/device/ALL/wrqm_per_sec": {},
"/intel/linux/iostat/device/ALL/r_per_sec": {},
"/intel/linux/iostat/device/ALL/w_per_sec": {},
"/intel/linux/iostat/device/ALL/rkB_per_sec": {},
"/intel/linux/iostat/device/ALL/wkB_per_sec": {},
"/intel/linux/iostat/device/ALL/%util": {}
"/intel/iostat/avg-cpu/%user": {},
"/intel/iostat/avg-cpu/%system": {},
"/intel/iostat/avg-cpu/%idle": {},
"/intel/iostat/avg-cpu/%iowait": {},
"/intel/iostat/avg-cpu/%nice": {},
"/intel/iostat/avg-cpu/%steal": {},
"/intel/iostat/device/sda1/rrqm_per_sec": {},
"/intel/iostat/device/sda1/wrqm_per_sec": {},
"/intel/iostat/device/sda1/r_per_sec": {},
"/intel/iostat/device/sda1/w_per_sec": {},
"/intel/iostat/device/sda1/rkB_per_sec": {},
"/intel/iostat/device/sda1/wkB_per_sec": {},
"/intel/iostat/device/sda1/%util": {},
"/intel/iostat/device/ALL/rrqm_per_sec": {},
"/intel/iostat/device/ALL/wrqm_per_sec": {},
"/intel/iostat/device/ALL/r_per_sec": {},
"/intel/iostat/device/ALL/w_per_sec": {},
"/intel/iostat/device/ALL/rkB_per_sec": {},
"/intel/iostat/device/ALL/wkB_per_sec": {},
"/intel/iostat/device/ALL/%util": {}
},
"config": {
"/intel/linux/iostat": {
"/intel/iostat": {
"ReportSinceBoot": false
}
},
Expand Down
42 changes: 21 additions & 21 deletions examples/tasks/iostat-influxdb.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,29 @@
"workflow": {
"collect": {
"metrics": {
"/intel/linux/iostat/avg-cpu/%user": {},
"/intel/linux/iostat/avg-cpu/%system": {},
"/intel/linux/iostat/avg-cpu/%idle": {},
"/intel/linux/iostat/avg-cpu/%iowait": {},
"/intel/linux/iostat/avg-cpu/%nice": {},
"/intel/linux/iostat/avg-cpu/%steal": {},
"/intel/linux/iostat/device/sda1/rrqm_per_sec": {},
"/intel/linux/iostat/device/sda1/wrqm_per_sec": {},
"/intel/linux/iostat/device/sda1/r_per_sec": {},
"/intel/linux/iostat/device/sda1/w_per_sec": {},
"/intel/linux/iostat/device/sda1/rkB_per_sec": {},
"/intel/linux/iostat/device/sda1/wkB_per_sec": {},
"/intel/linux/iostat/device/sda1/%util": {},
"/intel/linux/iostat/device/ALL/rrqm_per_sec": {},
"/intel/linux/iostat/device/ALL/wrqm_per_sec": {},
"/intel/linux/iostat/device/ALL/r_per_sec": {},
"/intel/linux/iostat/device/ALL/w_per_sec": {},
"/intel/linux/iostat/device/ALL/rkB_per_sec": {},
"/intel/linux/iostat/device/ALL/wkB_per_sec": {},
"/intel/linux/iostat/device/ALL/%util": {}
"/intel/iostat/avg-cpu/%user": {},
"/intel/iostat/avg-cpu/%system": {},
"/intel/iostat/avg-cpu/%idle": {},
"/intel/iostat/avg-cpu/%iowait": {},
"/intel/iostat/avg-cpu/%nice": {},
"/intel/iostat/avg-cpu/%steal": {},
"/intel/iostat/device/sda1/rrqm_per_sec": {},
"/intel/iostat/device/sda1/wrqm_per_sec": {},
"/intel/iostat/device/sda1/r_per_sec": {},
"/intel/iostat/device/sda1/w_per_sec": {},
"/intel/iostat/device/sda1/rkB_per_sec": {},
"/intel/iostat/device/sda1/wkB_per_sec": {},
"/intel/iostat/device/sda1/%util": {},
"/intel/iostat/device/ALL/rrqm_per_sec": {},
"/intel/iostat/device/ALL/wrqm_per_sec": {},
"/intel/iostat/device/ALL/r_per_sec": {},
"/intel/iostat/device/ALL/w_per_sec": {},
"/intel/iostat/device/ALL/rkB_per_sec": {},
"/intel/iostat/device/ALL/wkB_per_sec": {},
"/intel/iostat/device/ALL/%util": {}
},
"config": {
"/intel/linux/iostat": {
"/intel/iostat": {
"ReportSinceBoot": false
}
},
Expand Down
20 changes: 10 additions & 10 deletions iostat/iostat.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const (
// Name of plugin
Name = "iostat"
// Version of plugin
Version = 5
Version = 6
// Type of plugin
Type = plugin.CollectorPluginType
deviceMetric = "device"
Expand Down Expand Up @@ -79,14 +79,14 @@ func (iostat *IOSTAT) CollectMetrics(mts []plugin.MetricType) ([]plugin.MetricTy

for _, mt := range mts {
ns := mt.Namespace()
if len(ns) < 5 {
if len(ns) < 4 {
return nil, fmt.Errorf("Namespace length is too short (len = %d)", len(ns))
}

if ns[4].Value == "*" {
if ns[3].Value == deviceMetric {
if ns[3].Value == "*" {
if ns[2].Value == deviceMetric {
for k, _ := range data {
reg := ns[:3].String() + "/device/.*" + ns[5:].String()
reg := ns[:2].String() + "/device/.*" + ns[4:].String()
matched, err := regexp.MatchString(reg, k)
if !matched {
continue
Expand All @@ -95,14 +95,14 @@ func (iostat *IOSTAT) CollectMetrics(mts []plugin.MetricType) ([]plugin.MetricTy
return nil, fmt.Errorf("Error matching namespaces %v", ns)
}

dev, err := extractFromNamespace(k, 4)
dev, err := extractFromNamespace(k, 3)
if err != nil {
return nil, err
}

nsCopy := make(core.Namespace, len(ns))
copy(nsCopy, ns)
nsCopy[4].Value = dev
nsCopy[3].Value = dev

if v, ok := data[nsCopy.String()]; ok {
metrics = append(metrics, plugin.MetricType{
Expand Down Expand Up @@ -146,16 +146,16 @@ func (iostat *IOSTAT) GetMetricTypes(_ plugin.ConfigType) ([]plugin.MetricType,
for _, namespace := range namespaces {
ns := core.NewNamespace(strings.Split(strings.TrimPrefix(namespace, "/"), "/")...)

if len(ns) < 5 {
if len(ns) < 4 {
return nil, fmt.Errorf("Namespace length is too short (len = %d)", len(ns))
}
// terminal metric name
mItem := ns[len(ns)-1]
if ns[3].Value == deviceMetric {
if ns[2].Value == deviceMetric {
if !mList[mItem.Value] {
mList[mItem.Value] = true
metric = plugin.MetricType{
Namespace_: core.NewNamespace(parser.NsVendor, parser.NsClass, parser.NsType, deviceMetric).
Namespace_: core.NewNamespace(parser.NsVendor, parser.NsType, deviceMetric).
AddDynamicElement("device_id", "Device ID").
AddStaticElement(mItem.Value),
Description_: "dynamic device metric: " + mItem.Value}
Expand Down
Loading

0 comments on commit 1225bc6

Please # to comment.