<commit_before>    #!/usr/bin/env python
from checks import AgentCheck
import time

class RethinkDBCheck(AgentCheck):
    def check(self, instance):
        self.log.info('Checking RethinkDB connectivity')
        msg_title = 'RethinkDB is functioning'
        msg_text = 'RethinkDB was successfully queried for data'
        alert_type = 'info'
        self.event({
            'timestamp': int(time.time()),
            'event_type': 'rethinkdb_check',
            'msg_title': msg_title,
            'msg_text': msg_text,
            'alert_type': alert_type,
        })

if __name__ == '__main__':
    check, instances = RethinkDBCheck.from_yaml('/path/to/conf.d/http.yaml')
    for instance in instances:
        print('Checking RethinkDB...')
        check.check(instance)
        if check.has_events():
            print('Events: {}'.format(check.get_events()))
        print('Metrics: {}'.format(check.get_metrics()))<commit_msg>Update rethinkdb check<commit_after>    #!/usr/bin/env python
from checks import AgentCheck
import time
import rethinkdb as r
import os


class RethinkDBCheck(AgentCheck):
    def check(self, instance):
        self.log.info('Checking RethinkDB connectivity...')
        rethinkdb_host = os.environ.get('RETHINKDB_HOST', 'localhost')
        with r.connect(host=rethinkdb_host, db='muzhack') as conn:
            projects = r.table('projects').run(conn)
        if projects:
            self.log.info('RethinkDB works, successfully queried projects')
            msg_title = 'RethinkDB is functioning'
            msg_text = 'RethinkDB was successfully queried for data'
            alert_type = 'info'
        else:
            self.log.info('RethinkDB doesn\'t work, couldn\t query projects')
            msg_title = 'RethinkDB returns no data'
            msg_text = 'RethinkDB did not return any projects'
            alert_type = 'error'
        self.event({
            'timestamp': int(time.time()),
            'event_type': 'rethinkdb_check',
            'msg_title': msg_title,
            'msg_text': msg_text,
            'alert_type': alert_type,
        })
{'fraction_non_alphanumeric': 0.11485524442335074, 'fraction_numerical': 0.0, 'mean_word_length': 2.4728171334431632, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4853319', 'n_tokens_mistral': 621, 'n_tokens_neox': 628, 'n_words': 146}