Coverage for mtools.mplotqueries.plottypes.event_type : 32%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
except ImportError: raise ImportError("Can't import matplotlib. See https://github.com/rueckstiess/mtools/blob/master/INSTALL.md for \ instructions how to install matplotlib or try mlogvis instead, which is a simplified version of mplotqueries \ that visualizes the logfile in a web browser.")
x = date2num( [ logevent.datetime for logevent in self.groups[group] ] )
# event plots use axvline artists = [] color, marker = self.color_map(group)
for i, xcoord in enumerate(x): if i == 0: artist = axis.axvline(xcoord, linewidth=2, picker=5, color=color, alpha=0.7, label=group) else: artist = axis.axvline(xcoord, linewidth=2, picker=5, color=color, alpha=0.7) # add meta-data for picking artist._mt_plot_type = self artist._mt_group = group artist._mt_line_id = i artists.append(artist)
axis.autoscale_view(scaley=False) return artists
group = event.artist._mt_group line_id = event.artist._mt_line_id print self.groups[group][line_id].line_str
""" This plot type derives from the event plot type (vertical lines), but instead of plotting arbitrary events, it will only accept lines that indicate a replica set change.
Those lines either contain the string "is now in state" (for other members) or are of the form "[rsMgr] replSet PRIMARY" for own state changes.
A custom group_by method 'lastword()' groups those lines by their last word (which is representative of the new state) and an overloaded color_map() method assigns colors to each of those states, similar to the ones used in MMS. """
# force group() to always use lastword method to group by # group_by = 'lastword'
""" only match log lines containing 'is now in state' (reflects other node's state changes) or of type "[rsMgr] replSet PRIMARY" (reflects own state changes). """ if "is now in state" in logevent.line_str and logevent.split_tokens[-1] in self.states: return True
if "replSet" in logevent.line_str and logevent.thread == "rsMgr" and logevent.split_tokens[-1] in self.states: return True
return False
""" group by the last token of the log line (PRIMARY, SECONDARY, ...) """ return logevent.split_tokens[-1]
def color_map(cls, group): print "Group", group """ change default color behavior to map certain states always to the same colors (similar to MMS). """ try: state_idx = cls.states.index(group) except ValueError: # on any unexpected state, return black state_idx = 5 return cls.colors[state_idx], cls.markers[0] |