Example #1
0
 def time(self, database, type):
     if database == 'all':
         obj = Mongo.objects()['hour']
     else:
         obj = Mongo.objects(database=database)[0]['hour']
     o = []
     all_total = 0
     slow_total = 0
     for i in range(24):
         i = str(i)
         d = {}
         d['name'] = u'{0}时'.format(str(i))
         d['op'] = obj[i]['op'][type]
         d['slow'] = obj[i]['slow'][type]
         all_total += d['op']
         slow_total += d['slow']
         o.append(d)
     titles = (u'慢查询', u'全部查询')
     values = ('slow', 'op')
     return make_factory({'titles': titles, type: o,
                          'total': '慢查询:{0}, 全部查询:{1}'.format(
                              slow_total, all_total),
                          'des': '[数据库{0} 类型{1}] 总量'.format(database,
                                                                   type),
                          'category': u'mongodb分析', 'values': values})
Example #2
0
 def time(self, database, type):
     if database == 'all':
         obj = Mongo.objects()['hour']
     else:
         obj = Mongo.objects(database=database)[0]['hour']
     o = []
     all_total = 0
     slow_total = 0
     for i in range(24):
         i = str(i)
         d = {}
         d['name'] = u'{0}时'.format(str(i))
         d['op'] = obj[i]['op'][type]
         d['slow'] = obj[i]['slow'][type]
         all_total += d['op']
         slow_total += d['slow']
         o.append(d)
     titles = (u'慢查询', u'全部查询')
     values = ('slow', 'op')
     return make_factory({
         'titles':
         titles,
         type:
         o,
         'total':
         '慢查询:{0}, 全部查询:{1}'.format(slow_total, all_total),
         'des':
         '[数据库{0} 类型{1}] 总量'.format(database, type),
         'category':
         u'mongodb分析',
         'values':
         values
     })
Example #3
0
 def total_data(self, type):
     getmore, insert, update, command, query = 0, 0, 0, 0, 0
     for i in range(24):
         for obj in Mongo.objects():
             insert += obj['hour'][str(i)][type]['insert']
             update += obj['hour'][str(i)][type]['update']
             command += obj['hour'][str(i)][type]['command']
             query += obj['hour'][str(i)][type]['query']
             getmore += obj['hour'][str(i)][type]['getmore']
     count = []
     for name, call in ((u'查询', query), (u'插入', insert), (u'命令', command),
                        (u'更新', update), ('getomre', getmore)):
         d = {}
         d['name'] = name
         d['call'] = call
         count.append(d)
     total = getmore + insert + update + command + query
     return count, total
Example #4
0
 def total_data(self, type):
     getmore, insert, update, command, query = 0, 0, 0, 0, 0
     for i in range(24):
         for obj in Mongo.objects():
             insert += obj['hour'][str(i)][type]['insert']
             update += obj['hour'][str(i)][type]['update']
             command += obj['hour'][str(i)][type]['command']
             query += obj['hour'][str(i)][type]['query']
             getmore += obj['hour'][str(i)][type]['getmore']
     count = []
     for name, call in ((u'查询', query), (u'插入', insert),
                        (u'命令', command), (u'更新', update),
                        ('getomre', getmore)):
         d = {}
         d['name'] = name
         d['call'] = call
         count.append(d)
     total = getmore + insert + update + command + query
     return count, total
Example #5
0
 def total(self, type):
     if type == 'all_op':
         return self.all_op()
     elif type == 'all_slow':
         return self.all_slow()
     call = 0
     call_total = 0
     count = []
     for i in range(24):
         d = {}
         for obj in Mongo.objects():
             call += obj['hour'][str(i)]['total']
         d['name'] = u'{0}时'.format(str(i))
         d['call'] = call
         call_total += call
         call = 0
         count.append(d)
     return make_factory({type: count, 'category':u'mongodb分布',
                          'des': u'数据库查询总量',
                          'total': call_total})
Example #6
0
 def total(self, type):
     if type == 'all_op':
         return self.all_op()
     elif type == 'all_slow':
         return self.all_slow()
     call = 0
     call_total = 0
     count = []
     for i in range(24):
         d = {}
         for obj in Mongo.objects():
             call += obj['hour'][str(i)]['total']
         d['name'] = u'{0}时'.format(str(i))
         d['call'] = call
         call_total += call
         call = 0
         count.append(d)
     return make_factory({
         type: count,
         'category': u'mongodb分布',
         'des': u'数据库查询总量',
         'total': call_total
     })