Пример #1
0
	def __init__(self, host=None):
		if (host != None):
			raise error("Remote agents not supported.")
		_agent = libweb100.web100_attach(libweb100.WEB100_AGENT_TYPE_LOCAL, None)
		if _agent == None:
			libweb100_err()
		self._agent = _agent
		
		self._tune_group = libweb100.web100_group_find(_agent, "tune")
		if self._tune_group == None:
			libweb100_err()
		self.write_vars = {}
		_cur = libweb100.web100_var_head(self._tune_group)
		while _cur != None:
			var = Web100Var(_cur, self._tune_group)
			self.write_vars[str(var)] = var
			_cur = libweb100.web100_var_next(_cur)
		
		self.read_vars = {}
		for (name, var) in self.write_vars.items():
			self.read_vars[name] = var
		
		self._read_group = libweb100.web100_group_find(_agent, "read")
		if self._read_group == None:
			libweb100_err()
		_cur = libweb100.web100_var_head(self._read_group)
		while _cur != None:
			var = Web100Var(_cur, self._read_group)
			self.read_vars[str(var)] = var
			_cur = libweb100.web100_var_next(_cur)
		
		self.bufp = libweb100.new_bufp()
Пример #2
0
    def __init__(self, host=None):
        if (host != None):
            raise error("Remote agents not supported.")
        _agent = libweb100.web100_attach(libweb100.WEB100_AGENT_TYPE_LOCAL,
                                         None)
        if _agent == None:
            libweb100_err()
        self._agent = _agent

        self._tune_group = libweb100.web100_group_find(_agent, "tune")
        if self._tune_group == None:
            libweb100_err()
        self.write_vars = {}
        _cur = libweb100.web100_var_head(self._tune_group)
        while _cur != None:
            var = Web100Var(_cur, self._tune_group)
            self.write_vars[str(var)] = var
            _cur = libweb100.web100_var_next(_cur)

        self.read_vars = {}
        for (name, var) in self.write_vars.items():
            self.read_vars[name] = var

        self._read_group = libweb100.web100_group_find(_agent, "read")
        if self._read_group == None:
            libweb100_err()
        _cur = libweb100.web100_var_head(self._read_group)
        while _cur != None:
            var = Web100Var(_cur, self._read_group)
            self.read_vars[str(var)] = var
            _cur = libweb100.web100_var_next(_cur)

        self.bufp = libweb100.new_bufp()
Пример #3
0
def mkdict(ctl, new, old):
    """
    Convert a tctrl and two snaps into a dictionary.   This parallels John Heffners
    new python API for Web100, but handles deltas differently.

    Don't compute deltas, if there is no prior (old) sample.

    """
    r = {}

    # process the control structure
    # eeeewww clearly this is lame XXX
    r["flag"]=ctl.flag
    r["basemss"]=ctl.basemss
    r["win"]=ctl.win
    r["burstwin"]=ctl.burstwin
    r["duration"]=ctl.duration
    r["obswin"]=ctl.obswin
    r["SSbursts"]=ctl.SSbursts
    r["SSbully"]=ctl.SSbully
    r["SSbullyStall"]=ctl.SSbullyStall
    r["SSsumAwnd"]=ctl.SSsumAwnd
    r["SScntAwnd"]=ctl.SScntAwnd
    r["SSpoll"]=ctl.SSpoll

    # Process the snaps
    # This interim version violates clean layering:
    # it uses a hybrid of libweb100 and PyWeb100

    v = libweb100.web100_var_head(cvar.gread)
    while v:
	vv = PyWeb100.Web100Var(v, cvar.gread)   # ugly

        n = libweb100.web100_get_var_name(v)
        t = libweb100.web100_get_var_type(v)
	if libweb100.web100_snap_read(v, new, cvar.nbuf) != libweb100.WEB100_ERR_SUCCESS:
	    raise "snap read fail"
	if old:
	    if libweb100.web100_snap_read(v, old, cvar.obuf) != libweb100.WEB100_ERR_SUCCESS:
		raise "snap read fail"
        if   ( t == libweb100.WEB100_TYPE_COUNTER32 ):
	    r["abs_"+n]=rntohl(vv.val(cvar.nbuf))	# abs_ is absolute magnitude
	    if old:
		delta = rntohl(vv.val(cvar.nbuf)) - rntohl(vv.val(cvar.obuf))
		if delta < 0:
		    delta = delta + 4294967296
		r[n] = delta
        elif   ( t == libweb100.WEB100_TYPE_COUNTER64 ):
	    r["abs_"+n]=rntohll(vv.val(cvar.nbuf))	# abs_ is absolute magnitude
	    if old:
		# rntohl() is wrong
		delta = rntohll(vv.val(cvar.nbuf)) - rntohll(vv.val(cvar.obuf))
		if delta < 0:
		    delta = delta + 18446744073709551616
		r[n] = delta
        elif ( t == libweb100.WEB100_TYPE_GAUGE32 or
	       t == libweb100.WEB100_TYPE_INTEGER32 or
	       t == libweb100.WEB100_TYPE_UNSIGNED32 or
	       t == libweb100.WEB100_TYPE_TIME_TICKS or
	       t == libweb100.WEB100_TYPE_INTEGER ):
	    r[n] = rntohl(vv.val(cvar.nbuf))
        else:
            r[n] = vv.val(cvar.nbuf)
        v = libweb100.web100_var_next(v)
#	vv.free()
    return(r)
Пример #4
0
def mkdict(ctl, new, old):
    """
    Convert a tctrl and two snaps into a dictionary.   This parallels John Heffners
    new python API for Web100, but handles deltas differently.

    Don't compute deltas, if there is no prior (old) sample.

    """
    r = {}

    # process the control structure
    # eeeewww clearly this is lame XXX
    r["flag"] = ctl.flag
    r["basemss"] = ctl.basemss
    r["win"] = ctl.win
    r["burstwin"] = ctl.burstwin
    r["duration"] = ctl.duration
    r["obswin"] = ctl.obswin
    r["SSbursts"] = ctl.SSbursts
    r["SSbully"] = ctl.SSbully
    r["SSbullyStall"] = ctl.SSbullyStall
    r["SSsumAwnd"] = ctl.SSsumAwnd
    r["SScntAwnd"] = ctl.SScntAwnd
    r["SSpoll"] = ctl.SSpoll

    # Process the snaps
    # This interim version violates clean layering:
    # it uses a hybrid of libweb100 and PyWeb100

    v = libweb100.web100_var_head(cvar.gread)
    while v:
        vv = PyWeb100.Web100Var(v, cvar.gread)  # ugly

        n = libweb100.web100_get_var_name(v)
        t = libweb100.web100_get_var_type(v)
        if libweb100.web100_snap_read(
                v, new, cvar.nbuf) != libweb100.WEB100_ERR_SUCCESS:
            raise "snap read fail"
        if old:
            if libweb100.web100_snap_read(
                    v, old, cvar.obuf) != libweb100.WEB100_ERR_SUCCESS:
                raise "snap read fail"
        if (t == libweb100.WEB100_TYPE_COUNTER32):
            r["abs_" + n] = rntohl(vv.val(
                cvar.nbuf))  # abs_ is absolute magnitude
            if old:
                delta = rntohl(vv.val(cvar.nbuf)) - rntohl(vv.val(cvar.obuf))
                if delta < 0:
                    delta = delta + 4294967296
                r[n] = delta
        elif (t == libweb100.WEB100_TYPE_COUNTER64):
            r["abs_" + n] = rntohll(vv.val(
                cvar.nbuf))  # abs_ is absolute magnitude
            if old:
                # rntohl() is wrong
                delta = rntohll(vv.val(cvar.nbuf)) - rntohll(vv.val(cvar.obuf))
                if delta < 0:
                    delta = delta + 18446744073709551616
                r[n] = delta
        elif (t == libweb100.WEB100_TYPE_GAUGE32
              or t == libweb100.WEB100_TYPE_INTEGER32
              or t == libweb100.WEB100_TYPE_UNSIGNED32
              or t == libweb100.WEB100_TYPE_TIME_TICKS
              or t == libweb100.WEB100_TYPE_INTEGER):
            r[n] = rntohl(vv.val(cvar.nbuf))
        else:
            r[n] = vv.val(cvar.nbuf)
        v = libweb100.web100_var_next(v)
#	vv.free()
    return (r)