Repository: DataDog/dd-agent

Issue:
[core] io metrics linux: device names with dashes are not supported
io metrics are grabbed from `iostat`: https://github.com/DataDog/dd-agent/blob/master/checks/system/unix.py#L121-L139

```
$ iostat -d 1 2 -x -k

Linux 2.6.32-573.7.1.el6.x86_64 (address.net) 05/19/2016 _x86_64_ (32 CPU)

Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz avgqu-sz await svctm %util
xvaa 1.22 112.88 9.70 21.89 220.78 626.35 53.63 0.25 7.76 0.44 1.38
pm-0 0.00 0.00 6.63 13.80 38.52 55.19 9.17 0.67 33.01 0.26 0.53
pm-1 0.00 0.00 3.97 100.49 161.44 401.98 10.79 0.90 8.59 0.06 0.60
```

No data is reported under device name `pm-0` or `pm-1`, instead all data is reported under `pm`, and the last disk metrics erase values from previous pm disks.

Supporting dashes in device names regex (https://github.com/DataDog/dd-agent/blob/master/checks/system/unix.py#L38) solves the problem a.k.a:

`self.item_re = re.compile(r'^([\-a-zA-Z0-9\/]+)')`

See ticket: https://datadog.zendesk.com/agent/tickets/53558



Discussion:
Thanks!

Confirmed that the proposed regex works fine


Resolving patch:
diff --git a/checks/system/unix.py b/checks/system/unix.py
--- a/checks/system/unix.py
+++ b/checks/system/unix.py
@@ -35,7 +35,7 @@ class IO(Check):
     def __init__(self, logger):
         Check.__init__(self, logger)
         self.header_re = re.compile(r'([%\\/\-_a-zA-Z0-9]+)[\s+]?')
-        self.item_re = re.compile(r'^([a-zA-Z0-9\/]+)')
+        self.item_re = re.compile(r'^([\-a-zA-Z0-9\/]+)')
         self.value_re = re.compile(r'\d+\.\d+')
 
     def _parse_linux2(self, output):


Test patch:
diff --git a/tests/checks/mock/test_sysstat.py b/tests/checks/mock/test_sysstat.py
--- a/tests/checks/mock/test_sysstat.py
+++ b/tests/checks/mock/test_sysstat.py
@@ -125,6 +125,22 @@ def testDiskLatency(self):
             {'system.io.bytes_per_s': float(0),}
         )
 
+
+        linux_output_dashes = """Linux 3.13.0-32-generic (ubuntu-1204)  05/20/2016  _x86_64_    (2 CPU)
+
+Device:         rrqm/s   wrqm/s     r/s     w/s    rkB/s    wkB/s avgrq-sz avgqu-sz   await r_await w_await  svctm  %util
+sda               5.77     8.20    7.79   30.08   320.67   219.91    28.55     0.05    1.32    1.53    1.27   0.32   1.20
+dm-0              0.00     0.00   11.71   37.97   313.61   219.90    21.48     0.11    2.16    2.13    2.17   0.24   1.20
+dm-1              0.00     0.00    0.08    0.00     0.32     0.00     8.00     0.00    1.68    1.68    0.00   1.07   0.01
+
+Device:         rrqm/s   wrqm/s     r/s     w/s    rkB/s    wkB/s avgrq-sz avgqu-sz   await r_await w_await  svctm  %util
+sda               0.00     0.00    0.00    1.00     0.00     4.00     8.00     0.00    0.00    0.00    0.00   0.00   0.00
+dm-0              0.00     0.00    0.00    1.00     0.00     4.00     8.00     0.00    0.00    0.00    0.00   0.00   0.00
+dm-1              0.00     0.00    0.00    0.00     0.00     0.00     0.00     0.00    0.00    0.00    0.00   0.00   0.00
+"""
+        results = checker._parse_linux2(linux_output_dashes)
+        self.assertTrue(sorted(results.keys()) == ['dm-0', 'dm-1', 'sda'])
+
     def testNetwork(self):
         # FIXME: cx_state to true, but needs sysstat installed
         config = """