コード例 #1
0
#!/usr/bin/env python

import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "sentry_conf")

from datetime import datetime

from photon import Client
from sentry.models import Event
from sentry.models import Project

client = Client(server="http://holodeck.praekelt.com", )

client.send(
    samples=(('Mom Connect Daily Errors',
              Event.objects.filter(project__slug='mom-connect').count())),
    api_key='3bc93b5e0f8d4c30936ad5786b185007',
    timestamp=datetime.now(),
)

client.send(
    samples=(('Central Daily Errors',
              Event.objects.filter(project__slug='praekelt-central').count())),
    api_key='160d43a54e244ee59d5486cc384cade0',
    timestamp=datetime.now(),
)

client.send(
    samples=(('Ummeli Daily Errors',
              Event.objects.filter(project__slug='ummeli').count())),
    api_key='e54bb71a19c34f29aafdf18dcbf12941',
コード例 #2
0
    def handle(self, *args, **options):
        users = User.objects.filter(is_active=True, is_staff=False)
        questionnaires = Questionnaire.objects.filter(active=True)

        client = Client(server=settings.HOLODECK_URL)
        now = datetime.datetime.now()

        for questionnaire in questionnaires:
            # check if we have holodeck keys for the questionnaire
            pending_key = self._get_holodeck_key(
                questionnaire, constants.QUESTIONNAIRE_PENDING)
            completed_key = self._get_holodeck_key(
                questionnaire, constants.QUESTIONNAIRE_COMPLETED)
            incomplete_key = self._get_holodeck_key(
                questionnaire, constants.QUESTIONNAIRE_INCOMPLETE)
            rejected_key = self._get_holodeck_key(
                questionnaire, constants.QUESTIONNAIRE_REJECTED)

            # collect the stats for the questionnaire
            if pending_key or completed_key or incomplete_key or rejected_key:
                pending = incomplete = completed = rejected = 0
                for user in users:
                    status = questionnaire.get_status(user)
                    if status == constants.QUESTIONNAIRE_PENDING:
                        pending += 1
                    elif status == constants.QUESTIONNAIRE_REJECTED:
                        rejected += 1
                    elif status == constants.QUESTIONNAIRE_INCOMPLETE:
                        incomplete += 1
                    elif status == constants.QUESTIONNAIRE_COMPLETED:
                        completed += 1

                # send the pending stats to holodeck
                if pending_key:
                    try:
                        client.send(samples=(("Total", pending), ),
                                    api_key=pending_key,
                                    timestamp=now)
                    except HTTPError:
                        logger.error("Could not connect to holodeck service")

                # send the incomplete stats to holodeck
                if incomplete_key:
                    try:
                        client.send(samples=(("Total", incomplete), ),
                                    api_key=incomplete_key,
                                    timestamp=now)
                    except HTTPError:
                        logger.error("Could not connect to holodeck service")

                # send the complete stats to holodeck
                if completed_key:
                    try:
                        client.send(samples=(("Total", completed), ),
                                    api_key=completed_key,
                                    timestamp=now)
                    except HTTPError:
                        logger.error("Could not connect to holodeck service")

                # send the rejected stats to holodeck
                if rejected_key:
                    try:
                        client.send(samples=(("Total", rejected), ),
                                    api_key=rejected_key,
                                    timestamp=now)
                    except HTTPError:
                        logger.error("Could not connect to holodeck service")
コード例 #3
0
ファイル: randomizer.py プロジェクト: benroeder/photon
#!/usr/bin/env python

from datetime import datetime
import random
import time

from photon import Client

client = Client(server="http://localhost:8000/", )

while True:
    # Push random data to a single line chart metric.
    client.send(
        samples=(("Indicator", random.randint(100, 999)), ),
        api_key='1',
        timestamp=datetime.now(),
    )
    # Push random data to a multi-line chart metric.
    client.send(
        samples=(
            ("Line 1", random.randint(100, 999)),
            ("Line 2", random.randint(100, 999)),
            ("Line 3", random.randint(100, 999)),
            ("Line 4", random.randint(100, 999)),
            ("Line 5", random.randint(100, 999)),
        ),
        api_key='2',
        timestamp=datetime.now(),
    )
    # Push random data to a sample deviation metric.
    client.send(