Search is not available for this dataset
text
stringlengths
75
104k
def autoconf(self): """Implements Munin Plugin Auto-Configuration Option. @return: True if plugin can be auto-configured, False otherwise. """ ntpinfo = NTPinfo() ntpstats = ntpinfo.getHostOffsets(self._remoteHosts) return len(ntpstats) > 0
def retrieveVals(self): """Retrieve values for graphs.""" lighttpdInfo = LighttpdInfo(self._host, self._port, self._user, self._password, self._statuspath, self._ssl) stats = lighttpdInfo.getServerStats() if self.hasGraph('...
def autoconf(self): """Implements Munin Plugin Auto-Configuration Option. @return: True if plugin can be auto-configured, False otherwise. """ lighttpdInfo = LighttpdInfo(self._host, self._port, self._user, self._password, ...
def retrieveVals(self): """Retrieve values for graphs.""" name = 'diskspace' if self.hasGraph(name): for fspath in self._fslist: if self._statsSpace.has_key(fspath): self.setGraphVal(name, fspath, self._statsSp...
def symbolic(self, mtx): """ Perform symbolic object (symbolic LU decomposition) computation for a given sparsity pattern. """ self.free_symbolic() indx = self._getIndx(mtx) if not assumeSortedIndices: # row/column indices cannot be assumed to be sor...
def numeric(self, mtx): """ Perform numeric object (LU decomposition) computation using the symbolic decomposition. The symbolic decomposition is (re)computed if necessary. """ self.free_numeric() if self._symbolic is None: self.symbolic(mtx) ...
def free_symbolic(self): """Free symbolic data""" if self._symbolic is not None: self.funs.free_symbolic(self._symbolic) self._symbolic = None self.mtx = None
def free_numeric(self): """Free numeric data""" if self._numeric is not None: self.funs.free_numeric(self._numeric) self._numeric = None self.free_symbolic()
def solve(self, sys, mtx, rhs, autoTranspose=False): """ Solution of system of linear equation using the Numeric object. Parameters ---------- sys : constant one of UMFPACK system description constants, like UMFPACK_A, UMFPACK_At, see umfSys list and UMFP...
def linsolve(self, sys, mtx, rhs, autoTranspose=False): """ One-shot solution of system of linear equation. Reuses Numeric object if possible. Parameters ---------- sys : constant one of UMFPACK system description constants, like UMFPACK_A, UMFPAC...
def lu(self, mtx): """ Perform LU decomposition. For a given matrix A, the decomposition satisfies:: LU = PRAQ when do_recip is true LU = P(R^-1)AQ when do_recip is false Parameters ---------- mtx : scipy.sparse.csc_matrix or sc...
def order_stick(presenter, egg, dist_dict, strategy, fingerprint): """ Reorders a list according to strategy """ def compute_feature_stick(features, weights, alpha): '''create a 'stick' of feature weights''' feature_stick = [] for f, w in zip(features, weights): fea...
def stick_perm(presenter, egg, dist_dict, strategy): """Computes weights for one reordering using stick-breaking method""" # seed RNG np.random.seed() # unpack egg egg_pres, egg_rec, egg_features, egg_dist_funcs = parse_egg(egg) # reorder regg = order_stick(presenter, egg, dist_dict, stra...
def compute_distances_dict(egg): """ Creates a nested dict of distances """ pres, rec, features, dist_funcs = parse_egg(egg) pres_list = list(pres) features_list = list(features) # initialize dist dict distances = {} # for each word in the list for idx1, item1 in enumerate(pres_list): ...
def compute_feature_weights_dict(pres_list, rec_list, feature_list, dist_dict): """ Compute clustering scores along a set of feature dimensions Parameters ---------- pres_list : list list of presented words rec_list : list list of recalled words feature_list : list l...
def update(self, egg, permute=False, nperms=1000, parallel=False): """ In-place method that updates fingerprint with new data Parameters ---------- egg : quail.Egg Data to update fingerprint Returns ---------- None """...
def order(self, egg, method='permute', nperms=2500, strategy=None, distfun='correlation', fingerprint=None): """ Reorders a list of stimuli to match a fingerprint Parameters ---------- egg : quail.Egg Data to compute fingerprint method : str ...
def initStats(self, extras=None): """Query and parse Web Server Status Page. @param extras: Include extra metrics, which can be computationally more expensive. """ url = "%s://%s:%d/%s" % (self._proto, self._host, self._port, self._monpath) ...
def _getDevMajorMinor(self, devpath): """Return major and minor device number for block device path devpath. @param devpath: Full path for block device. @return: Tuple (major, minor). """ fstat = os.stat(devpath) if stat.S_ISBLK(fstat.st_mode): ...
def _getUniqueDev(self, devpath): """Return unique device for any block device path. @param devpath: Full path for block device. @return: Unique device string without the /dev prefix. """ realpath = os.path.realpath(devpath) mobj = re.match('\/dev...
def _initBlockMajorMap(self): """Parses /proc/devices to initialize device class - major number map for block devices. """ self._mapMajorDevclass = {} try: fp = open(devicesFile, 'r') data = fp.read() fp.close() except: ...
def _initDMinfo(self): """Check files in /dev/mapper to initialize data structures for mappings between device-mapper devices, minor device numbers, VGs and LVs. """ self._mapLVtuple2dm = {} self._mapLVname2dm = {} self._vgTree = {} if self._dmM...
def _initFilesystemInfo(self): """Initialize filesystem to device mappings.""" self._mapFSpathDev = {} fsinfo = FilesystemInfo() for fs in fsinfo.getFSlist(): devpath = fsinfo.getFSdev(fs) dev = self._getUniqueDev(devpath) if dev is not None: ...
def _initSwapInfo(self): """Initialize swap partition to device mappings.""" self._swapList = [] sysinfo = SystemInfo() for (swap,attrs) in sysinfo.getSwapStats().iteritems(): if attrs['type'] == 'partition': dev = self._getUniqueDev(swap) if d...
def _initDiskStats(self): """Parse and initialize block device I/O stats in /proc/diskstats.""" self._diskStats = {} self._mapMajorMinor2dev = {} try: fp = open(diskStatsFile, 'r') data = fp.read() fp.close() except: raise IOError('...
def _initDevClasses(self): """Sort block devices into lists depending on device class and initialize device type map and partition map.""" self._devClassTree = {} self._partitionTree = {} self._mapDevType = {} basedevs = [] otherdevs = [] if self._mapMajo...
def getDevType(self, dev): """Returns type of device dev. @return: Device type as string. """ if self._devClassTree is None: self._initDevClasses() return self._mapDevType.get(dev)
def getPartitionList(self): """Returns list of partitions. @return: List of (disk,partition) pairs. """ if self._partList is None: self._partList = [] for (disk,parts) in self.getPartitionDict().iteritems(): for part in parts: ...
def getDevStats(self, dev, devtype = None): """Returns I/O stats for block device. @param dev: Device name @param devtype: Device type. (Ignored if None.) @return: Dict of stats. """ if devtype is not None: if self._devClassTree is...
def getSwapStats(self, dev): """Returns I/O stats for swap partition. @param dev: Device name for swap partition. @return: Dict of stats. """ if self._swapList is None: self._initSwapInfo() if dev in self._swapList: return self.ge...
def getLVstats(self, *args): """Returns I/O stats for LV. @param args: Two calling conventions are implemented: - Passing two parameters vg and lv. - Passing only one parameter in 'vg-lv' format. @return: Dict of stats. ""...
def getFilesystemStats(self, fs): """Returns I/O stats for filesystem. @param fs: Filesystem path. @return: Dict of stats. """ if self._mapFSpathDev is None: self._initFilesystemInfo() return self._diskStats.get(self._mapFSpathDev.get(fs))
def retrieveVals(self): """Retrieve values for graphs.""" ntpinfo = NTPinfo() stats = ntpinfo.getHostOffset(self._remoteHost) if stats: graph_name = 'ntp_host_stratum_%s' % self._remoteHost if self.hasGraph(graph_name): self.setGraphVal(graph_name,...
def getContainerStats(self, limit=None, marker=None): """Returns Rackspace Cloud Files usage stats for containers. @param limit: Number of containers to return. @param marker: Return only results whose name is greater than marker. @return: Dictionary of container stats in...
def decode_speech(path, keypath=None, save=False, speech_context=None, sample_rate=44100, max_alternatives=1, language_code='en-US', enable_word_time_offsets=True, return_raw=False): """ Decode speech for a file or folder and return results This function wraps the Google...
def parse_value(val): """Parse input string and return int, float or str depending on format. @param val: Input string. @return: Value of type int, float or str. """ mobj = re.match('(-{0,1}\d+)\s*(\sseconds|/\s*\w+)$', val) if mobj: return int(mobj.group(1)) m...
def _connect(self): """Connect to Squid Proxy Manager interface.""" if sys.version_info[:2] < (2,6): self._conn = httplib.HTTPConnection(self._host, self._port) else: self._conn = httplib.HTTPConnection(self._host, self._port, ...
def _retrieve(self, map): """Query Squid Proxy Server Manager Interface for stats. @param map: Statistics map name. @return: Dictionary of query results. """ self._conn.request('GET', "cache_object://%s/%s" % (self._host, map), Non...
def _parseCounters(self, data): """Parse simple stats list of key, value pairs. @param data: Multiline data with one key-value pair in each line. @return: Dictionary of stats. """ info_dict = util.NestedDict() for line in data.splitlines(): ...
def _parseSections(self, data): """Parse data and separate sections. Returns dictionary that maps section name to section data. @param data: Multiline data. @return: Dictionary that maps section names to section data. """ section_dict = {} l...
def getMenu(self): """Get manager interface section list from Squid Proxy Server @return: List of tuples (section, description, type) """ data = self._retrieve('') info_list = [] for line in data.splitlines(): mobj = re.match('^\s*(\S.*\S...
def getIfaceStats(self): """Return dictionary of Traffic Stats for each Wanpipe Interface. @return: Nested dictionary of statistics for each interface. """ ifInfo = netiface.NetIfaceInfo() ifStats = ifInfo.getIfStats() info_dict = {} for ifname i...
def getPRIstats(self, iface): """Return RDSI Operational Stats for interface. @param iface: Interface name. (Ex. w1g1) @return: Nested dictionary of statistics for interface. """ info_dict = {} output = util.exec_command([wanpipemonCmd, '-i', iface, '-c', ...
def _connect(self): """Connect to FreeSWITCH ESL Interface.""" try: self._eslconn = ESL.ESLconnection(self._eslhost, str(self._eslport), self._eslpass) except: pass if no...
def _execCmd(self, cmd, args): """Execute command and return result body as list of lines. @param cmd: Command string. @param args: Comand arguments string. @return: Result dictionary. """ output = self._eslconn.api(cmd, args) ...
def _execShowCmd(self, showcmd): """Execute 'show' command and return result dictionary. @param cmd: Command string. @return: Result dictionary. """ result = None lines = self._execCmd("show", showcmd) if lines and len(lines) >= 2 and...
def _execShowCountCmd(self, showcmd): """Execute 'show' command and return result dictionary. @param cmd: Command string. @return: Result dictionary. """ result = None lines = self._execCmd("show", showcmd + " count") for line in line...
def retrieveVals(self): """Retrieve values for graphs.""" if self.hasGraph('asterisk_calls') or self.hasGraph('asterisk_channels'): stats = self._ami.getChannelStats(self._chanList) if self.hasGraph('asterisk_calls') and stats: self.setGraphVal('asterisk_calls',...
def retrieveVals(self): """Retrieve values for graphs.""" fpminfo = PHPfpmInfo(self._host, self._port, self._user, self._password, self._monpath, self._ssl) stats = fpminfo.getStats() if self.hasGraph('php_fpm_connections') and stats: self.setGr...
def autoconf(self): """Implements Munin Plugin Auto-Configuration Option. @return: True if plugin can be auto-configured, False otherwise. """ fpminfo = PHPfpmInfo(self._host, self._port, self._user, self._password, self._monpath,...
def ping(self): """Ping Redis Server and return Round-Trip-Time in seconds. @return: Round-trip-time in seconds as float. """ start = time.time() self._conn.ping() return (time.time() - start)
def list2pd(all_data, subjindex=None, listindex=None): """ Makes multi-indexed dataframe of subject data Parameters ---------- all_data : list of lists of strings strings are either all presented or all recalled items, in the order of presentation or recall *should also work for pre...
def recmat2egg(recmat, list_length=None): """ Creates egg data object from zero-indexed recall matrix Parameters ---------- recmat : list of lists (subs) of lists (encoding lists) of ints or 2D numpy array recall matrix representing serial positions of freely recalle...
def default_dist_funcs(dist_funcs, feature_example): """ Fills in default distance metrics for fingerprint analyses """ if dist_funcs is None: dist_funcs = dict() for key in feature_example: if key in dist_funcs: pass if key =...
def stack_eggs(eggs, meta='concatenate'): ''' Takes a list of eggs, stacks them and reindexes the subject number Parameters ---------- eggs : list of Egg data objects A list of Eggs that you want to combine meta : string Determines how the meta data of each Egg combines. Default...
def crack_egg(egg, subjects=None, lists=None): ''' Takes an egg and returns a subset of the subjects or lists Parameters ---------- egg : Egg data object Egg that you want to crack subjects : list List of subject idxs lists : list List of lists idxs Returns ...
def df2list(df): """ Convert a MultiIndex df to list Parameters ---------- df : pandas.DataFrame A MultiIndex DataFrame where the first level is subjects and the second level is lists (e.g. egg.pres) Returns ---------- lst : a list of lists of lists of values ...
def fill_missing(x): """ Fills in missing lists (assumes end lists are missing) """ # find subject with max number of lists maxlen = max([len(xi) for xi in x]) subs = [] for sub in x: if len(sub)<maxlen: for i in range(maxlen-len(sub)): sub.append([]) ...
def parse_egg(egg): """Parses an egg and returns fields""" pres_list = egg.get_pres_items().values[0] rec_list = egg.get_rec_items().values[0] feature_list = egg.get_pres_features().values[0] dist_funcs = egg.dist_funcs return pres_list, rec_list, feature_list, dist_funcs
def merge_pres_feats(pres, features): """ Helper function to merge pres and features to support legacy features argument """ sub = [] for psub, fsub in zip(pres, features): exp = [] for pexp, fexp in zip(psub, fsub): lst = [] for p, f in zip(pexp, fexp): ...
def r2z(r): """ Function that calculates the Fisher z-transformation Parameters ---------- r : int or ndarray Correlation value Returns ---------- result : int or ndarray Fishers z transformed correlation value """ with np.errstate(invalid='ignore', divide='ig...
def z2r(z): """ Function that calculates the inverse Fisher z-transformation Parameters ---------- z : int or ndarray Fishers z transformed correlation value Returns ---------- result : int or ndarray Correlation value """ with np.errstate(invalid='ignore', di...
def shuffle_egg(egg): """ Shuffle an Egg's recalls""" from .egg import Egg pres, rec, features, dist_funcs = parse_egg(egg) if pres.ndim==1: pres = pres.reshape(1, pres.shape[0]) rec = rec.reshape(1, rec.shape[0]) features = features.reshape(1, features.shape[0]) for ilist ...
def retrieveVals(self): """Retrieve values for graphs.""" for iface in self._ifaceList: stats = self._ifaceStats.get(iface) graph_name = 'netiface_traffic_%s' % iface if self.hasGraph(graph_name): self.setGraphVal(graph_name, 'rx', stats.get('rxbytes')...
def getPeerStats(self): """Get NTP Peer Stats for localhost by querying local NTP Server. @return: Dictionary of NTP stats converted to seconds. """ info_dict = {} output = util.exec_command([ntpqCmd, '-n', '-c', 'peers']) for line in output.splitlines(): ...
def getHostOffset(self, host): """Get NTP Stats and offset of remote host relative to localhost by querying NTP Server on remote host. @param host: Remote Host IP. @return: Dictionary of NTP stats converted to seconds. """ info_dict = {} output = uti...
def getHostOffsets(self, hosts): """Get NTP Stats and offset of multiple remote hosts relative to localhost by querying NTP Servers on remote hosts. @param host: List of Remote Host IPs. @return: Dictionary of NTP stats converted to seconds. """ info_dict = ...
def getUptime(self): """Return system uptime in seconds. @return: Float that represents uptime in seconds. """ try: fp = open(uptimeFile, 'r') line = fp.readline() fp.close() except: raise IOError('Failed reading s...
def getLoadAvg(self): """Return system Load Average. @return: List of 1 min, 5 min and 15 min Load Average figures. """ try: fp = open(loadavgFile, 'r') line = fp.readline() fp.close() except: raise IOError('Failed...
def getCPUuse(self): """Return cpu time utilization in seconds. @return: Dictionary of stats. """ hz = os.sysconf('SC_CLK_TCK') info_dict = {} try: fp = open(cpustatFile, 'r') line = fp.readline() fp.close() ex...
def getProcessStats(self): """Return stats for running and blocked processes, forks, context switches and interrupts. @return: Dictionary of stats. """ info_dict = {} try: fp = open(cpustatFile, 'r') data = fp.read() ...
def getMemoryUse(self): """Return stats for memory utilization. @return: Dictionary of stats. """ info_dict = {} try: fp = open(meminfoFile, 'r') data = fp.read() fp.close() except: raise IOError('Failed re...
def getSwapStats(self): """Return information on swap partition and / or files. @return: Dictionary of stats. """ info_dict = {} try: fp = open(swapsFile, 'r') data = fp.read() fp.close() except: ra...
def getVMstats(self): """Return stats for Virtual Memory Subsystem. @return: Dictionary of stats. """ info_dict = {} try: fp = open(vmstatFile, 'r') data = fp.read() fp.close() except: raise IOError('Failed...
def _connect(self): """Connect to Memcached.""" if self._socketFile is not None: if not os.path.exists(self._socketFile): raise Exception("Socket file (%s) for Memcached Instance not found." % self._socketFile) try: if self....
def _sendStatCmd(self, cmd): """Send stat command to Memcached Server and return response lines. @param cmd: Command string. @return: Array of strings. """ try: self._conn.write("%s\r\n" % cmd) regex = re.compile('^(END|ERROR)\r\n', r...
def _parseStats(self, lines, parse_slabs = False): """Parse stats output from memcached and return dictionary of stats- @param lines: Array of lines of input text. @param parse_slabs: Parse slab stats if True. @return: Stats dictionary. """ ...
def retrieveVals(self): """Retrieve values for graphs.""" if self._stats is None: serverInfo = MemcachedInfo(self._host, self._port, self._socket_file) stats = serverInfo.getStats() else: stats = self._stats if stats is None: raise Excepti...
def autoconf(self): """Implements Munin Plugin Auto-Configuration Option. @return: True if plugin can be auto-configured, False otherwise. """ serverInfo = MemcachedInfo(self._host, self._port, self._socket_file) return (serverInfo is not None)
def correlation(a, b): "Returns correlation distance between a and b" if isinstance(a, list): a = np.array(a) if isinstance(b, list): b = np.array(b) a = a.reshape(1, -1) b = b.reshape(1, -1) return cdist(a, b, 'correlation')
def euclidean(a, b): "Returns euclidean distance between a and b" return np.linalg.norm(np.subtract(a, b))
def execProcCmd(self, *args): """Execute ps command with positional params args and return result as list of lines. @param *args: Positional params for ps command. @return: List of output lines """ out = util.exec_command([psCmd,] + list(args)) ...
def parseProcCmd(self, fields=('pid', 'user', 'cmd',), threads=False): """Execute ps command with custom output format with columns from fields and return result as a nested list. The Standard Format Specifiers from ps man page must be used for the fields parameter. ...
def getProcList(self, fields=('pid', 'user', 'cmd',), threads=False, **kwargs): """Execute ps command with custom output format with columns columns from fields, select lines using the filters defined by kwargs and return result as a nested list. The Standa...
def getProcDict(self, fields=('user', 'cmd',), threads=False, **kwargs): """Execute ps command with custom output format with columns format with columns from fields, and return result as a nested dictionary with the key PID or SPID. The Standard Format Specifiers from ps man ...
def getProcStatStatus(self, threads=False, **kwargs): """Return process counts per status and priority. @param **kwargs: Keyword variables are used for filtering the results depending on the values of the columns. Each keyword must correspond t...
def retrieveVals(self): """Retrieve values for graphs.""" ntpinfo = NTPinfo() stats = ntpinfo.getPeerStats() if stats: if self.hasGraph('ntp_peer_stratum'): self.setGraphVal('ntp_peer_stratum', 'stratum', stats.get('stratum'))...
def muninMain(pluginClass, argv=None, env=None, debug=False): """Main Block for Munin Plugins. @param pluginClass: Child class of MuninPlugin that implements plugin. @param argv: List of command line arguments to Munin Plugin. @param env: Dictionary of environment variables passed to...
def fixLabel(label, maxlen, delim=None, repl='', truncend=True): """Truncate long graph and field labels. @param label: Label text. @param maxlen: Maximum field label length in characters. No maximum field label length is enforced by default. @param delim: ...
def _parseEnv(self, env=None): """Private method for parsing through environment variables. Parses for environment variables common to all Munin Plugins: - MUNIN_STATEFILE - MUNIN_CAP_DIRTY_CONFIG - nested_graphs @param env: Dictionary of env...
def _getGraph(self, graph_name, fail_noexist=False): """Private method for returning graph object with name graph_name. @param graph_name: Graph Name @param fail_noexist: If true throw exception if there is no graph with name graph_name. @return: ...
def _getSubGraph(self, parent_name, graph_name, fail_noexist=False): """Private method for returning subgraph object with name graph_name and parent graph with name parent_name. @param parent_name: Root Graph Name @param graph_name: Subgraph Name @param fail_noexist...
def _getMultigraphID(self, graph_name, subgraph_name=None): """Private method for generating Multigraph ID from graph name and subgraph name. @param graph_name: Graph Name. @param subgraph_name: Subgraph Name. @return: Multigraph ID. ...
def _formatConfig(self, conf_dict): """Formats configuration directory from Munin Graph and returns multi-line value entries for the plugin config cycle. @param conf_dict: Configuration directory. @return: Multi-line text. """ confs = [] ...
def _formatVals(self, val_list): """Formats value list from Munin Graph and returns multi-line value entries for the plugin fetch cycle. @param val_list: List of name-value pairs. @return: Multi-line text. """ vals = [] for (name, val) i...
def envGet(self, name, default=None, conv=None): """Return value for environment variable or None. @param name: Name of environment variable. @param default: Default value if variable is undefined. @param conv: Function for converting value to desired type. @retu...
def envGetList(self, name, attr_regex = '^\w+$', conv=None): """Parse the plugin environment variables to return list from variable with name list_<name>. The value of the variable must be a comma separated list of items. @param name: Name of list. ...
def envRegisterFilter(self, name, attr_regex = '^\w+$', default = True): """Register filter for including, excluding attributes in graphs through the use of include_<name> and exclude_<name> environment variables. The value of the variables must be a comma separated list of items. ...
def envCheckFilter(self, name, attr): """Check if a specific graph attribute is enabled or disabled through the use of a filter based on include_<name> and exclude_<name> environment variables. @param name: Name of the Filter. @param attr: Name of the Attribute. ...
def envCheckFlag(self, name, default = False): """Check graph flag for enabling / disabling attributes through the use of <name> environment variable. @param name: Name of flag. (Also determines the environment variable name.) @param default: Boolean (...