metrics

How to get screen display metrics in application class

自古美人都是妖i 提交于 2019-11-26 12:47:04
问题 If I put this in some activity class it works perfectly but, when I put it in my App class the method getWindowManager() can not be found. Is there some way to get the WindowManager in app class? My app class is defined like this: public class myApp extends Application { and in on create method I have this: DisplayMetrics dm = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(dm); int width = dm.widthPixels; 回答1: Here, Context.getResource() DisplayMetrics dm =

jenkins exporter(收集jenkins构建结果)

女生的网名这么多〃 提交于 2019-11-26 11:34:54
import re import time import requests import argparse from pprint import pprint import os from sys import exit from prometheus_client import start_http_server, Summary from prometheus_client.core import GaugeMetricFamily, REGISTRY DEBUG = int(os.environ.get('DEBUG', '0')) #DEBUG = True COLLECTION_TIME = Summary('jenkins_collector_collect_seconds', 'Time spent to collect metrics from Jenkins') class JenkinsCollector(object): # The build statuses we want to export about. #statuses = ["lastBuild", "lastCompletedBuild", "lastFailedBuild", # "lastStableBuild", "lastSuccessfulBuild",

【Android】屏幕尺寸的表示

泪湿孤枕 提交于 2019-11-26 04:52:36
1. 单位 - px(pixel): 普通的像素点描述,位图中的一个颜色点(RGBA或者YUV) - dip(device independent pixels): 设备独立像素。 - dp: 与dip一样。 - pt(point): 标准长度单位。1pt = 1.0 / 72 (in)。 - sp(scaled pixel): 用于字体显示。 - in(inch): 英寸 - mm(millimeter): 毫米 2. 屏幕密度 屏幕类型 宽度(pixels) 高度(pixels) 尺寸(inches) 屏幕密度 QVGA 240 320 2.6 - 3.0 low WQVGA 240 400 3.2 - 3.5 low FWQVGA 240 432 3.5 - 3.8 low HVGA 320 480 3.0 - 3.5 medium WVGA 480 800 3.3 - 4.0 high FWVGA 480 854 3.5 - 4.0 high WVGA 480 800 4.8 - 5.5 medium FWVGA 480 854 5.0 - 5.8 medium 默认屏幕密度:low = 120; medium = 160; high = 240 3. 屏幕单位的换算 / frameworks / base / core / java / android / util /

K8S集群使用自定义metrics指标HPA测试

瘦欲@ 提交于 2019-11-26 04:07:28
本文介绍使用基于prometheus的自定义metric进行HPA。一般来说,前文介绍的根据CPU和内存做metric进行HPA就已经满足了绝大多数应用场景。 现在主流公有云产商的弹性伸缩服务支持的metric类型也较为丰富。以华为云的弹性伸缩服务为例,指标主要涵盖:CPU、内存、网络、磁盘这些资源层面。针对应用级别的就比较少见了,因此本文将介绍基于http请求访问次数的HPA。 一、创建pormetheus # cd k8s-prom-hpa/ # kubectl create -f namespaces.yaml # kubectl create -f ./prometheus 由于apiserver的端口配置限制问题,这里修改了service的监听端口,其余的配置和github上下载的一致 # cat prometheus/prometheus-svc.yaml --- apiVersion: v1 kind: Service metadata: name: prometheus namespace: monitoring labels: app: prometheus spec: type: NodePort ports: - port: 9090 targetPort: 9090 nodePort: 8500 protocol: TCP selector: app:

K8S集群基于heapster的HPA测试

半世苍凉 提交于 2019-11-26 03:53:20
本文将介绍基于heapster获取metric的HPA配置。在开始之前,有必要先了解一下K8S的HPA特性。 1、HPA全称Horizontal Pod Autoscaling,即pod的水平自动扩展。 自动扩展主要分为两种,其一为水平扩展,针对于实例数目的增减;其二为垂直扩展,即单个实例可以使用的资源的增减。HPA属于前者。 2、HPA是Kubernetes中实现POD水平自动伸缩的功能。 云计算具有水平弹性的特性,这个是云计算区别于传统IT技术架构的主要特性。对于Kubernetes中的POD集群来说,HPA可以实现很多自动化功能,比如当POD中业务负载上升的时候,可以创建新的POD来保证业务系统稳定运行,当POD中业务负载下降的时候,可以销毁POD来提高资源利用率。 3、HPA控制器默认每隔30秒就会运行一次。 如果要修改间隔时间,可以设置horizontal-pod-autoscaler-sync-period参数。 4、HPA的操作对象是RC、RS或Deployment对应的Pod 根据观察到的CPU等实际使用量与用户的期望值进行比对,做出是否需要增减实例数量的决策。 5、hpa的发展历程 在Kubernetes v1.1中首次引入了hpa特性。hpa第一个版本基于观察到的CPU利用率,后续版本支持基于内存使用。 在Kubernetes 1

Big-O for Eight Year Olds? [duplicate]

给你一囗甜甜゛ 提交于 2019-11-25 23:02:40
This question already has an answer here: What is a plain English explanation of “Big O” notation? 39 answers I'm asking more about what this means to my code. I understand the concepts mathematically, I just have a hard time wrapping my head around what they mean conceptually. For example, if one were to perform an O(1) operation on a data structure, I understand that the number of operations it has to perform won't grow because there are more items. And an O(n) operation would mean that you would perform a set of operations on each element. Could somebody fill in the blanks here? Like what

Kubernetes集群监控方案

半世苍凉 提交于 2019-11-25 20:20:48
本文介绍在k8s集群中使用node-exporter、prometheus、grafana对集群进行监控。 其实现原理有点类似ELK、EFK组合。node-exporter组件负责收集节点上的metrics监控数据,并将数据推送给prometheus, prometheus负责存储这些数据,grafana将这些数据通过网页以图形的形式展现给用户。 在开始之前有必要了解下Prometheus是什么? Prometheus (中文名:普罗米修斯)是由 SoundCloud 开发的开源监控报警系统和时序列数据库(TSDB).自2012年起,许多公司及组织已经采用 Prometheus,并且该项目有着非常活跃的开发者和用户社区.现在已经成为一个独立的开源项目。Prometheus 在2016加入 CNCF ( Cloud Native Computing Foundation ), 作为在 kubernetes 之后的第二个由基金会主持的项目。 Prometheus 的实现参考了Google内部的监控实现,与源自Google的Kubernetes结合起来非常合适。另外相比influxdb的方案,性能更加突出,而且还内置了报警功能。它针对大规模的集群环境设计了拉取式的数据采集方式,只需要在应用里面实现一个metrics接口,然后把这个接口告诉Prometheus就可以完成数据采集了