def __init__(self, crkt): super(ThreeNodeCircuitComponent, self).__init__(crkt) self._node1 = get_next_id('node') self._node2 = get_next_id('node') self._node3 = get_next_id('node') # note that we do not add the component to the circuit's edge set! crkt.add_node(self._node1) crkt.add_node(self._node2) crkt.add_node(self._node3)
def create_service_check(check_name, status, tags=None, timestamp=None, hostname=None, check_run_id=None, message=None): """ Create a service_check dict. See AgentCheck.service_check() for docs on the parameters. """ if check_run_id is None: check_run_id = get_next_id('service_check') service_check = { 'id': check_run_id, 'check': check_name, 'status': status, 'timestamp': float(timestamp or time.time()), } if hostname is not None: service_check['host_name'] = hostname if tags is not None: service_check['tags'] = tags if message is not None: service_check["message"] = message return service_check
def service_check(self, check_name, status, tags=None, timestamp=None, host_name=None, check_run_id=None): """ Save a service check. :param check_name: string, name of the service check :param status: int, describing the status. 0 for success, 1 for warning, 2 for failure :param tags: (optional) list of strings, a list of tags for this run :param timestamp: (optional) float, unix timestamp for when the run occurred :param host_name: (optional) str, host that generated the service check. Defaults to the host_name of the agent :param check_run_id: (optional) int, id used for logging and tracing purposes. Don't need to be unique. If not specified, one will be generated. """ if host_name is None: host_name = self.host_name if check_run_id is None: check_run_id = get_next_id('service_check') self.service_checks.append({ 'id': check_run_id, 'check': check_name, 'status': status, 'host_name': host_name, 'tags': tags, 'timestamp': float(timestamp or time.time()) })
def createfile(): body = request.data.decode("utf-8") content = json.loads(body)['content'] id = get_next_id() try: write_file(id, content) except OSError as error: return new_error(str(error)) name = get_name(content) return json.dumps({'status': 'Ok', 'file': new_file_object(id, name)})
def create_service_check(check_name, status, tags=None, timestamp=None, hostname=None, check_run_id=None, message=None): """ Create a service_check dict. See AgentCheck.service_check() for docs on the parameters. """ if check_run_id is None: check_run_id = get_next_id("service_check") return { "id": check_run_id, "check": check_name, "status": status, "host_name": hostname, "tags": tags, "timestamp": float(timestamp or time.time()), "message": message, }
def create_service_check(check_name, status, tags=None, timestamp=None, hostname=None, check_run_id=None): """ Create a service_check dict. See AgentCheck.service_check() for docs on the parameters. """ if check_run_id is None: check_run_id = get_next_id('service_check') return { 'id': check_run_id, 'check': check_name, 'status': status, 'host_name': hostname, 'tags': tags, 'timestamp': float(timestamp or time.time()) }
def create_service_check(check_name, status, tags=None, timestamp=None, hostname=None, check_run_id=None, message=None): """ Create a service_check dict. See AgentCheck.service_check() for docs on the parameters. """ if check_run_id is None: check_run_id = get_next_id('service_check') return { 'id': check_run_id, 'check': check_name, 'status': status, 'host_name': hostname, 'tags': tags, 'timestamp': float(timestamp or time.time()), 'message': message }
def create_service_check(check_name, status, tags=None, timestamp=None, hostname=None, check_run_id=None, message=None): if check_run_id is None: check_run_id = get_next_id('service_check') return { 'id': check_run_id, 'check': check_name, 'status': status, 'host_name': hostname, 'tags': tags, 'timestamp': float(timestamp or time.time()), 'message': message }
def __init__(self, crkt, voltage): self.id = get_next_id('V') super(VoltageSource, self).__init__(crkt) self.voltage = voltage
def __init__(self, crkt, capacitance): self.id = get_next_id('C') super(Capacitor, self).__init__(crkt) self.capacitance = float(capacitance)
def __init__(self, crkt, resistance): self.id = get_next_id('R') super(Resistor, self).__init__(crkt) self.resistance = float(resistance)
def __init__(self, crkt): super(TwoNodeCircuitComponent, self).__init__(crkt) self._positive = get_next_id('node') self._negative = get_next_id('node') crkt.add_component(self, self._positive, self._negative)