Module: check_mk
Branch: master
Commit: 54b8389ff5dca6f673e55b96f402e25fee28a0cc
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=54b8389ff5dca6…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Fri Mar 11 16:16:51 2011 +0100
Agent simulator: fix sinus curve
---
modules/agent_simulator.py | 16 ++++++++++------
1 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/modules/agent_simulator.py b/modules/agent_simulator.py
index b6457dd..9847aec 100644
--- a/modules/agent_simulator.py
+++ b/modules/agent_simulator.py
@@ -3,7 +3,7 @@
import math
def our_uptime():
- return int(float((file("/proc/uptime").read().split()[0])))
+ return float((file("/proc/uptime").read().split()[0]))
# replace simulator tags in output
def agent_simulator_process(output):
@@ -18,20 +18,24 @@ def agent_simulator_process(output):
simfunc = output[i+2 : e]
replacement = str(eval("agentsim_" + simfunc))
output = output[:i] + replacement + output[e+1:]
- except:
- pass
+ except Exception, e:
+ if opt_debug:
+ raise
return output
def agentsim_uptime(rate = 1.0, period = None): # period = sinus wave
if period == None:
- return our_uptime() * rate
+ return int(our_uptime() * rate)
else:
a = (rate * period) / (2.0 * math.pi)
u = our_uptime()
- return u * rate + int(a * math.sin(u / (2.0 * math.pi * period)))
+ return int(u * rate + int(a * math.sin(u * 2.0 * math.pi / period)))
def agentsim_enum(values, period = 1): # period is in seconds
- hit = our_uptime() / period % len(values)
+ hit = int(our_uptime()) / period % len(values)
return values[hit]
+def agentsim_sinus(base = 50, amplitude = 50, period = 300):
+ return math.sin(our_uptime() * 2.0 * math.pi / period) * amplitude + base
+