Ejemplo n.º 1
0
    def get_arguments(self):
        ApiCli.get_arguments(self)

        if self.args.file is not None:
            self._file = self.args.path

        self.path = 'v1/relays/{0}/config'.format(self._meter)
Ejemplo n.º 2
0
    def get_arguments(self):
        ApiCli.get_arguments(self)

        if self.args.file is not None:
            self._file = self.args.path

        self.path = 'v1/relays/{0}/config'.format(self._meter)
Ejemplo n.º 3
0
 def __init__(self):
     ApiCli.__init__(self)
     self._path = None
     self._name = None
     self._disable = False
     self._remove = False
     self._sources = None
Ejemplo n.º 4
0
 def __init__(self):
     ApiCli.__init__(self)
     self._path = None
     self._name = None
     self._disable = False
     self._remove = False
     self._sources = None
    def __init__(self, update):
        ApiCli.__init__(self)
        self.update = update
        self.method = "POST"

        self.alarm_name = None
        self.metric_name = None
        self.aggregate = None
        self.operation = None
        self.threshold = None
        self.interval = None
        self.host_group_id = None
        self.note = None
        self.per_host_notify = None
        self.actions = None
        self.is_disabled = None

        self.intervals = {'1 second': 1,
                          '5 seconds': 15,
                          '1 minute': 60,
                          '5 minutes': 900,
                          '1 hour': 3600,
                          '1.5 hours': 5400,
                          '3 hours': 10800,
                          '6 hours': 21600,
                          '12 hours': 43200
                          }
 def getArguments(self):
     '''
     Extracts the specific arguments of this CLI
     '''
     ApiCli.getArguments(self)
     if self.args.pluginName != None:
         self.pluginName = self.args.pluginName
Ejemplo n.º 7
0
 def get_arguments(self):
     """
     Extracts the specific arguments of this CLI
     """
     ApiCli.get_arguments(self)
     if self.args.hostGroupName is not None:
         self.url_parameters = {"name": self.args.hostGroupName}
    def addArguments(self):
        ApiCli.addArguments(self)
        self.parser.add_argument('-b', '--status', dest='status', action='store',
                                 choices=[])
        self.parser.add_argument('-v', '--severity', dest='severity', action='store',
                                 choices=['INFO', 'WARN', 'ERROR', 'CRITICAL'],
                                 help='Severity of the the event')
        self.parser.add_argument('-m', '--message', dest='message', action='store',
                                 metavar='message', help='Text describing the event')
        self.parser.add_argument('-f', '--fingerprint-fields', dest='fingerprint_fields', action='store', required=True,
                                 type=split_string, metavar='aggregate', help='Metric aggregate to alarm upon')
        self.parser.add_argument('-o', '--organization-id', dest='organization_id', action='store',
                                 metavar='organization_id', help='Boundary account Id')
        #
        self.parser.add_argument('-p', '--properties', dest='properties', action='store')
        # self.parser.add_argument('-v', '--trigger-threshold', dest='triggerThreshold', action='store',
        # metavar='value',
        #                          help='Trigger threshold value')
        # self.parser.add_argument('-r', '--sender', dest='triggerInterval', action='store',
        #                          metavar='interval', help='Optional information about the sender of the event. \
        #                          This is used to describe a third party event system forwarding this event into \
        #                          Boundary, or a Boundary service sending the event.')
        # self.parser.add_argument('-i', '--host-group-id', dest='hostGroupId', action='store', metavar='hostgroup_id',
        #                          help='Host group the alarm applies to')
        self.parser.add_argument('-s', '--source', dest='source', action='store', metavar='ref:type:name:properties',
                                 type=string_to_dict, help='A description or resolution of the alarm')

        self.parser.add_argument('-w', '--title', dest='title', metavar='title', action='store', required=True,
                                 help='Title of the event')
Ejemplo n.º 9
0
    def add_arguments(self):
        """
        """
        ApiCli.add_arguments(self)

        self.parser.add_argument('-n', '--alarm-name', dest='alarm_name', action='store', required=True,
                                 metavar='alarm-name', help='Alarm name')
Ejemplo n.º 10
0
    def __init__(self, update):
        ApiCli.__init__(self)
        self._update = update

        # Mapping of alarm types to corresponding codes
        self._alarm_types = {"threshold": 3, "host": 4, "api": 5}

        self._aggregate = None
        self._actions = None
        self._alarm_name = None
        self._alarm_id = None
        self._host_group_id = None
        self._interval = None
        self._is_disabled = None
        self._metric = None
        self._note = None
        self._operation = None
        self._per_host_notify = None
        self._threshold = None
        self._type_id = None
        self._notify_clear = None
        self._notify_set = None
        self._payload = {}
        self._trigger_interval = None
        self._timeout_interval = None
Ejemplo n.º 11
0
    def add_arguments(self):
        """
        """
        ApiCli.add_arguments(self)

        self.parser.add_argument('-f', '--file', metavar='path', dest='file', action='store', required=True,
                                 help='Name of the meter to get plugin configuration information')
    def getArguments(self):
        """
        Extracts the specific arguments of this CLI
        """
        ApiCli.getArguments(self)
        if self.args.metricName is not None:
            self.metricName = self.args.metricName

        if self.args.source is not None:
            self.source = self.args.source
        else:
            self.source = ""

        if self.args.aggregate is not None:
            self.aggregate = self.args.aggregate
        else:
            self.aggregate = "avg"

        start_time = int(self.parse_time_date(self.args.start).strftime("%s"))

        # If the end time is not specified then
        # default to the current time
        if self.args.end is None:
            stop_time = int(self.now.strftime("%s"))
        else:
            stop_time = int(self.parse_time_date(self.args.end).strftime("%s"))

        # Convert to epoch time in milli-seconds
        start_time *= 1000
        stop_time *= 1000

        self.path = "v1/measurements/{0}".format(self.metricName)
        self.url_parameters = {"source": self.source, "start": str(start_time), "end": str(stop_time),
                               "agg": self.aggregate}
Ejemplo n.º 13
0
    def __init__(self, update):
        ApiCli.__init__(self)
        self._update = update

        # Mapping of alarm types to corresponding codes
        self._alarm_types = {"threshold": 3, "host": 4, "api": 5}

        self._aggregate = None
        self._actions = None
        self._alarm_name = None
        self._alarm_id = None
        self._host_group_id = None
        self._interval = None
        self._is_disabled = None
        self._metric = None
        self._note = None
        self._operation = None
        self._per_host_notify = None
        self._threshold = None
        self._type_id = None
        self._notify_clear = None
        self._notify_set = None
        self._payload = {}
        self._trigger_interval = None
        self._timeout_interval = None
Ejemplo n.º 14
0
    def __init__(self):
        ApiCli.__init__(self)
        self.method = "DELETE"
        self.path = "v1/hostgroups"

        self.hostGroupId = ""
        self.force = False
Ejemplo n.º 15
0
    def add_arguments(self):
        """
        """
        ApiCli.add_arguments(self)

        self.parser.add_argument('-i', '--alarm-id', dest='alarm_id', action='store', required=True,
                                 metavar='alarm-id', help='Alarm identifier')
Ejemplo n.º 16
0
    def get_arguments(self):
        """
        Extracts the specific arguments of this CLI
        """
        ApiCli.get_arguments(self)

        # Get the host group name
        if self.args.host_group_name is not None:
            self.host_group_name = self.args.host_group_name

        # Get the list of sources separated by commas
        if self.args.sources is not None:
            self.sources = self.args.sources

        payload = {}
        if self.host_group_name is not None:
            payload['name'] = self.host_group_name

        if self.sources is not None:
            source_list = str.split(self.sources, ',')
            if 'hostnames' not in payload:
                payload['hostnames'] = []

            for s in source_list:
                payload['hostnames'].append(s)
        self.data = json.dumps(payload, sort_keys=True)
        self.headers = {'Content-Type': 'application/json', "Accept": "application/json"}
Ejemplo n.º 17
0
    def add_arguments(self):
        """
        Add specific command line arguments for this command   
        """

        # Call our parent to add the default arguments
        ApiCli.add_arguments(self)

        # Command specific arguments
        self.parser.add_argument('-f', '--format', dest='format', action='store', required=False,
                                 choices=['csv', 'json', 'raw', 'xml'], help='Output format. Default is raw')
        self.parser.add_argument('-n', '--name', dest='metric_name', action='store', required=True,
                                 metavar="metric_name", help='Metric identifier')
        self.parser.add_argument('-g', '--aggregate', dest='aggregate', action='store', required=False,
                                 choices=['sum', 'avg', 'max', 'min'], help='Metric default aggregate')
        self.parser.add_argument('-r', '--sample', dest='sample', action='store', type=int, metavar="sample",
                                 help='Down sample rate sample in seconds')
        self.parser.add_argument('-s', '--source', dest='source', action='store', metavar="source", required=True,
                                 help='Source of measurement')
        self.parser.add_argument('-b', '--start', dest='start', action='store', required=True, metavar="start",
                                 help='Start of time range as ISO 8601 string or epoch seconds')
        self.parser.add_argument('-d', '--end', dest='end', action='store', metavar="end", required=False,
                                 help='End of time range as ISO 8601 string or epoch seconds')

        self.parser.add_argument('-o', '--date-format', dest='date_format', action='store', metavar="format",
                                 required=False,
                                 help='For CSV, JSON, and XML output formats dates (see Python date.strftime). ' +
                                      'Default format is %%s')
 def __init__(self):
     """
     """
     ApiCli.__init__(self)
     self.method = "GET"
     self.alarmName = None
     self.alarmId = None
Ejemplo n.º 19
0
    def add_arguments(self):
        ApiCli.add_arguments(self)
        self.parser.add_argument(
            '-n',
            '--name',
            metavar='meter_name',
            dest='meter',
            action='store',
            required=True,
            help='Name of the meter to get output information')

        self.parser.add_argument('-s',
                                 '--since',
                                 metavar='since',
                                 dest='since',
                                 action='store',
                                 required=False,
                                 default=1,
                                 help='Pull since items from end of log')

        self.parser.add_argument('-r',
                                 '--raw',
                                 dest='raw',
                                 action='store_true',
                                 required=False,
                                 help='Send output in raw JSON format')
Ejemplo n.º 20
0
 def get_arguments(self):
     """
     Extracts the specific arguments of this CLI
     """
     ApiCli.get_arguments(self)
     if self.args.pluginName is not None:
         self.pluginName = self.args.pluginName
Ejemplo n.º 21
0
    def __init__(self):
        ApiCli.__init__(self)
        self.method = "DELETE"
        self.path = "v1/hostgroups"

        self.hostGroupId = ""
        self.force = False
    def addArguments(self):
        ApiCli.addArguments(self)

        self.parser.add_argument('-n', '--host-group-name', dest='hostGroupName', action='store', required=True,
                                 metavar="host_group_name", help='Host group name')
        self.parser.add_argument('-s', '--sources', dest='sources', action='store', required=True, metavar='sources',
                                 help='Comma separated sources to add to the host group. If empty adds all hosts.')
Ejemplo n.º 23
0
    def get_arguments(self):
        """
        Extracts the specific arguments of this CLI
        """
        ApiCli.get_arguments(self)
        if self.args.metricName is not None:
            self.metricName = self.args.metricName

        if self.args.measurement is not None:
            self.measurement = self.args.measurement

        if self.args.source is not None:
            self.source = self.args.source
        else:
            self.source = socket.gethostname()

        if self.args.timestamp is not None:
            self.timestamp = int(self.args.timestamp)

        m = {'metric': self.metricName,
             'measure': self.measurement}

        if self.source is not None:
            m['source'] = self.source
        if self.timestamp is not None:
            m['timestamp'] = int(self.timestamp)

        self._process_properties()

        if self._properties is not None:
            m['metadata'] = self._properties

        self.data = json.dumps(m, sort_keys=True)
        self.headers = {'Content-Type': 'application/json', "Accept": "application/json"}
Ejemplo n.º 24
0
    def get_arguments(self):
        """
        Extracts the specific arguments of this CLI
        """
        ApiCli.get_arguments(self)

        # Get the host group name
        if self.args.host_group_name is not None:
            self.host_group_name = self.args.host_group_name

        # Get the list of sources separated by commas
        if self.args.sources is not None:
            self.sources = self.args.sources

        payload = {}
        if self.host_group_name is not None:
            payload['name'] = self.host_group_name

        if self.sources is not None:
            source_list = str.split(self.sources, ',')
            if 'hostnames' not in payload:
                payload['hostnames'] = []

            for s in source_list:
                payload['hostnames'].append(s)
        self.data = json.dumps(payload, sort_keys=True)
        self.headers = {
            'Content-Type': 'application/json',
            "Accept": "application/json"
        }
Ejemplo n.º 25
0
 def get_arguments(self):
     """
     Extracts the specific arguments of this CLI
     """
     ApiCli.get_arguments(self)
     if self.args.pluginName is not None:
         self.pluginName = self.args.pluginName
Ejemplo n.º 26
0
 def __init__(self):
     ApiCli.__init__(self)
     self.metric_definitions = None
     self.dashboards = None
     self.metrics = None
     self.manifest = None
     self.file_path = None
     self.fields = None
 def __init__(self):
     ApiCli.__init__(self)
     self.method = "POST"
     self.path = "v1/measurements"
     self.metricName = None
     self.measurement = None
     self.source = None
     self.timestamp = None
Ejemplo n.º 28
0
    def __init__(self):
        """
        """
        ApiCli.__init__(self)
        self.method = "GET"
        self.path = "v1/hostgroups"

        self.hostGroupId = ""
Ejemplo n.º 29
0
 def __init__(self):
     ApiCli.__init__(self)
     self.metric_definitions = None
     self.dashboards = None
     self.metrics = None
     self.manifest = None
     self.file_path = None
     self.fields = None
Ejemplo n.º 30
0
    def __init__(self):
        """
        """
        ApiCli.__init__(self)
        self.method = "GET"
        self.path = "v1/hostgroups"

        self.hostGroupId = ""
Ejemplo n.º 31
0
 def __init__(self):
     ApiCli.__init__(self)
     self.path = "v1/relays"
     self._control = None
     self._metrics = None
     self._plugins = None
     self._plugin_summary = None
     self._relays = None
    def getArguments(self):
        """
        Extracts the specific arguments of this CLI
        """
        ApiCli.getArguments(self)
        if self.args.alarmId is not None:
            self.alarmId = self.args.alarmId

        self.path = "v1/alarm/{0}".format(self.alarmId)
Ejemplo n.º 33
0
    def get_arguments(self):
        """
        Extracts the specific arguments of this CLI
        """
        ApiCli.get_arguments(self)
        if self.args.plugin_name is not None:
            self.plugin_name = self.args.plugin_name

        self.path = "v1/plugins/{0}".format(self.plugin_name)
Ejemplo n.º 34
0
 def __init__(self):
     ApiCli.__init__(self)
     self.rpc_data = []
     self.rpc_host = 'localhost'
     self.rpc_port = 9192
     self.rpc_message = None
     self.rpc_method = 'status'
     self.rpc_parameters = None
     self.MAX_LINE = 1024
Ejemplo n.º 35
0
    def get_arguments(self):
        ApiCli.get_arguments(self)

        if self.args.control is not None:
            self._control = self.args.control
        if self.args.metrics is not None:
            self._metrics = self.args.metrics
        if self.args.plugins is not None:
            self._plugins = self.args.plugins
Ejemplo n.º 36
0
    def add_arguments(self):
        ApiCli.add_arguments(self)

        self.parser.add_argument('--no-control', dest="control", action='store_true', required=False,
                                 help='Remove control field from the output')
        self.parser.add_argument('--no-metrics', dest="metrics", action='store_true', required=False,
                                 help='Remove metric field from the output')
        self.parser.add_argument('--no-plugins', dest="plugins", action='store_true', required=False,
                                 help='Remove plugins field from the output')
Ejemplo n.º 37
0
    def get_arguments(self):
        ApiCli.get_arguments(self)

        self._meter = self.args.meter if self.args.meter is not None else None
        self._since = self.args.since if self.args.since is not None else None
        self._raw = self.args.raw if self.args.raw is not None else None

        self.method = 'GET'
        self.path = 'v1/relays/{0}/output/{1}'.format(self._meter, self._since)
Ejemplo n.º 38
0
 def add_arguments(self):
     ApiCli.add_arguments(self)
     self.parser.add_argument('-n',
                              '--metric-name',
                              dest='metric_name',
                              action='store',
                              required=True,
                              metavar='metric_name',
                              help='Metric identifier')
Ejemplo n.º 39
0
 def add_arguments(self):
     ApiCli.add_arguments(self)
     self.parser.add_argument('-s',
                              '--sources',
                              dest='sources',
                              metavar='source1[,source2]',
                              action='store',
                              required=True,
                              help='List of sources to delete')
Ejemplo n.º 40
0
    def get_arguments(self):
        """
        Extracts the specific arguments of this CLI
        """
        ApiCli.get_arguments(self)
        if self.args.hostGroupId is not None:
            self.hostGroupId = self.args.hostGroupId

        self.path = "v1/hostgroup/{0}".format(str(self.hostGroupId))
Ejemplo n.º 41
0
 def __init__(self):
     ApiCli.__init__(self)
     self.method = "POST"
     self.path = "v1/measurements"
     self.metricName = None
     self.measurement = None
     self.source = None
     self.timestamp = None
     self._properties = None
Ejemplo n.º 42
0
    def get_arguments(self):

        ApiCli.get_arguments(self)

        if self.args.metric_manifest_path is not None:
            self.metric_manifest_path = self.args.metric_manifest_path

        if self.args.metric_manifest_path is not None:
            self.plugin_manifest_path = self.args.metric_manifest_path
Ejemplo n.º 43
0
    def __init__(self):
        ApiCli.__init__(self)
        self.metric_manifest_path = None
        self.plugin_manifest_path = None
        self.readme_path = None
        self.readme_template_path = None
        self.env = Environment(loader=PackageLoader('boundary', 'templates'))

        self.readme_template = """
Ejemplo n.º 44
0
    def get_arguments(self):
        """
        Extracts the specific arguments of this CLI
        """
        ApiCli.get_arguments(self)
        if self.args.metric_name is not None:
            self._metric_name = self.args.metric_name

        self.path = "v1/metrics/{0}".format(self._metric_name)
Ejemplo n.º 45
0
    def add_arguments(self):
        ApiCli.add_arguments(self)

        self.parser.add_argument('-d', '--disable', dest='disabled', action='store', default=None,
                                 choices=['yes', 'no'], help='Enable or disable the meter')
        self.parser.add_argument('-n', '--name', metavar='name', dest='name', action='store', required=True,
                                 help='Name of the meter to toggle')
        self.parser.add_argument('-r', '--remove', dest='remove', action='store', default=None,
                                 choices=['yes', 'no'], help='Remove the meter')
 def __init__(self):
     ApiCli.__init__(self)
     self.method = "GET"
     self.metricName = None
     self.source = None
     self.aggregate = None
     self.startTime = None
     self.stopTime = None
     self.now = datetime.now()
Ejemplo n.º 47
0
 def add_arguments(self):
     ApiCli.add_arguments(self)
     self.parser.add_argument('-n',
                              '--plugin-name',
                              dest='pluginName',
                              action='store',
                              required=True,
                              metavar="plugin_name",
                              help='Plugin name')
    def getArguments(self):
        """
        Extracts the specific arguments of this CLI
        """
        ApiCli.getArguments(self)
        if self.args.plugin_name is not None:
            self.plugin_name = self.args.plugin_name

        self.path = "v1/plugins/{0}".format(self.plugin_name)
Ejemplo n.º 49
0
    def get_arguments(self):
        """
        Extracts the specific arguments of this CLI
        """
        ApiCli.get_arguments(self)
        if self.args.hostGroupId is not None:
            self.hostGroupId = self.args.hostGroupId

        self.path = "v1/hostgroup/{0}".format(str(self.hostGroupId))
Ejemplo n.º 50
0
 def add_arguments(self):
     ApiCli.add_arguments(self)
     self.parser.add_argument(
         '-f',
         '--file',
         dest='file_path',
         action='store',
         required=False,
         metavar='path',
         help='Path to plugin.json manifest. Defaults to plugin.json')
Ejemplo n.º 51
0
    def add_arguments(self):
        ApiCli.add_arguments(self)

        self.parser.add_argument('-i',
                                 '--event-id',
                                 dest='event_id',
                                 action='store',
                                 required=True,
                                 metavar='event_id',
                                 help='Event id of the event to fetch')
Ejemplo n.º 52
0
 def add_arguments(self):
     ApiCli.add_arguments(self)
     self.parser.add_argument(
         '-f',
         '--file-name',
         dest='file_name',
         action='store',
         required=False,
         metavar='path',
         help='File name including path of data to plot')
Ejemplo n.º 53
0
 def __init__(self, update):
     ApiCli.__init__(self)
     self.update = update
     if self.update:
         self.method = "PUT"
     else:
         self.method = "POST"
     self.path = "v1/hostgroups"
     self.sources = None
     self.host_group_name = None