Created
December 23, 2017 23:56
-
-
Save banteg/685f6b802b88005c9dd2b01a3374173b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import puresnmp | |
from prometheus_client.core import REGISTRY, GaugeMetricFamily | |
from prometheus_client import start_http_server | |
class AirPortExporter: | |
def collect(self): | |
in_bytes = puresnmp.get('10.0.1.1', 'public', '1.3.6.1.2.1.2.2.1.10.1') | |
out_bytes = puresnmp.get('10.0.1.1', 'public', '1.3.6.1.2.1.2.2.1.16.1') | |
metric = GaugeMetricFamily('airport', 'airport', labels=['direction']) | |
print('in', in_bytes, 'out', out_bytes) | |
metric.add_metric(['in'], in_bytes) | |
metric.add_metric(['out'], out_bytes) | |
yield metric | |
if __name__ == '__main__': | |
REGISTRY.register(AirPortExporter()) | |
start_http_server(9116) | |
input() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment