Skip to content

Commit

Permalink
Renamed examples
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastien committed May 26, 2014
1 parent c4fac8d commit 6606cfd
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
@@ -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",
Expand Down
3 changes: 2 additions & 1 deletion Examples/example-service-isrunning.py → Examples/http-ping-restart.py 100644 → 100755
@@ -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
Expand Down
13 changes: 9 additions & 4 deletions Examples/example-system-health.py → Examples/system-health.py 100644 → 100755
@@ -1,24 +1,29 @@
#!/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())),
LogResult("myserver.system.cpu=", extract=lambda r,_:r["cpuUsage"]),
)
),
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")]
),
)
)
Expand Down

0 comments on commit 6606cfd

Please sign in to comment.