diff options
author | Ben Kochie <superq@gmail.com> | 2019-05-31 18:30:37 +0200 |
---|---|---|
committer | Ben Kochie <superq@gmail.com> | 2019-06-04 18:38:40 +0200 |
commit | 46fa12e63d8213ff5601be96599f90148e9e234b (patch) | |
tree | 3d48224d6c3a10f98ac8c8c2f1c37b5a81958e36 | |
parent | 5cee32bafee63687950537eb1cdffdfd6058c31a (diff) | |
download | prometheus_node_collector-46fa12e63d8213ff5601be96599f90148e9e234b.tar.bz2 prometheus_node_collector-46fa12e63d8213ff5601be96599f90148e9e234b.tar.xz prometheus_node_collector-46fa12e63d8213ff5601be96599f90148e9e234b.zip |
Fix rollover bug in mountstats collector (#1364)
* Update procfs vendor to pull in github.com/prometheus/procfs/pull/165
* Update mountstats collector to use new types.
* Rollover counter automatically to avoid float64 accuracy issues.
* Update e2e test.
Signed-off-by: Ben Kochie <superq@gmail.com>
21 files changed, 771 insertions, 76 deletions
diff --git a/collector/fixtures/e2e-64k-page-output.txt b/collector/fixtures/e2e-64k-page-output.txt index 47e8f9a..4653cd6 100644 --- a/collector/fixtures/e2e-64k-page-output.txt +++ b/collector/fixtures/e2e-64k-page-output.txt | |||
@@ -1577,6 +1577,7 @@ node_mountstats_nfs_event_write_extension_total{export="192.168.1.1:/srv/test",p | |||
1577 | node_mountstats_nfs_event_write_extension_total{export="192.168.1.1:/srv/test",protocol="udp"} 0 | 1577 | node_mountstats_nfs_event_write_extension_total{export="192.168.1.1:/srv/test",protocol="udp"} 0 |
1578 | # HELP node_mountstats_nfs_operations_major_timeouts_total Number of times a request has had a major timeout for a given operation. | 1578 | # HELP node_mountstats_nfs_operations_major_timeouts_total Number of times a request has had a major timeout for a given operation. |
1579 | # TYPE node_mountstats_nfs_operations_major_timeouts_total counter | 1579 | # TYPE node_mountstats_nfs_operations_major_timeouts_total counter |
1580 | node_mountstats_nfs_operations_major_timeouts_total{export="192.168.1.1:/srv/test",operation="ACCESS",protocol="udp"} 0 | ||
1580 | node_mountstats_nfs_operations_major_timeouts_total{export="192.168.1.1:/srv/test",operation="NULL",protocol="tcp"} 0 | 1581 | node_mountstats_nfs_operations_major_timeouts_total{export="192.168.1.1:/srv/test",operation="NULL",protocol="tcp"} 0 |
1581 | node_mountstats_nfs_operations_major_timeouts_total{export="192.168.1.1:/srv/test",operation="NULL",protocol="udp"} 0 | 1582 | node_mountstats_nfs_operations_major_timeouts_total{export="192.168.1.1:/srv/test",operation="NULL",protocol="udp"} 0 |
1582 | node_mountstats_nfs_operations_major_timeouts_total{export="192.168.1.1:/srv/test",operation="READ",protocol="tcp"} 0 | 1583 | node_mountstats_nfs_operations_major_timeouts_total{export="192.168.1.1:/srv/test",operation="READ",protocol="tcp"} 0 |
@@ -1585,6 +1586,7 @@ node_mountstats_nfs_operations_major_timeouts_total{export="192.168.1.1:/srv/tes | |||
1585 | node_mountstats_nfs_operations_major_timeouts_total{export="192.168.1.1:/srv/test",operation="WRITE",protocol="udp"} 0 | 1586 | node_mountstats_nfs_operations_major_timeouts_total{export="192.168.1.1:/srv/test",operation="WRITE",protocol="udp"} 0 |
1586 | # HELP node_mountstats_nfs_operations_queue_time_seconds_total Duration all requests spent queued for transmission for a given operation before they were sent, in seconds. | 1587 | # HELP node_mountstats_nfs_operations_queue_time_seconds_total Duration all requests spent queued for transmission for a given operation before they were sent, in seconds. |
1587 | # TYPE node_mountstats_nfs_operations_queue_time_seconds_total counter | 1588 | # TYPE node_mountstats_nfs_operations_queue_time_seconds_total counter |
1589 | node_mountstats_nfs_operations_queue_time_seconds_total{export="192.168.1.1:/srv/test",operation="ACCESS",protocol="udp"} 9.007044786793922e+12 | ||
1588 | node_mountstats_nfs_operations_queue_time_seconds_total{export="192.168.1.1:/srv/test",operation="NULL",protocol="tcp"} 0 | 1590 | node_mountstats_nfs_operations_queue_time_seconds_total{export="192.168.1.1:/srv/test",operation="NULL",protocol="tcp"} 0 |
1589 | node_mountstats_nfs_operations_queue_time_seconds_total{export="192.168.1.1:/srv/test",operation="NULL",protocol="udp"} 0 | 1591 | node_mountstats_nfs_operations_queue_time_seconds_total{export="192.168.1.1:/srv/test",operation="NULL",protocol="udp"} 0 |
1590 | node_mountstats_nfs_operations_queue_time_seconds_total{export="192.168.1.1:/srv/test",operation="READ",protocol="tcp"} 0.006 | 1592 | node_mountstats_nfs_operations_queue_time_seconds_total{export="192.168.1.1:/srv/test",operation="READ",protocol="tcp"} 0.006 |
@@ -1593,6 +1595,7 @@ node_mountstats_nfs_operations_queue_time_seconds_total{export="192.168.1.1:/srv | |||
1593 | node_mountstats_nfs_operations_queue_time_seconds_total{export="192.168.1.1:/srv/test",operation="WRITE",protocol="udp"} 0 | 1595 | node_mountstats_nfs_operations_queue_time_seconds_total{export="192.168.1.1:/srv/test",operation="WRITE",protocol="udp"} 0 |
1594 | # HELP node_mountstats_nfs_operations_received_bytes_total Number of bytes received for a given operation, including RPC headers and payload. | 1596 | # HELP node_mountstats_nfs_operations_received_bytes_total Number of bytes received for a given operation, including RPC headers and payload. |
1595 | # TYPE node_mountstats_nfs_operations_received_bytes_total counter | 1597 | # TYPE node_mountstats_nfs_operations_received_bytes_total counter |
1598 | node_mountstats_nfs_operations_received_bytes_total{export="192.168.1.1:/srv/test",operation="ACCESS",protocol="udp"} 3.62996810236e+11 | ||
1596 | node_mountstats_nfs_operations_received_bytes_total{export="192.168.1.1:/srv/test",operation="NULL",protocol="tcp"} 0 | 1599 | node_mountstats_nfs_operations_received_bytes_total{export="192.168.1.1:/srv/test",operation="NULL",protocol="tcp"} 0 |
1597 | node_mountstats_nfs_operations_received_bytes_total{export="192.168.1.1:/srv/test",operation="NULL",protocol="udp"} 0 | 1600 | node_mountstats_nfs_operations_received_bytes_total{export="192.168.1.1:/srv/test",operation="NULL",protocol="udp"} 0 |
1598 | node_mountstats_nfs_operations_received_bytes_total{export="192.168.1.1:/srv/test",operation="READ",protocol="tcp"} 1.210292152e+09 | 1601 | node_mountstats_nfs_operations_received_bytes_total{export="192.168.1.1:/srv/test",operation="READ",protocol="tcp"} 1.210292152e+09 |
@@ -1601,6 +1604,7 @@ node_mountstats_nfs_operations_received_bytes_total{export="192.168.1.1:/srv/tes | |||
1601 | node_mountstats_nfs_operations_received_bytes_total{export="192.168.1.1:/srv/test",operation="WRITE",protocol="udp"} 0 | 1604 | node_mountstats_nfs_operations_received_bytes_total{export="192.168.1.1:/srv/test",operation="WRITE",protocol="udp"} 0 |
1602 | # HELP node_mountstats_nfs_operations_request_time_seconds_total Duration all requests took from when a request was enqueued to when it was completely handled for a given operation, in seconds. | 1605 | # HELP node_mountstats_nfs_operations_request_time_seconds_total Duration all requests took from when a request was enqueued to when it was completely handled for a given operation, in seconds. |
1603 | # TYPE node_mountstats_nfs_operations_request_time_seconds_total counter | 1606 | # TYPE node_mountstats_nfs_operations_request_time_seconds_total counter |
1607 | node_mountstats_nfs_operations_request_time_seconds_total{export="192.168.1.1:/srv/test",operation="ACCESS",protocol="udp"} 1.953587717e+06 | ||
1604 | node_mountstats_nfs_operations_request_time_seconds_total{export="192.168.1.1:/srv/test",operation="NULL",protocol="tcp"} 0 | 1608 | node_mountstats_nfs_operations_request_time_seconds_total{export="192.168.1.1:/srv/test",operation="NULL",protocol="tcp"} 0 |
1605 | node_mountstats_nfs_operations_request_time_seconds_total{export="192.168.1.1:/srv/test",operation="NULL",protocol="udp"} 0 | 1609 | node_mountstats_nfs_operations_request_time_seconds_total{export="192.168.1.1:/srv/test",operation="NULL",protocol="udp"} 0 |
1606 | node_mountstats_nfs_operations_request_time_seconds_total{export="192.168.1.1:/srv/test",operation="READ",protocol="tcp"} 79.407 | 1610 | node_mountstats_nfs_operations_request_time_seconds_total{export="192.168.1.1:/srv/test",operation="READ",protocol="tcp"} 79.407 |
@@ -1609,6 +1613,7 @@ node_mountstats_nfs_operations_request_time_seconds_total{export="192.168.1.1:/s | |||
1609 | node_mountstats_nfs_operations_request_time_seconds_total{export="192.168.1.1:/srv/test",operation="WRITE",protocol="udp"} 0 | 1613 | node_mountstats_nfs_operations_request_time_seconds_total{export="192.168.1.1:/srv/test",operation="WRITE",protocol="udp"} 0 |
1610 | # HELP node_mountstats_nfs_operations_requests_total Number of requests performed for a given operation. | 1614 | # HELP node_mountstats_nfs_operations_requests_total Number of requests performed for a given operation. |
1611 | # TYPE node_mountstats_nfs_operations_requests_total counter | 1615 | # TYPE node_mountstats_nfs_operations_requests_total counter |
1616 | node_mountstats_nfs_operations_requests_total{export="192.168.1.1:/srv/test",operation="ACCESS",protocol="udp"} 2.927395007e+09 | ||
1612 | node_mountstats_nfs_operations_requests_total{export="192.168.1.1:/srv/test",operation="NULL",protocol="tcp"} 0 | 1617 | node_mountstats_nfs_operations_requests_total{export="192.168.1.1:/srv/test",operation="NULL",protocol="tcp"} 0 |
1613 | node_mountstats_nfs_operations_requests_total{export="192.168.1.1:/srv/test",operation="NULL",protocol="udp"} 0 | 1618 | node_mountstats_nfs_operations_requests_total{export="192.168.1.1:/srv/test",operation="NULL",protocol="udp"} 0 |
1614 | node_mountstats_nfs_operations_requests_total{export="192.168.1.1:/srv/test",operation="READ",protocol="tcp"} 1298 | 1619 | node_mountstats_nfs_operations_requests_total{export="192.168.1.1:/srv/test",operation="READ",protocol="tcp"} 1298 |
@@ -1617,6 +1622,7 @@ node_mountstats_nfs_operations_requests_total{export="192.168.1.1:/srv/test",ope | |||
1617 | node_mountstats_nfs_operations_requests_total{export="192.168.1.1:/srv/test",operation="WRITE",protocol="udp"} 0 | 1622 | node_mountstats_nfs_operations_requests_total{export="192.168.1.1:/srv/test",operation="WRITE",protocol="udp"} 0 |
1618 | # HELP node_mountstats_nfs_operations_response_time_seconds_total Duration all requests took to get a reply back after a request for a given operation was transmitted, in seconds. | 1623 | # HELP node_mountstats_nfs_operations_response_time_seconds_total Duration all requests took to get a reply back after a request for a given operation was transmitted, in seconds. |
1619 | # TYPE node_mountstats_nfs_operations_response_time_seconds_total counter | 1624 | # TYPE node_mountstats_nfs_operations_response_time_seconds_total counter |
1625 | node_mountstats_nfs_operations_response_time_seconds_total{export="192.168.1.1:/srv/test",operation="ACCESS",protocol="udp"} 1.667369447e+06 | ||
1620 | node_mountstats_nfs_operations_response_time_seconds_total{export="192.168.1.1:/srv/test",operation="NULL",protocol="tcp"} 0 | 1626 | node_mountstats_nfs_operations_response_time_seconds_total{export="192.168.1.1:/srv/test",operation="NULL",protocol="tcp"} 0 |
1621 | node_mountstats_nfs_operations_response_time_seconds_total{export="192.168.1.1:/srv/test",operation="NULL",protocol="udp"} 0 | 1627 | node_mountstats_nfs_operations_response_time_seconds_total{export="192.168.1.1:/srv/test",operation="NULL",protocol="udp"} 0 |
1622 | node_mountstats_nfs_operations_response_time_seconds_total{export="192.168.1.1:/srv/test",operation="READ",protocol="tcp"} 79.386 | 1628 | node_mountstats_nfs_operations_response_time_seconds_total{export="192.168.1.1:/srv/test",operation="READ",protocol="tcp"} 79.386 |
@@ -1625,6 +1631,7 @@ node_mountstats_nfs_operations_response_time_seconds_total{export="192.168.1.1:/ | |||
1625 | node_mountstats_nfs_operations_response_time_seconds_total{export="192.168.1.1:/srv/test",operation="WRITE",protocol="udp"} 0 | 1631 | node_mountstats_nfs_operations_response_time_seconds_total{export="192.168.1.1:/srv/test",operation="WRITE",protocol="udp"} 0 |
1626 | # HELP node_mountstats_nfs_operations_sent_bytes_total Number of bytes sent for a given operation, including RPC headers and payload. | 1632 | # HELP node_mountstats_nfs_operations_sent_bytes_total Number of bytes sent for a given operation, including RPC headers and payload. |
1627 | # TYPE node_mountstats_nfs_operations_sent_bytes_total counter | 1633 | # TYPE node_mountstats_nfs_operations_sent_bytes_total counter |
1634 | node_mountstats_nfs_operations_sent_bytes_total{export="192.168.1.1:/srv/test",operation="ACCESS",protocol="udp"} 5.26931094212e+11 | ||
1628 | node_mountstats_nfs_operations_sent_bytes_total{export="192.168.1.1:/srv/test",operation="NULL",protocol="tcp"} 0 | 1635 | node_mountstats_nfs_operations_sent_bytes_total{export="192.168.1.1:/srv/test",operation="NULL",protocol="tcp"} 0 |
1629 | node_mountstats_nfs_operations_sent_bytes_total{export="192.168.1.1:/srv/test",operation="NULL",protocol="udp"} 0 | 1636 | node_mountstats_nfs_operations_sent_bytes_total{export="192.168.1.1:/srv/test",operation="NULL",protocol="udp"} 0 |
1630 | node_mountstats_nfs_operations_sent_bytes_total{export="192.168.1.1:/srv/test",operation="READ",protocol="tcp"} 207680 | 1637 | node_mountstats_nfs_operations_sent_bytes_total{export="192.168.1.1:/srv/test",operation="READ",protocol="tcp"} 207680 |
@@ -1633,6 +1640,7 @@ node_mountstats_nfs_operations_sent_bytes_total{export="192.168.1.1:/srv/test",o | |||
1633 | node_mountstats_nfs_operations_sent_bytes_total{export="192.168.1.1:/srv/test",operation="WRITE",protocol="udp"} 0 | 1640 | node_mountstats_nfs_operations_sent_bytes_total{export="192.168.1.1:/srv/test",operation="WRITE",protocol="udp"} 0 |
1634 | # HELP node_mountstats_nfs_operations_transmissions_total Number of times an actual RPC request has been transmitted for a given operation. | 1641 | # HELP node_mountstats_nfs_operations_transmissions_total Number of times an actual RPC request has been transmitted for a given operation. |
1635 | # TYPE node_mountstats_nfs_operations_transmissions_total counter | 1642 | # TYPE node_mountstats_nfs_operations_transmissions_total counter |
1643 | node_mountstats_nfs_operations_transmissions_total{export="192.168.1.1:/srv/test",operation="ACCESS",protocol="udp"} 2.927394995e+09 | ||
1636 | node_mountstats_nfs_operations_transmissions_total{export="192.168.1.1:/srv/test",operation="NULL",protocol="tcp"} 0 | 1644 | node_mountstats_nfs_operations_transmissions_total{export="192.168.1.1:/srv/test",operation="NULL",protocol="tcp"} 0 |
1637 | node_mountstats_nfs_operations_transmissions_total{export="192.168.1.1:/srv/test",operation="NULL",protocol="udp"} 0 | 1645 | node_mountstats_nfs_operations_transmissions_total{export="192.168.1.1:/srv/test",operation="NULL",protocol="udp"} 0 |
1638 | node_mountstats_nfs_operations_transmissions_total{export="192.168.1.1:/srv/test",operation="READ",protocol="tcp"} 1298 | 1646 | node_mountstats_nfs_operations_transmissions_total{export="192.168.1.1:/srv/test",operation="READ",protocol="tcp"} 1298 |
diff --git a/collector/fixtures/e2e-output.txt b/collector/fixtures/e2e-output.txt index 147113e..baef224 100644 --- a/collector/fixtures/e2e-output.txt +++ b/collector/fixtures/e2e-output.txt | |||
@@ -1577,6 +1577,7 @@ node_mountstats_nfs_event_write_extension_total{export="192.168.1.1:/srv/test",p | |||
1577 | node_mountstats_nfs_event_write_extension_total{export="192.168.1.1:/srv/test",protocol="udp"} 0 | 1577 | node_mountstats_nfs_event_write_extension_total{export="192.168.1.1:/srv/test",protocol="udp"} 0 |
1578 | # HELP node_mountstats_nfs_operations_major_timeouts_total Number of times a request has had a major timeout for a given operation. | 1578 | # HELP node_mountstats_nfs_operations_major_timeouts_total Number of times a request has had a major timeout for a given operation. |
1579 | # TYPE node_mountstats_nfs_operations_major_timeouts_total counter | 1579 | # TYPE node_mountstats_nfs_operations_major_timeouts_total counter |
1580 | node_mountstats_nfs_operations_major_timeouts_total{export="192.168.1.1:/srv/test",operation="ACCESS",protocol="udp"} 0 | ||
1580 | node_mountstats_nfs_operations_major_timeouts_total{export="192.168.1.1:/srv/test",operation="NULL",protocol="tcp"} 0 | 1581 | node_mountstats_nfs_operations_major_timeouts_total{export="192.168.1.1:/srv/test",operation="NULL",protocol="tcp"} 0 |
1581 | node_mountstats_nfs_operations_major_timeouts_total{export="192.168.1.1:/srv/test",operation="NULL",protocol="udp"} 0 | 1582 | node_mountstats_nfs_operations_major_timeouts_total{export="192.168.1.1:/srv/test",operation="NULL",protocol="udp"} 0 |
1582 | node_mountstats_nfs_operations_major_timeouts_total{export="192.168.1.1:/srv/test",operation="READ",protocol="tcp"} 0 | 1583 | node_mountstats_nfs_operations_major_timeouts_total{export="192.168.1.1:/srv/test",operation="READ",protocol="tcp"} 0 |
@@ -1585,6 +1586,7 @@ node_mountstats_nfs_operations_major_timeouts_total{export="192.168.1.1:/srv/tes | |||
1585 | node_mountstats_nfs_operations_major_timeouts_total{export="192.168.1.1:/srv/test",operation="WRITE",protocol="udp"} 0 | 1586 | node_mountstats_nfs_operations_major_timeouts_total{export="192.168.1.1:/srv/test",operation="WRITE",protocol="udp"} 0 |
1586 | # HELP node_mountstats_nfs_operations_queue_time_seconds_total Duration all requests spent queued for transmission for a given operation before they were sent, in seconds. | 1587 | # HELP node_mountstats_nfs_operations_queue_time_seconds_total Duration all requests spent queued for transmission for a given operation before they were sent, in seconds. |
1587 | # TYPE node_mountstats_nfs_operations_queue_time_seconds_total counter | 1588 | # TYPE node_mountstats_nfs_operations_queue_time_seconds_total counter |
1589 | node_mountstats_nfs_operations_queue_time_seconds_total{export="192.168.1.1:/srv/test",operation="ACCESS",protocol="udp"} 9.007044786793922e+12 | ||
1588 | node_mountstats_nfs_operations_queue_time_seconds_total{export="192.168.1.1:/srv/test",operation="NULL",protocol="tcp"} 0 | 1590 | node_mountstats_nfs_operations_queue_time_seconds_total{export="192.168.1.1:/srv/test",operation="NULL",protocol="tcp"} 0 |
1589 | node_mountstats_nfs_operations_queue_time_seconds_total{export="192.168.1.1:/srv/test",operation="NULL",protocol="udp"} 0 | 1591 | node_mountstats_nfs_operations_queue_time_seconds_total{export="192.168.1.1:/srv/test",operation="NULL",protocol="udp"} 0 |
1590 | node_mountstats_nfs_operations_queue_time_seconds_total{export="192.168.1.1:/srv/test",operation="READ",protocol="tcp"} 0.006 | 1592 | node_mountstats_nfs_operations_queue_time_seconds_total{export="192.168.1.1:/srv/test",operation="READ",protocol="tcp"} 0.006 |
@@ -1593,6 +1595,7 @@ node_mountstats_nfs_operations_queue_time_seconds_total{export="192.168.1.1:/srv | |||
1593 | node_mountstats_nfs_operations_queue_time_seconds_total{export="192.168.1.1:/srv/test",operation="WRITE",protocol="udp"} 0 | 1595 | node_mountstats_nfs_operations_queue_time_seconds_total{export="192.168.1.1:/srv/test",operation="WRITE",protocol="udp"} 0 |
1594 | # HELP node_mountstats_nfs_operations_received_bytes_total Number of bytes received for a given operation, including RPC headers and payload. | 1596 | # HELP node_mountstats_nfs_operations_received_bytes_total Number of bytes received for a given operation, including RPC headers and payload. |
1595 | # TYPE node_mountstats_nfs_operations_received_bytes_total counter | 1597 | # TYPE node_mountstats_nfs_operations_received_bytes_total counter |
1598 | node_mountstats_nfs_operations_received_bytes_total{export="192.168.1.1:/srv/test",operation="ACCESS",protocol="udp"} 3.62996810236e+11 | ||
1596 | node_mountstats_nfs_operations_received_bytes_total{export="192.168.1.1:/srv/test",operation="NULL",protocol="tcp"} 0 | 1599 | node_mountstats_nfs_operations_received_bytes_total{export="192.168.1.1:/srv/test",operation="NULL",protocol="tcp"} 0 |
1597 | node_mountstats_nfs_operations_received_bytes_total{export="192.168.1.1:/srv/test",operation="NULL",protocol="udp"} 0 | 1600 | node_mountstats_nfs_operations_received_bytes_total{export="192.168.1.1:/srv/test",operation="NULL",protocol="udp"} 0 |
1598 | node_mountstats_nfs_operations_received_bytes_total{export="192.168.1.1:/srv/test",operation="READ",protocol="tcp"} 1.210292152e+09 | 1601 | node_mountstats_nfs_operations_received_bytes_total{export="192.168.1.1:/srv/test",operation="READ",protocol="tcp"} 1.210292152e+09 |
@@ -1601,6 +1604,7 @@ node_mountstats_nfs_operations_received_bytes_total{export="192.168.1.1:/srv/tes | |||
1601 | node_mountstats_nfs_operations_received_bytes_total{export="192.168.1.1:/srv/test",operation="WRITE",protocol="udp"} 0 | 1604 | node_mountstats_nfs_operations_received_bytes_total{export="192.168.1.1:/srv/test",operation="WRITE",protocol="udp"} 0 |
1602 | # HELP node_mountstats_nfs_operations_request_time_seconds_total Duration all requests took from when a request was enqueued to when it was completely handled for a given operation, in seconds. | 1605 | # HELP node_mountstats_nfs_operations_request_time_seconds_total Duration all requests took from when a request was enqueued to when it was completely handled for a given operation, in seconds. |
1603 | # TYPE node_mountstats_nfs_operations_request_time_seconds_total counter | 1606 | # TYPE node_mountstats_nfs_operations_request_time_seconds_total counter |
1607 | node_mountstats_nfs_operations_request_time_seconds_total{export="192.168.1.1:/srv/test",operation="ACCESS",protocol="udp"} 1.953587717e+06 | ||
1604 | node_mountstats_nfs_operations_request_time_seconds_total{export="192.168.1.1:/srv/test",operation="NULL",protocol="tcp"} 0 | 1608 | node_mountstats_nfs_operations_request_time_seconds_total{export="192.168.1.1:/srv/test",operation="NULL",protocol="tcp"} 0 |
1605 | node_mountstats_nfs_operations_request_time_seconds_total{export="192.168.1.1:/srv/test",operation="NULL",protocol="udp"} 0 | 1609 | node_mountstats_nfs_operations_request_time_seconds_total{export="192.168.1.1:/srv/test",operation="NULL",protocol="udp"} 0 |
1606 | node_mountstats_nfs_operations_request_time_seconds_total{export="192.168.1.1:/srv/test",operation="READ",protocol="tcp"} 79.407 | 1610 | node_mountstats_nfs_operations_request_time_seconds_total{export="192.168.1.1:/srv/test",operation="READ",protocol="tcp"} 79.407 |
@@ -1609,6 +1613,7 @@ node_mountstats_nfs_operations_request_time_seconds_total{export="192.168.1.1:/s | |||
1609 | node_mountstats_nfs_operations_request_time_seconds_total{export="192.168.1.1:/srv/test",operation="WRITE",protocol="udp"} 0 | 1613 | node_mountstats_nfs_operations_request_time_seconds_total{export="192.168.1.1:/srv/test",operation="WRITE",protocol="udp"} 0 |
1610 | # HELP node_mountstats_nfs_operations_requests_total Number of requests performed for a given operation. | 1614 | # HELP node_mountstats_nfs_operations_requests_total Number of requests performed for a given operation. |
1611 | # TYPE node_mountstats_nfs_operations_requests_total counter | 1615 | # TYPE node_mountstats_nfs_operations_requests_total counter |
1616 | node_mountstats_nfs_operations_requests_total{export="192.168.1.1:/srv/test",operation="ACCESS",protocol="udp"} 2.927395007e+09 | ||
1612 | node_mountstats_nfs_operations_requests_total{export="192.168.1.1:/srv/test",operation="NULL",protocol="tcp"} 0 | 1617 | node_mountstats_nfs_operations_requests_total{export="192.168.1.1:/srv/test",operation="NULL",protocol="tcp"} 0 |
1613 | node_mountstats_nfs_operations_requests_total{export="192.168.1.1:/srv/test",operation="NULL",protocol="udp"} 0 | 1618 | node_mountstats_nfs_operations_requests_total{export="192.168.1.1:/srv/test",operation="NULL",protocol="udp"} 0 |
1614 | node_mountstats_nfs_operations_requests_total{export="192.168.1.1:/srv/test",operation="READ",protocol="tcp"} 1298 | 1619 | node_mountstats_nfs_operations_requests_total{export="192.168.1.1:/srv/test",operation="READ",protocol="tcp"} 1298 |
@@ -1617,6 +1622,7 @@ node_mountstats_nfs_operations_requests_total{export="192.168.1.1:/srv/test",ope | |||
1617 | node_mountstats_nfs_operations_requests_total{export="192.168.1.1:/srv/test",operation="WRITE",protocol="udp"} 0 | 1622 | node_mountstats_nfs_operations_requests_total{export="192.168.1.1:/srv/test",operation="WRITE",protocol="udp"} 0 |
1618 | # HELP node_mountstats_nfs_operations_response_time_seconds_total Duration all requests took to get a reply back after a request for a given operation was transmitted, in seconds. | 1623 | # HELP node_mountstats_nfs_operations_response_time_seconds_total Duration all requests took to get a reply back after a request for a given operation was transmitted, in seconds. |
1619 | # TYPE node_mountstats_nfs_operations_response_time_seconds_total counter | 1624 | # TYPE node_mountstats_nfs_operations_response_time_seconds_total counter |
1625 | node_mountstats_nfs_operations_response_time_seconds_total{export="192.168.1.1:/srv/test",operation="ACCESS",protocol="udp"} 1.667369447e+06 | ||
1620 | node_mountstats_nfs_operations_response_time_seconds_total{export="192.168.1.1:/srv/test",operation="NULL",protocol="tcp"} 0 | 1626 | node_mountstats_nfs_operations_response_time_seconds_total{export="192.168.1.1:/srv/test",operation="NULL",protocol="tcp"} 0 |
1621 | node_mountstats_nfs_operations_response_time_seconds_total{export="192.168.1.1:/srv/test",operation="NULL",protocol="udp"} 0 | 1627 | node_mountstats_nfs_operations_response_time_seconds_total{export="192.168.1.1:/srv/test",operation="NULL",protocol="udp"} 0 |
1622 | node_mountstats_nfs_operations_response_time_seconds_total{export="192.168.1.1:/srv/test",operation="READ",protocol="tcp"} 79.386 | 1628 | node_mountstats_nfs_operations_response_time_seconds_total{export="192.168.1.1:/srv/test",operation="READ",protocol="tcp"} 79.386 |
@@ -1625,6 +1631,7 @@ node_mountstats_nfs_operations_response_time_seconds_total{export="192.168.1.1:/ | |||
1625 | node_mountstats_nfs_operations_response_time_seconds_total{export="192.168.1.1:/srv/test",operation="WRITE",protocol="udp"} 0 | 1631 | node_mountstats_nfs_operations_response_time_seconds_total{export="192.168.1.1:/srv/test",operation="WRITE",protocol="udp"} 0 |
1626 | # HELP node_mountstats_nfs_operations_sent_bytes_total Number of bytes sent for a given operation, including RPC headers and payload. | 1632 | # HELP node_mountstats_nfs_operations_sent_bytes_total Number of bytes sent for a given operation, including RPC headers and payload. |
1627 | # TYPE node_mountstats_nfs_operations_sent_bytes_total counter | 1633 | # TYPE node_mountstats_nfs_operations_sent_bytes_total counter |
1634 | node_mountstats_nfs_operations_sent_bytes_total{export="192.168.1.1:/srv/test",operation="ACCESS",protocol="udp"} 5.26931094212e+11 | ||
1628 | node_mountstats_nfs_operations_sent_bytes_total{export="192.168.1.1:/srv/test",operation="NULL",protocol="tcp"} 0 | 1635 | node_mountstats_nfs_operations_sent_bytes_total{export="192.168.1.1:/srv/test",operation="NULL",protocol="tcp"} 0 |
1629 | node_mountstats_nfs_operations_sent_bytes_total{export="192.168.1.1:/srv/test",operation="NULL",protocol="udp"} 0 | 1636 | node_mountstats_nfs_operations_sent_bytes_total{export="192.168.1.1:/srv/test",operation="NULL",protocol="udp"} 0 |
1630 | node_mountstats_nfs_operations_sent_bytes_total{export="192.168.1.1:/srv/test",operation="READ",protocol="tcp"} 207680 | 1637 | node_mountstats_nfs_operations_sent_bytes_total{export="192.168.1.1:/srv/test",operation="READ",protocol="tcp"} 207680 |
@@ -1633,6 +1640,7 @@ node_mountstats_nfs_operations_sent_bytes_total{export="192.168.1.1:/srv/test",o | |||
1633 | node_mountstats_nfs_operations_sent_bytes_total{export="192.168.1.1:/srv/test",operation="WRITE",protocol="udp"} 0 | 1640 | node_mountstats_nfs_operations_sent_bytes_total{export="192.168.1.1:/srv/test",operation="WRITE",protocol="udp"} 0 |
1634 | # HELP node_mountstats_nfs_operations_transmissions_total Number of times an actual RPC request has been transmitted for a given operation. | 1641 | # HELP node_mountstats_nfs_operations_transmissions_total Number of times an actual RPC request has been transmitted for a given operation. |
1635 | # TYPE node_mountstats_nfs_operations_transmissions_total counter | 1642 | # TYPE node_mountstats_nfs_operations_transmissions_total counter |
1643 | node_mountstats_nfs_operations_transmissions_total{export="192.168.1.1:/srv/test",operation="ACCESS",protocol="udp"} 2.927394995e+09 | ||
1636 | node_mountstats_nfs_operations_transmissions_total{export="192.168.1.1:/srv/test",operation="NULL",protocol="tcp"} 0 | 1644 | node_mountstats_nfs_operations_transmissions_total{export="192.168.1.1:/srv/test",operation="NULL",protocol="tcp"} 0 |
1637 | node_mountstats_nfs_operations_transmissions_total{export="192.168.1.1:/srv/test",operation="NULL",protocol="udp"} 0 | 1645 | node_mountstats_nfs_operations_transmissions_total{export="192.168.1.1:/srv/test",operation="NULL",protocol="udp"} 0 |
1638 | node_mountstats_nfs_operations_transmissions_total{export="192.168.1.1:/srv/test",operation="READ",protocol="tcp"} 1298 | 1646 | node_mountstats_nfs_operations_transmissions_total{export="192.168.1.1:/srv/test",operation="READ",protocol="tcp"} 1298 |
diff --git a/collector/fixtures/proc/10/mountstats b/collector/fixtures/proc/10/mountstats index ddddcd3..a1f24b5 100644 --- a/collector/fixtures/proc/10/mountstats +++ b/collector/fixtures/proc/10/mountstats | |||
@@ -31,6 +31,7 @@ device 192.168.1.1:/srv/test mounted on /mnt/nfs/test-dupe with fstype nfs4 stat | |||
31 | NULL: 0 0 0 0 0 0 0 0 | 31 | NULL: 0 0 0 0 0 0 0 0 |
32 | READ: 1298 1298 0 207680 1210292152 6 79386 79407 | 32 | READ: 1298 1298 0 207680 1210292152 6 79386 79407 |
33 | WRITE: 0 0 0 0 0 0 0 0 | 33 | WRITE: 0 0 0 0 0 0 0 0 |
34 | ACCESS: 2927395007 2927394995 0 526931094212 362996810236 18446743919241604546 1667369447 1953587717 | ||
34 | 35 | ||
35 | device 192.168.1.1:/srv/test mounted on /mnt/nfs/test-dupe with fstype nfs4 statvers=1.1 | 36 | device 192.168.1.1:/srv/test mounted on /mnt/nfs/test-dupe with fstype nfs4 statvers=1.1 |
36 | opts: rw,vers=4.0,rsize=1048576,wsize=1048576,namlen=255,acregmin=3,acregmax=60,acdirmin=30,acdirmax=60,hard,proto=udp,port=0,timeo=600,retrans=2,sec=sys,clientaddr=192.168.1.5,local_lock=none | 37 | opts: rw,vers=4.0,rsize=1048576,wsize=1048576,namlen=255,acregmin=3,acregmax=60,acdirmin=30,acdirmax=60,hard,proto=udp,port=0,timeo=600,retrans=2,sec=sys,clientaddr=192.168.1.5,local_lock=none |
@@ -46,3 +47,4 @@ device 192.168.1.1:/srv/test mounted on /mnt/nfs/test-dupe with fstype nfs4 stat | |||
46 | NULL: 0 0 0 0 0 0 0 0 | 47 | NULL: 0 0 0 0 0 0 0 0 |
47 | READ: 1298 1298 0 207680 1210292152 6 79386 79407 | 48 | READ: 1298 1298 0 207680 1210292152 6 79386 79407 |
48 | WRITE: 0 0 0 0 0 0 0 0 | 49 | WRITE: 0 0 0 0 0 0 0 0 |
50 | ACCESS: 2927395007 2927394995 0 526931094212 362996810236 18446743919241604546 1667369447 1953587717 | ||
diff --git a/collector/mountstats_linux.go b/collector/mountstats_linux.go index 561c7aa..47827dd 100644 --- a/collector/mountstats_linux.go +++ b/collector/mountstats_linux.go | |||
@@ -21,6 +21,11 @@ import ( | |||
21 | "github.com/prometheus/procfs" | 21 | "github.com/prometheus/procfs" |
22 | ) | 22 | ) |
23 | 23 | ||
24 | var ( | ||
25 | // 64-bit float mantissa: https://en.wikipedia.org/wiki/Double-precision_floating-point_format | ||
26 | float64Mantissa uint64 = 9007199254740992 | ||
27 | ) | ||
28 | |||
24 | type mountStatsCollector struct { | 29 | type mountStatsCollector struct { |
25 | // General statistics | 30 | // General statistics |
26 | NFSAgeSecondsTotal *prometheus.Desc | 31 | NFSAgeSecondsTotal *prometheus.Desc |
@@ -618,7 +623,7 @@ func (c *mountStatsCollector) updateNFSStats(ch chan<- prometheus.Metric, export | |||
618 | ch <- prometheus.MustNewConstMetric( | 623 | ch <- prometheus.MustNewConstMetric( |
619 | c.NFSTransportIdleTimeSeconds, | 624 | c.NFSTransportIdleTimeSeconds, |
620 | prometheus.GaugeValue, | 625 | prometheus.GaugeValue, |
621 | s.Transport.IdleTime.Seconds(), | 626 | float64(s.Transport.IdleTimeSeconds%float64Mantissa), |
622 | export, | 627 | export, |
623 | protocol, | 628 | protocol, |
624 | ) | 629 | ) |
@@ -728,7 +733,7 @@ func (c *mountStatsCollector) updateNFSStats(ch chan<- prometheus.Metric, export | |||
728 | ch <- prometheus.MustNewConstMetric( | 733 | ch <- prometheus.MustNewConstMetric( |
729 | c.NFSOperationsQueueTimeSecondsTotal, | 734 | c.NFSOperationsQueueTimeSecondsTotal, |
730 | prometheus.CounterValue, | 735 | prometheus.CounterValue, |
731 | op.CumulativeQueueTime.Seconds(), | 736 | float64(op.CumulativeQueueMilliseconds%float64Mantissa)/1000.0, |
732 | export, | 737 | export, |
733 | protocol, | 738 | protocol, |
734 | op.Operation, | 739 | op.Operation, |
@@ -737,7 +742,7 @@ func (c *mountStatsCollector) updateNFSStats(ch chan<- prometheus.Metric, export | |||
737 | ch <- prometheus.MustNewConstMetric( | 742 | ch <- prometheus.MustNewConstMetric( |
738 | c.NFSOperationsResponseTimeSecondsTotal, | 743 | c.NFSOperationsResponseTimeSecondsTotal, |
739 | prometheus.CounterValue, | 744 | prometheus.CounterValue, |
740 | op.CumulativeTotalResponseTime.Seconds(), | 745 | float64(op.CumulativeTotalResponseMilliseconds%float64Mantissa)/1000.0, |
741 | export, | 746 | export, |
742 | protocol, | 747 | protocol, |
743 | op.Operation, | 748 | op.Operation, |
@@ -746,7 +751,7 @@ func (c *mountStatsCollector) updateNFSStats(ch chan<- prometheus.Metric, export | |||
746 | ch <- prometheus.MustNewConstMetric( | 751 | ch <- prometheus.MustNewConstMetric( |
747 | c.NFSOperationsRequestTimeSecondsTotal, | 752 | c.NFSOperationsRequestTimeSecondsTotal, |
748 | prometheus.CounterValue, | 753 | prometheus.CounterValue, |
749 | op.CumulativeTotalRequestTime.Seconds(), | 754 | float64(op.CumulativeTotalRequestMilliseconds%float64Mantissa)/1000.0, |
750 | export, | 755 | export, |
751 | protocol, | 756 | protocol, |
752 | op.Operation, | 757 | op.Operation, |
@@ -18,7 +18,7 @@ require ( | |||
18 | github.com/prometheus/client_golang v0.9.2 | 18 | github.com/prometheus/client_golang v0.9.2 |
19 | github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90 | 19 | github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90 |
20 | github.com/prometheus/common v0.3.0 | 20 | github.com/prometheus/common v0.3.0 |
21 | github.com/prometheus/procfs v0.0.0-20190507043628-bc6930f2d510 | 21 | github.com/prometheus/procfs v0.0.0-20190529155944-65bdadfa96ae |
22 | github.com/siebenmann/go-kstat v0.0.0-20160321171754-d34789b79745 | 22 | github.com/siebenmann/go-kstat v0.0.0-20160321171754-d34789b79745 |
23 | github.com/sirupsen/logrus v1.4.1 // indirect | 23 | github.com/sirupsen/logrus v1.4.1 // indirect |
24 | github.com/soundcloud/go-runit v0.0.0-20150630195641-06ad41a06c4a | 24 | github.com/soundcloud/go-runit v0.0.0-20150630195641-06ad41a06c4a |
@@ -65,8 +65,8 @@ github.com/prometheus/common v0.3.0 h1:taZ4h8Tkxv2kNyoSctBvfXEHmBmxrwmIidZTIaHon | |||
65 | github.com/prometheus/common v0.3.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= | 65 | github.com/prometheus/common v0.3.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= |
66 | github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= | 66 | github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= |
67 | github.com/prometheus/procfs v0.0.0-20181204211112-1dc9a6cbc91a/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= | 67 | github.com/prometheus/procfs v0.0.0-20181204211112-1dc9a6cbc91a/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= |
68 | github.com/prometheus/procfs v0.0.0-20190507043628-bc6930f2d510 h1:xDFyJxLucSC7yg81N/VozfnSEEB2dRj1VgR/YEzl5dA= | 68 | github.com/prometheus/procfs v0.0.0-20190529155944-65bdadfa96ae h1:kF6Y/ES9NQmW3t400V0XH+lO1jqvCpXBC1XoLDkvuMM= |
69 | github.com/prometheus/procfs v0.0.0-20190507043628-bc6930f2d510/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= | 69 | github.com/prometheus/procfs v0.0.0-20190529155944-65bdadfa96ae/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= |
70 | github.com/siebenmann/go-kstat v0.0.0-20160321171754-d34789b79745 h1:IuH7WumZNax0D+rEqmy2TyhKCzrtMGqbZO0b8rO00JA= | 70 | github.com/siebenmann/go-kstat v0.0.0-20160321171754-d34789b79745 h1:IuH7WumZNax0D+rEqmy2TyhKCzrtMGqbZO0b8rO00JA= |
71 | github.com/siebenmann/go-kstat v0.0.0-20160321171754-d34789b79745/go.mod h1:G81aIFAMS9ECrwBYR9YxhlPjWgrItd+Kje78O6+uqm8= | 71 | github.com/siebenmann/go-kstat v0.0.0-20160321171754-d34789b79745/go.mod h1:G81aIFAMS9ECrwBYR9YxhlPjWgrItd+Kje78O6+uqm8= |
72 | github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= | 72 | github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= |
diff --git a/vendor/github.com/prometheus/procfs/MAINTAINERS.md b/vendor/github.com/prometheus/procfs/MAINTAINERS.md index f1d3b99..56ba67d 100644 --- a/vendor/github.com/prometheus/procfs/MAINTAINERS.md +++ b/vendor/github.com/prometheus/procfs/MAINTAINERS.md | |||
@@ -1,2 +1,2 @@ | |||
1 | * Tobias Schmidt <tobidt@gmail.com> @grobie | ||
2 | * Johannes 'fish' Ziemke <github@freigeist.org> @discordianfish | 1 | * Johannes 'fish' Ziemke <github@freigeist.org> @discordianfish |
2 | * Paul Gier <pgier@redhat.com> @pgier | ||
diff --git a/vendor/github.com/prometheus/procfs/Makefile b/vendor/github.com/prometheus/procfs/Makefile index 314d1ba..616a0d2 100644 --- a/vendor/github.com/prometheus/procfs/Makefile +++ b/vendor/github.com/prometheus/procfs/Makefile | |||
@@ -14,6 +14,7 @@ | |||
14 | include Makefile.common | 14 | include Makefile.common |
15 | 15 | ||
16 | %/.unpacked: %.ttar | 16 | %/.unpacked: %.ttar |
17 | @echo ">> extracting fixtures" | ||
17 | ./ttar -C $(dir $*) -x -f $*.ttar | 18 | ./ttar -C $(dir $*) -x -f $*.ttar |
18 | touch $@ | 19 | touch $@ |
19 | 20 | ||
diff --git a/vendor/github.com/prometheus/procfs/Makefile.common b/vendor/github.com/prometheus/procfs/Makefile.common index 4f18ea5..c7f9ea6 100644 --- a/vendor/github.com/prometheus/procfs/Makefile.common +++ b/vendor/github.com/prometheus/procfs/Makefile.common | |||
@@ -69,7 +69,7 @@ else | |||
69 | GO_BUILD_PLATFORM ?= $(GOHOSTOS)-$(GOHOSTARCH) | 69 | GO_BUILD_PLATFORM ?= $(GOHOSTOS)-$(GOHOSTARCH) |
70 | endif | 70 | endif |
71 | 71 | ||
72 | PROMU_VERSION ?= 0.3.0 | 72 | PROMU_VERSION ?= 0.4.0 |
73 | PROMU_URL := https://github.com/prometheus/promu/releases/download/v$(PROMU_VERSION)/promu-$(PROMU_VERSION).$(GO_BUILD_PLATFORM).tar.gz | 73 | PROMU_URL := https://github.com/prometheus/promu/releases/download/v$(PROMU_VERSION)/promu-$(PROMU_VERSION).$(GO_BUILD_PLATFORM).tar.gz |
74 | 74 | ||
75 | GOLANGCI_LINT := | 75 | GOLANGCI_LINT := |
diff --git a/vendor/github.com/prometheus/procfs/README.md b/vendor/github.com/prometheus/procfs/README.md index 2095494..951c043 100644 --- a/vendor/github.com/prometheus/procfs/README.md +++ b/vendor/github.com/prometheus/procfs/README.md | |||
@@ -1,7 +1,7 @@ | |||
1 | # procfs | 1 | # procfs |
2 | 2 | ||
3 | This procfs package provides functions to retrieve system, kernel and process | 3 | This procfs package provides functions to retrieve system, kernel and process |
4 | metrics from the pseudo-filesystem proc. | 4 | metrics from the pseudo-filesystems /proc and /sys. |
5 | 5 | ||
6 | *WARNING*: This package is a work in progress. Its API may still break in | 6 | *WARNING*: This package is a work in progress. Its API may still break in |
7 | backwards-incompatible ways without warnings. Use it at your own risk. | 7 | backwards-incompatible ways without warnings. Use it at your own risk. |
@@ -9,3 +9,38 @@ backwards-incompatible ways without warnings. Use it at your own risk. | |||
9 | [![GoDoc](https://godoc.org/github.com/prometheus/procfs?status.png)](https://godoc.org/github.com/prometheus/procfs) | 9 | [![GoDoc](https://godoc.org/github.com/prometheus/procfs?status.png)](https://godoc.org/github.com/prometheus/procfs) |
10 | [![Build Status](https://travis-ci.org/prometheus/procfs.svg?branch=master)](https://travis-ci.org/prometheus/procfs) | 10 | [![Build Status](https://travis-ci.org/prometheus/procfs.svg?branch=master)](https://travis-ci.org/prometheus/procfs) |
11 | [![Go Report Card](https://goreportcard.com/badge/github.com/prometheus/procfs)](https://goreportcard.com/report/github.com/prometheus/procfs) | 11 | [![Go Report Card](https://goreportcard.com/badge/github.com/prometheus/procfs)](https://goreportcard.com/report/github.com/prometheus/procfs) |
12 | |||
13 | ## Usage | ||
14 | |||
15 | The procfs library is organized by packages based on whether the gathered data is coming from | ||
16 | /proc, /sys, or both. Each package contains an `FS` type which represents the path to either /proc, /sys, or both. For example, current cpu statistics are gathered from | ||
17 | `/proc/stat` and are available via the root procfs package. First, the proc filesystem mount | ||
18 | point is initialized, and then the stat information is read. | ||
19 | |||
20 | ```go | ||
21 | fs, err := procfs.NewFS("/proc") | ||
22 | stats, err := fs.NewStat() | ||
23 | ``` | ||
24 | |||
25 | ## Building and Testing | ||
26 | |||
27 | The procfs library is normally built as part of another application. However, when making | ||
28 | changes to the library, the `make test` command can be used to run the API test suite. | ||
29 | |||
30 | ### Updating Test Fixtures | ||
31 | |||
32 | The procfs library includes a set of test fixtures which include many example files from | ||
33 | the `/proc` and `/sys` filesystems. These fixtures are included as a ttar (text tar) file | ||
34 | which is extracted automatically during testing. To add/update the test fixtures, first | ||
35 | ensure the `fixtures` directory is up to date by removing the existing directory and then | ||
36 | extracting the ttar file using `make fixtures/.unpacked` or just `make test`. | ||
37 | |||
38 | ```bash | ||
39 | rm -rf fixtures | ||
40 | make test | ||
41 | ``` | ||
42 | |||
43 | Next, make the required changes to the extracted files in the `fixtures` directory. When | ||
44 | the changes are complete, run `make update_fixtures` to create a new `fixtures.ttar` file | ||
45 | based on the updated `fixtures` directory. And finally, verify the changes using | ||
46 | `git diff fixtures.ttar`. | ||
diff --git a/vendor/github.com/prometheus/procfs/fixtures.ttar b/vendor/github.com/prometheus/procfs/fixtures.ttar index f7f84ef..951d909 100644 --- a/vendor/github.com/prometheus/procfs/fixtures.ttar +++ b/vendor/github.com/prometheus/procfs/fixtures.ttar | |||
@@ -75,13 +75,13 @@ Max realtime timeout unlimited unlimited us | |||
75 | Mode: 644 | 75 | Mode: 644 |
76 | # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | 76 | # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
77 | Path: fixtures/proc/26231/mountstats | 77 | Path: fixtures/proc/26231/mountstats |
78 | Lines: 19 | 78 | Lines: 20 |
79 | device rootfs mounted on / with fstype rootfs | 79 | device rootfs mounted on / with fstype rootfs |
80 | device sysfs mounted on /sys with fstype sysfs | 80 | device sysfs mounted on /sys with fstype sysfs |
81 | device proc mounted on /proc with fstype proc | 81 | device proc mounted on /proc with fstype proc |
82 | device /dev/sda1 mounted on / with fstype ext4 | 82 | device /dev/sda1 mounted on / with fstype ext4 |
83 | device 192.168.1.1:/srv/test mounted on /mnt/nfs/test with fstype nfs4 statvers=1.1 | 83 | device 192.168.1.1:/srv/test mounted on /mnt/nfs/test with fstype nfs4 statvers=1.1 |
84 | opts: rw,vers=4.0,rsize=1048576,wsize=1048576,namlen=255,acregmin=3,acregmax=60,acdirmin=30,acdirmax=60,hard,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,clientaddr=192.168.1.5,local_lock=none | 84 | opts: rw,vers=4.0,rsize=1048576,wsize=1048576,namlen=255,acregmin=3,acregmax=60,acdirmin=30,acdirmax=60,hard,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,mountaddr=192.168.1.1,clientaddr=192.168.1.5,local_lock=none |
85 | age: 13968 | 85 | age: 13968 |
86 | caps: caps=0xfff7,wtmult=512,dtsize=32768,bsize=0,namlen=255 | 86 | caps: caps=0xfff7,wtmult=512,dtsize=32768,bsize=0,namlen=255 |
87 | nfsv4: bm0=0xfdffafff,bm1=0xf9be3e,bm2=0x0,acl=0x0,pnfs=not configured | 87 | nfsv4: bm0=0xfdffafff,bm1=0xf9be3e,bm2=0x0,acl=0x0,pnfs=not configured |
@@ -94,6 +94,7 @@ device 192.168.1.1:/srv/test mounted on /mnt/nfs/test with fstype nfs4 statvers= | |||
94 | NULL: 0 0 0 0 0 0 0 0 | 94 | NULL: 0 0 0 0 0 0 0 0 |
95 | READ: 1298 1298 0 207680 1210292152 6 79386 79407 | 95 | READ: 1298 1298 0 207680 1210292152 6 79386 79407 |
96 | WRITE: 0 0 0 0 0 0 0 0 | 96 | WRITE: 0 0 0 0 0 0 0 0 |
97 | ACCESS: 2927395007 2927394995 0 526931094212 362996810236 18446743919241604546 1667369447 1953587717 | ||
97 | 98 | ||
98 | Mode: 644 | 99 | Mode: 644 |
99 | # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | 100 | # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
@@ -125,6 +126,63 @@ Lines: 1 | |||
125 | 26231 (vim) R 5392 7446 5392 34835 7446 4218880 32533 309516 26 82 1677 44 158 99 20 0 1 0 82375 56274944 1981 18446744073709551615 4194304 6294284 140736914091744 140736914087944 139965136429984 0 0 12288 1870679807 0 0 0 17 0 0 0 31 0 0 8391624 8481048 16420864 140736914093252 140736914093279 140736914093279 140736914096107 0 | 126 | 26231 (vim) R 5392 7446 5392 34835 7446 4218880 32533 309516 26 82 1677 44 158 99 20 0 1 0 82375 56274944 1981 18446744073709551615 4194304 6294284 140736914091744 140736914087944 139965136429984 0 0 12288 1870679807 0 0 0 17 0 0 0 31 0 0 8391624 8481048 16420864 140736914093252 140736914093279 140736914093279 140736914096107 0 |
126 | Mode: 644 | 127 | Mode: 644 |
127 | # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | 128 | # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
129 | Path: fixtures/proc/26231/status | ||
130 | Lines: 53 | ||
131 | |||
132 | Name: prometheus | ||
133 | Umask: 0022 | ||
134 | State: S (sleeping) | ||
135 | Tgid: 1 | ||
136 | Ngid: 0 | ||
137 | Pid: 1 | ||
138 | PPid: 0 | ||
139 | TracerPid: 0 | ||
140 | Uid: 0 0 0 0 | ||
141 | Gid: 0 0 0 0 | ||
142 | FDSize: 128 | ||
143 | Groups: | ||
144 | NStgid: 1 | ||
145 | NSpid: 1 | ||
146 | NSpgid: 1 | ||
147 | NSsid: 1 | ||
148 | VmPeak: 58472 kB | ||
149 | VmSize: 58440 kB | ||
150 | VmLck: 0 kB | ||
151 | VmPin: 0 kB | ||
152 | VmHWM: 8028 kB | ||
153 | VmRSS: 6716 kB | ||
154 | RssAnon: 2092 kB | ||
155 | RssFile: 4624 kB | ||
156 | RssShmem: 0 kB | ||
157 | VmData: 2580 kB | ||
158 | VmStk: 136 kB | ||
159 | VmExe: 948 kB | ||
160 | VmLib: 6816 kB | ||
161 | VmPTE: 128 kB | ||
162 | VmPMD: 12 kB | ||
163 | VmSwap: 660 kB | ||
164 | HugetlbPages: 0 kB | ||
165 | Threads: 1 | ||
166 | SigQ: 8/63965 | ||
167 | SigPnd: 0000000000000000 | ||
168 | ShdPnd: 0000000000000000 | ||
169 | SigBlk: 7be3c0fe28014a03 | ||
170 | SigIgn: 0000000000001000 | ||
171 | SigCgt: 00000001800004ec | ||
172 | CapInh: 0000000000000000 | ||
173 | CapPrm: 0000003fffffffff | ||
174 | CapEff: 0000003fffffffff | ||
175 | CapBnd: 0000003fffffffff | ||
176 | CapAmb: 0000000000000000 | ||
177 | Seccomp: 0 | ||
178 | Cpus_allowed: ff | ||
179 | Cpus_allowed_list: 0-7 | ||
180 | Mems_allowed: 00000000,00000001 | ||
181 | Mems_allowed_list: 0 | ||
182 | voluntary_ctxt_switches: 4742839 | ||
183 | nonvoluntary_ctxt_switches: 1727500 | ||
184 | Mode: 644 | ||
185 | # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||
128 | Directory: fixtures/proc/26232 | 186 | Directory: fixtures/proc/26232 |
129 | Mode: 755 | 187 | Mode: 755 |
130 | # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | 188 | # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
@@ -160,23 +218,23 @@ SymlinkTo: ../../symlinktargets/xyz | |||
160 | # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | 218 | # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
161 | Path: fixtures/proc/26232/limits | 219 | Path: fixtures/proc/26232/limits |
162 | Lines: 17 | 220 | Lines: 17 |
163 | Limit Soft Limit Hard Limit Units | 221 | Limit Soft Limit Hard Limit Units |
164 | Max cpu time unlimited unlimited seconds | 222 | Max cpu time unlimited unlimited seconds |
165 | Max file size unlimited unlimited bytes | 223 | Max file size unlimited unlimited bytes |
166 | Max data size unlimited unlimited bytes | 224 | Max data size unlimited unlimited bytes |
167 | Max stack size 8388608 unlimited bytes | 225 | Max stack size 8388608 unlimited bytes |
168 | Max core file size 0 unlimited bytes | 226 | Max core file size 0 unlimited bytes |
169 | Max resident set unlimited unlimited bytes | 227 | Max resident set unlimited unlimited bytes |
170 | Max processes 29436 29436 processes | 228 | Max processes 29436 29436 processes |
171 | Max open files 1024 4096 files | 229 | Max open files 1024 4096 files |
172 | Max locked memory 65536 65536 bytes | 230 | Max locked memory 65536 65536 bytes |
173 | Max address space unlimited unlimited bytes | 231 | Max address space unlimited unlimited bytes |
174 | Max file locks unlimited unlimited locks | 232 | Max file locks unlimited unlimited locks |
175 | Max pending signals 29436 29436 signals | 233 | Max pending signals 29436 29436 signals |
176 | Max msgqueue size 819200 819200 bytes | 234 | Max msgqueue size 819200 819200 bytes |
177 | Max nice priority 0 0 | 235 | Max nice priority 0 0 |
178 | Max realtime priority 0 0 | 236 | Max realtime priority 0 0 |
179 | Max realtime timeout unlimited unlimited us | 237 | Max realtime timeout unlimited unlimited us |
180 | Mode: 644 | 238 | Mode: 644 |
181 | # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | 239 | # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
182 | Path: fixtures/proc/26232/root | 240 | Path: fixtures/proc/26232/root |
@@ -206,9 +264,9 @@ Mode: 644 | |||
206 | # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | 264 | # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
207 | Path: fixtures/proc/buddyinfo | 265 | Path: fixtures/proc/buddyinfo |
208 | Lines: 3 | 266 | Lines: 3 |
209 | Node 0, zone DMA 1 0 1 0 2 1 1 0 1 1 3 | 267 | Node 0, zone DMA 1 0 1 0 2 1 1 0 1 1 3 |
210 | Node 0, zone DMA32 759 572 791 475 194 45 12 0 0 0 0 | 268 | Node 0, zone DMA32 759 572 791 475 194 45 12 0 0 0 0 |
211 | Node 0, zone Normal 4381 1093 185 1530 567 102 4 0 0 0 0 | 269 | Node 0, zone Normal 4381 1093 185 1530 567 102 4 0 0 0 0 |
212 | Mode: 644 | 270 | Mode: 644 |
213 | # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | 271 | # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
214 | Path: fixtures/proc/diskstats | 272 | Path: fixtures/proc/diskstats |
@@ -302,13 +360,13 @@ Lines: 26 | |||
302 | Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10] | 360 | Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10] |
303 | md3 : active raid6 sda1[8] sdh1[7] sdg1[6] sdf1[5] sde1[11] sdd1[3] sdc1[10] sdb1[9] | 361 | md3 : active raid6 sda1[8] sdh1[7] sdg1[6] sdf1[5] sde1[11] sdd1[3] sdc1[10] sdb1[9] |
304 | 5853468288 blocks super 1.2 level 6, 64k chunk, algorithm 2 [8/8] [UUUUUUUU] | 362 | 5853468288 blocks super 1.2 level 6, 64k chunk, algorithm 2 [8/8] [UUUUUUUU] |
305 | 363 | ||
306 | md127 : active raid1 sdi2[0] sdj2[1] | 364 | md127 : active raid1 sdi2[0] sdj2[1] |
307 | 312319552 blocks [2/2] [UU] | 365 | 312319552 blocks [2/2] [UU] |
308 | 366 | ||
309 | md0 : active raid1 sdk[2](S) sdi1[0] sdj1[1] | 367 | md0 : active raid1 sdk[2](S) sdi1[0] sdj1[1] |
310 | 248896 blocks [2/2] [UU] | 368 | 248896 blocks [2/2] [UU] |
311 | 369 | ||
312 | md4 : inactive raid1 sda3[0] sdb3[1] | 370 | md4 : inactive raid1 sda3[0] sdb3[1] |
313 | 4883648 blocks [2/2] [UU] | 371 | 4883648 blocks [2/2] [UU] |
314 | 372 | ||
@@ -402,6 +460,26 @@ proc4 2 2 10853 | |||
402 | proc4ops 72 0 0 0 1098 2 0 0 0 0 8179 5896 0 0 0 0 5900 0 0 2 0 2 0 9609 0 2 150 1272 0 0 0 1236 0 0 0 0 3 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | 460 | proc4ops 72 0 0 0 1098 2 0 0 0 0 8179 5896 0 0 0 0 5900 0 0 2 0 2 0 9609 0 2 150 1272 0 0 0 1236 0 0 0 0 3 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |
403 | Mode: 644 | 461 | Mode: 644 |
404 | # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | 462 | # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
463 | Path: fixtures/proc/net/unix | ||
464 | Lines: 6 | ||
465 | Num RefCount Protocol Flags Type St Inode Path | ||
466 | 0000000000000000: 00000002 00000000 00010000 0001 01 3442596 /var/run/postgresql/.s.PGSQL.5432 | ||
467 | 0000000000000000: 0000000a 00000000 00010000 0005 01 10061 /run/udev/control | ||
468 | 0000000000000000: 00000007 00000000 00000000 0002 01 12392 /dev/log | ||
469 | 0000000000000000: 00000003 00000000 00000000 0001 03 4787297 /var/run/postgresql/.s.PGSQL.5432 | ||
470 | 0000000000000000: 00000003 00000000 00000000 0001 03 5091797 | ||
471 | Mode: 644 | ||
472 | # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||
473 | Path: fixtures/proc/net/unix_without_inode | ||
474 | Lines: 6 | ||
475 | Num RefCount Protocol Flags Type St Path | ||
476 | 0000000000000000: 00000002 00000000 00010000 0001 01 /var/run/postgresql/.s.PGSQL.5432 | ||
477 | 0000000000000000: 0000000a 00000000 00010000 0005 01 /run/udev/control | ||
478 | 0000000000000000: 00000007 00000000 00000000 0002 01 /dev/log | ||
479 | 0000000000000000: 00000003 00000000 00000000 0001 03 /var/run/postgresql/.s.PGSQL.5432 | ||
480 | 0000000000000000: 00000003 00000000 00000000 0001 03 | ||
481 | Mode: 644 | ||
482 | # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||
405 | Path: fixtures/proc/net/xfrm_stat | 483 | Path: fixtures/proc/net/xfrm_stat |
406 | Lines: 28 | 484 | Lines: 28 |
407 | XfrmInError 1 | 485 | XfrmInError 1 |
@@ -1107,6 +1185,22 @@ Mode: 644 | |||
1107 | Directory: fixtures/sys/devices/system | 1185 | Directory: fixtures/sys/devices/system |
1108 | Mode: 775 | 1186 | Mode: 775 |
1109 | # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | 1187 | # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
1188 | Directory: fixtures/sys/devices/system/clocksource | ||
1189 | Mode: 775 | ||
1190 | # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||
1191 | Directory: fixtures/sys/devices/system/clocksource/clocksource0 | ||
1192 | Mode: 775 | ||
1193 | # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||
1194 | Path: fixtures/sys/devices/system/clocksource/clocksource0/available_clocksource | ||
1195 | Lines: 1 | ||
1196 | tsc hpet acpi_pm | ||
1197 | Mode: 444 | ||
1198 | # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||
1199 | Path: fixtures/sys/devices/system/clocksource/clocksource0/current_clocksource | ||
1200 | Lines: 1 | ||
1201 | tsc | ||
1202 | Mode: 644 | ||
1203 | # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||
1110 | Directory: fixtures/sys/devices/system/cpu | 1204 | Directory: fixtures/sys/devices/system/cpu |
1111 | Mode: 775 | 1205 | Mode: 775 |
1112 | # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | 1206 | # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
diff --git a/vendor/github.com/prometheus/procfs/fs.go b/vendor/github.com/prometheus/procfs/fs.go index 9c56c83..5b4a1f0 100644 --- a/vendor/github.com/prometheus/procfs/fs.go +++ b/vendor/github.com/prometheus/procfs/fs.go | |||
@@ -27,7 +27,7 @@ type FS struct { | |||
27 | const DefaultMountPoint = fs.DefaultProcMountPoint | 27 | const DefaultMountPoint = fs.DefaultProcMountPoint |
28 | 28 | ||
29 | // NewFS returns a new proc FS mounted under the given proc mountPoint. It will error | 29 | // NewFS returns a new proc FS mounted under the given proc mountPoint. It will error |
30 | // if the mount point dirctory can't be read or is a file. | 30 | // if the mount point directory can't be read or is a file. |
31 | func NewFS(mountPoint string) (FS, error) { | 31 | func NewFS(mountPoint string) (FS, error) { |
32 | fs, err := fs.NewFS(mountPoint) | 32 | fs, err := fs.NewFS(mountPoint) |
33 | if err != nil { | 33 | if err != nil { |
diff --git a/vendor/github.com/prometheus/procfs/mountstats.go b/vendor/github.com/prometheus/procfs/mountstats.go index fc385af..35b2ef3 100644 --- a/vendor/github.com/prometheus/procfs/mountstats.go +++ b/vendor/github.com/prometheus/procfs/mountstats.go | |||
@@ -69,8 +69,8 @@ type MountStats interface { | |||
69 | type MountStatsNFS struct { | 69 | type MountStatsNFS struct { |
70 | // The version of statistics provided. | 70 | // The version of statistics provided. |
71 | StatVersion string | 71 | StatVersion string |
72 | // The optional mountaddr of the NFS mount. | 72 | // The mount options of the NFS mount. |
73 | MountAddress string | 73 | Opts map[string]string |
74 | // The age of the NFS mount. | 74 | // The age of the NFS mount. |
75 | Age time.Duration | 75 | Age time.Duration |
76 | // Statistics related to byte counters for various operations. | 76 | // Statistics related to byte counters for various operations. |
@@ -181,11 +181,11 @@ type NFSOperationStats struct { | |||
181 | // Number of bytes received for this operation, including RPC headers and payload. | 181 | // Number of bytes received for this operation, including RPC headers and payload. |
182 | BytesReceived uint64 | 182 | BytesReceived uint64 |
183 | // Duration all requests spent queued for transmission before they were sent. | 183 | // Duration all requests spent queued for transmission before they were sent. |
184 | CumulativeQueueTime time.Duration | 184 | CumulativeQueueMilliseconds uint64 |
185 | // Duration it took to get a reply back after the request was transmitted. | 185 | // Duration it took to get a reply back after the request was transmitted. |
186 | CumulativeTotalResponseTime time.Duration | 186 | CumulativeTotalResponseMilliseconds uint64 |
187 | // Duration from when a request was enqueued to when it was completely handled. | 187 | // Duration from when a request was enqueued to when it was completely handled. |
188 | CumulativeTotalRequestTime time.Duration | 188 | CumulativeTotalRequestMilliseconds uint64 |
189 | } | 189 | } |
190 | 190 | ||
191 | // A NFSTransportStats contains statistics for the NFS mount RPC requests and | 191 | // A NFSTransportStats contains statistics for the NFS mount RPC requests and |
@@ -204,7 +204,7 @@ type NFSTransportStats struct { | |||
204 | // spent waiting for connections to the server to be established. | 204 | // spent waiting for connections to the server to be established. |
205 | ConnectIdleTime uint64 | 205 | ConnectIdleTime uint64 |
206 | // Duration since the NFS mount last saw any RPC traffic. | 206 | // Duration since the NFS mount last saw any RPC traffic. |
207 | IdleTime time.Duration | 207 | IdleTimeSeconds uint64 |
208 | // Number of RPC requests for this mount sent to the NFS server. | 208 | // Number of RPC requests for this mount sent to the NFS server. |
209 | Sends uint64 | 209 | Sends uint64 |
210 | // Number of RPC responses for this mount received from the NFS server. | 210 | // Number of RPC responses for this mount received from the NFS server. |
@@ -342,10 +342,15 @@ func parseMountStatsNFS(s *bufio.Scanner, statVersion string) (*MountStatsNFS, e | |||
342 | 342 | ||
343 | switch ss[0] { | 343 | switch ss[0] { |
344 | case fieldOpts: | 344 | case fieldOpts: |
345 | if stats.Opts == nil { | ||
346 | stats.Opts = map[string]string{} | ||
347 | } | ||
345 | for _, opt := range strings.Split(ss[1], ",") { | 348 | for _, opt := range strings.Split(ss[1], ",") { |
346 | split := strings.Split(opt, "=") | 349 | split := strings.Split(opt, "=") |
347 | if len(split) == 2 && split[0] == "mountaddr" { | 350 | if len(split) == 2 { |
348 | stats.MountAddress = split[1] | 351 | stats.Opts[split[0]] = split[1] |
352 | } else { | ||
353 | stats.Opts[opt] = "" | ||
349 | } | 354 | } |
350 | } | 355 | } |
351 | case fieldAge: | 356 | case fieldAge: |
@@ -519,15 +524,15 @@ func parseNFSOperationStats(s *bufio.Scanner) ([]NFSOperationStats, error) { | |||
519 | } | 524 | } |
520 | 525 | ||
521 | ops = append(ops, NFSOperationStats{ | 526 | ops = append(ops, NFSOperationStats{ |
522 | Operation: strings.TrimSuffix(ss[0], ":"), | 527 | Operation: strings.TrimSuffix(ss[0], ":"), |
523 | Requests: ns[0], | 528 | Requests: ns[0], |
524 | Transmissions: ns[1], | 529 | Transmissions: ns[1], |
525 | MajorTimeouts: ns[2], | 530 | MajorTimeouts: ns[2], |
526 | BytesSent: ns[3], | 531 | BytesSent: ns[3], |
527 | BytesReceived: ns[4], | 532 | BytesReceived: ns[4], |
528 | CumulativeQueueTime: time.Duration(ns[5]) * time.Millisecond, | 533 | CumulativeQueueMilliseconds: ns[5], |
529 | CumulativeTotalResponseTime: time.Duration(ns[6]) * time.Millisecond, | 534 | CumulativeTotalResponseMilliseconds: ns[6], |
530 | CumulativeTotalRequestTime: time.Duration(ns[7]) * time.Millisecond, | 535 | CumulativeTotalRequestMilliseconds: ns[7], |
531 | }) | 536 | }) |
532 | } | 537 | } |
533 | 538 | ||
@@ -603,7 +608,7 @@ func parseNFSTransportStats(ss []string, statVersion string) (*NFSTransportStats | |||
603 | Bind: ns[1], | 608 | Bind: ns[1], |
604 | Connect: ns[2], | 609 | Connect: ns[2], |
605 | ConnectIdleTime: ns[3], | 610 | ConnectIdleTime: ns[3], |
606 | IdleTime: time.Duration(ns[4]) * time.Second, | 611 | IdleTimeSeconds: ns[4], |
607 | Sends: ns[5], | 612 | Sends: ns[5], |
608 | Receives: ns[6], | 613 | Receives: ns[6], |
609 | BadTransactionIDs: ns[7], | 614 | BadTransactionIDs: ns[7], |
diff --git a/vendor/github.com/prometheus/procfs/net_dev.go b/vendor/github.com/prometheus/procfs/net_dev.go index 0063594..8249c98 100644 --- a/vendor/github.com/prometheus/procfs/net_dev.go +++ b/vendor/github.com/prometheus/procfs/net_dev.go | |||
@@ -75,7 +75,7 @@ func newNetDev(file string) (NetDev, error) { | |||
75 | } | 75 | } |
76 | defer f.Close() | 76 | defer f.Close() |
77 | 77 | ||
78 | nd := NetDev{} | 78 | netDev := NetDev{} |
79 | s := bufio.NewScanner(f) | 79 | s := bufio.NewScanner(f) |
80 | for n := 0; s.Scan(); n++ { | 80 | for n := 0; s.Scan(); n++ { |
81 | // Skip the 2 header lines. | 81 | // Skip the 2 header lines. |
@@ -83,20 +83,20 @@ func newNetDev(file string) (NetDev, error) { | |||
83 | continue | 83 | continue |
84 | } | 84 | } |
85 | 85 | ||
86 | line, err := nd.parseLine(s.Text()) | 86 | line, err := netDev.parseLine(s.Text()) |
87 | if err != nil { | 87 | if err != nil { |
88 | return nd, err | 88 | return netDev, err |
89 | } | 89 | } |
90 | 90 | ||
91 | nd[line.Name] = *line | 91 | netDev[line.Name] = *line |
92 | } | 92 | } |
93 | 93 | ||
94 | return nd, s.Err() | 94 | return netDev, s.Err() |
95 | } | 95 | } |
96 | 96 | ||
97 | // parseLine parses a single line from the /proc/net/dev file. Header lines | 97 | // parseLine parses a single line from the /proc/net/dev file. Header lines |
98 | // must be filtered prior to calling this method. | 98 | // must be filtered prior to calling this method. |
99 | func (nd NetDev) parseLine(rawLine string) (*NetDevLine, error) { | 99 | func (netDev NetDev) parseLine(rawLine string) (*NetDevLine, error) { |
100 | parts := strings.SplitN(rawLine, ":", 2) | 100 | parts := strings.SplitN(rawLine, ":", 2) |
101 | if len(parts) != 2 { | 101 | if len(parts) != 2 { |
102 | return nil, errors.New("invalid net/dev line, missing colon") | 102 | return nil, errors.New("invalid net/dev line, missing colon") |
@@ -185,11 +185,11 @@ func (nd NetDev) parseLine(rawLine string) (*NetDevLine, error) { | |||
185 | 185 | ||
186 | // Total aggregates the values across interfaces and returns a new NetDevLine. | 186 | // Total aggregates the values across interfaces and returns a new NetDevLine. |
187 | // The Name field will be a sorted comma separated list of interface names. | 187 | // The Name field will be a sorted comma separated list of interface names. |
188 | func (nd NetDev) Total() NetDevLine { | 188 | func (netDev NetDev) Total() NetDevLine { |
189 | total := NetDevLine{} | 189 | total := NetDevLine{} |
190 | 190 | ||
191 | names := make([]string, 0, len(nd)) | 191 | names := make([]string, 0, len(netDev)) |
192 | for _, ifc := range nd { | 192 | for _, ifc := range netDev { |
193 | names = append(names, ifc.Name) | 193 | names = append(names, ifc.Name) |
194 | total.RxBytes += ifc.RxBytes | 194 | total.RxBytes += ifc.RxBytes |
195 | total.RxPackets += ifc.RxPackets | 195 | total.RxPackets += ifc.RxPackets |
diff --git a/vendor/github.com/prometheus/procfs/net_unix.go b/vendor/github.com/prometheus/procfs/net_unix.go new file mode 100644 index 0000000..240340a --- /dev/null +++ b/vendor/github.com/prometheus/procfs/net_unix.go | |||
@@ -0,0 +1,275 @@ | |||
1 | // Copyright 2018 The Prometheus Authors | ||
2 | // Licensed under the Apache License, Version 2.0 (the "License"); | ||
3 | // you may not use this file except in compliance with the License. | ||
4 | // You may obtain a copy of the License at | ||
5 | // | ||
6 | // http://www.apache.org/licenses/LICENSE-2.0 | ||
7 | // | ||
8 | // Unless required by applicable law or agreed to in writing, software | ||
9 | // distributed under the License is distributed on an "AS IS" BASIS, | ||
10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
11 | // See the License for the specific language governing permissions and | ||
12 | // limitations under the License. | ||
13 | |||
14 | package procfs | ||
15 | |||
16 | import ( | ||
17 | "bufio" | ||
18 | "errors" | ||
19 | "fmt" | ||
20 | "io" | ||
21 | "os" | ||
22 | "strconv" | ||
23 | "strings" | ||
24 | ) | ||
25 | |||
26 | // For the proc file format details, | ||
27 | // see https://elixir.bootlin.com/linux/v4.17/source/net/unix/af_unix.c#L2815 | ||
28 | // and https://elixir.bootlin.com/linux/latest/source/include/uapi/linux/net.h#L48. | ||
29 | |||
30 | const ( | ||
31 | netUnixKernelPtrIdx = iota | ||
32 | netUnixRefCountIdx | ||
33 | _ | ||
34 | netUnixFlagsIdx | ||
35 | netUnixTypeIdx | ||
36 | netUnixStateIdx | ||
37 | netUnixInodeIdx | ||
38 | |||
39 | // Inode and Path are optional. | ||
40 | netUnixStaticFieldsCnt = 6 | ||
41 | ) | ||
42 | |||
43 | const ( | ||
44 | netUnixTypeStream = 1 | ||
45 | netUnixTypeDgram = 2 | ||
46 | netUnixTypeSeqpacket = 5 | ||
47 | |||
48 | netUnixFlagListen = 1 << 16 | ||
49 | |||
50 | netUnixStateUnconnected = 1 | ||
51 | netUnixStateConnecting = 2 | ||
52 | netUnixStateConnected = 3 | ||
53 | netUnixStateDisconnected = 4 | ||
54 | ) | ||
55 | |||
56 | var errInvalidKernelPtrFmt = errors.New("Invalid Num(the kernel table slot number) format") | ||
57 | |||
58 | // NetUnixType is the type of the type field. | ||
59 | type NetUnixType uint64 | ||
60 | |||
61 | // NetUnixFlags is the type of the flags field. | ||
62 | type NetUnixFlags uint64 | ||
63 | |||
64 | // NetUnixState is the type of the state field. | ||
65 | type NetUnixState uint64 | ||
66 | |||
67 | // NetUnixLine represents a line of /proc/net/unix. | ||
68 | type NetUnixLine struct { | ||
69 | KernelPtr string | ||
70 | RefCount uint64 | ||
71 | Protocol uint64 | ||
72 | Flags NetUnixFlags | ||
73 | Type NetUnixType | ||
74 | State NetUnixState | ||
75 | Inode uint64 | ||
76 | Path string | ||
77 | } | ||
78 | |||
79 | // NetUnix holds the data read from /proc/net/unix. | ||
80 | type NetUnix struct { | ||
81 | Rows []*NetUnixLine | ||
82 | } | ||
83 | |||
84 | // NewNetUnix returns data read from /proc/net/unix. | ||
85 | func NewNetUnix() (*NetUnix, error) { | ||
86 | fs, err := NewFS(DefaultMountPoint) | ||
87 | if err != nil { | ||
88 | return nil, err | ||
89 | } | ||
90 | |||
91 | return fs.NewNetUnix() | ||
92 | } | ||
93 | |||
94 | // NewNetUnix returns data read from /proc/net/unix. | ||
95 | func (fs FS) NewNetUnix() (*NetUnix, error) { | ||
96 | return NewNetUnixByPath(fs.proc.Path("net/unix")) | ||
97 | } | ||
98 | |||
99 | // NewNetUnixByPath returns data read from /proc/net/unix by file path. | ||
100 | // It might returns an error with partial parsed data, if an error occur after some data parsed. | ||
101 | func NewNetUnixByPath(path string) (*NetUnix, error) { | ||
102 | f, err := os.Open(path) | ||
103 | if err != nil { | ||
104 | return nil, err | ||
105 | } | ||
106 | defer f.Close() | ||
107 | return NewNetUnixByReader(f) | ||
108 | } | ||
109 | |||
110 | // NewNetUnixByReader returns data read from /proc/net/unix by a reader. | ||
111 | // It might returns an error with partial parsed data, if an error occur after some data parsed. | ||
112 | func NewNetUnixByReader(reader io.Reader) (*NetUnix, error) { | ||
113 | nu := &NetUnix{ | ||
114 | Rows: make([]*NetUnixLine, 0, 32), | ||
115 | } | ||
116 | scanner := bufio.NewScanner(reader) | ||
117 | // Omit the header line. | ||
118 | scanner.Scan() | ||
119 | header := scanner.Text() | ||
120 | // From the man page of proc(5), it does not contain an Inode field, | ||
121 | // but in actually it exists. | ||
122 | // This code works for both cases. | ||
123 | hasInode := strings.Contains(header, "Inode") | ||
124 | |||
125 | minFieldsCnt := netUnixStaticFieldsCnt | ||
126 | if hasInode { | ||
127 | minFieldsCnt++ | ||
128 | } | ||
129 | for scanner.Scan() { | ||
130 | line := scanner.Text() | ||
131 | item, err := nu.parseLine(line, hasInode, minFieldsCnt) | ||
132 | if err != nil { | ||
133 | return nu, err | ||
134 | } | ||
135 | nu.Rows = append(nu.Rows, item) | ||
136 | } | ||
137 | |||
138 | return nu, scanner.Err() | ||
139 | } | ||
140 | |||
141 | func (u *NetUnix) parseLine(line string, hasInode bool, minFieldsCnt int) (*NetUnixLine, error) { | ||
142 | fields := strings.Fields(line) | ||
143 | fieldsLen := len(fields) | ||
144 | if fieldsLen < minFieldsCnt { | ||
145 | return nil, fmt.Errorf( | ||
146 | "Parse Unix domain failed: expect at least %d fields but got %d", | ||
147 | minFieldsCnt, fieldsLen) | ||
148 | } | ||
149 | kernelPtr, err := u.parseKernelPtr(fields[netUnixKernelPtrIdx]) | ||
150 | if err != nil { | ||
151 | return nil, fmt.Errorf("Parse Unix domain num(%s) failed: %s", fields[netUnixKernelPtrIdx], err) | ||
152 | } | ||
153 | users, err := u.parseUsers(fields[netUnixRefCountIdx]) | ||
154 | if err != nil { | ||
155 | return nil, fmt.Errorf("Parse Unix domain ref count(%s) failed: %s", fields[netUnixRefCountIdx], err) | ||
156 | } | ||
157 | flags, err := u.parseFlags(fields[netUnixFlagsIdx]) | ||
158 | if err != nil { | ||
159 | return nil, fmt.Errorf("Parse Unix domain flags(%s) failed: %s", fields[netUnixFlagsIdx], err) | ||
160 | } | ||
161 | typ, err := u.parseType(fields[netUnixTypeIdx]) | ||
162 | if err != nil { | ||
163 | return nil, fmt.Errorf("Parse Unix domain type(%s) failed: %s", fields[netUnixTypeIdx], err) | ||
164 | } | ||
165 | state, err := u.parseState(fields[netUnixStateIdx]) | ||
166 | if err != nil { | ||
167 | return nil, fmt.Errorf("Parse Unix domain state(%s) failed: %s", fields[netUnixStateIdx], err) | ||
168 | } | ||
169 | var inode uint64 | ||
170 | if hasInode { | ||
171 | inodeStr := fields[netUnixInodeIdx] | ||
172 | inode, err = u.parseInode(inodeStr) | ||
173 | if err != nil { | ||
174 | return nil, fmt.Errorf("Parse Unix domain inode(%s) failed: %s", inodeStr, err) | ||
175 | } | ||
176 | } | ||
177 | |||
178 | nuLine := &NetUnixLine{ | ||
179 | KernelPtr: kernelPtr, | ||
180 | RefCount: users, | ||
181 | Type: typ, | ||
182 | Flags: flags, | ||
183 | State: state, | ||
184 | Inode: inode, | ||
185 | } | ||
186 | |||
187 | // Path field is optional. | ||
188 | if fieldsLen > minFieldsCnt { | ||
189 | pathIdx := netUnixInodeIdx + 1 | ||
190 | if !hasInode { | ||
191 | pathIdx-- | ||
192 | } | ||
193 | nuLine.Path = fields[pathIdx] | ||
194 | } | ||
195 | |||
196 | return nuLine, nil | ||
197 | } | ||
198 | |||
199 | func (u NetUnix) parseKernelPtr(str string) (string, error) { | ||
200 | if !strings.HasSuffix(str, ":") { | ||
201 | return "", errInvalidKernelPtrFmt | ||
202 | } | ||
203 | return str[:len(str)-1], nil | ||
204 | } | ||
205 | |||
206 | func (u NetUnix) parseUsers(hexStr string) (uint64, error) { | ||
207 | return strconv.ParseUint(hexStr, 16, 32) | ||
208 | } | ||
209 | |||
210 | func (u NetUnix) parseProtocol(hexStr string) (uint64, error) { | ||
211 | return strconv.ParseUint(hexStr, 16, 32) | ||
212 | } | ||
213 | |||
214 | func (u NetUnix) parseType(hexStr string) (NetUnixType, error) { | ||
215 | typ, err := strconv.ParseUint(hexStr, 16, 16) | ||
216 | if err != nil { | ||
217 | return 0, err | ||
218 | } | ||
219 | return NetUnixType(typ), nil | ||
220 | } | ||
221 | |||
222 | func (u NetUnix) parseFlags(hexStr string) (NetUnixFlags, error) { | ||
223 | flags, err := strconv.ParseUint(hexStr, 16, 32) | ||
224 | if err != nil { | ||
225 | return 0, err | ||
226 | } | ||
227 | return NetUnixFlags(flags), nil | ||
228 | } | ||
229 | |||
230 | func (u NetUnix) parseState(hexStr string) (NetUnixState, error) { | ||
231 | st, err := strconv.ParseInt(hexStr, 16, 8) | ||
232 | if err != nil { | ||
233 | return 0, err | ||
234 | } | ||
235 | return NetUnixState(st), nil | ||
236 | } | ||
237 | |||
238 | func (u NetUnix) parseInode(inodeStr string) (uint64, error) { | ||
239 | return strconv.ParseUint(inodeStr, 10, 64) | ||
240 | } | ||
241 | |||
242 | func (t NetUnixType) String() string { | ||
243 | switch t { | ||
244 | case netUnixTypeStream: | ||
245 | return "stream" | ||
246 | case netUnixTypeDgram: | ||
247 | return "dgram" | ||
248 | case netUnixTypeSeqpacket: | ||
249 | return "seqpacket" | ||
250 | } | ||
251 | return "unknown" | ||
252 | } | ||
253 | |||
254 | func (f NetUnixFlags) String() string { | ||
255 | switch f { | ||
256 | case netUnixFlagListen: | ||
257 | return "listen" | ||
258 | default: | ||
259 | return "default" | ||
260 | } | ||
261 | } | ||
262 | |||
263 | func (s NetUnixState) String() string { | ||
264 | switch s { | ||
265 | case netUnixStateUnconnected: | ||
266 | return "unconnected" | ||
267 | case netUnixStateConnecting: | ||
268 | return "connecting" | ||
269 | case netUnixStateConnected: | ||
270 | return "connected" | ||
271 | case netUnixStateDisconnected: | ||
272 | return "disconnected" | ||
273 | } | ||
274 | return "unknown" | ||
275 | } | ||
diff --git a/vendor/github.com/prometheus/procfs/nfs/parse.go b/vendor/github.com/prometheus/procfs/nfs/parse.go index 95a83cc..5e78c54 100644 --- a/vendor/github.com/prometheus/procfs/nfs/parse.go +++ b/vendor/github.com/prometheus/procfs/nfs/parse.go | |||
@@ -118,7 +118,7 @@ func parseClientRPC(v []uint64) (ClientRPC, error) { | |||
118 | 118 | ||
119 | func parseV2Stats(v []uint64) (V2Stats, error) { | 119 | func parseV2Stats(v []uint64) (V2Stats, error) { |
120 | values := int(v[0]) | 120 | values := int(v[0]) |
121 | if len(v[1:]) != values || values != 18 { | 121 | if len(v[1:]) != values || values < 18 { |
122 | return V2Stats{}, fmt.Errorf("invalid V2Stats line %q", v) | 122 | return V2Stats{}, fmt.Errorf("invalid V2Stats line %q", v) |
123 | } | 123 | } |
124 | 124 | ||
@@ -146,7 +146,7 @@ func parseV2Stats(v []uint64) (V2Stats, error) { | |||
146 | 146 | ||
147 | func parseV3Stats(v []uint64) (V3Stats, error) { | 147 | func parseV3Stats(v []uint64) (V3Stats, error) { |
148 | values := int(v[0]) | 148 | values := int(v[0]) |
149 | if len(v[1:]) != values || values != 22 { | 149 | if len(v[1:]) != values || values < 22 { |
150 | return V3Stats{}, fmt.Errorf("invalid V3Stats line %q", v) | 150 | return V3Stats{}, fmt.Errorf("invalid V3Stats line %q", v) |
151 | } | 151 | } |
152 | 152 | ||
diff --git a/vendor/github.com/prometheus/procfs/proc_ns.go b/vendor/github.com/prometheus/procfs/proc_ns.go index d06c26e..3f8d6d6 100644 --- a/vendor/github.com/prometheus/procfs/proc_ns.go +++ b/vendor/github.com/prometheus/procfs/proc_ns.go | |||
@@ -29,7 +29,7 @@ type Namespace struct { | |||
29 | // Namespaces contains all of the namespaces that the process is contained in. | 29 | // Namespaces contains all of the namespaces that the process is contained in. |
30 | type Namespaces map[string]Namespace | 30 | type Namespaces map[string]Namespace |
31 | 31 | ||
32 | // NewNamespaces reads from /proc/[pid/ns/* to get the namespaces of which the | 32 | // NewNamespaces reads from /proc/<pid>/ns/* to get the namespaces of which the |
33 | // process is a member. | 33 | // process is a member. |
34 | func (p Proc) NewNamespaces() (Namespaces, error) { | 34 | func (p Proc) NewNamespaces() (Namespaces, error) { |
35 | d, err := os.Open(p.path("ns")) | 35 | d, err := os.Open(p.path("ns")) |
diff --git a/vendor/github.com/prometheus/procfs/proc_status.go b/vendor/github.com/prometheus/procfs/proc_status.go new file mode 100644 index 0000000..6b4b61f --- /dev/null +++ b/vendor/github.com/prometheus/procfs/proc_status.go | |||
@@ -0,0 +1,162 @@ | |||
1 | // Copyright 2018 The Prometheus Authors | ||
2 | // Licensed under the Apache License, Version 2.0 (the "License"); | ||
3 | // you may not use this file except in compliance with the License. | ||
4 | // You may obtain a copy of the License at | ||
5 | // | ||
6 | // http://www.apache.org/licenses/LICENSE-2.0 | ||
7 | // | ||
8 | // Unless required by applicable law or agreed to in writing, software | ||
9 | // distributed under the License is distributed on an "AS IS" BASIS, | ||
10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
11 | // See the License for the specific language governing permissions and | ||
12 | // limitations under the License. | ||
13 | |||
14 | package procfs | ||
15 | |||
16 | import ( | ||
17 | "bytes" | ||
18 | "io/ioutil" | ||
19 | "os" | ||
20 | "strconv" | ||
21 | "strings" | ||
22 | ) | ||
23 | |||
24 | // ProcStat provides status information about the process, | ||
25 | // read from /proc/[pid]/stat. | ||
26 | type ProcStatus struct { | ||
27 | // The process ID. | ||
28 | PID int | ||
29 | // The process name. | ||
30 | Name string | ||
31 | |||
32 | // Peak virtual memory size. | ||
33 | VmPeak uint64 | ||
34 | // Virtual memory size. | ||
35 | VmSize uint64 | ||
36 | // Locked memory size. | ||
37 | VmLck uint64 | ||
38 | // Pinned memory size. | ||
39 | VmPin uint64 | ||
40 | // Peak resident set size. | ||
41 | VmHWM uint64 | ||
42 | // Resident set size (sum of RssAnnon RssFile and RssShmem). | ||
43 | VmRSS uint64 | ||
44 | // Size of resident anonymous memory. | ||
45 | RssAnon uint64 | ||
46 | // Size of resident file mappings. | ||
47 | RssFile uint64 | ||
48 | // Size of resident shared memory. | ||
49 | RssShmem uint64 | ||
50 | // Size of data segments. | ||
51 | VmData uint64 | ||
52 | // Size of stack segments. | ||
53 | VmStk uint64 | ||
54 | // Size of text segments. | ||
55 | VmExe uint64 | ||
56 | // Shared library code size. | ||
57 | VmLib uint64 | ||
58 | // Page table entries size. | ||
59 | VmPTE uint64 | ||
60 | // Size of second-level page tables. | ||
61 | VmPMD uint64 | ||
62 | // Swapped-out virtual memory size by anonymous private. | ||
63 | VmSwap uint64 | ||
64 | // Size of hugetlb memory portions | ||
65 | HugetlbPages uint64 | ||
66 | |||
67 | // Number of voluntary context switches. | ||
68 | VoluntaryCtxtSwitches uint64 | ||
69 | // Number of involuntary context switches. | ||
70 | NonVoluntaryCtxtSwitches uint64 | ||
71 | } | ||
72 | |||
73 | // NewStatus returns the current status information of the process. | ||
74 | func (p Proc) NewStatus() (ProcStatus, error) { | ||
75 | f, err := os.Open(p.path("status")) | ||
76 | if err != nil { | ||
77 | return ProcStatus{}, err | ||
78 | } | ||
79 | defer f.Close() | ||
80 | |||
81 | data, err := ioutil.ReadAll(f) | ||
82 | if err != nil { | ||
83 | return ProcStatus{}, err | ||
84 | } | ||
85 | |||
86 | s := ProcStatus{PID: p.PID} | ||
87 | |||
88 | lines := strings.Split(string(data), "\n") | ||
89 | for _, line := range lines { | ||
90 | if !bytes.Contains([]byte(line), []byte(":")) { | ||
91 | continue | ||
92 | } | ||
93 | |||
94 | kv := strings.SplitN(line, ":", 2) | ||
95 | |||
96 | // removes spaces | ||
97 | k := string(strings.TrimSpace(kv[0])) | ||
98 | v := string(strings.TrimSpace(kv[1])) | ||
99 | // removes "kB" | ||
100 | v = string(bytes.Trim([]byte(v), " kB")) | ||
101 | |||
102 | // value to int when possible | ||
103 | // we can skip error check here, 'cause vKBytes is not used when value is a string | ||
104 | vKBytes, _ := strconv.ParseUint(v, 10, 64) | ||
105 | // convert kB to B | ||
106 | vBytes := vKBytes * 1024 | ||
107 | |||
108 | s.fillStatus(k, v, vKBytes, vBytes) | ||
109 | } | ||
110 | |||
111 | return s, nil | ||
112 | } | ||
113 | |||
114 | func (s *ProcStatus) fillStatus(k string, vString string, vUint uint64, vUintBytes uint64) { | ||
115 | switch k { | ||
116 | case "Name": | ||
117 | s.Name = vString | ||
118 | case "VmPeak": | ||
119 | s.VmPeak = vUintBytes | ||
120 | case "VmSize": | ||
121 | s.VmSize = vUintBytes | ||
122 | case "VmLck": | ||
123 | s.VmLck = vUintBytes | ||
124 | case "VmPin": | ||
125 | s.VmPin = vUintBytes | ||
126 | case "VmHWM": | ||
127 | s.VmHWM = vUintBytes | ||
128 | case "VmRSS": | ||
129 | s.VmRSS = vUintBytes | ||
130 | case "RssAnon": | ||
131 | s.RssAnon = vUintBytes | ||
132 | case "RssFile": | ||
133 | s.RssFile = vUintBytes | ||
134 | case "RssShmem": | ||
135 | s.RssShmem = vUintBytes | ||
136 | case "VmData": | ||
137 | s.VmData = vUintBytes | ||
138 | case "VmStk": | ||
139 | s.VmStk = vUintBytes | ||
140 | case "VmExe": | ||
141 | s.VmExe = vUintBytes | ||
142 | case "VmLib": | ||
143 | s.VmLib = vUintBytes | ||
144 | case "VmPTE": | ||
145 | s.VmPTE = vUintBytes | ||
146 | case "VmPMD": | ||
147 | s.VmPMD = vUintBytes | ||
148 | case "VmSwap": | ||
149 | s.VmSwap = vUintBytes | ||
150 | case "HugetlbPages": | ||
151 | s.HugetlbPages = vUintBytes | ||
152 | case "voluntary_ctxt_switches": | ||
153 | s.VoluntaryCtxtSwitches = vUint | ||
154 | case "nonvoluntary_ctxt_switches": | ||
155 | s.NonVoluntaryCtxtSwitches = vUint | ||
156 | } | ||
157 | } | ||
158 | |||
159 | // TotalCtxtSwitches returns the total context switch. | ||
160 | func (s ProcStatus) TotalCtxtSwitches() uint64 { | ||
161 | return s.VoluntaryCtxtSwitches + s.NonVoluntaryCtxtSwitches | ||
162 | } | ||
diff --git a/vendor/github.com/prometheus/procfs/sysfs/clocksource.go b/vendor/github.com/prometheus/procfs/sysfs/clocksource.go new file mode 100644 index 0000000..d96c389 --- /dev/null +++ b/vendor/github.com/prometheus/procfs/sysfs/clocksource.go | |||
@@ -0,0 +1,76 @@ | |||
1 | // Copyright 2019 The Prometheus Authors | ||
2 | // Licensed under the Apache License, Version 2.0 (the "License"); | ||
3 | // you may not use this file except in compliance with the License. | ||
4 | // You may obtain a copy of the License at | ||
5 | // | ||
6 | // http://www.apache.org/licenses/LICENSE-2.0 | ||
7 | // | ||
8 | // Unless required by applicable law or agreed to in writing, software | ||
9 | // distributed under the License is distributed on an "AS IS" BASIS, | ||
10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
11 | // See the License for the specific language governing permissions and | ||
12 | // limitations under the License. | ||
13 | |||
14 | // +build !windows | ||
15 | |||
16 | package sysfs | ||
17 | |||
18 | import ( | ||
19 | "path/filepath" | ||
20 | "strings" | ||
21 | |||
22 | "github.com/prometheus/procfs/internal/util" | ||
23 | ) | ||
24 | |||
25 | // ClockSource contains metrics related to the clock source | ||
26 | type ClockSource struct { | ||
27 | Name string | ||
28 | Available []string | ||
29 | Current string | ||
30 | } | ||
31 | |||
32 | // ClockSources returns clocksource information including current and available clocksources | ||
33 | // read from '/sys/devices/system/clocksource' | ||
34 | func (fs FS) ClockSources() ([]ClockSource, error) { | ||
35 | |||
36 | clocksourcePaths, err := filepath.Glob(fs.sys.Path("devices/system/clocksource/clocksource[0-9]*")) | ||
37 | if err != nil { | ||
38 | return nil, err | ||
39 | } | ||
40 | |||
41 | clocksources := make([]ClockSource, len(clocksourcePaths)) | ||
42 | for i, clocksourcePath := range clocksourcePaths { | ||
43 | clocksourceName := strings.TrimPrefix(filepath.Base(clocksourcePath), "clocksource") | ||
44 | |||
45 | clocksource, err := parseClocksource(clocksourcePath) | ||
46 | if err != nil { | ||
47 | return nil, err | ||
48 | } | ||
49 | clocksource.Name = clocksourceName | ||
50 | clocksources[i] = *clocksource | ||
51 | } | ||
52 | |||
53 | return clocksources, nil | ||
54 | } | ||
55 | |||
56 | func parseClocksource(clocksourcePath string) (*ClockSource, error) { | ||
57 | |||
58 | stringFiles := []string{ | ||
59 | "available_clocksource", | ||
60 | "current_clocksource", | ||
61 | } | ||
62 | stringOut := make([]string, len(stringFiles)) | ||
63 | var err error | ||
64 | |||
65 | for i, f := range stringFiles { | ||
66 | stringOut[i], err = util.SysReadFile(filepath.Join(clocksourcePath, f)) | ||
67 | if err != nil { | ||
68 | return &ClockSource{}, err | ||
69 | } | ||
70 | } | ||
71 | |||
72 | return &ClockSource{ | ||
73 | Available: strings.Fields(stringOut[0]), | ||
74 | Current: stringOut[1], | ||
75 | }, nil | ||
76 | } | ||
diff --git a/vendor/github.com/prometheus/procfs/ttar b/vendor/github.com/prometheus/procfs/ttar index b0171a1..19ef02b 100644 --- a/vendor/github.com/prometheus/procfs/ttar +++ b/vendor/github.com/prometheus/procfs/ttar | |||
@@ -86,8 +86,10 @@ Usage: $bname [-C <DIR>] -c -f <ARCHIVE> <FILE...> (create archive) | |||
86 | $bname [-C <DIR>] -x -f <ARCHIVE> (extract archive) | 86 | $bname [-C <DIR>] -x -f <ARCHIVE> (extract archive) |
87 | 87 | ||
88 | Options: | 88 | Options: |
89 | -C <DIR> (change directory) | 89 | -C <DIR> (change directory) |
90 | -v (verbose) | 90 | -v (verbose) |
91 | --recursive-unlink (recursively delete existing directory if path | ||
92 | collides with file or directory to extract) | ||
91 | 93 | ||
92 | Example: Change to sysfs directory, create ttar file from fixtures directory | 94 | Example: Change to sysfs directory, create ttar file from fixtures directory |
93 | $bname -C sysfs -c -f sysfs/fixtures.ttar fixtures/ | 95 | $bname -C sysfs -c -f sysfs/fixtures.ttar fixtures/ |
@@ -111,8 +113,9 @@ function set_cmd { | |||
111 | } | 113 | } |
112 | 114 | ||
113 | unset VERBOSE | 115 | unset VERBOSE |
116 | unset RECURSIVE_UNLINK | ||
114 | 117 | ||
115 | while getopts :cf:htxvC: opt; do | 118 | while getopts :cf:-:htxvC: opt; do |
116 | case $opt in | 119 | case $opt in |
117 | c) | 120 | c) |
118 | set_cmd "create" | 121 | set_cmd "create" |
@@ -136,6 +139,18 @@ while getopts :cf:htxvC: opt; do | |||
136 | C) | 139 | C) |
137 | CDIR=$OPTARG | 140 | CDIR=$OPTARG |
138 | ;; | 141 | ;; |
142 | -) | ||
143 | case $OPTARG in | ||
144 | recursive-unlink) | ||
145 | RECURSIVE_UNLINK="yes" | ||
146 | ;; | ||
147 | *) | ||
148 | echo -e "Error: invalid option -$OPTARG" | ||
149 | echo | ||
150 | usage 1 | ||
151 | ;; | ||
152 | esac | ||
153 | ;; | ||
139 | *) | 154 | *) |
140 | echo >&2 "ERROR: invalid option -$OPTARG" | 155 | echo >&2 "ERROR: invalid option -$OPTARG" |
141 | echo | 156 | echo |
@@ -212,16 +227,16 @@ function extract { | |||
212 | local eof_without_newline | 227 | local eof_without_newline |
213 | if [ "$size" -gt 0 ]; then | 228 | if [ "$size" -gt 0 ]; then |
214 | if [[ "$line" =~ [^\\]EOF ]]; then | 229 | if [[ "$line" =~ [^\\]EOF ]]; then |
215 | # An EOF not preceeded by a backslash indicates that the line | 230 | # An EOF not preceded by a backslash indicates that the line |
216 | # does not end with a newline | 231 | # does not end with a newline |
217 | eof_without_newline=1 | 232 | eof_without_newline=1 |
218 | else | 233 | else |
219 | eof_without_newline=0 | 234 | eof_without_newline=0 |
220 | fi | 235 | fi |
221 | # Replace NULLBYTE with null byte if at beginning of line | 236 | # Replace NULLBYTE with null byte if at beginning of line |
222 | # Replace NULLBYTE with null byte unless preceeded by backslash | 237 | # Replace NULLBYTE with null byte unless preceded by backslash |
223 | # Remove one backslash in front of NULLBYTE (if any) | 238 | # Remove one backslash in front of NULLBYTE (if any) |
224 | # Remove EOF unless preceeded by backslash | 239 | # Remove EOF unless preceded by backslash |
225 | # Remove one backslash in front of EOF | 240 | # Remove one backslash in front of EOF |
226 | if [ $USE_PYTHON -eq 1 ]; then | 241 | if [ $USE_PYTHON -eq 1 ]; then |
227 | echo -n "$line" | python -c "$PYTHON_EXTRACT_FILTER" >> "$path" | 242 | echo -n "$line" | python -c "$PYTHON_EXTRACT_FILTER" >> "$path" |
@@ -245,7 +260,16 @@ function extract { | |||
245 | fi | 260 | fi |
246 | if [[ $line =~ ^Path:\ (.*)$ ]]; then | 261 | if [[ $line =~ ^Path:\ (.*)$ ]]; then |
247 | path=${BASH_REMATCH[1]} | 262 | path=${BASH_REMATCH[1]} |
248 | if [ -e "$path" ] || [ -L "$path" ]; then | 263 | if [ -L "$path" ]; then |
264 | rm "$path" | ||
265 | elif [ -d "$path" ]; then | ||
266 | if [ "${RECURSIVE_UNLINK:-}" == "yes" ]; then | ||
267 | rm -r "$path" | ||
268 | else | ||
269 | # Safe because symlinks to directories are dealt with above | ||
270 | rmdir "$path" | ||
271 | fi | ||
272 | elif [ -e "$path" ]; then | ||
249 | rm "$path" | 273 | rm "$path" |
250 | fi | 274 | fi |
251 | elif [[ $line =~ ^Lines:\ (.*)$ ]]; then | 275 | elif [[ $line =~ ^Lines:\ (.*)$ ]]; then |
@@ -338,8 +362,8 @@ function _create { | |||
338 | else | 362 | else |
339 | < "$file" \ | 363 | < "$file" \ |
340 | sed 's/EOF/\\EOF/g; | 364 | sed 's/EOF/\\EOF/g; |
341 | s/NULLBYTE/\\NULLBYTE/g; | 365 | s/NULLBYTE/\\NULLBYTE/g; |
342 | s/\x0/NULLBYTE/g; | 366 | s/\x0/NULLBYTE/g; |
343 | ' | 367 | ' |
344 | fi | 368 | fi |
345 | if [[ "$eof_without_newline" -eq 1 ]]; then | 369 | if [[ "$eof_without_newline" -eq 1 ]]; then |
diff --git a/vendor/modules.txt b/vendor/modules.txt index c32c57d..9cc4173 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt | |||
@@ -45,7 +45,7 @@ github.com/prometheus/common/version | |||
45 | github.com/prometheus/common/expfmt | 45 | github.com/prometheus/common/expfmt |
46 | github.com/prometheus/common/model | 46 | github.com/prometheus/common/model |
47 | github.com/prometheus/common/internal/bitbucket.org/ww/goautoneg | 47 | github.com/prometheus/common/internal/bitbucket.org/ww/goautoneg |
48 | # github.com/prometheus/procfs v0.0.0-20190507043628-bc6930f2d510 | 48 | # github.com/prometheus/procfs v0.0.0-20190529155944-65bdadfa96ae |
49 | github.com/prometheus/procfs | 49 | github.com/prometheus/procfs |
50 | github.com/prometheus/procfs/bcache | 50 | github.com/prometheus/procfs/bcache |
51 | github.com/prometheus/procfs/nfs | 51 | github.com/prometheus/procfs/nfs |