Skip to content

Commit a28659b

Browse files
author
Daniel Abercrombie
authored
Merge pull request #122 from phylsix/master
workflowmonit
2 parents 92cc6b5 + b3007eb commit a28659b

18 files changed

Lines changed: 1222 additions & 5 deletions

.travis.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
language: python
2-
cache: pip
32
python: 2.7
43
dist: trusty
54
services:
@@ -8,4 +7,4 @@ env: TMPDIR=$PWD/tmp
87
install:
98
- python setup.py install
109
script:
11-
- opsspace-test
10+
- package=workflowwebtools opsspace-test

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Welcome to WorkflowWebTools!
1414
machine_learning
1515
python_modules
1616
javascript
17+
workflowmonit
1718
troubleshooting
1819

1920
Indices and tables

docs/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ sphinx
22
sphinx_rtd_theme
33
sphinxcontrib-programoutput
44
sphinxcontrib-autoanysrc
5+
-r ../workflowmonit/requirements.txt

docs/workflowmonit.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.. include:: ../workflowmonit/README.rst

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
'templates/*']
1919
},
2020
install_requires=[
21-
'cmstoolbox',
21+
'cmstoolbox>=0.11.3',
2222
'more-itertools<6.0.0',
2323
'cherrypy<18.0.0',
2424
'mako',

workflowmonit/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
*.json
2+
*.yml
3+
*.sqlite
4+
test*

workflowmonit/README.rst

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
workflowmonit
2+
-------------
3+
4+
Component which periodically fetches information of workflows in the system(list extracted from Unified database), process and organizes into static documents, then sends to CMSMONIT service via :py:mod:`workflowmonit.stompAMQ` for storage, monitoring and post-aggregation.
5+
6+
- :ref:`usedApi-ref`
7+
- Composition
8+
- :ref:`wmCollector-ref`
9+
- :ref:`wmSender-ref`
10+
- :ref:`wmScheduler-ref`
11+
- :ref:`wmStompAMQ-ref`
12+
- :ref:`wmDocExample-ref`
13+
14+
.. _usedApi-ref:
15+
16+
Used APIs
17+
~~~~~~~~~
18+
19+
- wmstatserver:
20+
- https://cmsweb.cern.ch/wmstatsserver/data/jobdetail/
21+
- https://cmsweb.cern.ch/wmstatsserver/data/request/
22+
- couchdb:
23+
- https://cmsweb.cern.ch/couchdb/acdcserver/_design/ACDC/_view/byCollectionName/
24+
25+
26+
.. _wmCollector-ref:
27+
28+
workflowCollector
29+
~~~~~~~~~~~~~~~~~
30+
31+
.. automodule:: workflowmonit.workflowCollector
32+
:members:
33+
34+
35+
.. _wmSender-ref:
36+
37+
sendToMonit
38+
~~~~~~~~~~~
39+
40+
.. automodule:: workflowmonit.sendToMonit
41+
:members:
42+
43+
44+
.. _wmScheduler-ref:
45+
46+
workflowMonitScheduler
47+
~~~~~~~~~~~~~~~~~~~~~~
48+
49+
Schedule the ``main`` function of :ref:`wmSender-ref` every hour with :py:mod:`schedule`::
50+
51+
import workflowmonit.sendToMonit as wms
52+
schedule.every().hour.do(wms.main)
53+
while True:
54+
schedule.run_pending()
55+
time.sleep(1)
56+
57+
58+
.. _wmStompAMQ-ref:
59+
60+
stompAMQ
61+
~~~~~~~~
62+
63+
.. automodule:: workflowmonit.stompAMQ
64+
:members:
65+
66+
67+
.. _wmDocExample-ref:
68+
69+
Document examples
70+
~~~~~~~~~~~~~~~~~
71+
72+
1. document describling a single workflow `example1 <http://wsi.web.cern.ch/wsi/public/toSaveExample4.json>`_
73+
2. document wrapped by ``stompAMQ`` as a batch `example2.1 <http://wsi.web.cern.ch/wsi/public/godummy2.json>`_, `example2.2 <http://wsi.web.cern.ch/wsi/public/amqMsg_190208-201142.json>`_
74+
3. document sent out by ``stomp`` (what ``stompAMQ`` wrapped around) `example3 <http://wsi.web.cern.ch/wsi/public/bab2ef60-b0f2-4b55-9434-95a9cfd00510.json>`_

workflowmonit/__init__.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
"""
2+
WorkflowWebTools workflowmonit module
3+
4+
:author: Weinan Si <weinan.si@cern.ch>
5+
"""
6+
7+
__version__ = '0.0.1'
8+
9+
__all__ = []

workflowmonit/configLogging.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
version: 1
2+
formatters:
3+
simple:
4+
format: '%(asctime)s - %(levelname)s - %(module)s.%(funcName)s - %(message)s'
5+
handlers:
6+
console:
7+
class: logging.StreamHandler
8+
level: INFO
9+
formatter: simple
10+
stream: ext://sys.stdout
11+
agentmonit:
12+
class: logging.FileHandler
13+
level: INFO
14+
formatter: simple
15+
filename: agentmonit.log
16+
workflowmonit:
17+
class: logging.FileHandler
18+
level: INFO
19+
formatter: simple
20+
filename: workflowmonit.log
21+
loggers:
22+
agentmonitLogger:
23+
level: INFO
24+
handlers: [agentmonit]
25+
propagate: no
26+
workflowmonitLogger:
27+
level: INFO
28+
handlers: [workflowmonit]
29+
propagate: no
30+
root:
31+
level: DEBUG
32+
handlers: [console]

workflowmonit/dumpWfStatusDb.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/user/bin/env python
2+
import os
3+
import sys
4+
import sqlite3
5+
6+
import workflowmonit.workflowCollector as wc
7+
8+
CONFIG_FILE_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'config.yml')
9+
10+
def main():
11+
12+
config = wc.get_yamlconfig(CONFIG_FILE_PATH)
13+
if not config:
14+
sys.exit('Config file: {} not exist, exiting..'.format(CONFIG_FILE_PATH))
15+
dbPath = config.get(
16+
'workflow_status_db',
17+
os.path.join(os.path.dirname(os.path.abspath(__file__)), 'workflow_status.sqlite')
18+
)
19+
20+
conn = sqlite3.connect(dbPath)
21+
with conn:
22+
c = conn.cursor()
23+
for row in c.execute("SELECT * FROM workflowStatuses WHERE status='running-open' ORDER BY failurerate"):
24+
print('[ {1:^15} ]\t{2:.6f}\t{0}'.format(*row))
25+
26+
if __name__ == "__main__":
27+
main()

0 commit comments

Comments
 (0)