-
Notifications
You must be signed in to change notification settings - Fork 7
/
irq.py
32 lines (28 loc) · 814 Bytes
/
irq.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# -*- coding: UTF-8 -*-
"""
This module pokes Mikrotik for IRQ Counters
"""
import time
from libs.strings import zabbix_escape
from logging import getLogger
def run(api, ts=False, log=getLogger(__name__), ver=''):
"""
Returns IRQ Counters
:param api: initialized librouteros' connect()
:param ts: Use timestamps
:return:
"""
if ts:
unixtime = " {time} ".format(
time=int(time.time())
)
else:
unixtime = " "
irqstats = api(cmd='/system/resource/irq/print')
for irqitem in irqstats:
print("{host} \"{key}\"{unixtime}{value}".format(
host='-',
key='mikrotik.irq[' + irqitem.get('users').replace(",", "__") + ']',
unixtime=unixtime,
value=zabbix_escape(irqitem['count'])
))