diff --git a/Examples/example-service-monitoring.py b/Examples/http-latency.py similarity index 68% rename from Examples/example-service-monitoring.py rename to Examples/http-latency.py index e53282d..cf51836 100755 --- a/Examples/example-service-monitoring.py +++ b/Examples/http-latency.py @@ -1,8 +1,12 @@ #!/usr/bin/env python from monitoring import * +__doc__ = """ +Queries the Google search engin and fail if the query takes +more than 80ms. +""" Monitor( Service( - name = "google-search-latency", + name=__file__[0].split(".")[0], monitor = ( HTTP( GET="http://www.google.ca/search?q=monitoring", diff --git a/Examples/example-service-isrunning.py b/Examples/http-ping-restart.py old mode 100644 new mode 100755 similarity index 93% rename from Examples/example-service-isrunning.py rename to Examples/http-ping-restart.py index 5158e0b..eabba5d --- a/Examples/example-service-isrunning.py +++ b/Examples/http-ping-restart.py @@ -1,8 +1,9 @@ +#!/usr/bin/env python from monitoring import * __doc__ = """How to ensure that a given (HTTP) service stays up and running.""" Monitor( Service( - name="myservice-ensure-up", + name=__file__[0].split(".")[0], monitor=( HTTP( # We monitor the 'http://localhost:8000' URL, which is where diff --git a/Examples/example-system-health.py b/Examples/system-health.py old mode 100644 new mode 100755 similarity index 62% rename from Examples/example-system-health.py rename to Examples/system-health.py index 3e07366..eb97089 --- a/Examples/example-system-health.py +++ b/Examples/system-health.py @@ -1,9 +1,14 @@ +#!/usr/bin/env python from monitoring import * +__doc__ = """ +Shows how to periodically query a system's memory, disk & cpy usage +and logs to a file when the system metrics exceeds the values. +""" Monitor ( Service( - name = "system-health", + name=__file__[0].split(".")[0], monitor = ( - SystemInfo(freq=Time.s(1), + SystemInfo(freq=Time.s(5), success = ( LogResult("myserver.system.mem=", extract=lambda r,_:r["memoryUsage"]), LogResult("myserver.system.disk=", extract=lambda r,_:reduce(max,r["diskUsage"].values())), @@ -11,14 +16,14 @@ ) ), Delta( - Bandwidth("eth0", freq=Time.s(1)), + Bandwidth("eth0", freq=Time.s(5)), extract = lambda v:v["total"]["bytes"]/1000.0/1000.0, success = [LogResult("myserver.system.eth0.sent=")] ), SystemHealth( cpu=0.90, disk=0.90, mem=0.90, freq=Time.s(60), - fail=[Log(path="monitoring-system-failures.log")] + fail=[Log(path=__file__.split(".")[0] + "-errors.log")] ), ) )