/[pdpsoft]/nl.nikhef.ndpf.groupviews/trunk/ndpf-gv-mkplots
ViewVC logotype

Diff of /nl.nikhef.ndpf.groupviews/trunk/ndpf-gv-mkplots

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3273 by templon, Wed Oct 9 14:43:35 2019 UTC revision 3274 by templon, Thu Dec 12 15:13:14 2019 UTC
# Line 14  p = optparse.OptionParser(description="P Line 14  p = optparse.OptionParser(description="P
14  p.add_option("--rank-only",action="store_true",dest="rankonly",  p.add_option("--rank-only",action="store_true",dest="rankonly",
15               help="don't plot, just print ranking of groups",default=False)               help="don't plot, just print ranking of groups",default=False)
16    
17    p.add_option("-c", "--calmonth",action="store",dest="month",
18            help="plot for a calendar month.  Format for specified month: 201707 for\n July 2017, or prev for the most recent fully-completed month.",default=None)
19    
20    
21  debug = 0  debug = 0
22    
23  opts, args = p.parse_args()  opts, args = p.parse_args()
# Line 105  plotrangedef = { Line 109  plotrangedef = {
109                                },                                },
110                 'numgroups' : 7,                 'numgroups' : 7,
111                  },                  },
112        # note the construction "repr(372*n)" here --- this is because the plot is
113        # based on 120 min bins, and 372 bins of 120 minutes is 31 days.
114        # 120 min is the granularity of one of the RRAs.  The string START
115        # needs to be replaced at run time based on the program arguments.
116        
117        'cmonth' : { 'timeargs' : [ '-s', 'START', '-e', 's+'+repr(372*120)+'min'],
118                     'timetag'  : 'cmonth',
119                     'avrange'  : 31*24*3600,
120                     'avres'    : 1800,
121                     'sizeargs' : {
122                        'small' : [ '--width', '372', '--height', '105',
123                            '--x-grid', 'DAY:1:DAY:10:DAY:5:0:%d' ],
124                        'large' : [ '--width', '1488', '--height', '420' # ,
125                        #   '-n', 'DEFAULT:18:',
126                        #   '--x-grid',
127                        #   'HOUR:12:DAY:1:DAY:3:86400:%d-%b'
128                        ]
129                    },
130                    'numgroups' : 7,
131                },
132    
133    
134      'year' : { 'timeargs' : [ '-s', 'n-'+repr(576*1440)+'min',  '-e', 'n'],      'year' : { 'timeargs' : [ '-s', 'n-'+repr(576*1440)+'min',  '-e', 'n'],
135                 'timetag' : 'year',                 'timetag' : 'year',
# Line 281  def makeplots(prangedef): Line 306  def makeplots(prangedef):
306      # first need to find "top eight" list      # first need to find "top eight" list
307      # base it on running jobs      # base it on running jobs
308    
309      now=int(time.mktime(time.localtime()))      if prangedef['timetag'] == "cmonth":
310      end = (now / resolu) * resolu          cmstarttime = time.strptime(prangedef['timeargs'][1], "%Y%m%d" )
311      start  = end - (prangedef['avrange']) + resolu          start = int(time.mktime(cmstarttime))
312            start = (start / resolu) * resolu
313            end   = start + prangedef['avrange']
314        else:
315            now=int(time.mktime(time.localtime()))
316            end = (now / resolu) * resolu
317            start  = end - (prangedef['avrange']) + resolu
318    
319      ### block finding 'top N' group list ###      ### block finding 'top N' group list ###
320    
# Line 373  def makeplots(prangedef): Line 404  def makeplots(prangedef):
404  if opts.rankonly:  if opts.rankonly:
405      from signal import signal, SIGPIPE, SIG_DFL      from signal import signal, SIGPIPE, SIG_DFL
406      signal(SIGPIPE,SIG_DFL)      signal(SIGPIPE,SIG_DFL)
407    import sys
408    
409    if opts.month:
410        if opts.month == 'prev':
411            import datetime
412            today = datetime.date.today()
413            first = today.replace(day=1)
414            lastMonth = first - datetime.timedelta(days=1)
415            curmonthstring = lastMonth.strftime("%Y%m")
416        else:
417            curmonthstring = opts.month
418    
419        monthstr = curmonthstring + "01"
420        plotrangedef['cmonth']['timeargs'][1] = monthstr
421        makeplots(plotrangedef['cmonth'])
422        sys.exit(0)
423    
424  for k in ['hr', 'day', 'week', 'month', 'year', 'alltime']:  #  plotrangedef.keys():  for k in ['hr', 'day', 'week', 'month', 'year', 'alltime']:  #  plotrangedef.keys():
425      makeplots(plotrangedef[k])      makeplots(plotrangedef[k])
426            
 import sys  
427    
428  sys.stdout.flush()  sys.stdout.flush()
429  sys.stdout.close()  sys.stdout.close()

Legend:
Removed from v.3273  
changed lines
  Added in v.3274

grid.support@nikhef.nl
ViewVC Help
Powered by ViewVC 1.1.28