How to use derive method in lisa

Best Python code snippet using lisa_python

client_arcus_plugin.py

Source:client_arcus_plugin.py Github

copy

Full Screen

1#2# Hubblemon - Yet another general purpose system monitor3#4# Copyright 2015 NAVER Corp.5#6# Licensed under the Apache License, Version 2.0 (the "License");7# you may not use this file except in compliance with the License.8# You may obtain a copy of the License at9#10# http://www.apache.org/licenses/LICENSE-2.011#12# Unless required by applicable law or agreed to in writing, software13# distributed under the License is distributed on an "AS IS" BASIS,14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.15# See the License for the specific language governing permissions and16# limitations under the License.17#18import socket19import telnetlib20import subprocess21import shlex22class arcus_stat:23 def __init__(self):24 self.name = 'arcus'25 self.type = 'rrd'26 self.addr = []27 self.collect_prefix_limit = 3228 self.collect_key_init()29 self.collect_prefix_key_init()30 self.create_key_init()31 self.flag_auto_register = False32 def __repr__(self):33 return '[%s-(%s,%s)]' % (self.addr.__repr__(), self.name, self.type)34 def auto_register(self):35 self.flag_auto_register = True36 proc1 = subprocess.Popen(shlex.split('ps -ef'), stdout=subprocess.PIPE)37 proc2 = subprocess.Popen(shlex.split('grep memcached'), stdin=proc1.stdout, stdout=subprocess.PIPE, stderr=subprocess.PIPE)38 proc1.stdout.close()39 out, err = proc2.communicate()40 out = out.decode('utf-8')41 lines = out.split('\n')42 tmp_addr = []43 for line in lines:44 lst = line.split()45 flag = False46 port = 047 for a in lst:48 if a == '-p':49 flag = True50 continue51 if flag == True:52 try:53 port = int(a)54 except ValueError:55 port = 056 break57 if port > 0:58 tmp_addr.append( ('127.0.0.1', str(port)) )59 tmp_addr.sort()60 if self.addr != tmp_addr:61 print('## auto register memcached port')62 print(tmp_addr)63 self.addr = tmp_addr64 return True65 return False66 def push_addr(self, addr):67 ip, port = addr.split(':')68 ip = socket.gethostbyname(ip)69 70 self.addr.append((ip, port))71 def do_arcus_command(self, ip, port, command, timeout=0.2):72 tn = telnetlib.Telnet(ip, port)73 tn.write(bytes(command + '\r\n', 'utf-8'))74 result = tn.read_until(bytes('END', 'utf-8'), timeout)75 result = result.decode('utf-8');76 tn.write(bytes('quit\r\n', 'utf-8'))77 tn.close()78 return result;79 def collect_stat(self, all_stats):80 for addr in self.addr:81 stat = {}82 end_count = 083 cmds = ['stats', 'stats slabs']84 for cmd in cmds:85 result = self.do_arcus_command(addr[0], addr[1], cmd)86 lines = result.split('\r\n')87 for line in lines:88 if line == 'END':89 end_count += 190 continue91 if line.strip() == '':92 continue93 dummy, key, value = line.split()94 if key not in self.collect_key: # don't send this key95 continue96 alias_key = self.collect_key[key]97 98 if key == 'rusage_user' or key == 'rusage_system':99 value = int(float(value) * 1000000) # change to micro ticks100 else:101 value = int(value)102 stat[alias_key] = value # real name in rrd file103 if end_count != len(cmds): # timout or bad communication. ignore current stats104 return105 for k, v in self.collect_key.items():106 if v not in stat:107 stat[v] = 0108 all_stats['arcus_%s' % addr[1]] = stat109 def collect_prefix(self, all_stats):110 flag_fail = False111 for addr in self.addr:112 result = self.do_arcus_command(addr[0], addr[1], 'stats prefixes')113 if 'END' not in result: # ignore this result. timeout or bad packet, or too many prefixes114 continue115 lines = result.split('\r\n')116 prefixes_set = {}117 for line in lines:118 if line == 'END' or line.strip() == '':119 continue120 items = line.split()121 prefixes_set[items[1]] = 1122 result = self.do_arcus_command(addr[0], addr[1], 'stats detail dump')123 if 'END' not in result: # ignore this result. timeout or bad packet, or too many prefixes124 flag_fail = True125 lines = result.split('\r\n')126 stat = {}127 flush_count = 0128 for line in lines:129 if line == 'END' or line.strip() == '':130 continue131 items = line.split()132 prefix = items[1]133 items = items[2:] 134 if len(lines) > len(prefixes_set) + 20 and prefix not in prefixes_set and prefix != "<null>": # keep 20 extra stats for margin135 print('[%s:%s] flush_frefix %s' % (addr[0], addr[1], prefix))136 self.do_arcus_command(addr[0], addr[1], 'flush_prefix %s' % prefix)137 flush_count += 1138 if flush_count > 32: # delete later139 break140 if flag_fail == True or len(lines) > self.collect_prefix_limit: # ignore too many prefixes141 continue142 tmp_stats = dict(zip(items[0::2], items[1::2]))143 stats = {}144 for k, v in tmp_stats.items():145 if k not in self.collect_prefix_key: # don't send this key146 continue147 alias_key = self.collect_prefix_key[k]148 stats[alias_key] = int(v)149 for k, v in self.collect_prefix_key.items():150 if v not in stats:151 stats[v] = 0152 153 all_stats['arcus_%s-%s' % (addr[1], prefix)] = stats154 def collect(self):155 all_stats = {}156 157 if self.flag_auto_register == True:158 if self.auto_register() == True:159 return None # for create new file160 161 self.collect_stat(all_stats)162 self.collect_prefix(all_stats)163 return all_stats164 165 def create(self):166 all_map = {}167 for addr in self.addr:168 all_map['arcus_%s' % addr[1]] = self.create_key_list # stats per port169 prefix_stat = {}170 self.collect_prefix(prefix_stat)171 for key in prefix_stat:172 all_map[key] = self.create_prefix_key_list # stats per port-prefix173 174 all_map['RRA'] = self.rra_list175 return all_map176 def create_key_init(self):177 self.create_key_list=[178 ('rusage_user', 'DERIVE', 60, '0', 'U'),179 ('rusage_system', 'DERIVE', 60, '0', 'U'),180 ('cmd_set', 'DERIVE', 60, '0', 'U'),181 ('cmd_bop_insert', 'DERIVE', 60, '0', 'U'),182 ('cmd_bop_delete', 'DERIVE', 60, '0', 'U'),183 ('cmd_sop_exist', 'DERIVE', 60, '0', 'U'),184 ('rejected_conns', 'DERIVE', 60, '0', 'U'),185 ('limit_maxbytes', 'GAUGE', 60, '0', 'U'),186 ('cmd_bop_position', 'DERIVE', 60, '0', 'U'),187 ('bytes', 'GAUGE', 60, '0', 'U'),188 ('sop_exist_hits', 'DERIVE', 60, '0', 'U'),189 ('lop_get_nhits', 'DERIVE', 60, '0', 'U'),190 ('lop_delete_nhits', 'DERIVE', 60, '0', 'U'),191 ('cmd_bop_update', 'DERIVE', 60, '0', 'U'),192 ('cmd_bop_incr', 'DERIVE', 60, '0', 'U'),193 ('cmd_lop_create', 'DERIVE', 60, '0', 'U'),194 ('cmd_lop_get', 'DERIVE', 60, '0', 'U'),195 ('bop_decr_nhits', 'DERIVE', 60, '0', 'U'),196 ('bop_gbp_nhits', 'DERIVE', 60, '0', 'U'),197 ('reclaimed', 'DERIVE', 60, '0', 'U'),198 ('bop_insert_hits', 'DERIVE', 60, '0', 'U'),199 ('cmd_bop_decr', 'DERIVE', 60, '0', 'U'),200 ('sticky_bytes', 'GAUGE', 60, '0', 'U'),201 ('lop_insert_hits', 'DERIVE', 60, '0', 'U'),202 ('cmd_sop_insert', 'DERIVE', 60, '0', 'U'),203 ('sop_delete_ehits', 'DERIVE', 60, '0', 'U'),204 ('bytes_written', 'DERIVE', 60, '0', 'U'),205 ('cmd_setattr', 'DERIVE', 60, '0', 'U'),206 ('sop_create_oks', 'DERIVE', 60, '0', 'U'),207 ('cmd_bop_count', 'DERIVE', 60, '0', 'U'),208 ('lop_delete_ehits', 'DERIVE', 60, '0', 'U'),209 ('curr_connections', 'GAUGE', 60, '0', 'U'),210 ('bop_count_hits', 'DERIVE', 60, '0', 'U'),211 ('bop_position_nhits', 'DERIVE', 60, '0', 'U'),212 ('cmd_bop_get', 'DERIVE', 60, '0', 'U'),213 ('sop_insert_hits', 'DERIVE', 60, '0', 'U'),214 ('decr_hits', 'DERIVE', 60, '0', 'U'),215 ('bop_smget_oks', 'DERIVE', 60, '0', 'U'),216 ('getattr_hits', 'DERIVE', 60, '0', 'U'),217 ('bop_incr_ehits', 'DERIVE', 60, '0', 'U'),218 ('setattr_hits', 'DERIVE', 60, '0', 'U'),219 ('lop_create_oks', 'DERIVE', 60, '0', 'U'),220 ('incr_hits', 'DERIVE', 60, '0', 'U'),221 ('cmd_bop_mget', 'DERIVE', 60, '0', 'U'),222 ('cmd_sop_create', 'DERIVE', 60, '0', 'U'),223 ('lop_get_ehits', 'DERIVE', 60, '0', 'U'),224 ('sop_delete_nhits', 'DERIVE', 60, '0', 'U'),225 ('cmd_lop_delete', 'DERIVE', 60, '0', 'U'),226 ('bop_get_nhits', 'DERIVE', 60, '0', 'U'),227 ('bop_update_ehits', 'DERIVE', 60, '0', 'U'),228 ('bop_create_oks', 'DERIVE', 60, '0', 'U'),229 ('bop_decr_ehits', 'DERIVE', 60, '0', 'U'),230 ('delete_hits', 'DERIVE', 60, '0', 'U'),231 ('sticky_limit', 'GAUGE', 60, '0', 'U'),232 ('bop_gbp_ehits', 'DERIVE', 60, '0', 'U'),233 ('bop_get_ehits', 'DERIVE', 60, '0', 'U'),234 ('cmd_lop_insert', 'DERIVE', 60, '0', 'U'),235 ('engine_maxbytes', 'GAUGE', 60, '0', 'U'),236 ('bop_delete_nhits', 'DERIVE', 60, '0', 'U'),237 ('bop_incr_nhits', 'DERIVE', 60, '0', 'U'),238 ('cmd_flush', 'DERIVE', 60, '0', 'U'),239 ('curr_items', 'GAUGE', 60, '0', 'U'),240 ('cmd_sop_get', 'DERIVE', 60, '0', 'U'),241 ('total_items', 'DERIVE', 60, '0', 'U'),242 ('bop_delete_ehits', 'DERIVE', 60, '0', 'U'),243 ('evictions', 'DERIVE', 60, '0', 'U'),244 ('bop_update_nhits', 'DERIVE', 60, '0', 'U'),245 ('bytes_read', 'DERIVE', 60, '0', 'U'),246 ('get_hits', 'DERIVE', 60, '0', 'U'),247 ('cmd_get', 'DERIVE', 60, '0', 'U'),248 ('sticky_items', 'DERIVE', 60, '0', 'U'),249 ('bop_position_ehits', 'DERIVE', 60, '0', 'U'),250 ('cmd_bop_create', 'DERIVE', 60, '0', 'U'),251 ('cmd_getattr', 'DERIVE', 60, '0', 'U'),252 ('cas_hits', 'DERIVE', 60, '0', 'U'),253 ('cas_badval', 'DERIVE', 60, '0', 'U'),254 ('cmd_flush_prefix', 'DERIVE', 60, '0', 'U'),255 ('cmd_bop_gbp', 'DERIVE', 60, '0', 'U'),256 ('conn_yields', 'DERIVE', 60, '0', 'U'),257 ('sop_get_nhits', 'DERIVE', 60, '0', 'U'),258 ('cmd_bop_smget', 'DERIVE', 60, '0', 'U'),259 ('cmd_sop_delete', 'DERIVE', 60, '0', 'U'),260 ('sop_get_ehits', 'DERIVE', 60, '0', 'U'),261 ('bop_mget_oks', 'DERIVE', 60, '0', 'U'),262 ('total_malloced', 'GAUGE', 60, '0', 'U'),263 ('hb_count', 'DERIVE', 60, '0', 'U'),264 ('hb_latency', 'DERIVE', 60, '0', 'U'),265 #('auth_errors', 'DERIVE', 60, '0', 'U'),266 #('auth_cmds', 'DERIVE', 60, '0', 'U'),267 #('time', 'DERIVE', 60, '0', 'U'),268 #('threads', 'DERIVE', 60, '0', 'U'),269 ('stat_drv_01', 'DERIVE', 60, '0', 'U'), # for additional counter & gauge270 ('stat_drv_02', 'DERIVE', 60, '0', 'U'),271 ('stat_drv_03', 'DERIVE', 60, '0', 'U'),272 ('stat_drv_04', 'DERIVE', 60, '0', 'U'),273 ('stat_drv_05', 'DERIVE', 60, '0', 'U'),274 ('stat_drv_06', 'DERIVE', 60, '0', 'U'),275 ('stat_drv_07', 'DERIVE', 60, '0', 'U'),276 ('stat_drv_08', 'DERIVE', 60, '0', 'U'),277 ('stat_drv_09', 'DERIVE', 60, '0', 'U'),278 ('stat_drv_10', 'DERIVE', 60, '0', 'U'),279 ('stat_drv_11', 'DERIVE', 60, '0', 'U'),280 ('stat_drv_12', 'DERIVE', 60, '0', 'U'),281 ('stat_drv_13', 'DERIVE', 60, '0', 'U'),282 ('stat_drv_14', 'DERIVE', 60, '0', 'U'),283 ('stat_drv_15', 'DERIVE', 60, '0', 'U'),284 ('stat_drv_16', 'DERIVE', 60, '0', 'U'),285 ('stat_drv_17', 'DERIVE', 60, '0', 'U'),286 ('stat_drv_18', 'DERIVE', 60, '0', 'U'),287 ('stat_drv_19', 'DERIVE', 60, '0', 'U'),288 ('stat_drv_20', 'DERIVE', 60, '0', 'U'),289 ('stat_gauge_01', 'GAUGE', 60, '0', 'U'),290 ('stat_gauge_02', 'GAUGE', 60, '0', 'U'),291 ('stat_gauge_03', 'GAUGE', 60, '0', 'U'),292 ('stat_gauge_04', 'GAUGE', 60, '0', 'U'),293 ('stat_gauge_05', 'GAUGE', 60, '0', 'U')]294 self.create_prefix_key_list= [ ('cmd_get', 'DERIVE', 60, '0', 'U'),295 ('cmd_hit', 'DERIVE', 60, '0', 'U'),296 ('cmd_set', 'DERIVE', 60, '0', 'U'),297 ('cmd_del', 'DERIVE', 60, '0', 'U'),298 ('cmd_lop_create', 'DERIVE', 60, '0', 'U'),299 ('cmd_lop_insert', 'DERIVE', 60, '0', 'U'),300 ('lop_insert_hits', 'DERIVE', 60, '0', 'U'),301 ('cmd_lop_delete', 'DERIVE', 60, '0', 'U'),302 ('lop_delete_hits', 'DERIVE', 60, '0', 'U'),303 ('cmd_lop_get', 'DERIVE', 60, '0', 'U'),304 ('lop_get_hits', 'DERIVE', 60, '0', 'U'),305 ('cmd_sop_create', 'DERIVE', 60, '0', 'U'),306 ('cmd_sop_insert', 'DERIVE', 60, '0', 'U'),307 ('sop_insert_hits', 'DERIVE', 60, '0', 'U'),308 ('cmd_sop_delete', 'DERIVE', 60, '0', 'U'),309 ('sop_delete_hits', 'DERIVE', 60, '0', 'U'),310 ('cmd_sop_get', 'DERIVE', 60, '0', 'U'),311 ('sop_get_hits', 'DERIVE', 60, '0', 'U'),312 ('cmd_bop_create', 'DERIVE', 60, '0', 'U'),313 ('cmd_bop_insert', 'DERIVE', 60, '0', 'U'),314 ('bop_insert_hits', 'DERIVE', 60, '0', 'U'),315 ('cmd_bop_update', 'DERIVE', 60, '0', 'U'),316 ('bop_update_hits', 'DERIVE', 60, '0', 'U'),317 ('cmd_bop_incr', 'DERIVE', 60, '0', 'U'),318 ('bop_incr_hits', 'DERIVE', 60, '0', 'U'),319 ('cmd_bop_decr', 'DERIVE', 60, '0', 'U'),320 ('bop_decr_hits', 'DERIVE', 60, '0', 'U'),321 ('cmd_bop_delete', 'DERIVE', 60, '0', 'U'),322 ('bop_delete_hits', 'DERIVE', 60, '0', 'U'),323 ('cmd_bop_get', 'DERIVE', 60, '0', 'U'),324 ('bop_get_hits', 'DERIVE', 60, '0', 'U'),325 ('cmd_bop_count', 'DERIVE', 60, '0', 'U'),326 ('bop_count_hits', 'DERIVE', 60, '0', 'U'),327 ('cmd_getattr', 'DERIVE', 60, '0', 'U'),328 ('getattr_hits', 'DERIVE', 60, '0', 'U'),329 ('prefix_derive_01', 'DERIVE', 60, '0', 'U'),330 ('prefix_derive_02', 'DERIVE', 60, '0', 'U'),331 ('prefix_derive_03', 'DERIVE', 60, '0', 'U'),332 ('prefix_derive_04', 'DERIVE', 60, '0', 'U'),333 ('prefix_derive_05', 'DERIVE', 60, '0', 'U'),334 ('prefix_gauge_01', 'GAUGE', 60, '0', 'U'),335 ('prefix_gauge_02', 'GAUGE', 60, '0', 'U'),336 ('prefix_gauge_03', 'GAUGE', 60, '0', 'U') ]337 # used for RRA338 self.rra_list = [ ('MAX', 0.5, 5/5, (3600/5)*24), # 5sec (to 1day), 17280339 ('MAX', 0.5, 60/5, (3600/60)*24*7), # 1min (to 7day), 10080340 ('MAX', 0.5, 3600/5, 24*31), # 1hour (to 1month), 744341 ('MAX', 0.5, 3600*3/5, (24/3)*366*3) ] # 3hour (to 3year), 8734342 def collect_prefix_key_init(self):343 self.collect_prefix_key = {}344 self.collect_prefix_key['get'] = 'cmd_get'345 self.collect_prefix_key['hit'] = 'cmd_hit'346 self.collect_prefix_key['set'] = 'cmd_set'347 self.collect_prefix_key['del'] = 'cmd_del'348 self.collect_prefix_key['lcs'] = 'cmd_lop_create'349 self.collect_prefix_key['lis'] = 'cmd_lop_insert'350 self.collect_prefix_key['lih'] = 'lop_insert_hits'351 self.collect_prefix_key['lds'] = 'cmd_lop_delete'352 self.collect_prefix_key['ldh'] = 'lop_delete_hits'353 self.collect_prefix_key['lgs'] = 'cmd_lop_get'354 self.collect_prefix_key['lgh'] = 'lop_get_hits'355 self.collect_prefix_key['scs'] = 'cmd_sop_create'356 self.collect_prefix_key['sis'] = 'cmd_sop_insert'357 self.collect_prefix_key['sih'] = 'sop_insert_hits'358 self.collect_prefix_key['sds'] = 'cmd_sop_delete'359 self.collect_prefix_key['sdh'] = 'sop_delete_hits'360 self.collect_prefix_key['sgs'] = 'cmd_sop_get'361 self.collect_prefix_key['sgh'] = 'sop_get_hits'362 self.collect_prefix_key['bcs'] = 'cmd_bop_create'363 self.collect_prefix_key['bis'] = 'cmd_bop_insert'364 self.collect_prefix_key['bih'] = 'bop_insert_hits'365 self.collect_prefix_key['bus'] = 'cmd_bop_update'366 self.collect_prefix_key['buh'] = 'bop_update_hits'367 self.collect_prefix_key['bps'] = 'cmd_bop_incr'368 self.collect_prefix_key['bph'] = 'bop_incr_hits'369 self.collect_prefix_key['bms'] = 'cmd_bop_decr'370 self.collect_prefix_key['bmh'] = 'bop_decr_hits'371 self.collect_prefix_key['bds'] = 'cmd_bop_delete'372 self.collect_prefix_key['bdh'] = 'bop_delete_hits'373 self.collect_prefix_key['bgs'] = 'cmd_bop_get'374 self.collect_prefix_key['bgh'] = 'bop_get_hits'375 self.collect_prefix_key['bns'] = 'cmd_bop_count'376 self.collect_prefix_key['bnh'] = 'bop_count_hits'377 self.collect_prefix_key['gas'] = 'cmd_getattr'378 self.collect_prefix_key['sas'] = 'cmd_setattr'379 self.collect_prefix_key['prefix_derive_01'] = 'prefix_derive_01' # for reserved380 self.collect_prefix_key['prefix_derive_02'] = 'prefix_derive_02'381 self.collect_prefix_key['prefix_derive_03'] = 'prefix_derive_03'382 self.collect_prefix_key['prefix_derive_04'] = 'prefix_derive_04'383 self.collect_prefix_key['prefix_derive_05'] = 'prefix_derive_05'384 self.collect_prefix_key['prefix_gauge_01'] = 'prefix_gauge_01'385 self.collect_prefix_key['prefix_gauge_02'] = 'prefix_gauge_02'386 self.collect_prefix_key['prefix_gauge_03'] = 'prefix_gauge_03'387 def collect_key_init(self):388 self.collect_key = {}389 self.collect_key['rusage_user'] = 'rusage_user'390 self.collect_key['rusage_system'] = 'rusage_system'391 self.collect_key['cmd_set'] = 'cmd_set'392 self.collect_key['cmd_bop_insert'] = 'cmd_bop_insert'393 self.collect_key['cmd_bop_delete'] = 'cmd_bop_delete'394 self.collect_key['cmd_sop_exist'] = 'cmd_sop_exist'395 self.collect_key['rejected_conns'] = 'rejected_conns'396 self.collect_key['limit_maxbytes'] = 'limit_maxbytes'397 self.collect_key['cmd_bop_position'] = 'cmd_bop_position'398 self.collect_key['bytes'] = 'bytes'399 self.collect_key['sop_exist_hits'] = 'sop_exist_hits'400 self.collect_key['lop_get_none_hits'] = 'lop_get_nhits'401 self.collect_key['lop_delete_none_hits'] = 'lop_delete_nhits'402 self.collect_key['cmd_bop_update'] = 'cmd_bop_update'403 self.collect_key['cmd_bop_incr'] = 'cmd_bop_incr'404 self.collect_key['cmd_lop_create'] = 'cmd_lop_create'405 self.collect_key['cmd_lop_get'] = 'cmd_lop_get'406 self.collect_key['bop_decr_none_hits'] = 'bop_decr_nhits'407 self.collect_key['bop_gbp_none_hits'] = 'bop_gbp_nhits'408 self.collect_key['reclaimed'] = 'reclaimed'409 self.collect_key['bop_insert_hits'] = 'bop_insert_hits'410 self.collect_key['cmd_bop_decr'] = 'cmd_bop_decr'411 self.collect_key['sticky_bytes'] = 'sticky_bytes'412 self.collect_key['lop_insert_hits'] = 'lop_insert_hits'413 self.collect_key['cmd_sop_insert'] = 'cmd_sop_insert'414 self.collect_key['sop_delete_elem_hits'] = 'sop_delete_ehits'415 self.collect_key['bytes_written'] = 'bytes_written'416 self.collect_key['cmd_setattr'] = 'cmd_setattr'417 self.collect_key['sop_create_oks'] = 'sop_create_oks'418 self.collect_key['cmd_bop_count'] = 'cmd_bop_count'419 self.collect_key['lop_delete_elem_hits'] = 'lop_delete_ehits'420 self.collect_key['curr_connections'] = 'curr_connections'421 self.collect_key['bop_count_hits'] = 'bop_count_hits'422 self.collect_key['bop_position_none_hits'] = 'bop_position_nhits'423 self.collect_key['cmd_bop_get'] = 'cmd_bop_get'424 self.collect_key['sop_insert_hits'] = 'sop_insert_hits'425 self.collect_key['decr_hits'] = 'decr_hits'426 self.collect_key['bop_smget_oks'] = 'bop_smget_oks'427 self.collect_key['getattr_hits'] = 'getattr_hits'428 self.collect_key['bop_incr_elem_hits'] = 'bop_incr_ehits'429 self.collect_key['setattr_hits'] = 'setattr_hits'430 self.collect_key['lop_create_oks'] = 'lop_create_oks'431 self.collect_key['incr_hits'] = 'incr_hits'432 self.collect_key['cmd_bop_mget'] = 'cmd_bop_mget'433 self.collect_key['cmd_sop_create'] = 'cmd_sop_create'434 self.collect_key['lop_get_elem_hits'] = 'lop_get_ehits'435 self.collect_key['sop_delete_none_hits'] = 'sop_delete_nhits'436 self.collect_key['cmd_lop_delete'] = 'cmd_lop_delete'437 self.collect_key['bop_get_none_hits'] = 'bop_get_nhits'438 self.collect_key['bop_update_elem_hits'] = 'bop_update_ehits'439 self.collect_key['bop_create_oks'] = 'bop_create_oks'440 self.collect_key['bop_decr_elem_hits'] = 'bop_decr_ehits'441 self.collect_key['delete_hits'] = 'delete_hits'442 self.collect_key['sticky_limit'] = 'sticky_limit'443 self.collect_key['bop_gbp_elem_hits'] = 'bop_gbp_ehits'444 self.collect_key['bop_get_elem_hits'] = 'bop_get_ehits'445 self.collect_key['cmd_lop_insert'] = 'cmd_lop_insert'446 self.collect_key['engine_maxbytes'] = 'engine_maxbytes'447 self.collect_key['bop_delete_none_hits'] = 'bop_delete_nhits'448 self.collect_key['bop_incr_none_hits'] = 'bop_incr_nhits'449 self.collect_key['cmd_flush'] = 'cmd_flush'450 self.collect_key['curr_items'] = 'curr_items'451 self.collect_key['cmd_sop_get'] = 'cmd_sop_get'452 self.collect_key['total_items'] = 'total_items'453 self.collect_key['bop_delete_elem_hits'] = 'bop_delete_ehits'454 self.collect_key['evictions'] = 'evictions'455 self.collect_key['bop_update_none_hits'] = 'bop_update_nhits'456 self.collect_key['bytes_read'] = 'bytes_read'457 self.collect_key['get_hits'] = 'get_hits'458 self.collect_key['cmd_get'] = 'cmd_get'459 self.collect_key['sticky_items'] = 'sticky_items'460 self.collect_key['bop_position_elem_hits'] = 'bop_position_ehits'461 self.collect_key['cmd_bop_create'] = 'cmd_bop_create'462 self.collect_key['cmd_getattr'] = 'cmd_getattr'463 self.collect_key['cas_hits'] = 'cas_hits'464 self.collect_key['cas_badval'] = 'cas_badval'465 self.collect_key['cmd_flush_prefix'] = 'cmd_flush_prefix'466 self.collect_key['cmd_bop_gbp'] = 'cmd_bop_gbp'467 self.collect_key['conn_yields'] = 'conn_yields'468 self.collect_key['sop_get_none_hits'] = 'sop_get_nhits'469 self.collect_key['cmd_bop_smget'] = 'cmd_bop_smget'470 self.collect_key['cmd_sop_delete'] = 'cmd_sop_delete'471 self.collect_key['sop_get_elem_hits'] = 'sop_get_ehits'472 self.collect_key['bop_mget_oks'] = 'bop_mget_oks'473 self.collect_key['total_malloced'] = 'total_malloced'474 self.collect_key['hb_count'] = 'hb_count'475 self.collect_key['hb_latency'] = 'hb_latency'476 #self.collect_key['auth_errors'] = 'auth_errors'477 #self.collect_key['auth_cmds'] = 'auth_cmds'478 #self.collect_key['threads'] = 'threads'479 #self.collect_key['time'] = 'time'480 self.collect_key['stat_drv_01'] = 'stat_drv_01' # for reserved481 self.collect_key['stat_drv_02'] = 'stat_drv_02'482 self.collect_key['stat_drv_03'] = 'stat_drv_03'483 self.collect_key['stat_drv_04'] = 'stat_drv_04'484 self.collect_key['stat_drv_05'] = 'stat_drv_05'485 self.collect_key['stat_drv_06'] = 'stat_drv_06'486 self.collect_key['stat_drv_07'] = 'stat_drv_07'487 self.collect_key['stat_drv_08'] = 'stat_drv_08'488 self.collect_key['stat_drv_09'] = 'stat_drv_09'489 self.collect_key['stat_drv_10'] = 'stat_drv_10'490 self.collect_key['stat_drv_11'] = 'stat_drv_11' 491 self.collect_key['stat_drv_12'] = 'stat_drv_12'492 self.collect_key['stat_drv_13'] = 'stat_drv_13'493 self.collect_key['stat_drv_14'] = 'stat_drv_14'494 self.collect_key['stat_drv_15'] = 'stat_drv_15'495 self.collect_key['stat_drv_16'] = 'stat_drv_16'496 self.collect_key['stat_drv_17'] = 'stat_drv_17'497 self.collect_key['stat_drv_18'] = 'stat_drv_18'498 self.collect_key['stat_drv_19'] = 'stat_drv_19'499 self.collect_key['stat_drv_20'] = 'stat_drv_20'500 self.collect_key['stat_gauge_01'] = 'stat_gauge_01'501 self.collect_key['stat_gauge_02'] = 'stat_gauge_02'502 self.collect_key['stat_gauge_03'] = 'stat_gauge_03'503 self.collect_key['stat_gauge_04'] = 'stat_gauge_04'...

Full Screen

Full Screen

collect_client.client_mysql_plugin.py

Source:collect_client.client_mysql_plugin.py Github

copy

Full Screen

1#2# Hubblemon - Yet another general purpose system monitor3#4# Copyright 2015 NAVER Corp.5#6# Licensed under the Apache License, Version 2.0 (the "License");7# you may not use this file except in compliance with the License.8# You may obtain a copy of the License at9#10# http://www.apache.org/licenses/LICENSE-2.011#12# Unless required by applicable law or agreed to in writing, software13# distributed under the License is distributed on an "AS IS" BASIS,14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.15# See the License for the specific language governing permissions and16# limitations under the License.17#18import pymysql19class mysql_stat:20 def __init__(self):21 self.name = 'mysql'22 self.type = 'rrd'23 self.name_sock_map = {}24 self.name_conn_map = {}25 self.collect_key_init()26 self.create_key_init()27 28 def __repr__(self):29 return '[%s-(%s,%s)]' % (self.name_sock_map.__repr__(), self.name, self.type)30 def push_db(self, name, unix_sock, id, pw):31 self.name_sock_map[name] = (unix_sock, id, pw)32 self.name_conn_map[name] = pymysql.connect(host='0.0.0.0', unix_socket=unix_sock, user=id, passwd=pw)33 def collect(self):34 all_stats = {}35 for name, conn in self.name_conn_map.items():36 stat = {}37 try:38 curr = conn.cursor()39 ret = curr.execute('show status')40 #print(ret)41 for resp in curr:42 key, value = resp[0], resp[1]43 if key not in self.collect_key: # don't send this key44 continue45 alias_key = self.collect_key[key]46 value = int(float(value))47 stat[alias_key] = value # real name in rrd file48 for k, v in self.collect_key.items():49 if v not in stat:50 stat[v] = 051 52 all_stats['mysql_%s' % name] = stat53 curr.close()54 except: # reconnect55 ret = self.name_sock_map[name]56 self.name_conn_map[name] = pymysql.connect(host='0.0.0.0', unix_socket=ret[0], user=ret[1], passwd=ret[2])57 #print(all_stats)58 return all_stats59 60 def create(self):61 all_map = {}62 for name, sock in self.name_sock_map.items():63 all_map['mysql_%s' % name] = self.create_key_list # stats per port64 all_map['RRA'] = self.rra_list65 return all_map66 def create_key_init(self):67 self.collect_key_init()68 self.create_key_list=[ (self.collect_key['Binlog_cache_disk_use'], 'GAUGE', 60, '0', 'U'),69 (self.collect_key['Binlog_cache_use'], 'GAUGE', 60, '0', 'U'),70 (self.collect_key['Bytes_received'], 'DERIVE', 60, '0', 'U'),71 (self.collect_key['Bytes_sent'], 'DERIVE', 60, '0', 'U'),72 (self.collect_key['Com_alter_table'], 'DERIVE', 60, '0', 'U'),73 (self.collect_key['Com_call_procedure'], 'DERIVE', 60, '0', 'U'),74 (self.collect_key['Com_commit'], 'DERIVE', 60, '0', 'U'),75 (self.collect_key['Com_create_table'], 'DERIVE', 60, '0', 'U'),76 (self.collect_key['Com_dealloc_sql'], 'DERIVE', 60, '0', 'U'),77 (self.collect_key['Com_delete'], 'DERIVE', 60, '0', 'U'),78 (self.collect_key['Com_delete_multi'], 'DERIVE', 60, '0', 'U'),79 (self.collect_key['Com_do'], 'DERIVE', 60, '0', 'U'),80 (self.collect_key['Com_drop_table'], 'DERIVE', 60, '0', 'U'),81 (self.collect_key['Com_execute_sql'], 'DERIVE', 60, '0', 'U'),82 (self.collect_key['Com_flush'], 'DERIVE', 60, '0', 'U'),83 (self.collect_key['Com_insert'], 'DERIVE', 60, '0', 'U'),84 (self.collect_key['Com_insert_select'], 'DERIVE', 60, '0', 'U'),85 (self.collect_key['Com_prepare_sql'], 'DERIVE', 60, '0', 'U'),86 (self.collect_key['Com_release_savepoint'], 'DERIVE', 60, '0', 'U'),87 (self.collect_key['Com_rename_table'], 'DERIVE', 60, '0', 'U'),88 (self.collect_key['Com_replace'], 'DERIVE', 60, '0', 'U'),89 (self.collect_key['Com_replace_select'], 'DERIVE', 60, '0', 'U'),90 (self.collect_key['Com_rollback'], 'DERIVE', 60, '0', 'U'),91 (self.collect_key['Com_rollback_to_savepoint'], 'DERIVE', 60, '0', 'U'),92 (self.collect_key['Com_savepoint'], 'DERIVE', 60, '0', 'U'),93 (self.collect_key['Com_select'], 'DERIVE', 60, '0', 'U'),94 (self.collect_key['Com_stmt_close'], 'DERIVE', 60, '0', 'U'),95 (self.collect_key['Com_stmt_execute'], 'DERIVE', 60, '0', 'U'),96 (self.collect_key['Com_stmt_fetch'], 'DERIVE', 60, '0', 'U'),97 (self.collect_key['Com_stmt_prepare'], 'DERIVE', 60, '0', 'U'),98 (self.collect_key['Com_stmt_reprepare'], 'DERIVE', 60, '0', 'U'),99 (self.collect_key['Com_stmt_reset'], 'DERIVE', 60, '0', 'U'),100 (self.collect_key['Com_truncate'], 'DERIVE', 60, '0', 'U'),101 (self.collect_key['Com_update'], 'DERIVE', 60, '0', 'U'),102 (self.collect_key['Com_update_multi'], 'DERIVE', 60, '0', 'U'),103 (self.collect_key['Connections'], 'DERIVE', 60, '0', 'U'),104 (self.collect_key['Innodb_buffer_pool_pages_data'], 'GAUGE', 60, '0', 'U'),105 (self.collect_key['Innodb_buffer_pool_pages_dirty'], 'GAUGE', 60, '0', 'U'),106 (self.collect_key['Innodb_buffer_pool_pages_flushed'], 'DERIVE', 60, '0', 'U'),107 (self.collect_key['Innodb_buffer_pool_pages_free'], 'GAUGE', 60, '0', 'U'),108 (self.collect_key['Innodb_buffer_pool_pages_misc'], 'GAUGE', 60, '0', 'U'),109 (self.collect_key['Innodb_buffer_pool_pages_total'], 'GAUGE', 60, '0', 'U'),110 (self.collect_key['Innodb_buffer_pool_read_ahead'], 'DERIVE', 60, '0', 'U'),111 (self.collect_key['Innodb_buffer_pool_read_ahead_evicted'], 'DERIVE', 60, '0', 'U'),112 (self.collect_key['Innodb_buffer_pool_read_requests'], 'DERIVE', 60, '0', 'U'),113 (self.collect_key['Innodb_buffer_pool_reads'], 'DERIVE', 60, '0', 'U'),114 (self.collect_key['Innodb_buffer_pool_wait_free'], 'DERIVE', 60, '0', 'U'),115 (self.collect_key['Innodb_buffer_pool_write_requests'], 'DERIVE', 60, '0', 'U'),116 (self.collect_key['Innodb_data_fsyncs'], 'DERIVE', 60, '0', 'U'),117 (self.collect_key['Innodb_data_pending_fsyncs'], 'GAUGE', 60, '0', 'U'),118 (self.collect_key['Innodb_data_pending_reads'], 'GAUGE', 60, '0', 'U'),119 (self.collect_key['Innodb_data_pending_writes'], 'GAUGE', 60, '0', 'U'),120 (self.collect_key['Innodb_data_read'], 'DERIVE', 60, '0', 'U'),121 (self.collect_key['Innodb_data_reads'], 'DERIVE', 60, '0', 'U'),122 (self.collect_key['Innodb_data_writes'], 'DERIVE', 60, '0', 'U'),123 (self.collect_key['Innodb_data_written'], 'DERIVE', 60, '0', 'U'),124 (self.collect_key['Innodb_dblwr_pages_written'], 'DERIVE', 60, '0', 'U'),125 (self.collect_key['Innodb_dblwr_writes'], 'DERIVE', 60, '0', 'U'),126 (self.collect_key['Innodb_log_waits'], 'DERIVE', 60, '0', 'U'),127 (self.collect_key['Innodb_log_write_requests'], 'DERIVE', 60, '0', 'U'),128 (self.collect_key['Innodb_log_writes'], 'DERIVE', 60, '0', 'U'),129 (self.collect_key['Innodb_pages_created'], 'DERIVE', 60, '0', 'U'),130 (self.collect_key['Innodb_pages_read'], 'DERIVE', 60, '0', 'U'),131 (self.collect_key['Innodb_pages_written'], 'DERIVE', 60, '0', 'U'),132 (self.collect_key['Innodb_row_lock_current_waits'], 'DERIVE', 60, '0', 'U'),133 (self.collect_key['Innodb_row_lock_time'], 'DERIVE', 60, '0', 'U'),134 (self.collect_key['Innodb_row_lock_time_avg'], 'DERIVE', 60, '0', 'U'),135 (self.collect_key['Innodb_row_lock_time_max'], 'DERIVE', 60, '0', 'U'),136 (self.collect_key['Innodb_row_lock_waits'], 'DERIVE', 60, '0', 'U'),137 (self.collect_key['Innodb_rows_deleted'], 'DERIVE', 60, '0', 'U'),138 (self.collect_key['Innodb_rows_inserted'], 'DERIVE', 60, '0', 'U'),139 (self.collect_key['Innodb_rows_read'], 'DERIVE', 60, '0', 'U'),140 (self.collect_key['Innodb_rows_updated'], 'DERIVE', 60, '0', 'U'),141 (self.collect_key['Not_flushed_delayed_rows'], 'GAUGE', 60, '0', 'U'),142 (self.collect_key['Opened_files'], 'DERIVE', 60, '0', 'U'),143 (self.collect_key['Opened_table_definitions'], 'DERIVE', 60, '0', 'U'),144 (self.collect_key['Opened_tables'], 'DERIVE', 60, '0', 'U'),145 (self.collect_key['Prepared_stmt_count'], 'GAUGE', 60, '0', 'U'),146 (self.collect_key['Qcache_free_blocks'], 'GAUGE', 60, '0', 'U'),147 (self.collect_key['Qcache_free_memory'], 'GAUGE', 60, '0', 'U'),148 (self.collect_key['Qcache_hits'], 'DERIVE', 60, '0', 'U'),149 (self.collect_key['Qcache_inserts'], 'DERIVE', 60, '0', 'U'),150 (self.collect_key['Qcache_lowmem_prunes'], 'DERIVE', 60, '0', 'U'),151 (self.collect_key['Qcache_not_cached'], 'DERIVE', 60, '0', 'U'),152 (self.collect_key['Qcache_queries_in_cache'], 'GAUGE', 60, '0', 'U'),153 (self.collect_key['Qcache_total_blocks'], 'GAUGE', 60, '0', 'U'),154 (self.collect_key['Queries'], 'DERIVE', 60, '0', 'U'),155 (self.collect_key['Select_full_join'], 'DERIVE', 60, '0', 'U'),156 (self.collect_key['Select_full_range_join'], 'DERIVE', 60, '0', 'U'),157 (self.collect_key['Select_range'], 'DERIVE', 60, '0', 'U'),158 (self.collect_key['Select_range_check'], 'DERIVE', 60, '0', 'U'),159 (self.collect_key['Select_scan'], 'DERIVE', 60, '0', 'U'),160 (self.collect_key['Slow_queries'], 'DERIVE', 60, '0', 'U'),161 (self.collect_key['Sort_merge_passes'], 'DERIVE', 60, '0', 'U'),162 (self.collect_key['Sort_range'], 'DERIVE', 60, '0', 'U'),163 (self.collect_key['Sort_rows'], 'DERIVE', 60, '0', 'U'),164 (self.collect_key['Sort_scan'], 'DERIVE', 60, '0', 'U'),165 (self.collect_key['Table_locks_immediate'], 'DERIVE', 60, '0', 'U'),166 (self.collect_key['Table_locks_waited'], 'DERIVE', 60, '0', 'U'),167 (self.collect_key['Threads_cached'], 'GAUGE', 60, '0', 'U'),168 (self.collect_key['Threads_connected'], 'GAUGE', 60, '0', 'U'),169 (self.collect_key['Threads_created'], 'GAUGE', 60, '0', 'U'),170 (self.collect_key['Threads_running'], 'GAUGE', 60, '0', 'U')]171 # used for RRA172 self.rra_list = [ ('MAX', 0.5, 5/5, (3600/5)*24), # 5sec (to 1day)173 ('MAX', 0.5, 60/5, (3600/60)*24*7), # 30sec (to 7day)174 ('MAX', 0.5, 3600/5, 24*31), # 1hour (to 1month)175 ('MAX', 0.5, 3600*3/5, (24/3)*366*3) ] # 3hour (to 3year)176 def collect_key_init(self):177 self.collect_key = {}178 self.collect_key['Binlog_cache_disk_use'] = 'Binlog_cache_disk'179 self.collect_key['Binlog_cache_use'] = 'Binlog_cache'180 self.collect_key['Bytes_received'] = 'Bytes_received'181 self.collect_key['Bytes_sent'] = 'Bytes_sent'182 self.collect_key['Com_alter_table'] = 'Com_alter_table'183 self.collect_key['Com_call_procedure'] = 'Com_call_proc'184 self.collect_key['Com_commit'] = 'Com_commit'185 self.collect_key['Com_create_table'] = 'Com_create_table'186 self.collect_key['Com_dealloc_sql'] = 'Com_dealloc_sql'187 self.collect_key['Com_delete'] = 'Com_delete'188 self.collect_key['Com_delete_multi'] = 'Com_delete_multi'189 self.collect_key['Com_do'] = 'Com_do'190 self.collect_key['Com_drop_table'] = 'Com_drop_table'191 self.collect_key['Com_execute_sql'] = 'Com_execute_sql'192 self.collect_key['Com_flush'] = 'Com_flush'193 self.collect_key['Com_insert'] = 'Com_insert'194 self.collect_key['Com_insert_select'] = 'Com_insert_select'195 self.collect_key['Com_prepare_sql'] = 'Com_prepare_sql'196 self.collect_key['Com_release_savepoint'] = 'Com_release_SP'197 self.collect_key['Com_rename_table'] = 'Com_rename_table'198 self.collect_key['Com_replace'] = 'Com_replace'199 self.collect_key['Com_replace_select'] = 'Com_replace_select'200 self.collect_key['Com_rollback'] = 'Com_rollback'201 self.collect_key['Com_rollback_to_savepoint'] = 'Com_rollback_to_SP'202 self.collect_key['Com_savepoint'] = 'Com_savepoint'203 self.collect_key['Com_select'] = 'Com_select'204 self.collect_key['Com_stmt_close'] = 'Com_stmt_close'205 self.collect_key['Com_stmt_execute'] = 'Com_stmt_execute'206 self.collect_key['Com_stmt_fetch'] = 'Com_stmt_fetch'207 self.collect_key['Com_stmt_prepare'] = 'Com_stmt_prepare'208 self.collect_key['Com_stmt_reprepare'] = 'Com_stmt_reprepare'209 self.collect_key['Com_stmt_reset'] = 'Com_stmt_reset'210 self.collect_key['Com_truncate'] = 'Com_truncate'211 self.collect_key['Com_update'] = 'Com_update'212 self.collect_key['Com_update_multi'] = 'Com_update_multi'213 self.collect_key['Connections'] = 'Connections'214 self.collect_key['Innodb_buffer_pool_pages_data'] = 'idb_bpool_P_data'215 self.collect_key['Innodb_buffer_pool_pages_dirty'] = 'idb_bpool_P_dirty'216 self.collect_key['Innodb_buffer_pool_pages_flushed'] = 'idb_bpool_P_flushed'217 self.collect_key['Innodb_buffer_pool_pages_free'] = 'idb_bpool_P_free'218 self.collect_key['Innodb_buffer_pool_pages_misc'] = 'idb_bpool_P_misc'219 self.collect_key['Innodb_buffer_pool_pages_total'] = 'idb_bpool_P_total'220 self.collect_key['Innodb_buffer_pool_read_ahead'] = 'idb_bpool_ra'221 self.collect_key['Innodb_buffer_pool_read_ahead_evicted'] = 'idb_bpool_ra_evict'222 self.collect_key['Innodb_buffer_pool_read_requests'] = 'idb_bpool_read_req'223 self.collect_key['Innodb_buffer_pool_reads'] = 'idb_bpool_reads'224 self.collect_key['Innodb_buffer_pool_wait_free'] = 'idb_bpool_wait_free'225 self.collect_key['Innodb_buffer_pool_write_requests'] = 'idb_bpool_write_req'226 self.collect_key['Innodb_data_fsyncs'] = 'idb_data_fsyncs'227 self.collect_key['Innodb_data_pending_fsyncs'] = 'idb_data_pend_fsync'228 self.collect_key['Innodb_data_pending_reads'] = 'idb_data_pend_rds'229 self.collect_key['Innodb_data_pending_writes'] = 'idb_data_pend_wrs'230 self.collect_key['Innodb_data_read'] = 'idb_data_read'231 self.collect_key['Innodb_data_reads'] = 'idb_data_reads'232 self.collect_key['Innodb_data_writes'] = 'idb_data_writes'233 self.collect_key['Innodb_data_written'] = 'idb_data_written'234 self.collect_key['Innodb_dblwr_pages_written'] = 'idb_dblwr_P_written'235 self.collect_key['Innodb_dblwr_writes'] = 'idb_dblwr_writes'236 self.collect_key['Innodb_log_waits'] = 'idb_log_waits'237 self.collect_key['Innodb_log_write_requests'] = 'idb_log_wr_req'238 self.collect_key['Innodb_log_writes'] = 'idb_log_writes'239 self.collect_key['Innodb_pages_created'] = 'idb_P_created'240 self.collect_key['Innodb_pages_read'] = 'idb_P_read'241 self.collect_key['Innodb_pages_written'] = 'idb_P_written'242 self.collect_key['Innodb_row_lock_current_waits'] = 'idb_row_lck_C_waits'243 self.collect_key['Innodb_row_lock_time'] = 'idb_row_lock_time'244 self.collect_key['Innodb_row_lock_time_avg'] = 'idb_row_lck_avg'245 self.collect_key['Innodb_row_lock_time_max'] = 'idb_row_lck_max'246 self.collect_key['Innodb_row_lock_waits'] = 'idb_row_lck_waits'247 self.collect_key['Innodb_rows_deleted'] = 'idb_rows_deleted'248 self.collect_key['Innodb_rows_inserted'] = 'idb_rows_inserted'249 self.collect_key['Innodb_rows_read'] = 'idb_rows_read'250 self.collect_key['Innodb_rows_updated'] = 'idb_rows_updated'251 self.collect_key['Not_flushed_delayed_rows'] = 'Not_flu_delayed_R'252 self.collect_key['Opened_files'] = 'Opened_files'253 self.collect_key['Opened_table_definitions'] = 'Opened_table_def'254 self.collect_key['Opened_tables'] = 'Opened_tables'255 self.collect_key['Prepared_stmt_count'] = 'Prepared_stmt_count'256 self.collect_key['Qcache_free_blocks'] = 'Qcache_free_blocks'257 self.collect_key['Qcache_free_memory'] = 'Qcache_free_memory'258 self.collect_key['Qcache_hits'] = 'Qcache_hits'259 self.collect_key['Qcache_inserts'] = 'Qcache_inserts'260 self.collect_key['Qcache_lowmem_prunes'] = 'Qcache_lowm_prunes'261 self.collect_key['Qcache_not_cached'] = 'Qcache_not_cached'262 self.collect_key['Qcache_queries_in_cache'] = 'Qcache_Q_in_cache'263 self.collect_key['Qcache_total_blocks'] = 'Qcache_total_blocks'264 self.collect_key['Queries'] = 'Queries'265 self.collect_key['Select_full_join'] = 'Select_full_join'266 self.collect_key['Select_full_range_join'] = 'Select_F_range_join'267 self.collect_key['Select_range'] = 'Select_range'268 self.collect_key['Select_range_check'] = 'Select_range_check'269 self.collect_key['Select_scan'] = 'Select_scan'270 self.collect_key['Slow_queries'] = 'Slow_queries'271 self.collect_key['Sort_merge_passes'] = 'Sort_merge_passes'272 self.collect_key['Sort_range'] = 'Sort_range'273 self.collect_key['Sort_rows'] = 'Sort_rows'274 self.collect_key['Sort_scan'] = 'Sort_scan'275 self.collect_key['Table_locks_immediate'] = 'Table_locks_imme'276 self.collect_key['Table_locks_waited'] = 'Table_locks_waited'277 self.collect_key['Threads_cached'] = 'Threads_cached'278 self.collect_key['Threads_connected'] = 'Threads_connected'279 self.collect_key['Threads_created'] = 'Threads_created'...

Full Screen

Full Screen

test_derive.py

Source:test_derive.py Github

copy

Full Screen

1from .derive import derive_str2def test_derive_num() -> None:3 assert derive_str("7", "x") == "0"4def test_derive_var() -> None:5 assert derive_str("x", "x") == "1"6def test_derive_var_sum() -> None:7 assert derive_str("x+3", "x") == "1"8def test_derive_var_mul() -> None:9 assert derive_str("x*y", "x") == "y"10def test_derive_poly_mul() -> None:11 assert derive_str("a*x*x + b*x + c", "x") == "a * x + x * a + b" # -> 2*a*x + b12def test_derive_poly_2() -> None:13 assert derive_str("a*x**2 + b*x + c", "x") == "a * (2 * x) + b" # -> 2*a*x + b14def test_derive_poly_3() -> None:15 assert derive_str("a*x**3 + b*x**2 + c*x + d", "x") == \16 "a * (3 * x ** 2) + b * (2 * x) + c" # -> 3*a*x**2 + 2*b*x + c17def test_derive_poly_4() -> None:...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run lisa automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful