Skip to content

Commit

Permalink
Moved to the new database table run2
Browse files Browse the repository at this point in the history
  • Loading branch information
coccetti committed Oct 27, 2016
1 parent 3d10ea0 commit 97971ab
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 26 deletions.
6 changes: 3 additions & 3 deletions apps/e3db.py
Expand Up @@ -72,7 +72,7 @@
logger.info('Query for the last run transferred at CNAF of each school')
query = ("SELECT station_name, run_date, run_id, bin_file_size, "
"transfer_timestamp, last_update "
"FROM runs WHERE station_name = %s "
"FROM runs2 WHERE station_name = %s "
"ORDER BY transfer_timestamp DESC LIMIT 1;")
logger.info('About to query: ' + query)
for _schoolName in schoolNames:
Expand All @@ -89,7 +89,7 @@
_beginTime = datetime.today().strftime("%Y-%m-%d") + " 00:00:00"
_endTime = datetime.today().strftime("%Y-%m-%d") + " 23:59:59"
logger.info('Query for the number of files transferred today')
query = ("SELECT COUNT(*) FROM runs "
query = ("SELECT COUNT(*) FROM runs2 "
"WHERE station_name = %s "
"AND (transfer_timestamp BETWEEN %s AND %s);")
logger.info('About to query: ' + query)
Expand Down Expand Up @@ -133,7 +133,7 @@
# Query for Statistics
logger.info('Query for statistics:')
logger.info('1. Query of the total number of Tracks')
query = ("SELECT SUM(num_track_events) from runs WHERE (run_date >= %s AND run_date <= %s);")
query = ("SELECT SUM(num_track_events) from runs2 WHERE (run_date >= %s AND run_date <= %s);")
queryParam = (startRunStr, todayStr)
cur.execute(query, queryParam)
try:
Expand Down
2 changes: 1 addition & 1 deletion apps/e3dbstat.py
Expand Up @@ -64,7 +64,7 @@ def enumerate_month_dates(start_date, end_date):

# Query for the number of tracks every month
logger.info('Queries of the total number of Tracks')
query = "SELECT SUM(num_track_events) from runs WHERE (run_date >= %s AND run_date <= %s);"
query = "SELECT SUM(num_track_events) from runs2 WHERE (run_date >= %s AND run_date <= %s);"
logger.info("Exec loop: " + query)
for _firstDay, _lastDay in enumerate_month_dates(startRun, today):
_lastDayStr = _lastDay.strftime("%Y-%m-%d")
Expand Down
2 changes: 1 addition & 1 deletion apps/e3plotstat.py
Expand Up @@ -93,7 +93,7 @@
ax.plot_date(dates, ntracks, color='#0088CC', linestyle='dotted', marker='o')
fig.autofmt_xdate()
fig.savefig(pathSaveFig + 'tracks.png')
logger.info("Plot saved in " + str(pathSaveFig) + 'tracksStat.png')
logger.info("Plot saved in " + str(pathSaveFig) + 'tracks.png')

#
# Make the webpage
Expand Down
4 changes: 2 additions & 2 deletions config/__files_server__.py
Expand Up @@ -65,8 +65,8 @@
pathWorkDir = '/opt/eee/e3monitor_work'

# Path of Dqm and Dqmreport
pathDqm = "/var/www/html/monitor/dqm"
pathDqmreport = "/var/www/html/monitor/dqmreport"
pathDqm = "/var/www/html/monitor/dqm2"
pathDqmreport = "/var/www/html/monitor/dqmreport2"

# Path of the directory where we save transferred files plots
pathSaveFig = '/var/www/html/monitor/plots/'
Expand Down
2 changes: 1 addition & 1 deletion stats/e3sTrackDayStation.py
Expand Up @@ -67,7 +67,7 @@ def daterange(start_date, end_date):

# Query for the number of tracks every month
logger.info('Queries of the total number of Tracks')
query = "SELECT SUM(num_track_events) from runs WHERE (run_date = %s) AND station_name = %s;"
query = "SELECT SUM(num_track_events) from runs2 WHERE (run_date = %s) AND station_name = %s;"
logger.info("Exec loop: " + query)
for _lastDay in daterange(startRun, endRun):
_lastDayStr = _lastDay.strftime("%Y-%m-%d")
Expand Down
2 changes: 1 addition & 1 deletion stats/e3sTracksMonthStation.py
Expand Up @@ -74,7 +74,7 @@ def enumerate_month_dates(start_date, end_date):

# Query for the number of tracks every month
logger.info('Queries of the total number of Tracks')
query = "SELECT SUM(num_track_events) from runs WHERE (run_date >= %s AND run_date <= %s) AND station_name = %s;"
query = "SELECT SUM(num_track_events) from runs2 WHERE (run_date >= %s AND run_date <= %s) AND station_name = %s;"
logger.info("Exec loop: " + query)
for _firstDay, _lastDay in enumerate_month_dates(startRun, endRun):
_lastDayStr = _lastDay.strftime("%Y-%m-%d")
Expand Down
6 changes: 3 additions & 3 deletions tasks/make_webpage_index.py
Expand Up @@ -215,12 +215,12 @@ def make_webpage_index(monitorData,
try:
_dqmreportTs = datetime.strptime(
monitorData.get_dqmreportTs(schoolName), '%Y-%m-%d')
w.write('<a href=\"dqmreport/' + schoolName + '/')
w.write('<a href=\"dqmreport2/' + schoolName + '/')
w.write(monitorData.get_dqmreportTs(schoolName))
w.write('/\">')
w.write(_dqmreportTs.strftime("%d/%m"))
w.write('</a> <br />')
w.write('<a href =\"dqmreport/' + schoolName + '/?C=M;O=D\">')
w.write('<a href =\"dqmreport2/' + schoolName + '/?C=M;O=D\">')
w.write('[History]')
w.write('</a>')
except:
Expand Down Expand Up @@ -267,7 +267,7 @@ def make_webpage_index(monitorData,

# Print link to DMQ directory
w.write('<td>')
w.write('<a href=\"dqm/' + schoolName + '/?C=M;O=D\">')
w.write('<a href=\"dqm2/' + schoolName + '/?C=M;O=D\">')
w.write(schoolName)
w.write('</a>')
w.write('</td>')
Expand Down
2 changes: 1 addition & 1 deletion tasks/read_dqmreport.py
Expand Up @@ -9,7 +9,7 @@

def read_dqmreport(schoolNamesList, pathDqmreport):
''' Find directory for the last daily dqmreport
the format is: dqmreport/ALTA-01/2014-11-12/index.html
the format is: dqmreport2/ALTA-01/2014-11-12/index.html
'''
lastDqmreport = {}
schoolsDqmreportList = []
Expand Down
47 changes: 34 additions & 13 deletions tasks/report_write.py
Expand Up @@ -35,6 +35,7 @@ def report_write(reportData,
# Array of schools with no problems
schoolsOk = []
schoolsTrackRed = []
schoolsTrackYellow = []
schoolsTransferRed = []
schoolsTransferYellow = []
schoolsElog = []
Expand Down Expand Up @@ -70,6 +71,9 @@ def report_write(reportData,
# Check stations: if transfer is fine then track rate Red
elif (reportData.get_trackStatus(schoolName) == -2):
schoolsTrackRed.append(schoolName)
# Check stations: if transfer is fine then track rate yellow
elif (reportData.get_trackStatus(schoolName) == -1):
schoolsTrackYellow.append(schoolName)

# Check stations: elog Red
if (reportData.get_elogEntryStatus(schoolName) == 2):
Expand Down Expand Up @@ -119,16 +123,30 @@ def report_write(reportData,
w.write('Nessun telescopio mi risulta attivo, deve esserci un errore di sistema o un problema al CNAF.\n')

################################################
# Write the list of schools with track very low (red)
# Write the list of schools with track rate yellow (yellow)
################################################
if len(schoolsTrackYellow) > 1:
w.write('- Ci sono ')
w.write(str(len(schoolsTrackYellow)))
w.write(' telescopi in trasmissione, con un rate di acquisizione delle tracce minore di 10 Hz:\n')
w.write(', '.join(map(str, schoolsTrackYellow)))
w.write('.\n\n')
elif len(schoolsTrackYellow) == 1:
w.write('- C\'e\' un telescopio in trasmissione, con un rate di acquisizione delle tracce minore di 10 Hz:\n')
w.write(schoolsTrackYellow[0])
w.write('.\n\n')

################################################
# Write the list of schools with track rate very low (red)
################################################
if len(schoolsTrackRed) > 1:
w.write('- Ci sono ')
w.write(str(len(schoolsTrackRed)))
w.write(' telescopi che sono in trasmissione, ma hanno un rate di acquisizione delle tracce minore di 5 Hz:\n')
w.write(' telescopi in trasmissione, ma hanno un rate di acquisizione delle tracce inferiore a 5 Hz:\n')
w.write(', '.join(map(str, schoolsTrackRed)))
w.write('.\n\n')
elif len(schoolsTrackRed) == 1:
w.write('- C\'e\' un telescopio in trasmissione, ma ha un rate di acquisizione delle tracce minore di 5 Hz:\n')
w.write('- C\'e\' un telescopio in trasmissione, ma ha un rate di acquisizione delle tracce inferiore a 5 Hz:\n')
w.write(schoolsTrackRed[0])
w.write('.\n\n')

Expand Down Expand Up @@ -163,17 +181,20 @@ def report_write(reportData,
################################################
# Write the list of schools with elog red
################################################
# if len(schoolsElog) > 1:
# w.write('- Ci sono ')
# w.write(str(len(schoolsElog)))
# w.write(' scuole che non compilano l\'elogbook da piu\' di due giorni:\n')
# w.write(', '.join(map(str, schoolsElog)))
# w.write('.\n\n')
# elif len(schoolsElog) == 1:
# w.write('C\'e\' una scuola che non compila l\'elogbook da piu\' di due giorni:\n')
# w.write(schoolsElog[0])
# w.write('.\n')
if len(schoolsElog) > 1:
w.write('- Ci sono ')
w.write(str(len(schoolsElog)))
w.write(' scuole che non compilano l\'elogbook da piu\' di due giorni:\n')
w.write(', '.join(map(str, schoolsElog)))
w.write('.\n\n')
elif len(schoolsElog) == 1:
w.write('C\'e\' una scuola che non compila l\'elogbook da piu\' di due giorni:\n')
w.write(schoolsElog[0])
w.write('.\n')

################################################
# Message about elog for all schools
################################################
w.write('Tutte le scuole sono invitate a compilare ogni giorno l\'e-logbook del Run 3\n')
w.write('al seguente indirizzo: http://eee.centrofermi.it/elog/Run3\n\n')

Expand Down

0 comments on commit 97971ab

Please sign in to comment.