rda-python-metrics 2.0.4__tar.gz → 2.0.5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {rda_python_metrics-2.0.4/src/rda_python_metrics.egg-info → rda_python_metrics-2.0.5}/PKG-INFO +1 -1
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/pyproject.toml +1 -1
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/fillawsusage.py +1 -1
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/fillcdgusage.py +1 -1
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/fillcodusage.py +1 -1
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/fillglobususage.py +1 -1
- rda_python_metrics-2.0.5/src/rda_python_metrics/fillrdadb.py +130 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5/src/rda_python_metrics.egg-info}/PKG-INFO +1 -1
- rda_python_metrics-2.0.4/src/rda_python_metrics/fillrdadb.py +0 -129
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/LICENSE +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/MANIFEST.in +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/README.md +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/setup.cfg +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/PgIPInfo.py +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/PgView.py +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/__init__.py +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/fill_awsusage.py +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/fill_cdgusage.py +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/fill_codusage.py +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/fill_country.py +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/fill_endtime.py +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/fill_globususage.py +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/fill_ipinfo.py +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/fill_oneorder.py +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/fill_osdfusage.py +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/fill_rdadb.py +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/fill_tdsusage.py +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/fill_user.py +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/fillawsusage.usg +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/fillcdgusage.usg +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/fillcodusage.usg +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/fillcountry.py +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/fillendtime.py +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/fillgdexusage.py +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/fillgdexusage.usg +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/fillglobususage.usg +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/fillipinfo.py +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/fillipinfo.usg +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/filloneorder.py +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/filloneorder.usg +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/fillosdfusage.py +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/fillosdfusage.usg +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/fillrdadb.usg +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/filltdsusage.py +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/filltdsusage.usg +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/filluser.py +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/filluser.usg +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/fillzenodousage.py +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/log_arch.py +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/logarch.py +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/logarch.usg +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/pg_ipinfo.py +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/pg_person.py +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/pg_username.py +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/pg_view.py +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/pgperson.py +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/pgsyspath.py +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/pgusername.py +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/view_allusage.py +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/view_awsusage.py +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/view_checkusage.py +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/view_codusage.py +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/view_ordusage.py +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/view_osdfusage.py +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/view_rqstusage.py +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/view_tdsusage.py +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/view_webfile.py +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/view_webusage.py +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/viewallusage.py +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/viewallusage.usg +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/viewawsusage.py +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/viewawsusage.usg +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/viewcheckusage.py +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/viewcheckusage.usg +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/viewcodusage.py +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/viewcodusage.usg +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/viewordusage.py +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/viewordusage.usg +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/viewosdfusage.py +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/viewosdfusage.usg +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/viewrqstusage.py +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/viewrqstusage.usg +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/viewtdsusage.py +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/viewtdsusage.usg +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/viewwebfile.py +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/viewwebfile.usg +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/viewwebusage.py +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/viewwebusage.usg +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics.egg-info/SOURCES.txt +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics.egg-info/dependency_links.txt +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics.egg-info/entry_points.txt +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics.egg-info/requires.txt +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics.egg-info/top_level.txt +0 -0
- {rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/tests/test_metrics.py +0 -0
{rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/fillcodusage.py
RENAMED
|
@@ -19,7 +19,7 @@ from .pg_ipinfo import PgIPInfo
|
|
|
19
19
|
class FillCODUsage(PgIPInfo):
|
|
20
20
|
|
|
21
21
|
def __init__(self):
|
|
22
|
-
super().
|
|
22
|
+
super().__init__()
|
|
23
23
|
# the define options for gathering COD data usage, one at a time
|
|
24
24
|
self.MONTH = 0x02 # fet COD data usages for given months
|
|
25
25
|
self.YEARS = 0x04 # get COD data usages for given years
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
###############################################################################
|
|
3
|
+
# Title : fillrdadb
|
|
4
|
+
# Author : Zaihua Ji, zji@ucar.edu
|
|
5
|
+
# Date : 04/07/2022
|
|
6
|
+
# 2025-03-26 transferred to package rda_python_metrics from
|
|
7
|
+
# https://github.com/NCAR/rda-database.git
|
|
8
|
+
# 2025-12-17 convert to class FillRDADB
|
|
9
|
+
# Purpose : python program to retrieve info from data logs, and fill tables
|
|
10
|
+
# in PostgreSQL database.schema rdadb.dssdb
|
|
11
|
+
# Github : https://github.com/NCAR/rda-pythn-metrics.git
|
|
12
|
+
###############################################################################
|
|
13
|
+
import sys
|
|
14
|
+
import re
|
|
15
|
+
from rda_python_common.pg_util import PgUtil
|
|
16
|
+
from rda_python_common.pg_dbi import PgDBI
|
|
17
|
+
|
|
18
|
+
class FillRDADB(PgUtil, PgDBI):
|
|
19
|
+
|
|
20
|
+
def __init__(self):
|
|
21
|
+
super().__init__()
|
|
22
|
+
# the define options for gathering web online file usage, one at a time
|
|
23
|
+
self.DATES = 0x01 # get web file usages for given dates
|
|
24
|
+
self.MONTH = 0x02 # fet web file usages for given months
|
|
25
|
+
self.YEARS = 0x04 # get web file usages for given years
|
|
26
|
+
self.NDAYS = 0x08 # get web file usages in recent number of days
|
|
27
|
+
self.CLNFL = 0x10 # clean unused file only
|
|
28
|
+
self.MASKS = (self.MONTH|self.YEARS|self.DATES|self.NDAYS)
|
|
29
|
+
self.RDADB = {
|
|
30
|
+
'OPTION' : 0,
|
|
31
|
+
'OPTVAL' : '',
|
|
32
|
+
'DOMAIL' : 1,
|
|
33
|
+
'BCKGRND' : ''
|
|
34
|
+
}
|
|
35
|
+
self.params = [] # array of input values
|
|
36
|
+
|
|
37
|
+
# function to read parameters
|
|
38
|
+
def read_parameters(self):
|
|
39
|
+
argv = sys.argv[1:]
|
|
40
|
+
for arg in argv:
|
|
41
|
+
if arg == "-b":
|
|
42
|
+
self.PGLOG['BCKGRND'] = "-b"
|
|
43
|
+
self.RDADB['BCKGRND'] = " -b"
|
|
44
|
+
elif arg == "-n":
|
|
45
|
+
self.RDADB['DOMAIL'] = 0
|
|
46
|
+
self.PGLOG['LOGMASK'] &= ~(self.EMLALL)
|
|
47
|
+
elif re.match(r'^-[cdmNy]$', arg) and not self.RDADB['OPTVAL']:
|
|
48
|
+
self.RDADB['OPTVAL'] = arg
|
|
49
|
+
if arg == "-c":
|
|
50
|
+
self.RDADB['OPTION'] |= self.CLNFL
|
|
51
|
+
elif arg == "-d":
|
|
52
|
+
self.RDADB['OPTION'] |= self.DATES
|
|
53
|
+
elif arg == "-m":
|
|
54
|
+
self.RDADB['OPTION'] |= self.MONTH
|
|
55
|
+
elif arg == "-y":
|
|
56
|
+
self.RDADB['OPTION'] |= self.YEARS
|
|
57
|
+
elif arg == "-N":
|
|
58
|
+
self.RDADB['OPTION'] |= self.NDAYS
|
|
59
|
+
elif re.match(r'^-.*', arg):
|
|
60
|
+
self.pglog(arg + ": Invalid Option", self.LGWNEX)
|
|
61
|
+
elif self.RDADB['OPTION']&self.MASKS:
|
|
62
|
+
self.params.append(arg)
|
|
63
|
+
else:
|
|
64
|
+
self.pglog(arg + ": Invalid Parameter", self.LGWNEX)
|
|
65
|
+
if not self.RDADB['OPTION'] or (self.RDADB['OPTION']&self.MASKS and not self.params):
|
|
66
|
+
self.show_usage('fillrdadb')
|
|
67
|
+
self.cmdlog("fillrdadb {}".format(' '.join(argv)))
|
|
68
|
+
|
|
69
|
+
# function to start actions
|
|
70
|
+
def start_actions(self):
|
|
71
|
+
self.dssdb_dbname()
|
|
72
|
+
if self.RDADB['OPTION']&self.CLNFL: # clean unused file only
|
|
73
|
+
self.clean_unused_files()
|
|
74
|
+
elif self.RDADB['OPTION']&self.MASKS:
|
|
75
|
+
self.fill_rdadb(self.RDADB['OPTVAL'])
|
|
76
|
+
|
|
77
|
+
# Fill self.RDADB info for given condition
|
|
78
|
+
def fill_rdadb(self, option):
|
|
79
|
+
filecond = '{} {}'.format(option, ' '.join(self.params))
|
|
80
|
+
self.pglog("Filling RDADB info for '{}' at {}".format(filecond, self.current_datetime()), self.LOGWRN)
|
|
81
|
+
# fill available custom OPeNDAP usages
|
|
82
|
+
self.pgsystem("fillcodusage {} {}".format(self.RDADB['BCKGRND'], filecond), self.LGWNEM, 5)
|
|
83
|
+
# fill available globus web data usages
|
|
84
|
+
self.pgsystem("fillglobususage {} {}".format(self.RDADB['BCKGRND'], filecond), self.LGWNEM, 5)
|
|
85
|
+
# fill available AWS web data usages
|
|
86
|
+
self.pgsystem("fillawsusage {} {}".format(self.RDADB['BCKGRND'], filecond), self.LGWNEM, 5)
|
|
87
|
+
# fill available OSDF web data usages
|
|
88
|
+
self.pgsystem("fillosdfusage {} {}".format(self.RDADB['BCKGRND'], filecond), self.LGWNEM, 5)
|
|
89
|
+
if self.RDADB['DOMAIL']: self.send_email_notice()
|
|
90
|
+
self.pglog("End Filling RDADB info at {}".format(self.current_datetime()), self.LGWNEM)
|
|
91
|
+
|
|
92
|
+
# clean unused MSS and Web files
|
|
93
|
+
def clean_unused_files(self):
|
|
94
|
+
self.pglog("Check and clean deleted Web files that never been used at {}".format(self.current_datetime()), self.LOGWRN)
|
|
95
|
+
pgrecs = self.pgmget("wfile", "wid", "status = 'D'", self.LGWNEX)
|
|
96
|
+
allcnt = len(pgrecs['wid']) if pgrecs else 0
|
|
97
|
+
self.pglog("{} record(s) retrieved from Table 'wfile' at {}".format(allcnt, self.current_datetime()), self.LOGWRN)
|
|
98
|
+
procnt = delcnt = 0
|
|
99
|
+
if allcnt:
|
|
100
|
+
fcond = r"wid = {} AND org_type <> 'DSS' AND wuid_read = wuid"
|
|
101
|
+
for fid in pgrecs['wid']:
|
|
102
|
+
procnt += 1
|
|
103
|
+
if procnt%5000 == 0:
|
|
104
|
+
self.pglog("{}/{} record(s) processed/removed from Table 'wfile'".format(procnt, delcnt), self.WARNLG)
|
|
105
|
+
if not self.pgget("wusage, wuser", "", fcond.format(fid), self.LGWNEX):
|
|
106
|
+
# deleted web file never been used
|
|
107
|
+
delcnt += self.pgdel("wfile", "wid = {}".format(fid), self.LGWNEX)
|
|
108
|
+
self.pglog("{} record(s) removed from Table 'wfile' at {}".format(delcnt, self.current_datetime()), self.LOGWRN)
|
|
109
|
+
|
|
110
|
+
# email notice of job done
|
|
111
|
+
def send_email_notice(self):
|
|
112
|
+
msg = ("Hi All,\n\nRDADB weekly data usage gathering is done at {}.\n\n".format(self.current_datetime()) +
|
|
113
|
+
"Please Let me know if you notice any problem.\n\nThanks,\n\nHua\n")
|
|
114
|
+
pgrecs = self.pgmget("dssgrp", "logname", "email_flag = 'Y'", self.LGWNEX)
|
|
115
|
+
if pgrecs:
|
|
116
|
+
receiver = ""
|
|
117
|
+
for logname in pgrecs['logname']:
|
|
118
|
+
if receiver: receiver += ', '
|
|
119
|
+
receiver += (logname + "@ucar.edu")
|
|
120
|
+
self.send_email("RDADB Weekly Data Usage Gathered on " + self.curdate(), receiver, msg)
|
|
121
|
+
|
|
122
|
+
# main function to excecute this script
|
|
123
|
+
def main():
|
|
124
|
+
object = FillRDADB()
|
|
125
|
+
object.read_parameters()
|
|
126
|
+
object.start_actions()
|
|
127
|
+
object.pgexit(0)
|
|
128
|
+
|
|
129
|
+
# call main() to start program
|
|
130
|
+
if __name__ == "__main__": main()
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
###############################################################################
|
|
3
|
-
# Title : fillrdadb
|
|
4
|
-
# Author : Zaihua Ji, zji@ucar.edu
|
|
5
|
-
# Date : 04/07/2022
|
|
6
|
-
# 2025-03-26 transferred to package rda_python_metrics from
|
|
7
|
-
# https://github.com/NCAR/rda-database.git
|
|
8
|
-
# 2025-12-17 convert to class FillRDADB
|
|
9
|
-
# Purpose : python program to retrieve info from data logs, and fill tables
|
|
10
|
-
# in PostgreSQL database.schema rdadb.dssdb
|
|
11
|
-
# Github : https://github.com/NCAR/rda-pythn-metrics.git
|
|
12
|
-
###############################################################################
|
|
13
|
-
import sys
|
|
14
|
-
import re
|
|
15
|
-
from rda_python_common.pg_util import PgUtil
|
|
16
|
-
|
|
17
|
-
class FillRDADB(PgUtil):
|
|
18
|
-
|
|
19
|
-
def __init__(self):
|
|
20
|
-
super().__init__()
|
|
21
|
-
# the define options for gathering web online file usage, one at a time
|
|
22
|
-
self.DATES = 0x01 # get web file usages for given dates
|
|
23
|
-
self.MONTH = 0x02 # fet web file usages for given months
|
|
24
|
-
self.YEARS = 0x04 # get web file usages for given years
|
|
25
|
-
self.NDAYS = 0x08 # get web file usages in recent number of days
|
|
26
|
-
self.CLNFL = 0x10 # clean unused file only
|
|
27
|
-
self.MASKS = (self.MONTH|self.YEARS|self.DATES|self.NDAYS)
|
|
28
|
-
self.RDADB = {
|
|
29
|
-
'OPTION' : 0,
|
|
30
|
-
'OPTVAL' : '',
|
|
31
|
-
'DOMAIL' : 1,
|
|
32
|
-
'BCKGRND' : ''
|
|
33
|
-
}
|
|
34
|
-
self.params = [] # array of input values
|
|
35
|
-
|
|
36
|
-
# function to read parameters
|
|
37
|
-
def read_paramers(self):
|
|
38
|
-
argv = sys.argv[1:]
|
|
39
|
-
for arg in argv:
|
|
40
|
-
if arg == "-b":
|
|
41
|
-
self.PGLOG['BCKGRND'] = "-b"
|
|
42
|
-
self.RDADB['BCKGRND'] = " -b"
|
|
43
|
-
elif arg == "-n":
|
|
44
|
-
self.RDADB['DOMAIL'] = 0
|
|
45
|
-
self.PGLOG['LOGMASK'] &= ~(self.EMLALL)
|
|
46
|
-
elif re.match(r'^-[cdmNy]$', arg) and not self.RDADB['OPTVAL']:
|
|
47
|
-
self.RDADB['OPTVAL'] = arg
|
|
48
|
-
if arg == "-c":
|
|
49
|
-
self.RDADB['OPTION'] |= self.CLNFL
|
|
50
|
-
elif arg == "-d":
|
|
51
|
-
self.RDADB['OPTION'] |= self.DATES
|
|
52
|
-
elif arg == "-m":
|
|
53
|
-
self.RDADB['OPTION'] |= self.MONTH
|
|
54
|
-
elif arg == "-y":
|
|
55
|
-
self.RDADB['OPTION'] |= self.YEARS
|
|
56
|
-
elif arg == "-N":
|
|
57
|
-
self.RDADB['OPTION'] |= self.NDAYS
|
|
58
|
-
elif re.match(r'^-.*', arg):
|
|
59
|
-
self.pglog(arg + ": Invalid Option", self.LGWNEX)
|
|
60
|
-
elif self.RDADB['OPTION']&self.MASKS:
|
|
61
|
-
self.params.append(arg)
|
|
62
|
-
else:
|
|
63
|
-
self.pglog(arg + ": Invalid Parameter", self.LGWNEX)
|
|
64
|
-
if not self.RDADB['OPTION'] or (self.RDADB['OPTION']&self.MASKS and not self.params):
|
|
65
|
-
self.show_usage('fillrdadb')
|
|
66
|
-
self.cmdlog("fillrdadb {}".format(' '.join(argv)))
|
|
67
|
-
|
|
68
|
-
# function to start actions
|
|
69
|
-
def start_actions(self):
|
|
70
|
-
self.dssdb_dbname()
|
|
71
|
-
if self.RDADB['OPTION']&self.CLNFL: # clean unused file only
|
|
72
|
-
self.clean_unused_files()
|
|
73
|
-
elif self.RDADB['OPTION']&self.MASKS:
|
|
74
|
-
self.fill_rdadb(self.RDADB['OPTVAL'])
|
|
75
|
-
|
|
76
|
-
# Fill self.RDADB info for given condition
|
|
77
|
-
def fill_rdadb(self, option):
|
|
78
|
-
filecond = '{} {}'.format(option, ' '.join(self.params))
|
|
79
|
-
self.pglog("Filling self.RDADB info for '{}' at {}".format(filecond, self.current_datetime()), self.LOGWRN)
|
|
80
|
-
# fill available custom OPeNDAP usages
|
|
81
|
-
self.pgsystem("fillcodusage {} {}".format(self.RDADB['BCKGRND'], filecond), self.LGWNEM, 5)
|
|
82
|
-
# fill available globus web data usages
|
|
83
|
-
self.pgsystem("fillglobususage {} {}".format(self.RDADB['BCKGRND'], filecond), self.LGWNEM, 5)
|
|
84
|
-
# fill available AWS web data usages
|
|
85
|
-
self.pgsystem("fillawsusage {} {}".format(self.RDADB['BCKGRND'], filecond), self.LGWNEM, 5)
|
|
86
|
-
# fill available OSDF web data usages
|
|
87
|
-
self.pgsystem("fillosdfusage {} {}".format(self.RDADB['BCKGRND'], filecond), self.LGWNEM, 5)
|
|
88
|
-
if self.RDADB['DOMAIL']: self.send_email_notice()
|
|
89
|
-
self.pglog("End Filling self.RDADB info at {}".format(self.current_datetime()), self.LGWNEM)
|
|
90
|
-
|
|
91
|
-
# clean unused MSS and Web files
|
|
92
|
-
def clean_unused_files(self):
|
|
93
|
-
self.pglog("Check and clean deleted Web files that never been used at {}".format(self.current_datetime()), self.LOGWRN)
|
|
94
|
-
pgrecs = self.pgmget("wfile", "wid", "status = 'D'", self.LGWNEX)
|
|
95
|
-
allcnt = len(pgrecs['wid']) if pgrecs else 0
|
|
96
|
-
self.pglog("{} record(s) retrieved from Table 'wfile' at {}".format(allcnt, self.current_datetime()), self.LOGWRN)
|
|
97
|
-
procnt = delcnt = 0
|
|
98
|
-
if allcnt:
|
|
99
|
-
fcond = r"wid = {} AND org_type <> 'DSS' AND wuid_read = wuid"
|
|
100
|
-
for fid in pgrecs['wid']:
|
|
101
|
-
procnt += 1
|
|
102
|
-
if procnt%5000 == 0:
|
|
103
|
-
self.pglog("{}/{} record(s) processed/removed from Table 'wfile'".format(procnt, delcnt), self.WARNLG)
|
|
104
|
-
if not self.pgget("wusage, wuser", "", fcond.format(fid), self.LGWNEX):
|
|
105
|
-
# deleted web file never been used
|
|
106
|
-
delcnt += self.pgdel("wfile", "wid = {}".format(fid), self.LGWNEX)
|
|
107
|
-
self.pglog("{} record(s) removed from Table 'wfile' at {}".format(delcnt, self.current_datetime()), self.LOGWRN)
|
|
108
|
-
|
|
109
|
-
# email notice of job done
|
|
110
|
-
def send_email_notice(self):
|
|
111
|
-
msg = ("Hi All,\n\nself.RDADB weekly data usage gathering is done at {}.\n\n".format(self.current_datetime()) +
|
|
112
|
-
"Please Let me know if you notice any problem.\n\nThanks,\n\nHua\n")
|
|
113
|
-
pgrecs = self.pgmget("dssgrp", "logname", "email_flag = 'Y'", self.LGWNEX)
|
|
114
|
-
if pgrecs:
|
|
115
|
-
receiver = ""
|
|
116
|
-
for logname in pgrecs['logname']:
|
|
117
|
-
if receiver: receiver += ', '
|
|
118
|
-
receiver += (logname + "@ucar.edu")
|
|
119
|
-
self.send_email("self.RDADB Weekly Data Usage Gathered on " + self.curdate(), receiver, msg)
|
|
120
|
-
|
|
121
|
-
# main function to excecute this script
|
|
122
|
-
def main():
|
|
123
|
-
object = FillRDADB()
|
|
124
|
-
object.read_parameters()
|
|
125
|
-
object.start_actions()
|
|
126
|
-
object.pgexit(0)
|
|
127
|
-
|
|
128
|
-
# call main() to start program
|
|
129
|
-
if __name__ == "__main__": main()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/fill_awsusage.py
RENAMED
|
File without changes
|
{rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/fill_cdgusage.py
RENAMED
|
File without changes
|
{rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/fill_codusage.py
RENAMED
|
File without changes
|
{rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/fill_country.py
RENAMED
|
File without changes
|
{rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/fill_endtime.py
RENAMED
|
File without changes
|
{rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/fill_globususage.py
RENAMED
|
File without changes
|
|
File without changes
|
{rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/fill_oneorder.py
RENAMED
|
File without changes
|
{rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/fill_osdfusage.py
RENAMED
|
File without changes
|
|
File without changes
|
{rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/fill_tdsusage.py
RENAMED
|
File without changes
|
|
File without changes
|
{rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/fillawsusage.usg
RENAMED
|
File without changes
|
{rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/fillcdgusage.usg
RENAMED
|
File without changes
|
{rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/fillcodusage.usg
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/fillgdexusage.py
RENAMED
|
File without changes
|
{rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/fillgdexusage.usg
RENAMED
|
File without changes
|
{rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/fillglobususage.usg
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/filloneorder.py
RENAMED
|
File without changes
|
{rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/filloneorder.usg
RENAMED
|
File without changes
|
{rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/fillosdfusage.py
RENAMED
|
File without changes
|
{rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/fillosdfusage.usg
RENAMED
|
File without changes
|
|
File without changes
|
{rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/filltdsusage.py
RENAMED
|
File without changes
|
{rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/filltdsusage.usg
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/fillzenodousage.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/view_allusage.py
RENAMED
|
File without changes
|
{rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/view_awsusage.py
RENAMED
|
File without changes
|
{rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/view_checkusage.py
RENAMED
|
File without changes
|
{rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/view_codusage.py
RENAMED
|
File without changes
|
{rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/view_ordusage.py
RENAMED
|
File without changes
|
{rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/view_osdfusage.py
RENAMED
|
File without changes
|
{rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/view_rqstusage.py
RENAMED
|
File without changes
|
{rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/view_tdsusage.py
RENAMED
|
File without changes
|
{rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/view_webfile.py
RENAMED
|
File without changes
|
{rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/view_webusage.py
RENAMED
|
File without changes
|
{rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/viewallusage.py
RENAMED
|
File without changes
|
{rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/viewallusage.usg
RENAMED
|
File without changes
|
{rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/viewawsusage.py
RENAMED
|
File without changes
|
{rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/viewawsusage.usg
RENAMED
|
File without changes
|
{rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/viewcheckusage.py
RENAMED
|
File without changes
|
{rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/viewcheckusage.usg
RENAMED
|
File without changes
|
{rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/viewcodusage.py
RENAMED
|
File without changes
|
{rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/viewcodusage.usg
RENAMED
|
File without changes
|
{rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/viewordusage.py
RENAMED
|
File without changes
|
{rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/viewordusage.usg
RENAMED
|
File without changes
|
{rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/viewosdfusage.py
RENAMED
|
File without changes
|
{rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/viewosdfusage.usg
RENAMED
|
File without changes
|
{rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/viewrqstusage.py
RENAMED
|
File without changes
|
{rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/viewrqstusage.usg
RENAMED
|
File without changes
|
{rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/viewtdsusage.py
RENAMED
|
File without changes
|
{rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/viewtdsusage.usg
RENAMED
|
File without changes
|
|
File without changes
|
{rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/viewwebfile.usg
RENAMED
|
File without changes
|
{rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/viewwebusage.py
RENAMED
|
File without changes
|
{rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics/viewwebusage.usg
RENAMED
|
File without changes
|
{rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics.egg-info/requires.txt
RENAMED
|
File without changes
|
{rda_python_metrics-2.0.4 → rda_python_metrics-2.0.5}/src/rda_python_metrics.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|