Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: CMSCompOps/MonitoringScripts
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.4
Choose a base ref
...
head repository: CMSCompOps/MonitoringScripts
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Loading
Showing 346 changed files with 90,015 additions and 1,098 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*.pyc
*.tmp
*_.xml
output/
certs/
tmp/
42 changes: 42 additions & 0 deletions GGUS_SOAP/ggus.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import logging
from suds.client import Client
from suds.transport.http import HttpAuthenticated
from suds import WebFault

logging.basicConfig(level=logging.INFO)
logging.getLogger('suds.client').setLevel(logging.DEBUG)
client = Client('https://train-ars.ggus.eu/arsys/WSDL/public/train-ars/GGUS')
print client

class Ticket:
def __init__(self, site_name, subject, description):
self.site_name = site_name
self.subject = subject
self.description = description

def create(self):
person = client.factory.create('AuthenticationInfo')
person.userName = '********'
person.password = '********'
client.set_options(soapheaders=person)

result = client.service.TicketCreate(
#https://wiki.egi.eu/wiki/GGUS:SOAP_Interface_FAQ
#Mandatory fields
GHD_Submitter_Mail='email@email.com',
GHD_Loginname='YOUR DN',
GHD_Last_Login='user',
GHD_Last_Modifier='user',
GHD_Short_Description=self.subject,
GHD_Description=self.description,
GHD_Origin_ID='',
GHD_Origin_SG='CMSSST',
#Optional fields
GHD_Affected_Site=self.site_name,
GHD_Affected_VO='cms',
GHD_Responsible_Unit='TPM',
GHD_Status='new',
GHD_Name='NAME SURNAME',
GHD_Priority='urgent',
GHD_Type_Of_Problem='CMS_Facilities',
)
5 changes: 5 additions & 0 deletions GGUS_SOAP/init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

export SSTBASE=../
export PYTHONPATH="$PYTHONPATH:$SSTBASE"

101 changes: 101 additions & 0 deletions GGUS_SOAP/metric.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
from datetime import datetime, date, timedelta
from lib import dashboard, sites, url

from ggus import Ticket

# Reads a metric from SSB
def getJSONMetric(metricNumber, hoursToRead, sitesStr, sitesVar, dateStart="2000-01-01", dateEnd=datetime.now().strftime('%Y-%m-%d')):
urlstr = "http://dashb-ssb.cern.ch/dashboard/request.py/getplotdata?columnid=" + str(metricNumber) + "&time=" + str(hoursToRead) + "&dateFrom=" + dateStart + "&dateTo=" + dateEnd + "&site=" + sitesStr + "&sites=" + sitesVar + "&clouds=all&batch=1"
print urlstr
try:
metricData = url.read(urlstr)
return dashboard.parseJSONMetric(metricData)
except:
return None


def getJSONMetricforAllSitesForDate(metricNumber, dateStart, dateEnd):
return getJSONMetric(metricNumber, "custom", "", "all", dateStart, dateEnd)


waiting_room_subject = '%s was moved to the waiting room'
waiting_room_description = '''
Dear site admin,
%s was moved to the waiting room because of %s problems. Could you take a look?
https://cms-site-readiness.web.cern.ch/cms-site-readiness/SiteReadiness/HTML/SiteReadinessReport.html#%s
'''

#date_today = date.today()
date_today=date(2017,02,17)
print "NOW: %s" %date_today

date_yesterday = date_today + timedelta(days=-1)
print "YESTERDAY: %s" %date_yesterday

date_tomorrow = date_today + timedelta(days=1)
print "TOMORROW: %s" %date_tomorrow

life_status_metric=235
hc_metric=135
sam_metric=126
T1_T2_links_metric=78
T2_T1_links_metric=79

sam_results='http://wlcg-sam-cms.cern.ch/templates/ember/#/historicalsmry/heatMap?profile=CMS_CRITICAL_FULL&site=%s&time=24h&view=Test%%20History \n \n'
hc_results='http://dashb-cms-job.cern.ch/dashboard/templates/web-job2/#user=&refresh=0&table=Jobs&p=1&records=25&activemenu=1&usr=&site=%s&submissiontool=&application=&activity=hctest&status=&check=submitted&tier=&date1='+ str(date_yesterday) +'&date2='+ str(date_today) +'33&sortby=activity&scale=linear&bars=20&ce=&rb=&grid=&jobtype=&submissionui=&dataset=&submissiontype=&task=&subtoolver=&genactivity=&outputse=&appexitcode=&accesstype=&inputse=&cores= \n \n'
t1_t2_results='https://cmsweb.cern.ch/phedex/graphs/quality_all?link=link&no_mss=true&to_node=%s&from_node=T[01]&starttime='+ date_yesterday.strftime("%s") +'&span=3600&endtime='+ date_today.strftime("%s") +' \n \n'
t2_t1_results='https://cmsweb.cern.ch/phedex/graphs/quality_all?link=link&no_mss=true&to_node=T[01]&from_node=%s&starttime='+ date_yesterday.strftime("%s") +'&span=3600&endtime='+ date_today.strftime("%s") +' \n \n'
phedex_erros='https://cmsweb.cern.ch/phedex/prod/Activity::ErrorInfo?tofilter=%s&fromfilter=.*&report_code=.*&xfer_code=.*&to_pfn=.*&from_pfn=.*&log_detail=.*&log_validate=.*&.submit=Update \n \n'
sr_twiki='https://twiki.cern.ch/twiki/bin/view/CMS/SiteSupportSiteStatusSiteReadiness#Life_Status'

lifeStatus_metric_today = getJSONMetricforAllSitesForDate(life_status_metric, str(date_today), str(date_tomorrow))
lifeStatus_metric_yesterday = getJSONMetricforAllSitesForDate(life_status_metric, str(date_yesterday), str(date_today))
hc = getJSONMetricforAllSitesForDate(hc_metric, str(date_today), str(date_tomorrow))
sam = getJSONMetricforAllSitesForDate(sam_metric, str(date_today), str(date_tomorrow))
T2_T1_links = getJSONMetricforAllSitesForDate(T2_T1_links_metric, str(date_today), str(date_tomorrow))
T1_T2_links = getJSONMetricforAllSitesForDate(T1_T2_links_metric, str(date_today), str(date_tomorrow))


new_state_sites = []
for site in lifeStatus_metric_today.getSites():
if lifeStatus_metric_today.getLatestEntry(site).value != lifeStatus_metric_yesterday.getLatestEntry(site).value:
problems=[]
if hc.getLatestEntry(site):
if hc.getLatestEntry(site).color == 'red': problems.append("HammerCloud")
if sam.getLatestEntry(site):
if sam.getLatestEntry(site).color == 'red': problems.append("SAM")
if T2_T1_links.getLatestEntry(site):
if T2_T1_links.getLatestEntry(site).color == 'red': problems.append("T2_T1_links")
if T1_T2_links.getLatestEntry(site):
if T1_T2_links.getLatestEntry(site).color == 'red': problems.append("T1_T2_links")
item = {
"cms_name": site,
"name": sites.getSites()[site]['name'],
"new_status": lifeStatus_metric_today.getLatestEntry(site).value,
"old_status": lifeStatus_metric_yesterday.getLatestEntry(site).value,
"problems": ', '.join(problems)
}
new_state_sites.append(item)

for site in new_state_sites:
if site['new_status'] == "waiting_room":
subject = waiting_room_subject %(site['cms_name'])
description = waiting_room_description %(site['cms_name'], site['problems'], site['cms_name'])
if 'HammerCloud' in site['problems']:
description = description + hc_results % site['cms_name']
if 'SAM' in site['problems']:
description = description + sam_results % site['cms_name']
if "T2_T1_links" in site['problems']:
description = description + t2_t1_results % site['cms_name'] + phedex_erros % site['cms_name']
if "T1_T2_links" in site['problems']:
description = description + t1_t2_results % site['cms_name'] + phedex_erros % site['cms_name']
description = description + sr_twiki
print "SUBJECT: " + subject
print "TICKET DESCRIPTION: " + description
var = raw_input("If you want to create a ticket press - y, if not - n: \n")
if var == 'y':
ticket = Ticket(site['name'], subject, description)
ticket.create()
7 changes: 7 additions & 0 deletions GGUS_SOAP/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

# go to the path that contain this script
cd $(dirname $(readlink -f "${BASH_SOURCE[0]}"))
source ../../init.sh

python metric.py
7 changes: 7 additions & 0 deletions GGUS_SOAP/run_local.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

# go to the path that contain this script
cd $(dirname $(readlink -f "${BASH_SOURCE[0]}"))
source ./init.sh

python metric.py
8 changes: 0 additions & 8 deletions Pledges_View_SSB/Pledges_View_SSB.webloc

This file was deleted.

10 changes: 6 additions & 4 deletions Pledges_View_SSB/pledge/Readme.txt
Original file line number Diff line number Diff line change
@@ -2,12 +2,14 @@
Script for Dashboard metric 145: Pledge [cores] - obtains official pledge from SiteDB
Script responsible: John Artieda (artiedaj@fnal.gov)
output dir /afs/cern.ch/user/c/cmst1/www/SST/
output file pledge.txt
web https://cmst1.web.cern.ch/CMST1/SST/pledge.txt
output file pledges.txt
web https://cmst1.web.cern.ch/CMST1/SST/pledges.txt

—-
To run script:
not running in a cronjob
Run script manually when needed to update:
set up a proxy before running run_pledges.sh script
lxplus
source /afs/cern.ch/cms/LCG/LCG-2/UI/cms_ui_env.sh
voms-proxy-init -voms cms
voms-proxy-init -voms cms
X509_USER_PROXY=/tmp/x509up_u47967;export X509_USER_PROXY
1 change: 1 addition & 0 deletions Pledges_View_SSB/pledge/run_pledges.sh
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@ clear
#fixing access
source /afs/cern.ch/project/gd/LCG-share/new_3.2/etc/profile.d/grid_env.sh
voms-proxy-init -voms cms
X509_USER_PROXY=/tmp/x509up_u47967;export X509_USER_PROXY

# Email if things are running slowly

4 changes: 2 additions & 2 deletions Pledges_View_SSB/prod_cores/Readme.txt
Original file line number Diff line number Diff line change
@@ -6,5 +6,5 @@ output file prod.txt
web https://cmst1.web.cern.ch/CMST1/SST/prod.txt

—-
Script in acrontab jartieda
*/05 * * * * lxplus /afs/cern.ch/user/j/jartieda/MonitoringScripts/Pledges_View_SSB/prod_cores/run_prodcores.sh &> /dev/null
Script in acrontab cmst1
*/05 * * * * lxplus /afs/cern.ch/user/c/cmst1/scratch0/MonitoringScripts/Pledges_View_SSB/prod_cores/run_prodcores.sh &> /dev/null
22 changes: 16 additions & 6 deletions Pledges_View_SSB/prod_cores/prodcores.py
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
import json, time, string
#______________________get all datas from SSB___________________________
def getDatafromURL():
url='http://dashb-ssb.cern.ch/dashboard/request.py/getplotdata?columnid=136&time=24&dateFrom=&dateTo=&site=T0_CH_CERN&sites=all&clouds=undefined&batch=1';
url='http://dashb-ssb.cern.ch/dashboard/request.py/getplotdata?columnid=136&time=48&dateFrom=&dateTo=&site=T0_CH_CERN&sites=all&clouds=undefined&batch=1';
print "Getting the url %s" % url
obj = urllib2.urlopen(url)
data = obj.read()
@@ -18,20 +18,30 @@ def calculateProdCore(json):
jsonCodeEnd = ']}'
f = open(filename + ".txt", "w")
j = open(filename + ".json", "w")
for row in json['csvdata']:
sites = []
for row in json['csvdata']:
siteName = row['VOName']
sites.append(siteName)
sites = list(set(sites))
print sites
for row in json['csvdata']:
tierName = row['VOName'][0:2]
siteName = row['VOName']
if siteName in sites:
sites.remove(siteName)
else:
continue
value = row['Value']
status = row['Status']
color = row['COLORNAME']
#_______________Calculate Prod[Cores]____________________________
prodCore = 0 if value is None else value
if (tierName == 'T1'):
prodCore = int(int(prodCore) * 0.9)
prodCore = int(int(prodCore + 2) * 0.9)
elif (tierName == 'T3' or siteName == 'T2_CH_CERN_AI' or siteName == 'T2_CH_CERN_HLT' or siteName == 'T2_CH_CERN_T0'):
prodCore = int(int(prodCore) * 1)
prodCore = int(int(prodCore +1 ) * 1)
elif (tierName == 'T2'):
prodCore = int(int(prodCore) * 0.5)
prodCore = int(int(prodCore + 2) * 0.5)
if color == 'white':
prodCore = 'n/a'
jsonCode = jsonCode + "{" + '"siteName":"' + siteName + '", "prodCore":' + str(prodCore) + ',' + '"color":"' + color + '",' + '"url":"' + urll + '"},'
@@ -45,4 +55,4 @@ def calculateProdCore(json):
#__________________________________________________________________________________________________________
if __name__ == '__main__':
rows = getDatafromURL() #get all pledge from dashBoard SSB metric 136 (json)
calculateProdCore(rows)
calculateProdCore(rows)
48 changes: 24 additions & 24 deletions Pledges_View_SSB/prod_cores/run_prodcores.sh
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
#!/bin/bash
clear
location="/afs/cern.ch/user/j/jartieda/MonitoringScripts/Pledges_View_SSB/prod_cores"
location="/afs/cern.ch/user/c/cmst1/scratch0/MonitoringScripts/Pledges_View_SSB/prod_cores"
outputdir="/afs/cern.ch/user/c/cmst1/www/SST"
cd $location
# Email if things are running slowly
if [ -f scriptRunning.run ];
then
echo "run_prodcores.sh is already running. Will send an email to the admin."
# script to send simple email
# email subject
SUBJECT="[Prod[Cores]] load Prod[Cores]"
# Email To ?
EMAIL="artiedaj@fnal.gov, gokhan.kandemir@cern.ch"
# Email text/message
if [ -f emailmessage.txt ];
then
rm emailmessage.txt
fi
touch emailmessage.txt
EMAILMESSAGE="/tmp/emailmessage.txt"
echo "run_prodcores.sh is running to slowly."
# send an email using /bin/mail
/bin/mail -s "$SUBJECT" "$EMAIL" < $EMAILMESSAGE

echo "run_prodcores.sh is already running. Will send an email to the admin."
# script to send simple email
# email subject
SUBJECT="Prod[Cores] running slowly"
# Email To ?
EMAIL="artiedaj@fnal.gov"
# Email text/message
if [ -f emailmessage.txt ];
then
rm emailmessage.txt
fi
touch emailmessage.txt
EMAILMESSAGE="/tmp/emailmessage.txt"
echo "run_prodcores.sh is stuck!!"> $EMAILMESSAGE
echo $location >>$EMAILMESSAGE
# send an email using /bin/mail
/bin/mail -s "$SUBJECT" "$EMAIL" < $EMAILMESSAGE
else
echo "bash run_prodcores.sh succesfully"
touch scriptRunning.run
echo "bash run_prodcores.sh started succesfully"
touch scriptRunning.run
fi


#Run the script
txt="prod"
echo "python prodcores.py"
@@ -37,7 +37,7 @@ problem="$?"
echo "problem: $problem"
echo "The files were created succesfully."

cp $txt".txt" /afs/cern.ch/user/c/cmst1/www/SST
cp $txt".json" /afs/cern.ch/user/c/cmst1/www/SST
cp $txt".txt" $outputdir
cp $txt".json" $outputdir

rm scriptRunning.run
rm scriptRunning.run
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Site Support Team Monitoring Scripts
====================================
- Site Support Team (cms-comp-ops-site-support-team@cern.ch)
- If you are planning to write metric script, please visit [Monitoring Scripts](https://twiki.cern.ch/twiki/bin/view/CMSPublic/SiteSupportMonitoringScripts) twiki page
2 changes: 1 addition & 1 deletion SR_View_SSB/ActiveSites/ActiveSites.py
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@
import string

# Criteria
percentageThreshold = 0.6
percentageThreshold = 0.8

#T1+T2
#url = "http://dashb-ssb.cern.ch/dashboard/request.py/getsitereadinessrankdata?columnid=45&time=%s"
8 changes: 4 additions & 4 deletions SR_View_SSB/ActiveSites/Readme.txt
Original file line number Diff line number Diff line change
@@ -7,21 +7,21 @@ and that presently are in "active" status.

--- ACTIVE sites for SSB ---
SSB metric: 39 - Active T2s
Active Sites: SR >=60% last 1 week OR last 3 months
Active Sites: SR >=80% last 1 week OR last 3 months

--- WAITING ROOM LIST for SSB ---
Any site that is not in this list will be automatically moved to the Waiting Room.

--- INFO ---
# acronjob in acrontab jartieda
# acronjob in acrontab cmst1
# 00 08 * * 1 => Every monday at 8AM
# 00 08 * * 1 lxplus /afs/cern.ch/user/j/jartieda/MonitoringScripts/SR_View_SSB/ActiveSites/sActiveSites.sh &> /dev/null
# 00 08 * * 1 lxplus /afs/cern.ch/user/c/cmst1/scratch0/MonitoringScripts/SR_View_SSB/ActiveSites/sActiveSites.sh &> /dev/null

Script name:
sActiveSites.sh

Script Location:
/afs/cern.ch/user/j/jartieda/MonitoringScripts/SR_View_SSB/ActiveSites/
/afs/cern.ch/user/c/cmst1/scratch0/MonitoringScripts/SR_View_SSB/ActiveSites

Github repository:
https://github.com/CMSCompOps/MonitoringScripts/SR_View_SSB/ActiveSites/
Loading