Search is not available for this dataset
text
stringlengths
75
104k
def saveState(self, stateObj): """Utility methos to save plugin state stored in stateObj to persistent storage to permit access to previous state in subsequent plugin runs. Any object that can be pickled and unpickled can be used to store the plugin state. @p...
def restoreState(self): """Utility method to restore plugin state from persistent storage to permit access to previous plugin state. @return: Object that stores plugin state. """ if os.path.exists(self._stateFile): try: fp = open(sel...
def appendGraph(self, graph_name, graph): """Utility method to associate Graph Object to Plugin. This utility method is for use in constructor of child classes for associating a MuninGraph instances to the plugin. @param graph_name: Graph Name @param graph: ...
def appendSubgraph(self, parent_name, graph_name, graph): """Utility method to associate Subgraph Instance to Root Graph Instance. This utility method is for use in constructor of child classes for associating a MuninGraph Subgraph instance with a Root Graph instance. @param ...
def setGraphVal(self, graph_name, field_name, val): """Utility method to set Value for Field in Graph. The private method is for use in retrieveVals() method of child classes. @param graph_name: Graph Name @param field_name: Field Name. @param val: Value ...
def setSubgraphVal(self, parent_name, graph_name, field_name, val): """Set Value for Field in Subgraph. The private method is for use in retrieveVals() method of child classes. @param parent_name: Root Graph Name @param graph_name: Subgraph Name @param field_...
def getSubgraphList(self, parent_name): """Returns list of names of subgraphs for Root Graph with name parent_name. @param parent_name: Name of Root Graph. @return: List of subgraph names. """ if not self.isMultigraph: raise AttributeError...
def graphHasField(self, graph_name, field_name): """Return true if graph with name graph_name has field with name field_name. @param graph_name: Graph Name @param field_name: Field Name. @return: Boolean """ graph = self._graphDict.get(graph_nam...
def subGraphHasField(self, parent_name, graph_name, field_name): """Return true if subgraph with name graph_name with parent graph with name parent_name has field with name field_name. @param parent_name: Root Graph Name @param graph_name: Subgraph Name @param field_nam...
def getGraphFieldList(self, graph_name): """Returns list of names of fields for graph with name graph_name. @param graph_name: Graph Name @return: List of field names for graph. """ graph = self._getGraph(graph_name, True) return graph.getField...
def getGraphFieldCount(self, graph_name): """Returns number of fields for graph with name graph_name. @param graph_name: Graph Name @return: Number of fields for graph. """ graph = self._getGraph(graph_name, True) return graph.getFieldCount()
def getSubgraphFieldList(self, parent_name, graph_name): """Returns list of names of fields for subgraph with name graph_name and parent graph with name parent_name. @param parent_name: Root Graph Name @param graph_name: Subgraph Name @return: List of field n...
def getSubgraphFieldCount(self, parent_name, graph_name): """Returns number of fields for subgraph with name graph_name and parent graph with name parent_name. @param parent_name: Root Graph Name @param graph_name: Subgraph Name @return: Number of fields for...
def config(self): """Implements Munin Plugin Graph Configuration. Prints out configuration for graphs. Use as is. Not required to be overwritten in child classes. The plugin will work correctly as long as the Munin Graph objects have been populated. """ ...
def fetch(self): """Implements Munin Plugin Fetch Option. Prints out measured values. """ self.retrieveVals() for parent_name in self._graphNames: graph = self._graphDict[parent_name] if self.isMultigraph: print "multigraph %s" % self._ge...
def run(self): """Implements main entry point for plugin execution.""" if len(self._argv) > 1 and len(self._argv[1]) > 0: oper = self._argv[1] else: oper = 'fetch' if oper == 'fetch': ret = self.fetch() elif oper == 'config': ret = ...
def addField(self, name, label, type=None, draw=None, info=None, #@ReservedAssignment extinfo=None, colour=None, negative=None, graph=None, min=None, max=None, cdef=None, line=None, #@ReservedAssignment warning=None, critical=None): """Add field to Munin Grap...
def hasField(self, name): """Returns true if field with field_name exists. @param name: Field Name @return: Boolean """ if self._autoFixNames: name = self._fixName(name) return self._fieldAttrDict.has_key(name)
def getConfig(self): """Returns dictionary of config entries for Munin Graph. @return: Dictionary of config entries. """ return {'graph': self._graphAttrDict, 'fields': [(field_name, self._fieldAttrDict.get(field_name)) for fi...
def setVal(self, name, val): """Set value for field in graph. @param name : Graph Name @param value : Value for field. """ if self._autoFixNames: name = self._fixName(name) self._fieldValDict[name] = val
def getVals(self): """Returns value list for Munin Graph @return: List of name-value pairs. """ return [(name, self._fieldValDict.get(name)) for name in self._fieldNameList]
def initStats(self, extras=None): """Query and parse Web Server Status Page. @param extras: Include extra metrics, which can be computationally more expensive. """ if extras is not None: self._extras = extras if self._extras: ...
def initStats(self): """Query and parse Nginx Web Server Status Page.""" url = "%s://%s:%d/%s" % (self._proto, self._host, self._port, self._statuspath) response = util.get_url(url, self._user, self._password) self._statusDict = {} for line in re...
def read_file(filename): """Read a file into a string""" path = os.path.abspath(os.path.dirname(__file__)) filepath = os.path.join(path, filename) try: return open(filepath).read() except IOError: return ''
def retrieveVals(self): """Retrieve values for graphs.""" proc_info = ProcessInfo() stats = {} for (prefix, is_thread) in (('proc', False), ('thread', True)): graph_name = '%s_status' % prefix if self.hasGraph(graph_name): ...
def retrieveVals(self): """Retrieve values for graphs.""" file_stats = self._fileInfo.getContainerStats() for contname in self._fileContList: stats = file_stats.get(contname) if stats is not None: if self.hasGraph('rackspace_cloudfiles_container_size'): ...
def plot(results, subjgroup=None, subjname='Subject Group', listgroup=None, listname='List', subjconds=None, listconds=None, plot_type=None, plot_style=None, title=None, legend=True, xlim=None, ylim=None, save_path=None, show=True, ax=None, **kwargs): """ General plot function that gr...
def getIfStats(self): """Return dictionary of Traffic Stats for Network Interfaces. @return: Nested dictionary of statistics for each interface. """ info_dict = {} try: fp = open(ifaceStatsFile, 'r') data = fp.read() fp.close(...
def getIfConfig(self): """Return dictionary of Interface Configuration (ifconfig). @return: Dictionary of if configurations keyed by if name. """ conf = {} try: out = subprocess.Popen([ipCmd, "addr", "show"], stdou...
def getRoutes(self): """Get routing table. @return: List of routes. """ routes = [] try: out = subprocess.Popen([routeCmd, "-n"], stdout=subprocess.PIPE).communicate()[0] except: raise Exception...
def execNetstatCmd(self, *args): """Execute ps command with positional params args and return result as list of lines. @param *args: Positional params for netstat command. @return: List of output lines """ out = util.exec_command([netstatCmd,] + li...
def parseNetstatCmd(self, tcp=True, udp=True, ipv4=True, ipv6=True, include_listen=True, only_listen=False, show_users=False, show_procs=False, resolve_hosts=False, resolve_ports=False, resolve_users=True): """Exec...
def getStats(self, tcp=True, udp=True, ipv4=True, ipv6=True, include_listen=True, only_listen=False, show_users=False, show_procs=False, resolve_hosts=False, resolve_ports=False, resolve_users=True, **kwargs): """Execute netstat command and ...
def getTCPportConnStatus(self, ipv4=True, ipv6=True, include_listen=False, **kwargs): """Returns the number of TCP endpoints discriminated by status. @param ipv4: Include IPv4 ports in output if True. @param ipv6: Include IPv6 ports in ou...
def getTCPportConnCount(self, ipv4=True, ipv6=True, resolve_ports=False, **kwargs): """Returns TCP connection counts for each local port. @param ipv4: Include IPv4 ports in output if True. @param ipv6: Include IPv6 ports in output if True. ...
def accuracy_helper(egg, match='exact', distance='euclidean', features=None): """ Computes proportion of words recalled Parameters ---------- egg : quail.Egg Data to analyze match : str (exact, best or smooth) Matching approach to compute recall matrix. If ...
def _connect(self): """Establish connection to PostgreSQL Database.""" if self._connParams: self._conn = psycopg2.connect(**self._connParams) else: self._conn = psycopg2.connect('') try: ver_str = self._conn.get_parameter_status('server_version') ...
def _createStatsDict(self, headers, rows): """Utility method that returns database stats as a nested dictionary. @param headers: List of columns in query result. @param rows: List of rows in query result. @return: Nested dictionary of values. Fi...
def _createTotalsDict(self, headers, rows): """Utility method that returns totals for database statistics. @param headers: List of columns in query result. @param rows: List of rows in query result. @return: Dictionary of totals for each statistics column. ...
def _simpleQuery(self, query): """Executes simple query which returns a single column. @param query: Query string. @return: Query result string. """ cur = self._conn.cursor() cur.execute(query) row = cur.fetchone() return util.parse_...
def getParam(self, key): """Returns value of Run-time Database Parameter 'key'. @param key: Run-time parameter name. @return: Run-time parameter value. """ cur = self._conn.cursor() cur.execute("SHOW %s" % key) row = cur.fetchone() ret...
def getConnectionStats(self): """Returns dictionary with number of connections for each database. @return: Dictionary of database connection statistics. """ cur = self._conn.cursor() cur.execute("""SELECT datname,numbackends FROM pg_stat_database;""") ro...
def getDatabaseStats(self): """Returns database block read, transaction and tuple stats for each database. @return: Nested dictionary of stats. """ headers = ('datname', 'numbackends', 'xact_commit', 'xact_rollback', 'blks_read', 'blks_hit',...
def getLockStatsMode(self): """Returns the number of active lock discriminated by lock mode. @return: : Dictionary of stats. """ info_dict = {'all': dict(zip(self.lockModes, (0,) * len(self.lockModes))), 'wait': dict(zip(self.lockModes, (0,) * len(s...
def getLockStatsDB(self): """Returns the number of active lock discriminated by database. @return: : Dictionary of stats. """ info_dict = {'all': {}, 'wait': {}} cur = self._conn.cursor() cur.execute("SELECT d.datname, l.granted, COU...
def getBgWriterStats(self): """Returns Global Background Writer and Checkpoint Activity stats. @return: Nested dictionary of stats. """ info_dict = {} if self.checkVersion('8.3'): cur = self._conn.cursor(cursor_factory=psycopg2.extras.RealDictCursor)...
def getXlogStatus(self): """Returns Transaction Logging or Recovery Status. @return: Dictionary of status items. """ inRecovery = None if self.checkVersion('9.0'): inRecovery = self._simpleQuery("SELECT pg_is_in_recovery();") cur = self._conn...
def getSlaveStatus(self): """Returns status of replication slaves. @return: Dictionary of status items. """ info_dict = {} if self.checkVersion('9.1'): cols = ['procpid', 'usename', 'application_name', 'client_addr', 'client_port...
def _connect(self): """Establish connection to MySQL Database.""" if self._connParams: self._conn = MySQLdb.connect(**self._connParams) else: self._conn = MySQLdb.connect('')
def getStorageEngines(self): """Returns list of supported storage engines. @return: List of storage engine names. """ cur = self._conn.cursor() cur.execute("""SHOW STORAGE ENGINES;""") rows = cur.fetchall() if rows: return [row[0].low...
def getParam(self, key): """Returns value of Run-time Database Parameter 'key'. @param key: Run-time parameter name. @return: Run-time parameter value. """ cur = self._conn.cursor() cur.execute("SHOW GLOBAL VARIABLES LIKE %s", key) row = cur.f...
def getParams(self): """Returns dictionary of all run-time parameters. @return: Dictionary of all Run-time parameters. """ cur = self._conn.cursor() cur.execute("SHOW GLOBAL VARIABLES") rows = cur.fetchall() info_dict = {} for row in rows...
def getProcessStatus(self): """Returns number of processes discriminated by state. @return: Dictionary mapping process state to number of processes. """ info_dict = {} cur = self._conn.cursor() cur.execute("""SHOW FULL PROCESSLIST;""") rows = cur...
def getProcessDatabase(self): """Returns number of processes discriminated by database name. @return: Dictionary mapping database name to number of processes. """ info_dict = {} cur = self._conn.cursor() cur.execute("""SHOW FULL PROCESSLIST;""") ...
def getDatabases(self): """Returns list of databases. @return: List of databases. """ cur = self._conn.cursor() cur.execute("""SHOW DATABASES;""") rows = cur.fetchall() if rows: return [row[0] for row in rows] else: ...
def spc_helper(egg, match='exact', distance='euclidean', features=None): """ Computes probability of a word being recalled (in the appropriate recall list), given its presentation position Parameters ---------- egg : quail.Egg Data to analyze match : str (exact, best or ...
def _retrieve(self): """Query Apache Tomcat Server Status Page in XML format and return the result as an ElementTree object. @return: ElementTree object of Status Page XML. """ url = "%s://%s:%d/manager/status" % (self._proto, self._host, self._port) pa...
def getMemoryStats(self): """Return JVM Memory Stats for Apache Tomcat Server. @return: Dictionary of memory utilization stats. """ if self._statusxml is None: self.initStats() node = self._statusxml.find('jvm/memory') memstats = {} i...
def getConnectorStats(self): """Return dictionary of Connector Stats for Apache Tomcat Server. @return: Nested dictionary of Connector Stats. """ if self._statusxml is None: self.initStats() connnodes = self._statusxml.findall('connector') co...
def load(filepath, update=True): """ Loads eggs, fried eggs ands example data Parameters ---------- filepath : str Location of file update : bool If true, updates egg to latest format Returns ---------- data : quail.Egg or quail.FriedEgg Data loaded from di...
def load_fegg(filepath, update=True): """ Loads pickled egg Parameters ---------- filepath : str Location of pickled egg update : bool If true, updates egg to latest format Returns ---------- egg : Egg data object A loaded unpickled egg """ try: ...
def load_egg(filepath, update=True): """ Loads pickled egg Parameters ---------- filepath : str Location of pickled egg update : bool If true, updates egg to latest format Returns ---------- egg : Egg data object A loaded unpickled egg """ try: ...
def loadEL(dbpath=None, recpath=None, remove_subs=None, wordpool=None, groupby=None, experiments=None, filters=None): ''' Function that loads sql files generated by autoFR Experiment ''' assert (dbpath is not None), "You must specify a db file or files." assert (recpath is not None), "You must ...
def load_example_data(dataset='automatic'): """ Loads example data The automatic and manual example data are eggs containing 30 subjects who completed a free recall experiment as described here: https://psyarxiv.com/psh48/. The subjects studied 8 lists of 16 words each and then performed a free rec...
def retrieveVals(self): """Retrieve values for graphs.""" fs = FSinfo(self._fshost, self._fsport, self._fspass) if self.hasGraph('fs_calls'): count = fs.getCallCount() self.setGraphVal('fs_calls', 'calls', count) if self.hasGraph('fs_channels'): count ...
def autoconf(self): """Implements Munin Plugin Auto-Configuration Option. @return: True if plugin can be auto-configured, False otherwise. """ fs = FSinfo(self._fshost, self._fsport, self._fspass) return fs is not None
def spsolve(A, b): """Solve the sparse linear system Ax=b, where b may be a vector or a matrix. Parameters ---------- A : ndarray or sparse matrix The square matrix A will be converted into CSC or CSR form b : ndarray or sparse matrix The matrix or vector representing the right hand...
def solve(self, b): """ Solve linear equation A x = b for x Parameters ---------- b : ndarray Right-hand side of the matrix equation. Can be vector or a matrix. Returns ------- x : ndarray Solution to the matrix equation ...
def solve_sparse(self, B): """ Solve linear equation of the form A X = B. Where B and X are sparse matrices. Parameters ---------- B : any scipy.sparse matrix Right-hand side of the matrix equation. Note: it will be converted to csc_matrix via `.tocsc()`....
def recall_matrix(egg, match='exact', distance='euclidean', features=None): """ Computes recall matrix given list of presented and list of recalled words Parameters ---------- egg : quail.Egg Data to analyze match : str (exact, best or smooth) Matching approach to compute recal...
def retrieveVals(self): """Retrieve values for graphs.""" net_info = NetstatInfo() if self.hasGraph('netstat_conn_status'): stats = net_info.getTCPportConnStatus(include_listen=True) for fname in ('listen', 'established', 'syn_sent', 'syn_recv', ...
def _parseFreePBXconf(self): """Parses FreePBX configuration file /etc/amportal for user and password for Asterisk Manager Interface. @return: True if configuration file is found and parsed successfully. """ amiuser = None amipass = None if os.pa...
def _parseAsteriskConf(self): """Parses Asterisk configuration file /etc/asterisk/manager.conf for user and password for Manager Interface. Returns True on success. @return: True if configuration file is found and parsed successfully. """ if os.path.isfile(confF...
def _connect(self): """Connect to Asterisk Manager Interface.""" try: if sys.version_info[:2] >= (2,6): self._conn = telnetlib.Telnet(self._amihost, self._amiport, connTimeout) else: self._conn = telne...
def _sendAction(self, action, attrs=None, chan_vars=None): """Send action to Asterisk Manager Interface. @param action: Action name @param attrs: Tuple of key-value pairs for action attributes. @param chan_vars: Tuple of key-value pairs for channel variables. """...
def _getResponse(self): """Read and parse response from Asterisk Manager Interface. @return: Dictionary with response key-value pairs. """ resp_dict= dict() resp_str = self._conn.read_until("\r\n\r\n", connTimeout) for line in resp_str.split("\r\n"): ...
def _getGreeting(self): """Read and parse Asterisk Manager Interface Greeting to determine and set Manager Interface version. """ greeting = self._conn.read_until("\r\n", connTimeout) mobj = re.match('Asterisk Call Manager\/([\d\.]+)\s*$', greeting) if mobj: ...
def _initAsteriskVersion(self): """Query Asterisk Manager Interface for Asterisk Version to configure system for compatibility with multiple versions . CLI Command - core show version """ if self._ami_version > util.SoftwareVersion('1.0'): cmd = "core show ve...
def _login(self): """Login to Asterisk Manager Interface.""" self._sendAction("login", ( ("Username", self._amiuser), ("Secret", self._amipass), ("Events", "off"), )) resp = self._getResponse() if resp.get("Response") == "Success": ...
def executeCommand(self, command): """Send Action to Asterisk Manager Interface to execute CLI Command. @param command: CLI command to execute. @return: Command response string. """ self._sendAction("Command", ( ("Command", command), )) ...
def _initModuleList(self): """Query Asterisk Manager Interface to initialize internal list of loaded modules. CLI Command - core show modules """ if self.checkVersion('1.4'): cmd = "module show" else: cmd = "show modules" ...
def _initApplicationList(self): """Query Asterisk Manager Interface to initialize internal list of available applications. CLI Command - core show applications """ if self.checkVersion('1.4'): cmd = "core show applications" else: ...
def _initChannelTypesList(self): """Query Asterisk Manager Interface to initialize internal list of supported channel types. CLI Command - core show applications """ if self.checkVersion('1.4'): cmd = "core show channeltypes" else: ...
def hasModule(self, mod): """Returns True if mod is among the loaded modules. @param mod: Module name. @return: Boolean """ if self._modules is None: self._initModuleList() return mod in self._modules
def hasApplication(self, app): """Returns True if app is among the loaded modules. @param app: Module name. @return: Boolean """ if self._applications is None: self._initApplicationList() return app in self._applications
def hasChannelType(self, chan): """Returns True if chan is among the supported channel types. @param app: Module name. @return: Boolean """ if self._chantypes is None: self._initChannelTypesList() return chan in self._chantypes
def getCodecList(self): """Query Asterisk Manager Interface for defined codecs. CLI Command - core show codecs @return: Dictionary - Short Name -> (Type, Long Name) """ if self.checkVersion('1.4'): cmd = "core show codecs" else: ...
def getChannelStats(self, chantypes=('dahdi', 'zap', 'sip', 'iax2', 'local')): """Query Asterisk Manager Interface for Channel Stats. CLI Command - core show channels @return: Dictionary of statistics counters for channels. Number of active channels for each channel type. ...
def getPeerStats(self, chantype): """Query Asterisk Manager Interface for SIP / IAX2 Peer Stats. CLI Command - sip show peers iax2 show peers @param chantype: Must be 'sip' or 'iax2'. @return: Dictionary of statistics counters for VoIP Peer...
def getVoIPchanStats(self, chantype, codec_list=('ulaw', 'alaw', 'gsm', 'g729')): """Query Asterisk Manager Interface for SIP / IAX2 Channel / Codec Stats. CLI Commands - sip show channels iax2 show channnels @param chantype: M...
def getConferenceStats(self): """Query Asterisk Manager Interface for Conference Room Stats. CLI Command - meetme list @return: Dictionary of statistics counters for Conference Rooms. """ if not self.hasConference(): return None if self.checkVersion...
def getVoicemailStats(self): """Query Asterisk Manager Interface for Voicemail Stats. CLI Command - voicemail show users @return: Dictionary of statistics counters for Voicemail Accounts. """ if not self.hasVoicemail(): return None if self.checkVers...
def getTrunkStats(self, trunkList): """Query Asterisk Manager Interface for Trunk Stats. CLI Command - core show channels @param trunkList: List of tuples of one of the two following types: (Trunk Name, Regular Expression) (Trunk ...
def getQueueStats(self): """Query Asterisk Manager Interface for Queue Stats. CLI Command: queue show @return: Dictionary of queue stats. """ if not self.hasQueue(): return None info_dict = {} if self.checkVersion('1.4'): ...
def getFaxStatsCounters(self): """Query Asterisk Manager Interface for Fax Stats. CLI Command - fax show stats @return: Dictionary of fax stats. """ if not self.hasFax(): return None info_dict = {} cmdresp = self.executeComma...
def getFaxStatsSessions(self): """Query Asterisk Manager Interface for Fax Stats. CLI Command - fax show sessions @return: Dictionary of fax stats. """ if not self.hasFax(): return None info_dict = {} info_dict['total'] = 0 ...
def retrieveVals(self): """Retrieve values for graphs.""" for iface in self._ifaceList: if self._reqIfaceList is None or iface in self._reqIfaceList: if (self.graphEnabled('wanpipe_traffic') or self.graphEnabled('wanpipe_errors')): sta...
def simulate_list(nwords=16, nrec=10, ncats=4): """A function to simulate a list""" # load wordpool wp = pd.read_csv('data/cut_wordpool.csv') # get one list wp = wp[wp['GROUP']==np.random.choice(list(range(16)), 1)[0]].sample(16) wp['COLOR'] = [[int(np.random.rand() * 255) for i in range(3)] ...
def retrieveVals(self): """Retrieve values for graphs.""" if self._genStats is None: self._genStats = self._dbconn.getStats() if self._genVars is None: self._genVars = self._dbconn.getParams() if self.hasGraph('mysql_connections'): self.setGraphVal('my...
def engineIncluded(self, name): """Utility method to check if a storage engine is included in graphs. @param name: Name of storage engine. @return: Returns True if included in graphs, False otherwise. """ if self._engines is None: self._engin...