Module: check_mk
Branch: master
Commit: 13f4cbae7b4d838dc0f0cdd939052efabe043136
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=13f4cbae7b4d83…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Fri Mar 11 13:32:47 2011 +0100
agent simulator: new function sinus()
---
modules/agent_simulator.py | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/modules/agent_simulator.py b/modules/agent_simulator.py
index ad27303..8ecffbc 100644
--- a/modules/agent_simulator.py
+++ b/modules/agent_simulator.py
@@ -1,5 +1,7 @@
#!/usr/bin/python
+import math
+
def our_uptime():
return int(float((file("/proc/uptime").read().split()[0])))
@@ -27,3 +29,10 @@ def agentsim_uptime(factor = 1.0):
def agentsim_enum(values, period = 1): # period is in seconds
hit = our_uptime() / period % len(values)
return values[hit]
+
+# rate: average rate counter is raised per second
+# period: period of sinus wave added to this (in seconds)
+def agentsim_sinus(rate = 1, period = 360):
+ a = (rate * period) / (2.0 * math.pi)
+ u = our_uptime()
+ return u * rate + int(a * math.sin(u / (2.0 * math.pi * period)))