Skip to content
This repository
Browse code

Renamed watchdog -> monitoring

  • Loading branch information...
commit ee37b1bf5f53190c602d78d165bbb97c19b430fe 1 parent cf5c09e
Sébastien Pierre authored January 23, 2013
21  Contrib/monitoring_upstart.conf
... ...
@@ -0,0 +1,21 @@
  1
+# upstart - Monitoring Configuration File
  2
+# ========================================
  3
+# updated: 2011-02-28
  4
+
  5
+description "Monitoring - service monitoring daemon"
  6
+author      "Sebastien Pierre <sebastien@ffctn.com>"
  7
+
  8
+start on (net-device-up and local-filesystems)
  9
+stop  on runlevel [016]
  10
+
  11
+respawn
  12
+console output
  13
+
  14
+script
  15
+	# NOTE: Change this to wherever the monitoring is installed
  16
+	MONITORING_HOME=/opt/services/monitoring
  17
+	cd $MONITORING_HOME
  18
+	# NOTE: Change this to wherever your custom monitoring script is installed
  19
+    python $MONITORING_HOME/monitoring.py
  20
+end script
  21
+# EOF
21  Contrib/watchdog_upstart.conf
... ...
@@ -1,21 +0,0 @@
1  
-# upstart - Watchdog Configuration File
2  
-# ========================================
3  
-# updated: 2011-02-28
4  
-
5  
-description "Watchdog - service monitoring daemon"
6  
-author      "Sebastien Pierre <sebastien@ffctn.com>"
7  
-
8  
-start on (net-device-up and local-filesystems)
9  
-stop  on runlevel [016]
10  
-
11  
-respawn
12  
-console output
13  
-
14  
-script
15  
-	# NOTE: Change this to wherever the watchdog is installed
16  
-	DAEMONWATCH_HOME=/opt/services/watchdog
17  
-	cd $DAEMONWATCH_HOME
18  
-	# NOTE: Change this to wherever your custom watchdog script is installed
19  
-    python $DAEMONWATCH_HOME/watchdog.py
20  
-end script
21  
-# EOF
28  ERROR
... ...
@@ -0,0 +1,28 @@
  1
+Exception in thread Thread-138266:
  2
+Traceback (most recent call last):
  3
+ File "/usr/lib/python2.7/threading.py", line 552, in __bootstrap_inner
  4
+   self.run()
  5
+ File "/usr/lib/python2.7/threading.py", line 505, in run
  6
+   self.__target(*self.__args, **self.__kwargs)
  7
+ File "/opt/lib/python/monitoring.py", line 1198, in _run
  8
+   self.result = self.runnable.run(*self.args)
  9
+ File "/opt/lib/python/monitoring.py", line 974, in run
  10
+   pid = Process.GetWith(self.command)
  11
+ File "/opt/lib/python/monitoring.py", line 281, in GetWith
  12
+   if compare(cmdline, expression):
  13
+ File "/opt/lib/python/monitoring.py", line 275, in <lambda>
  14
+   def GetWith(self, expression, compare=(lambda a, b: fnmatch.fnmatch(a, b))):
  15
+ File "/usr/lib/python2.7/fnmatch.py", line 43, in fnmatch
  16
+   return fnmatchcase(name, pat)
  17
+ File "/usr/lib/python2.7/fnmatch.py", line 79, in fnmatchcase
  18
+   return _cache[pat].match(name) is not None
  19
+TypeError: expected string or buffer
  20
+
  21
+Traceback (most recent call last):
  22
+ File "/opt/apps/ngsexplorers/monitoring.conf", line 42, in <module>
  23
+   Run("echo '' > /tmp/monitoring-default.log","/tmp")
  24
+ File "/opt/lib/python/monitoring.py", line 1274, in run
  25
+   runner = self.runnerForRule(rule, service, self.iteration)
  26
+ File "/opt/lib/python/monitoring.py", line 1244, in runnerForRule
  27
+   if iteration - runner.iteration < 5:
  28
+AttributeError: 'bool' object has no attribute 'iteration'
4  Examples/example-service-isrunning.py
... ...
@@ -1,4 +1,4 @@
1  
-from watchdog import *
  1
+from monitoring import *
2 2
 __doc__ = """How to ensure that a given (HTTP) service stays up and running."""
3 3
 Monitor(
4 4
 	Service(
@@ -18,7 +18,7 @@
18 18
 							# We kill the 'myservice-start.py' script if it exists
19 19
 							# and (re)start it, so that the 'http://localhost:8000' will
20 20
 							# become available
21  
-							# NOTE: Restart will make the process a child of the watchdog, so
  21
+							# NOTE: Restart will make the process a child of the monitoring, so
22 22
 							# you might prefer to use something like upstart
23 23
 							Restart("myservice-start.py")
24 24
 						]
4  Examples/example-service-monitoring.py
... ...
@@ -1,11 +1,11 @@
1 1
 #!/usr/bin/env python
2  
-from watchdog import *
  2
+from monitoring import *
3 3
 Monitor(
4 4
 	Service(
5 5
 		name = "google-search-latency",
6 6
 		monitor = (
7 7
 			HTTP(
8  
-				GET="http://www.google.ca/search?q=watchdog",
  8
+				GET="http://www.google.ca/search?q=monitoring",
9 9
 				freq=Time.s(1),
10 10
 				timeout=Time.ms(80),
11 11
 				fail=[
4  Examples/example-system-health.py
... ...
@@ -1,4 +1,4 @@
1  
-from watchdog import *
  1
+from monitoring import *
2 2
 Monitor (
3 3
 	Service(
4 4
 		name    = "system-health",
@@ -18,7 +18,7 @@
18 18
 			SystemHealth(
19 19
 				cpu=0.90, disk=0.90, mem=0.90,
20 20
 				freq=Time.s(60),
21  
-				fail=[Log(path="watchdog-system-failures.log")]
  21
+				fail=[Log(path="monitoring-system-failures.log")]
22 22
 			),
23 23
 		)
24 24
 	)
8  Makefile
... ...
@@ -1,4 +1,4 @@
1  
-# Watchdog makefile
  1
+# Monitoring makefile
2 2
 # --------------------
3 3
 #
4 4
 # Revision 1.5.1 (24-Mar-2006)
@@ -24,7 +24,7 @@
24 24
 # Project variables___________________________________________________________
25 25
 #
26 26
 # Project name. Do not put spaces.
27  
-PROJECT         = watchdog
  27
+PROJECT         = monitoring
28 28
 PROJECT_VERSION = $(shell grep __version__ Sources/*.py | cut -d'"' -f2)
29 29
 
30 30
 DOCUMENTATION   = Documentation
@@ -38,10 +38,10 @@ DISTROCONTENT   = $(DOCUMENTATION) $(SOURCES) $(TESTS) $(RESOURCES) \
38 38
 
39 39
 # Project files_______________________________________________________________
40 40
 
41  
-PACKAGE = watchdog
  41
+PACKAGE = monitoring
42 42
 MAIN    = 
43 43
 MODULES = \
44  
-	watchdog \
  44
+	monitoring \
45 45
 
46 46
 TEST_MAIN       = $(TESTS)/$(PROJECT)Test.py
47 47
 SOURCE_FILES    = $(shell find $(SOURCES) -name "*.py")
15  README.rst
Source Rendered
... ...
@@ -1,8 +1,13 @@
1  
-Watchdog - Server monitoring and data-collection daemon
  1
+Monitoring - Server monitoring and data-collection daemon
2 2
 ==========================================================
3 3
 
4  
-We want...
5  
-----------
  4
+Monitoring is an API with a DSL feel to write monitoring daemons
  5
+in Python.
  6
+
  7
+Use cases
  8
+---------
  9
+
  10
+Monitoring works well for the following tasks:
6 11
 
7 12
 * to be notified when incidents happen (email, XMPP, ZeroMQ...)
8 13
 * automatic actions to be taken (restart, rm, git pull...)
@@ -38,11 +43,11 @@ python setup.py install
38 43
 or
39 44
 
40 45
 ```
41  
-easy_install watchdog
  46
+easy_install monitoring
42 47
 ```
43 48
 
44 49
 More?
45 50
 -----
46 51
 
47  
-Read the `presentation on Watchdog <http://ur1.ca/45ku5>`_ (previously named
  52
+Read the `presentation on Monitoring <http://ur1.ca/45ku5>`_ (previously named
48 53
 Watchdog).
3  Scripts/monitoring
... ...
@@ -0,0 +1,3 @@
  1
+#!/usr/bin/python
  2
+import sys, monitoring
  3
+monitoring.command(sys.argv[1:])
3  Scripts/watchdog
... ...
@@ -1,3 +0,0 @@
1  
-#!/usr/bin/python
2  
-import sys, watchdog
3  
-watchdog.command(sys.argv[1:])
26  Sources/watchdog.py → Sources/monitoring.py
... ...
@@ -1,6 +1,6 @@
1 1
 #!/usr/bin/env python
2 2
 # -----------------------------------------------------------------------------
3  
-# Project           :   Watchdog
  3
+# Project           :   Monitoring
4 4
 # -----------------------------------------------------------------------------
5 5
 # Author            :   Sebastien Pierre                  <sebastien@ffctn.com>
6 6
 # License           :   Revised BSD Licensed
@@ -27,9 +27,9 @@
27 27
 
28 28
 #  File "sample-reporter.py", line 35, in <module>
29 29
 #    fail    = [SendStat(ADKIT_STATSERVICE, "mediaserver.ms-1.failure")]
30  
-#  File "/home/sebastien/Projects/Local/lib/python/watchdog.py", line 669, in run
  30
+#  File "/home/sebastien/Projects/Local/lib/python/monitoring.py", line 669, in run
31 31
 #    Runner(rule,context=service,iteration=self.iteration).onRunEnded(self.onRuleEnded).run()
32  
-#  File "/home/sebastien/Projects/Local/lib/python/watchdog.py", line 620, in run
  32
+#  File "/home/sebastien/Projects/Local/lib/python/monitoring.py", line 620, in run
33 33
 #    self._thread.start()
34 34
 #  File "/usr/lib/python2.6/threading.py", line 474, in start
35 35
 #    _start_new_thread(self.__bootstrap, ())
@@ -188,7 +188,7 @@ def setup(self):
188 188
 					signal.signal(getattr(signal, sig), self._shutdown)
189 189
 					self.signalsRegistered.append(sig)
190 190
 				except Exception, e:
191  
-					Logger.Err("[!] watchdog.Signals._registerSignals:%s %s\n" % (sig, e))
  191
+					Logger.Err("[!] monitoring.Signals._registerSignals:%s %s\n" % (sig, e))
192 192
 
193 193
 	def _shutdown(self, *args):
194 194
 		"""Safely executes the callbacks registered in self.onShutdown."""
@@ -784,7 +784,7 @@ def successMessage(self, monitor, service, rule, runner):
784 784
 		return "%s %s %s" % (self.preamble(monitor, service, rule, runner), self.message, self.extractor(runner.result.value, runner))
785 785
 
786 786
 
787  
-class LogWatchdogStatus(Log):
  787
+class LogMonitoringStatus(Log):
788 788
 
789 789
 	def __init__(self, path=None, stdout=True, overwrite=False):
790 790
 		Log.__init__(self, path, stdout, overwrite)
@@ -848,7 +848,7 @@ def run(self, monitor, service, rule, runner):
848 848
 class Restart(Action):
849 849
 	"""Restarts the process with the given command, killing the process if it
850 850
 	already exists, starting it if it doesn't. Use this one with care as the
851  
-	process will become a child of the watchdog -- it's better to use
  851
+	process will become a child of the monitoring -- it's better to use
852 852
 	start/stop scripts if the process is long-running."""
853 853
 
854 854
 	def __init__(self, command, cwd=None):
@@ -901,7 +901,7 @@ def run(self, monitor, service, rule, runner):
901 901
 
902 902
 	def send(self, monitor=None, service=None, rule=None, runner=None):
903 903
 		server = smtplib.SMTP(self.host)
904  
-		origin = self.origin or "<Watchdog for %s> watchdog@%s" % (service and service.name, popen("hostname")[:-1])
  904
+		origin = self.origin or "<Monitoring for %s> monitoring@%s" % (service and service.name, popen("hostname")[:-1])
905 905
 		message = string.Template(self.MESSAGE).safe_substitute({
906 906
 			"from": origin,
907 907
 			"to": self.recipient,
@@ -1051,7 +1051,7 @@ def run(self, monitor, service, rule, runner):
1051 1051
 class Rule:
1052 1052
 	"""Rules return either a Sucess or Failure when run, and take actions
1053 1053
 	as 'fail' or 'success' arguments, which will be triggered by the
1054  
-	watchdog service."""
  1054
+	monitoring service."""
1055 1055
 
1056 1056
 	COUNT = 0
1057 1057
 
@@ -1344,7 +1344,7 @@ def getAction(self, nameOrAction):
1344 1344
 # -----------------------------------------------------------------------------
1345 1345
 
1346 1346
 class Pool:
1347  
-	"""Pools are used in Watchdog to limit the number of runners/rules executed
  1347
+	"""Pools are used in Monitoring to limit the number of runners/rules executed
1348 1348
 	at once. Pools have a maximum capacity, so that you can limit the numbers
1349 1349
 	of elements you create."""
1350 1350
 
@@ -1422,7 +1422,7 @@ def __init__(self, runable, context=None, iteration=None, pool=None, id=None):
1422 1422
 		self.id           = id
1423 1423
 		self._thread      = threading.Thread(target=self._run)
1424 1424
 		# We want the threads to be "daemonic", ie. they will all stop once
1425  
-		# the main watchdog stops.
  1425
+		# the main monitoring stops.
1426 1426
 		# SEE: http://docs.python.org/release/2.5.2/lib/thread-objects.html
1427 1427
 		self._thread.setDaemon(True)
1428 1428
 
@@ -1474,7 +1474,7 @@ def _run(self):
1474 1474
 # -----------------------------------------------------------------------------
1475 1475
 
1476 1476
 class Monitor:
1477  
-	"""The monitor is at the core of the Watchdog. Rules declared in registered
  1477
+	"""The monitor is at the core of the Monitoring. Rules declared in registered
1478 1478
 	services are run, and actions are executed according to the result."""
1479 1479
 
1480 1480
 	FREQUENCY = Time.s(5)
@@ -1484,7 +1484,7 @@ def __init__(self, *services):
1484 1484
 		self.services              = []
1485 1485
 		self.isRunning             = False
1486 1486
 		self.freq                  = self.FREQUENCY
1487  
-		self.logger                = Logger(prefix="watchdog ")
  1487
+		self.logger                = Logger(prefix="monitoring ")
1488 1488
 		self.iteration             = 0
1489 1489
 		self.iterationLastDuration = 0
1490 1490
 		self.runners               = {}
@@ -1639,7 +1639,7 @@ def getStatusMessage(self):
1639 1639
 
1640 1640
 def command(args):
1641 1641
 	if len(args) != 1:
1642  
-		print "Usage: watchdog FILE"
  1642
+		print "Usage: monitoring FILE"
1643 1643
 	else:
1644 1644
 		with file(args[0],"r") as f:
1645 1645
 			exec f.read() 
4  Tests/test-action-email.py
... ...
@@ -1,10 +1,10 @@
1 1
 #!/usr/bin/env python
2  
-from watchdog import *
  2
+from monitoring import *
3 3
 import json
4 4
 config = json.loads(file("email.passwd").read())
5 5
 action = Email(
6 6
 	"sebastien@ffctn.com",
7  
-	"[Watchdog] Test", "Sample message", 
  7
+	"[Monitoring] Test", "Sample message", 
8 8
 	config["smtp"],config["user"],config["password"]
9 9
 )
10 10
 Monitor(
2  Tests/test-action-incident.py
... ...
@@ -1,5 +1,5 @@
1 1
 #!/usr/bin/env python
2  
-from watchdog import *
  2
+from monitoring import *
3 3
 __doc__ = """
4 4
 Fail every second, and only triggers the log result after at least 5 failures over 10 seconds
5 5
 """
4  Tests/test-action-xmpp.py
... ...
@@ -1,10 +1,10 @@
1 1
 #!/usr/bin/env python
2  
-from watchdog import *
  2
+from monitoring import *
3 3
 import json
4 4
 config = json.loads(file("jabber.passwd").read())
5 5
 action = XMPP(
6 6
 	"sebastien@ffctn.com",
7  
-	"Watchdog: testing iteration #${iteration}@${timestamp}=${result}",
  7
+	"Monitoring: testing iteration #${iteration}@${timestamp}=${result}",
8 8
 	config["user"], config["password"]
9 9
 )
10 10
 Monitor(
4  Tests/test-looping-action.py
... ...
@@ -1,10 +1,10 @@
1 1
 #!/usr/bin/env python
2  
-from   watchdog import *
  2
+from   monitoring import *
3 3
 import time
4 4
 
5 5
 __doc__ = """
6 6
 In this test we create a LoopingAction (an action that will never end). We want
7  
-to make sure that at the third iteration the watchdog won't be able to start
  7
+to make sure that at the third iteration the monitoring won't be able to start
8 8
 the LoopingAction.
9 9
 """
10 10
 
13  setup.py
@@ -3,20 +3,21 @@
3 3
 # See: <http://docs.python.org/distutils/introduction.html>
4 4
 from distutils.core import setup
5 5
 import os, sys
6  
-VERSION = eval(filter(lambda _:_.startswith("__version__"), file("Sources/watchdog.py").readlines())[0].split("=")[1])
  6
+VERSION = eval(filter(lambda _:_.startswith("__version__"), file("Sources/monitoring.py").readlines())[0].split("=")[1])
7 7
 setup(
8  
-	name             = "watchdog",
  8
+	name             = "monitoring",
9 9
 	version          = VERSION,
10 10
 	description      = "Server monitoring and data-collection daemon",
11 11
 	author           = "Sébastien Pierre",
12 12
 	author_email     = "sebastien.pierre@gmail.com",
13  
-	url              = "http://github.com/sebastien/watchdog",
14  
-	download_url     = "https://github.com/sebastien/watchdog/tarball/%s" % (VERSION),
  13
+	url              = "http://github.com/sebastien/monitoring",
  14
+	download_url     = "https://github.com/sebastien/monitoring/tarball/%s" % (VERSION),
15 15
 	keywords         = ["daemon", "services", "monitoring", "administration"],
16 16
 	install_requires = [],
17 17
 	package_dir      = {"":"Sources"},
18  
-	py_modules       = ["watchdog"],
19  
-	scripts          = ["Scripts/watchdog"],
  18
+	py_modules       = ["monitoring"],
  19
+	scripts          = ["Scripts/monitoring"],
  20
+    license          = "License :: OSI Approved :: BSD License",
20 21
 	classifiers      = [
21 22
 		"Programming Language :: Python",
22 23
 		"Development Status :: 3 - Alpha",

0 notes on commit ee37b1b

Please sign in to comment.
Something went wrong with that request. Please try again.