sentence1
stringlengths
52
3.87M
sentence2
stringlengths
1
47.2k
label
stringclasses
1 value
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
Implements Munin Plugin Auto-Configuration Option. @return: True if plugin can be auto-configured, False otherwise.
entailment
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('...
Retrieve values for graphs.
entailment
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, ...
Implements Munin Plugin Auto-Configuration Option. @return: True if plugin can be auto-configured, False otherwise.
entailment
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...
Retrieve values for graphs.
entailment
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...
Perform symbolic object (symbolic LU decomposition) computation for a given sparsity pattern.
entailment
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) ...
Perform numeric object (LU decomposition) computation using the symbolic decomposition. The symbolic decomposition is (re)computed if necessary.
entailment
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
Free symbolic data
entailment
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()
Free numeric data
entailment
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...
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 UMFPACK docs mtx : scipy.sparse.csc_matrix or scipy.sparse.csr_matrix...
entailment
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...
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, UMFPACK_At, see umfSys list and UMFPACK docs mtx : scipy.sparse.csc_matrix...
entailment
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...
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 scipy.sparse.csr_matrix Input...
entailment
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...
Reorders a list according to strategy
entailment
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...
Computes weights for one reordering using stick-breaking method
entailment
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): ...
Creates a nested dict of distances
entailment
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...
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 list of feature dicts for presented words distances : dict dict of distance matri...
entailment
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 """...
In-place method that updates fingerprint with new data Parameters ---------- egg : quail.Egg Data to update fingerprint Returns ---------- None
entailment
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 ...
Reorders a list of stimuli to match a fingerprint Parameters ---------- egg : quail.Egg Data to compute fingerprint method : str Method to re-sort list. Can be 'stick' or 'permute' (default: permute) nperms : int Number of permutations to us...
entailment
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) ...
Query and parse Web Server Status Page. @param extras: Include extra metrics, which can be computationally more expensive.
entailment
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): ...
Return major and minor device number for block device path devpath. @param devpath: Full path for block device. @return: Tuple (major, minor).
entailment
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...
Return unique device for any block device path. @param devpath: Full path for block device. @return: Unique device string without the /dev prefix.
entailment
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: ...
Parses /proc/devices to initialize device class - major number map for block devices.
entailment
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...
Check files in /dev/mapper to initialize data structures for mappings between device-mapper devices, minor device numbers, VGs and LVs.
entailment
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: ...
Initialize filesystem to device mappings.
entailment
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...
Initialize swap partition to device mappings.
entailment
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('...
Parse and initialize block device I/O stats in /proc/diskstats.
entailment
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...
Sort block devices into lists depending on device class and initialize device type map and partition map.
entailment
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)
Returns type of device dev. @return: Device type as string.
entailment
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: ...
Returns list of partitions. @return: List of (disk,partition) pairs.
entailment
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...
Returns I/O stats for block device. @param dev: Device name @param devtype: Device type. (Ignored if None.) @return: Dict of stats.
entailment
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...
Returns I/O stats for swap partition. @param dev: Device name for swap partition. @return: Dict of stats.
entailment
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. ""...
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.
entailment
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))
Returns I/O stats for filesystem. @param fs: Filesystem path. @return: Dict of stats.
entailment
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,...
Retrieve values for graphs.
entailment
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...
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 indexed by container name.
entailment
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...
Decode speech for a file or folder and return results This function wraps the Google Speech API and ffmpeg to decode speech for free recall experiments. Note: in order for this to work, you must have a Google Speech account, a google speech credentials file referenced in your _bash_profile, and ffmpeg...
entailment
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...
Parse input string and return int, float or str depending on format. @param val: Input string. @return: Value of type int, float or str.
entailment
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, ...
Connect to Squid Proxy Manager interface.
entailment
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...
Query Squid Proxy Server Manager Interface for stats. @param map: Statistics map name. @return: Dictionary of query results.
entailment
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(): ...
Parse simple stats list of key, value pairs. @param data: Multiline data with one key-value pair in each line. @return: Dictionary of stats.
entailment
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...
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.
entailment
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...
Get manager interface section list from Squid Proxy Server @return: List of tuples (section, description, type)
entailment
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...
Return dictionary of Traffic Stats for each Wanpipe Interface. @return: Nested dictionary of statistics for each interface.
entailment
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', ...
Return RDSI Operational Stats for interface. @param iface: Interface name. (Ex. w1g1) @return: Nested dictionary of statistics for interface.
entailment
def _connect(self): """Connect to FreeSWITCH ESL Interface.""" try: self._eslconn = ESL.ESLconnection(self._eslhost, str(self._eslport), self._eslpass) except: pass if no...
Connect to FreeSWITCH ESL Interface.
entailment
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) ...
Execute command and return result body as list of lines. @param cmd: Command string. @param args: Comand arguments string. @return: Result dictionary.
entailment
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...
Execute 'show' command and return result dictionary. @param cmd: Command string. @return: Result dictionary.
entailment
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...
Execute 'show' command and return result dictionary. @param cmd: Command string. @return: Result dictionary.
entailment
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',...
Retrieve values for graphs.
entailment
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...
Retrieve values for graphs.
entailment
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,...
Implements Munin Plugin Auto-Configuration Option. @return: True if plugin can be auto-configured, False otherwise.
entailment
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)
Ping Redis Server and return Round-Trip-Time in seconds. @return: Round-trip-time in seconds as float.
entailment
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...
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 presented / recalled ints and floats, if desired Returns ---...
entailment
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...
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 recalled words \ e.g. [[[16, 15, 0, 2, 3, None, None...],...
entailment
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 =...
Fills in default distance metrics for fingerprint analyses
entailment
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...
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 is 'concatenate' 'concatenate' concatenates k...
entailment
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 ...
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 ---------- new_egg : Egg data object A sliced...
entailment
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 ...
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 The input df reformatted as a...
entailment
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([]) ...
Fills in missing lists (assumes end lists are missing)
entailment
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
Parses an egg and returns fields
entailment
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): ...
Helper function to merge pres and features to support legacy features argument
entailment
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...
Function that calculates the Fisher z-transformation Parameters ---------- r : int or ndarray Correlation value Returns ---------- result : int or ndarray Fishers z transformed correlation value
entailment
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...
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
entailment
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 ...
Shuffle an Egg's recalls
entailment
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')...
Retrieve values for graphs.
entailment
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(): ...
Get NTP Peer Stats for localhost by querying local NTP Server. @return: Dictionary of NTP stats converted to seconds.
entailment
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...
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.
entailment
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 = ...
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.
entailment
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...
Return system uptime in seconds. @return: Float that represents uptime in seconds.
entailment
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...
Return system Load Average. @return: List of 1 min, 5 min and 15 min Load Average figures.
entailment
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...
Return cpu time utilization in seconds. @return: Dictionary of stats.
entailment
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() ...
Return stats for running and blocked processes, forks, context switches and interrupts. @return: Dictionary of stats.
entailment
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...
Return stats for memory utilization. @return: Dictionary of stats.
entailment
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...
Return information on swap partition and / or files. @return: Dictionary of stats.
entailment
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...
Return stats for Virtual Memory Subsystem. @return: Dictionary of stats.
entailment
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....
Connect to Memcached.
entailment
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...
Send stat command to Memcached Server and return response lines. @param cmd: Command string. @return: Array of strings.
entailment
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. """ ...
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.
entailment
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...
Retrieve values for graphs.
entailment
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)
Implements Munin Plugin Auto-Configuration Option. @return: True if plugin can be auto-configured, False otherwise.
entailment
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')
Returns correlation distance between a and b
entailment
def euclidean(a, b): "Returns euclidean distance between a and b" return np.linalg.norm(np.subtract(a, b))
Returns euclidean distance between a and b
entailment
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)) ...
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
entailment
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. ...
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. @param fields: List of fields included in the output. ...
entailment
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...
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 Standard Format Specifiers from ps man page must be used for the fields parameter. @param fi...
entailment
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 ...
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 page must be used for the fields parameter. @param fields:...
entailment
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...
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 to a field name with an optional suffix:...
entailment
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'))...
Retrieve values for graphs.
entailment
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...
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 Munin Plugin. @param debug: Print debugging messages if Tr...
entailment
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: ...
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: Delimiter for field labels field labels longer than ...
entailment
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...
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 environment variables. (O...
entailment
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: ...
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: Graph Object or None
entailment
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...
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: If true throw exception if there is no subgraph ...
entailment
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. ...
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.
entailment
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 = [] ...
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.
entailment
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...
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.
entailment
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...
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. @return: Value of environment variable.
entailment
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. ...
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. (Also determines suffix for environment variable name.) @par...
entailment
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. ...
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. @param name: Name of filter. (Also determines ...
entailment
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. ...
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. @return: Return True if the attribute is en...
entailment
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 (...
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 (True or False). Default value for flag. @return: ...
entailment