Site Support Team - Monitoring Scripts

In monitoring scripts, we get data from tools/systems, such as PhEDEx, SAM, HammerCloud, and reshape this data (depending on a specific criteria) for the main monitoring interface, dashboard/site status board(SSB), please see the graph fallowing:


For example, if you want to monitor tickets opened for sites, you can visit GGUS column (columns in the SSB are called metrics). In order to provide this metric, we use XML interface of GGUS. We get data from the GGUS interface and collect all tickets for sites. After collecting tickets, we feed the dashboard in its own input format. You can have a look at this simple text based tab separated input format, link.

Writing Script for an SSB Metric

New Directory Structure

We would like to inform you that we have new directory structure for metric scripts. All new metric scripts should be written in line with this new structure:
$ tree -d
├── certs    # files that are used to access authorization required pages are stored here
├── data     # input files, templates etc.
├── lib      # tiny module set
├── metrics  # metric scripts
│ ├── ggus
│ ├── hammerCloud
│ └── sam
├── old      # old scripts & files
│ ├── GGUS
├── output   # outputs should be written here
│ └── metrics
│     ├── ggus
│     ├── hammerCloud
│     └── sam
Please note that in the new structure, directory names start with lowercase so this can be used to understand whether a directory belongs to new structure or not. Whenever you start writing a metric script, please stick to the new structure and use tiny module set (we will talk about it later). Also, if you are rewriting an existing metric script, please move it into the old/ directory and code it in the new structure. Existing metric scripts, which are working fine, will keep staying in the repository, until they are rewritten (please have a look at the repository). It is obvious that this will make the migration smooth.

Tiny Module Set

In site support team, we have really simple and tiny module set that you can use while coding your new metric script. The point here is to avoid writing the same code again and again. This basic and simple programming approach will not only save you to write the same thing again but also support life cycle of your scripts. In future, you may need to add new abilities to the module set, please feel free to do so, but consider the generality, do not add metric specific abilities to the module set.

Module Description
dashboard contains dashboard color definitions and dashboard entry structure
sites site name parsers and funciton to get site list
fileOps for basic file ops(write and read)
url functions to basic content reading from web


>>> from lib import dashboard
>>> ## let's create a dashboard entry
>>> entry = dashboard.entry('2015-03-06 01:56:17', 'T1_DE_KIT', 100.0,, '#')
>>> entry
<lib.dashboard.entry instance at 0x7fe839e76368>
>>> print entry
2015-03-06 01:56:17	T1_DE_KIT	100.0	green	#
>>> ## if you pass None for the time stamp, current time will be used for this field
... ## it is also good to use defined colors for the color field
>>> entry = dashboard.entry(None, 'T1_DE_KIT', 90.0,, '#')
>>> entry
<lib.dashboard.entry instance at 0x7fe839e763b0>
>>> print entry
2015-03-06 14:29:37	T1_DE_KIT	90.0	red	#
>>> ## creating a metric
>>> url = ''
>>> entries = [dashboard.entry(None, 'T1_DE_KIT', 91.0,, url), dashboard.entry(None, 'T1_ES_PIC', 91.0,, url)]
>>> entries
[<lib.dashboard.entry instance at 0x7fe839e76440>, <lib.dashboard.entry instance at 0x7fe839e76488>]
>>> metric = "\n".join(str(row) for row in entries)
>>> print metric
2015-03-06 14:30:00	T1_DE_KIT	91.0	green
2015-03-06 14:30:00	T1_ES_PIC	91.0	green
>>> ## parsing a metric
>>> parsedMetric = dashboard.parseMetric(metric)
>>> parsedMetric
[<lib.dashboard.entry instance at 0x7fe839e76680>, <lib.dashboard.entry instance at 0x7fe839e767a0>]
>>> for i in parsedMetric: print i
2015-03-06 14:30:00	T1_DE_KIT	91.0	green
2015-03-06 14:30:00	T1_ES_PIC	91.0	green


>>> from lib import sites
>>> sites.isValidCMSSiteName('T1_DE_KIT')
>>> ## note that there is no sitedb check in the isValidCMSSiteName function
... ## it is only trying to match the given site name with the CMS site naming convention
>>> sites.isValidCMSSiteName('T2_AB_XYZ')
>>> sites.isValidCMSSiteName('T4_AB_XYZ')
>>> sites.parseSiteName('T1_DE_KIT')
('T1', 'DE', 'KIT')
>>> sites.parseSiteName('T2_RU_RRC_KI')
('T2', 'RU', 'RRC_KI')
>>> sites.parseSiteName('T4_AB_XYZ')
>>> sites.getTier('T1_DE_KIT')
>>> sites.getTier('T2_AT_Vienna')
>>> sites.getTier('T4_AB_XYZ')
>>> # let's get all site names from
... #
>>> cmsSites = sites.getSites()
>>> print cmsSites.keys()
['T3_US_PuertoRico', 'T2_FI_HIP', 'T2_UK_SGrid_RALPP', 'T2_FR_GRIF_LLR', 'T3_US_Baylor', 'T3_UK_London_QMUL', 'T3_TW_NTU_HEP', 'T3_US_UIowa', 'T2_KR_KNU', 'T2_RU_SINP', ...

lib.url & lib.fileOps

>>> from lib import url, fileOps
>>> fileOps.write('morgue.txt',''))
Write: morgue.txt
>>> morgue ='morgue.txt')
Read: morgue.txt
>>> print morgue
2015-03-06 14:35:15	T2_CH_CERN_T0	out	green
2015-03-06 14:35:15	T2_BR_UERJ	in	red
2015-03-06 14:35:15	T2_TR_METU	in	red
2015-03-06 14:35:15	T2_AT_Vienna	out	green

-- AliMehmetAltundag - 2015-03-05

Topic attachments
I Attachment History Action Size Date Who Comment
PNGpng dataflow.png r1 manage 10.2 K 2015-03-05 - 10:20 AliMehmetAltundag  
Edit | Attach | Watch | Print version | History: r9 < r8 < r7 < r6 < r5 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r9 - 2015-04-08 - AliMehmetAltundag
    • Cern Search Icon Cern Search
    • TWiki Search Icon TWiki Search
    • Google Search Icon Google Search

    CMSPublic All webs login

This site is powered by the TWiki collaboration platform Powered by PerlCopyright & 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback