def check(self):
        if not all([self.host,
                    self.port,
                    isinstance(self.host, str),
                    isinstance(self.port, (str, int))]):
            self.error('Host is not defined in the module configuration file')
            return False

        # Hostname -> ip address
        try:
            self.host = gethostbyname(self.host)
        except gaierror as error:
            self.error(str(error))
            return False

        # Create URL for every Elasticsearch API
        self.methods = [METHODS(get_data=self._get_node_stats,
                                url=self.url + '/_nodes/_local/stats',
                                run=self.configuration.get('node_stats', True)),
                        METHODS(get_data=self._get_cluster_health,
                                url=self.url + '/_cluster/health',
                                run=self.configuration.get('cluster_health', True)),
                        METHODS(get_data=self._get_cluster_stats,
                                url=self.url + '/_cluster/stats',
                                run=self.configuration.get('cluster_stats', True))]

        # Remove disabled API calls from 'avail methods'
        return UrlService.check(self)
Beispiel #2
0
    def check(self):
        # We can't start if <host> AND <port> not specified
        if not (self.host and self.port):
            self.error('Host is not defined in the module configuration file')
            return False

        # Hostname -> ip address
        try:
            self.host = gethostbyname(self.host)
        except gaierror as error:
            self.error(str(error))
            return False

        # Add handlers (auth, self signed cert accept)
        self.url = '{scheme}://{host}:{port}'.format(scheme=self.scheme,
                                                     host=self.host,
                                                     port=self.port)
        # Add methods
        api_workers = self.url + '/workers.json'
        api_queues = self.url + '/queues.json'
        self.methods = [
            METHODS(get_data=self._get_overview_stats, url=api_queues),
            METHODS(get_data=self._get_overview_stats, url=api_workers)
        ]
        return UrlService.check(self)
Beispiel #3
0
    def check(self):
        if not all([self.host,
                    self.port,
                    isinstance(self.host, str),
                    isinstance(self.port, (str, int))]):
            self.error('Host is not defined in the module configuration file')
            return False

        # Hostname -> ip address
        try:
            self.host = gethostbyname(self.host)
        except gaierror as error:
            self.error(str(error))
            return False

        # Create URL for every Elasticsearch API
        self.methods = [METHODS(get_data=self._get_node_stats,
                                url=self.url + '/_nodes/_local/stats',
                                run=self.configuration.get('node_stats', True)),
                        METHODS(get_data=self._get_cluster_health,
                                url=self.url + '/_cluster/health',
                                run=self.configuration.get('cluster_health', True)),
                        METHODS(get_data=self._get_cluster_stats,
                                url=self.url + '/_cluster/stats',
                                run=self.configuration.get('cluster_stats', True))]

        # Remove disabled API calls from 'avail methods'
        return UrlService.check(self)
    def check(self):
        # We can't start if <host> AND <port> not specified
        if not (self.host and self.port):
            self.error('Host is not defined in the module configuration file')
            return False

        # Hostname -> ip address
        try:
            self.host = gethostbyname(self.host)
        except gaierror as error:
            self.error(str(error))
            return False

        # Add handlers (auth, self signed cert accept)
        self.url = '{scheme}://{host}:{port}/api'.format(scheme=self.scheme,
                                                         host=self.host,
                                                         port=self.port)
        # Add methods
        api_node = self.url + '/nodes'
        api_overview = self.url + '/overview'
        self.methods = [METHODS(get_data=self._get_overview_stats,
                                url=api_node,
                                stats=NODE_STATS),
                        METHODS(get_data=self._get_overview_stats,
                                url=api_overview,
                                stats=OVERVIEW_STATS)]
        return UrlService.check(self)
    def check(self):
        if not self.host:
            self.error('Host is not defined in the module configuration file')
            return False

        try:
            self.host = gethostbyname(self.host)
        except gaierror as error:
            self.error(repr(error))
            return False

        self.methods = [
            METHODS(
                get_data=self._get_node_stats,
                url=self.url + '/_nodes/_local/stats',
                run=self.configuration.get('node_stats', True),
            ),
            METHODS(
                get_data=self._get_cluster_health,
                url=self.url + '/_cluster/health',
                run=self.configuration.get('cluster_health', True)
            ),
            METHODS(
                get_data=self._get_cluster_stats,
                url=self.url + '/_cluster/stats',
                run=self.configuration.get('cluster_stats', True),
            ),
            METHODS(
                get_data=self._get_indices,
                url=self.url + '/_cat/indices?format=json',
                run=self.configuration.get('indices_stats', False),
            ),
        ]
        return UrlService.check(self)
    def check(self):
        """
        Check if the module can collect data:
        1) At least one JOB configuration has to be specified
        2) The JOB configuration needs to define the URL and either collect_memstats must be enabled or at least one
           extra_chart must be defined.

        The configuration and URL check is provided by the UrlService class.
        """

        if not (self.configuration.get('extra_charts') or self.configuration.get('collect_memstats')):
            self.error('Memstats collection is disabled and no extra_charts are defined, disabling module.')
            return False

        return UrlService.check(self)
Beispiel #7
0
 def check(self):
     if not (self.host and self.port):
         self.error('Host is not defined in the module configuration file')
         return False
     try:
         self.host = gethostbyname(self.host)
     except gaierror as error:
         self.error(str(error))
         return False
     self.url = '{scheme}://{host}:{port}'.format(scheme=self.scheme,
                                                  host=self.host,
                                                  port=self.port)
     stats = self.url + '/_node/{node}/_stats'.format(node=self.node)
     active_tasks = self.url + '/_active_tasks'
     system = self.url + '/_node/{node}/_system'.format(node=self.node)
     self.methods = [METHODS(get_data=self._get_overview_stats,
                             url=stats,
                             stats=OVERVIEW_STATS),
                     METHODS(get_data=self._get_active_tasks_stats,
                             url=active_tasks,
                             stats=None),
                     METHODS(get_data=self._get_overview_stats,
                             url=system,
                             stats=SYSTEM_STATS),
                     METHODS(get_data=self._get_dbs_stats,
                             url=self.url,
                             stats=DB_STATS)]
     # must initialise manager before using _get_raw_data
     self._manager = self._build_manager()
     self.dbs = [db for db in self.dbs
                 if self._get_raw_data(self.url + '/' + db)]
     for db in self.dbs:
         self.definitions['db_sizes_file']['lines'].append(
             ['db_'+db+'_sizes_file', db, 'absolute', 1, 1000]
         )
         self.definitions['db_sizes_external']['lines'].append(
             ['db_'+db+'_sizes_external', db, 'absolute', 1, 1000]
         )
         self.definitions['db_sizes_active']['lines'].append(
             ['db_'+db+'_sizes_active', db, 'absolute', 1, 1000]
         )
         self.definitions['db_doc_counts']['lines'].append(
             ['db_'+db+'_doc_count', db, 'absolute']
         )
         self.definitions['db_doc_del_counts']['lines'].append(
             ['db_'+db+'_doc_del_count', db, 'absolute']
         )
     return UrlService.check(self)
 def check(self):
     if not (self.host and self.port):
         self.error('Host is not defined in the module configuration file')
         return False
     try:
         self.host = gethostbyname(self.host)
     except gaierror as error:
         self.error(str(error))
         return False
     self.url = '{scheme}://{host}:{port}'.format(scheme=self.scheme,
                                                  host=self.host,
                                                  port=self.port)
     stats = self.url + '/_node/{node}/_stats'.format(node=self.node)
     active_tasks = self.url + '/_active_tasks'
     system = self.url + '/_node/{node}/_system'.format(node=self.node)
     self.methods = [METHODS(get_data=self._get_overview_stats,
                             url=stats,
                             stats=OVERVIEW_STATS),
                     METHODS(get_data=self._get_active_tasks_stats,
                             url=active_tasks,
                             stats=None),
                     METHODS(get_data=self._get_overview_stats,
                             url=system,
                             stats=SYSTEM_STATS),
                     METHODS(get_data=self._get_dbs_stats,
                             url=self.url,
                             stats=DB_STATS)]
     # must initialise manager before using _get_raw_data
     self._manager = self._build_manager()
     self.dbs = [db for db in self.dbs
                 if self._get_raw_data(self.url + '/' + db)]
     for db in self.dbs:
         self.definitions['db_sizes_file']['lines'].append(
             ['db_' + db + '_sizes_file', db, 'absolute', 1, 1000]
         )
         self.definitions['db_sizes_external']['lines'].append(
             ['db_' + db + '_sizes_external', db, 'absolute', 1, 1000]
         )
         self.definitions['db_sizes_active']['lines'].append(
             ['db_' + db + '_sizes_active', db, 'absolute', 1, 1000]
         )
         self.definitions['db_doc_counts']['lines'].append(
             ['db_' + db + '_doc_count', db, 'absolute']
         )
         self.definitions['db_doc_del_counts']['lines'].append(
             ['db_' + db + '_doc_del_count', db, 'absolute']
         )
     return UrlService.check(self)