adding zabbix sampler
This commit is contained in:
@@ -8,6 +8,7 @@ def run(app, xyzzy):
|
||||
ConvergenceSampler(xyzzy, 1),
|
||||
ProgressBarsSampler(xyzzy, 5),
|
||||
UsageGaugeSampler(xyzzy, 3),
|
||||
ZabbixSampler(xyzzy,3)
|
||||
]
|
||||
|
||||
try:
|
||||
|
||||
@@ -93,3 +93,26 @@ class UsageGaugeSampler(DashieSampler):
|
||||
def sample(self):
|
||||
return {'value': random.randint(0, 100), 'max': 100}
|
||||
|
||||
from pyzabbix import ZabbixAPI
|
||||
|
||||
class ZabbixSampler(DashieSampler):
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.seedX = 0
|
||||
self.items = collections.deque()
|
||||
DashieSampler.__init__(self, *args, **kwargs)
|
||||
|
||||
def name(self):
|
||||
return 'zabbix'
|
||||
|
||||
def sample(self):
|
||||
zapi = ZabbixAPI("http://zabbix.tonyrogers.me/zabbix/")
|
||||
zabbix.session.verify = False
|
||||
zapi.login("Admin", "zabbix")
|
||||
ret = zapi.item.get(output=['lastvalue'],filter={'host':'zabbix.tonyrogers.me'},search={'key_':'zabbix[wcache,values]'})
|
||||
|
||||
self.items.append({'x': self.seedX,
|
||||
'y': ret[0]['lastvalue']})
|
||||
self.seedX += 1
|
||||
if len(self.items) > 10:
|
||||
self.items.popleft()
|
||||
return {'points': list(self.items)}
|
||||
|
||||
@@ -32,6 +32,9 @@
|
||||
<div data-id="buzzwords" data-view="List" data-unordered="true" data-title="Buzzwords" data-moreinfo="Absolute ranking of pony preferences"></div>
|
||||
</li>
|
||||
|
||||
<li data-row="3" data-col="2" data-sizex="2" data-sizey="1">
|
||||
<div data-id="zabbix" data-view="Graph" data-title="Zabbix" style="background-color:#ff9618"></div>
|
||||
</li>
|
||||
|
||||
<li data-row="2" data-col="1" data-sizex="1" data-sizey="1">
|
||||
<div data-id="clock" data-view="Clock" data-title="Clock"></div>
|
||||
|
||||
Reference in New Issue
Block a user