示例#1
0
  def handle_noargs(self, **options):
    """Generates a Monitor Descriptor file."""
    registry = global_registry()
    definitions = []

    for schema in registry.schemas:
      definitions.extend(schema.to_json())

    definitions.sort(lambda a, b: cmp(a['context'], b['context']))

    d = {
        'name': 'HUE',
        'nameForCrossEntityAggregateMetrics': 'hues',
        'version': 1,
        'metricDefinitions': [],
        'roles': [
          {
            'name': 'HUE_SERVER',
            'nameForCrossEntityAggregateMetrics': 'hue_servers',
            'metricDefinitions': definitions,
          },
        ],
    }

    print json.dumps(d)
示例#2
0
def start_file_reporter():
  from desktop.conf import METRICS

  global _reporter

  if _reporter is None:
    location = METRICS.LOCATION.get()
    interval = METRICS.COLLECTION_INTERVAL.get()

    if location is not None and interval is not None:
      _reporter = FileReporter(
          location,
          reporting_interval=interval / 1000.0,
          registry=global_registry())
      _reporter.start()
示例#3
0
# limitations under the License.

from __future__ import absolute_import

import gc
import multiprocessing
import threading

from django.contrib.auth.models import User

from desktop.lib.metrics import global_registry

global_registry().gauge_callback(
    name='threads.total',
    callback=lambda: len(threading.enumerate()),
    label='Threads',
    description='The total number of threads',
    numerator='threads',
)

global_registry().gauge_callback(
    name='threads.daemon',
    callback=lambda: sum(1 for thread in threading.enumerate() if thread.isDaemon()),
    label='Daemon Threads',
    description='The number of daemon threads',
    numerator='threads',
)

# ------------------------------------------------------------------------------

global_registry().gauge_callback(
示例#4
0
文件: metrics.py 项目: copoo/hue
from __future__ import absolute_import

import gc
import multiprocessing
import threading

from django.contrib.auth.models import User
from django.contrib.auth.signals import user_logged_in, user_logged_out
from django.db.models.signals import post_save, post_delete
from django.dispatch import receiver

from desktop.lib.metrics import global_registry

global_registry().gauge_callback(
    name='python.threads.count',
    callback=lambda: len(threading.enumerate()),
    label='Thread count',
    description='Number of threads',
)

global_registry().gauge_callback(
    name='python.threads.active',
    callback=lambda: threading.active_count(),
    label='Active thread count',
    description='Number of active threads',
)

global_registry().gauge_callback(
    name='python.threads.daemon',
    callback=lambda: sum(1 for thread in threading.enumerate() if thread.isDaemon()),
    label='Daemon thread count',
    description='Number of daemon threads',
示例#5
0
文件: metrics.py 项目: 277800076/hue
# Licensed to Cloudera, Inc. under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  Cloudera, Inc. licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import absolute_import

from desktop.lib.metrics import global_registry

saml2_authentication_time = global_registry().timer(
    name='auth.saml2.auth-time',
    label='SAML2 Authentication Time',
    description='The time spent waiting for SAML2 to authenticate a user',
    numerator='seconds',
    counter_numerator='authentications',
    rate_denominator='seconds',
)
示例#6
0
文件: metrics.py 项目: copoo/hue
# Licensed to Cloudera, Inc. under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  Cloudera, Inc. licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import absolute_import

from desktop.lib.metrics import global_registry

openid_authentication_time = global_registry().timer(
    name='desktop.auth.openid.authentication-time',
    label='OpenID Authentication time',
    description='Time taken to authenticate a user with OpenID',
)
示例#7
0
文件: metrics.py 项目: 277800076/hue
# Licensed to Cloudera, Inc. under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  Cloudera, Inc. licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import absolute_import

from desktop.lib.metrics import global_registry

openid_authentication_time = global_registry().timer(
    name='auth.openid.auth-time',
    label='OpenID Authentication Time',
    description='The time spent waiting for OpenID to authenticate a user',
    numerator='seconds',
    counter_numerator='authentications',
    rate_denominator='seconds',
)
示例#8
0
文件: metrics.py 项目: ronwxy/hue
# Licensed to Cloudera, Inc. under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  Cloudera, Inc. licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import absolute_import

from desktop.lib.metrics import global_registry

saml2_authentication_time = global_registry().timer(
    name='desktop.auth.saml2.authentication-time',
    label='SAML2 Authentication time',
    description='Time taken to authenticate a user with SAML2',
    numerator='s',
    counter_numerator='auths',
    rate_denominator='seconds',
)
示例#9
0
文件: metrics.py 项目: ronwxy/hue
# Licensed to Cloudera, Inc. under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  Cloudera, Inc. licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import absolute_import

from desktop.lib.metrics import global_registry

openid_authentication_time = global_registry().timer(
    name='desktop.auth.openid.authentication-time',
    label='OpenID Authentication time',
    description='Time taken to authenticate a user with OpenID',
    numerator='s',
    counter_numerator='auths',
    rate_denominator='seconds',
)
示例#10
0
文件: metrics.py 项目: cloudera/hue
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import logging

from datetime import datetime, timedelta

from desktop.lib.metrics import global_registry

LOG = logging.getLogger(__name__)

def active_users():
  from useradmin.models import UserProfile
  try:
    count = UserProfile.objects.filter(last_activity__gt=datetime.now() - timedelta(hours=1)).count()
  except:
    LOG.exception('Could not get active_users')
    count = 0
  return count

global_registry().gauge_callback(
    name='users.active',
    callback=active_users,
    label='Active Users',
    description='Number of users that were active in the last hour',
    numerator='users',
)
示例#11
0
文件: metrics.py 项目: copoo/hue
# Licensed to Cloudera, Inc. under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  Cloudera, Inc. licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import absolute_import

from desktop.lib.metrics import global_registry

saml2_authentication_time = global_registry().timer(
    name='desktop.auth.saml2.authentication-time',
    label='SAML2 Authentication time',
    description='Time taken to authenticate a user with SAML2',
)