librato.librato
Ansible 角色: Librato
一个安装和配置 Librato Agent 及插件的 Ansible 角色
需求
无
依赖
无
快速开始
开始的最低要求是设置 email 和 token 变量,并包含该角色:
- hosts: all
roles:
- { role: librato.librato, librato_email: '你@域名.com', librato_token: '你的令牌' }
默认启用以下插件:cpu、df、disk、swap、memory、load。
要包括一个插件,只需设置它所需的任何变量,然后将其添加到 librato_enabled_plugins 变量中:
- hosts: all
vars:
librato_apache_path: '/my-status-endpoint'
librato_enabled_plugins: ['apache']
支持的插件
cpudfmemoryloaddiskswapapachenginxnginx_plusjvmmemcachedvarnishzookeeperdockerelasticsearchmongodbpostgresqlmysqlredishaproxy
使用
使用自定义或上游 collectd 插件
要使用自己的自定义或上游 collectd 插件,只需让其他模块将配置放入 /opt/collectd/etc/collectd.conf.d/ 中,将任何自定义插件放入 /opt/collectd/share/collectd/ 中。
参考
插件: apache
librato_apache_protocol类型: 字符串
要使用的协议。默认为
http。如果需要 SSL,请将其更改为https。librato_apache_host类型: 字符串
使用的主机名。默认为
localhost。librato.apace.path类型: 字符串
状态页面的路径。默认为
/server-status。?auto会自动添加,因此无需包含。librato_apache_user类型: 字符串
用于受密码保护的状态页面的用户名。默认为空。
librato_apache_password类型: 字符串
用于受密码保护的状态页面的密码。默认为空。
插件: docker
librato_docker_protocol类型: 字符串
要使用的协议。默认为
http。如果需要 SSL,请将其更改为https。librato_docker_host类型: 字符串
Docker 主机名。默认为
localhost。librato_docker_port类型: 字符串
Docker 端口。默认为
2735。
插件: elasticsearch
librato_elasticsearch_protocol类型: 字符串
要使用的协议。默认为
http。如果需要 SSL,请将其更改为https。librato_elasticsearch_host类型: 字符串
ElasticSearch 主机名。默认为
localhost。librato_elasticsearch_port类型: 字符串
ElasticSearch 端口。默认为
9200。librato_elasticsearch_cluster_name类型: 字符串
ElasticSearch 集群名称(如果设置)。默认为
nil。librato_elasticsearch_verbose类型: true/false
插件的详细触发器。默认为
true。
插件: haproxy
librato_haproxy_socket_file类型: 字符串
HAProxy 套接字文件。默认为
/run/haproxy/admin.sock。librato_haproxy_proxies类型: 数组
收集的默认代理。默认为
server、frontend、backend。
插件: jvm
librato_jvm_host类型: 字符串
JVM 主机。默认为
localhost。librato_jvm_service_url类型: 字符串
要查询的 JVM 服务 URL。默认为
service:jmx:rmi:///jndi/rmi://localhost:17264/jmxrmi。librato_jvm_mbeans类型: 映射
要收集的其他 mbeans。默认为空。
映射格式为:
librato_jvm_mbeans: [ { name: 'mbean 名称' object_name: '对象名称' instance_prefix: '实例前缀(可选)', instance_from: '实例来源(可选)', values: [ { type: '值类型', table: true|false, attribute: '属性' instance_prefix: '实例前缀(可选)', instance_from: '实例来源(可选)' } ] } ]
插件: memcached
librato_memcached_host类型: 字符串
memcached 主机名。默认为
localhost。librato_memcached_port类型: 字符串
memcached 端口。默认为
11211。
插件: mongodb
librato_mongodb_host类型: 字符串
MongoDB 主机名。默认为
localhost。librato_mongodb_port类型: 字符串
MongoDB 端口。默认为
27017。librato_mongodb_user类型: 字符串
用于连接的 MongoDB 用户名。默认为
nil。librato_mongodb_password类型: 字符串
用于连接的 MongoDB 密码。默认为
nil。librato_mongodb_databases类型: 数组
收集指标的数据库。默认为空。
admin数据库会自动包含在数组中。librato_mongodb_name类型: 字符串
设置插件实例的名称。默认为
mongodb。
插件: mysql
librato_mysql_databases类型: 映射
收集指标的数据库。默认为空。
哈希格式为:
databases: [ { name: 'mydb' host: 'localhost' port: 3306 user: '' password: '' innodb_stats: true slave_stats: false } ]
插件: nginx
librato_nginx_protocol类型: 字符串
要使用的协议。默认为
http。如果需要 SSL,请将其更改为https。librato_nginx_host类型: 字符串
使用的主机名。默认为
localhost。librato_nginx_path类型: 字符串
状态页面的路径。默认为
/basic_status。
插件: nginx_plus
librato_nginx_plus_protocol类型: 字符串
要使用的协议。默认为
http。如果需要 SSL,请将其更改为https。librato_nginx_plus_host类型: 字符串
使用的主机名。默认为
localhost。librato_nginx_plus_path类型: 字符串
状态页面的路径。默认为
/status。librato_nginx_plus_verbose类型: 字符串
插件的详细模式开/关。默认为
false。
插件: postgresql
librato_postgresql_socket_file类型: 字符串
PostgreSQL 套接字文件。默认为
/var/run/postgresql。librato_postgresql_user类型: 字符串
作为连接的 PostgreSQL 用户。默认为
postgresql。librato_postgresql_databases类型: 映射
收集指标的数据库。默认为空。
哈希格式为:
databases = [ { name: 'mydb' instance: 'baz' host: 'localhost' port: 5432 user: '' password: '' ssl_mode: 'prefer' } ]
插件: redis
librato_redis_host类型: 字符串
Redis 主机名。默认为
localhost。librato_redis_port类型: 字符串
Redis 端口。默认为
6379。librato_redis_timeout类型: 字符串
连接到 Redis 的超时时间(毫秒)。默认为
2000。
插件: varnish
Varnish 没有可配置的属性。
插件: zookeeper
librato_zookeeper_host类型: 字符串
ZooKeeper 主机名。默认为
localhost。librato_zookeeper_port类型: 字符串
ZooKeeper 端口。默认为
2181。
全局变量
librato_email类型: 字符串
用于发送指标的电子邮件。与
token一起使用。此属性为必填,默认为空。librato_token类型: 字符串
用于发送指标的 API 令牌。与
email一起使用。此属性为必填,默认为空。librato_version类型: 字符串
要安装的 Librato Agent 的版本。
librato_repo_url类型: 字符串
软件包的基本 URL。默认为 Librato 的仓库 URL
https://packagecloud.io/librato/。librato_repo_base类型: 字符串
要使用的仓库基础。默认为 Librato 的仓库集合
librato-collectd。librato_config_base类型: 字符串
collectd 配置文件的基本路径。默认为
/opt/collectd/etc。librato_plugin_config_path类型: 字符串
collectd 插件配置的路径。默认为
/opt/collectd/etc/collectd.conf.d。librato_hostname类型: 字符串
用于节点的主机名。默认为
nil,优先使用FQDNLookup。librato_fqdn_lookup类型: true/false
是否对主机名进行 FQDN 查找。默认为
true。librato_interval类型: 整数
插件的全局轮询间隔(秒)。默认为
60。librato_use_log_file类型: true/false
将 collectd 日志写入文件。默认为
true。librato_use_syslog类型: true/false
将 collectd 日志写入 syslog。默认为
false。librato_use_logstash类型: true/false
将 collectd 日志写入 logstash 格式的文件。默认为
false。librato_log_file_log_level类型: 字符串
用于
log_file的日志级别。默认为info。librato_log_file_filename类型: 字符串
用于
log_file的文件名。默认为/opt/collectd/var/log/collectd.log。librato_log_file_timestamp类型: true/false
在日志文件中使用时间戳。默认为
true。librato_log_file_print_severity类型: true/false
在日志文件中包含严重性级别。默认为
true。librato_syslog_log_level类型: 字符串
用于 syslog 的日志级别。默认为
info。librato_logstash_log_level类型: 字符串
用于 logstash 的日志级别。默认为
info。librato_logstash_filename类型: 字符串
用于 logstash 的文件名。默认为
/opt/collectd/var/log/collectd.json.log。librato_default_plugins类型: 数组
要包含的默认插件列表。默认为:
cpu、df、disk、swap、memory、load。librato_enabled_plugins类型: 数组
要启用的插件列表。这与默认插件分开,主要用于包含其他插件。默认为空。
支持的平台
- RHEL 6 / CentOS 6
- RHEL 7 / CentOS 7
- Fedora 23
- 亚马逊Linux 2016.03
- Ubuntu 12.04
- Ubuntu 14.04
- Ubuntu 15.04
- Ubuntu 15.10
- Ubuntu 16.04
- Debian 7
- Debian 8
支持的 Ansible 版本
此角色需要 Ansible 2.2 或更高版本。
开发
测试
集成测试使用 kitchen-ansible 和 serverspec。要运行测试套件:
- 运行
bundle install - 运行
kitchen test
测试亚马逊Linux
通过 test-kitchen 测试亚马逊 Linux 需要更多设置:
- 确保已安装
kitchen-ec2:gem install kitchen-ec2 - 更新
.kitchen.yml以具有您要使用的正确 AWS 密钥 ID - 在驱动程序部分设置
security_group_ids,以包括可从您的笔记本电脑访问的安全组。如果不设置,将使用default安全组。 - 设置
transport.ssh_key为您的 SSH 密钥的路径。默认情况下它查找id_rsa。
许可
MIT
作者和贡献者
Mike Julian (@mjulian)
