Fuel plugin to collect Logging Monitoring and Alerting metrics
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

collectd.pp 13KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  1. # Copyright 2016 Mirantis, Inc.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License"); you may
  4. # not use this file except in compliance with the License. You may obtain
  5. # a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  11. # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  12. # License for the specific language governing permissions and limitations
  13. # under the License.
  14. notice('fuel-plugin-lma-collector: collectd.pp')
  15. if hiera('lma::collector::influxdb::server', false) {
  16. prepare_network_config(hiera_hash('network_scheme', {}))
  17. $fuel_version = 0 + hiera('fuel_version')
  18. $management_vip = hiera('management_vip')
  19. $mgmt_address = get_network_role_property('management', 'ipaddr')
  20. $lma_collector = hiera_hash('lma_collector')
  21. $node_profiles = hiera_hash('lma::collector::node_profiles')
  22. $is_controller = $node_profiles['controller']
  23. $is_base_os = $node_profiles['base_os']
  24. $is_mysql_server = $node_profiles['mysql']
  25. $is_rabbitmq = $node_profiles['rabbitmq']
  26. $is_compute = $node_profiles['compute']
  27. $is_ceph_osd = $node_profiles['ceph_osd']
  28. $is_elasticsearch_node = $node_profiles['elasticsearch']
  29. $is_influxdb_node = $node_profiles['influxdb']
  30. $nova = hiera_hash('nova', {})
  31. $neutron = hiera_hash('quantum_settings', {})
  32. $cinder = hiera_hash('cinder', {})
  33. $haproxy_socket = '/var/lib/haproxy/stats'
  34. $storage_options = hiera_hash('storage', {})
  35. if $storage_options['volumes_ceph'] or $storage_options['images_ceph'] or
  36. $storage_options['objects_ceph'] or $storage_options['ephemeral_ceph']{
  37. $ceph_enabled = true
  38. } else {
  39. $ceph_enabled = false
  40. }
  41. if $is_controller or $is_rabbitmq {
  42. Service<| title == 'metric_collector' |> {
  43. provider => 'pacemaker'
  44. }
  45. }
  46. if $is_elasticsearch_node {
  47. $process_matches = [{name => 'elasticsearch', regex => 'java'}]
  48. } else {
  49. $process_matches = undef
  50. }
  51. if $is_influxdb_node {
  52. $processes = ['influxd', 'grafana-server', 'hekad', 'collectd']
  53. } else {
  54. $processes = ['hekad', 'collectd']
  55. }
  56. if $is_controller {
  57. # collectd plugins on controller do many network I/O operations, so
  58. # it is recommended to increase this value
  59. $read_threads = 10
  60. } else {
  61. $read_threads = 5
  62. }
  63. class { 'lma_collector::collectd::base':
  64. processes => $processes,
  65. process_matches => $process_matches,
  66. # Purge the default configuration shipped with the collectd package
  67. purge => true,
  68. read_threads => $read_threads,
  69. }
  70. if $is_mysql_server {
  71. class { 'lma_collector::collectd::mysql':
  72. username => hiera('lma::collector::monitor::mysql_username'),
  73. password => hiera('lma::collector::monitor::mysql_password'),
  74. socket => hiera('lma::collector::monitor::mysql_socket'),
  75. require => Class['lma_collector::collectd::base'],
  76. }
  77. lma_collector::collectd::dbi_mysql_status { 'mysql_status':
  78. username => hiera('lma::collector::monitor::mysql_username'),
  79. dbname => hiera('lma::collector::monitor::mysql_db'),
  80. password => hiera('lma::collector::monitor::mysql_password'),
  81. require => Class['lma_collector::collectd::base'],
  82. }
  83. }
  84. if $is_rabbitmq {
  85. $rabbit = hiera_hash('rabbit')
  86. if $rabbit['user'] {
  87. $rabbitmq_user = $rabbit['user']
  88. }
  89. else {
  90. $rabbitmq_user = 'nova'
  91. }
  92. class { 'lma_collector::collectd::rabbitmq':
  93. username => $rabbitmq_user,
  94. password => $rabbit['password'],
  95. require => Class['lma_collector::collectd::base'],
  96. }
  97. }
  98. # Configure Pacemaker plugin
  99. if $is_controller {
  100. $pacemaker_master_resource = 'vip__management'
  101. $controller_resources = {
  102. 'vip__public' => 'vip__public',
  103. 'vip__management' => 'vip__management',
  104. 'vip__vrouter_pub' => 'vip__vrouter_pub',
  105. 'vip__vrouter' => 'vip__vrouter',
  106. 'p_haproxy' => 'haproxy',
  107. }
  108. } else {
  109. $pacemaker_master_resource = undef
  110. $controller_resources = {}
  111. }
  112. # Deal with detach-* plugins
  113. if $is_mysql_server {
  114. if $fuel_version < 9.0 {
  115. $mysql_resource_name = 'p_mysql'
  116. } else {
  117. $mysql_resource_name = 'p_mysqld'
  118. }
  119. $mysql_resource = {
  120. "${mysql_resource_name}" => 'mysqld',
  121. }
  122. }
  123. else {
  124. $mysql_resource = {}
  125. }
  126. if $is_rabbitmq {
  127. $rabbitmq_resource = {
  128. 'p_rabbitmq-server' => 'rabbitmq',
  129. }
  130. }
  131. else {
  132. $rabbitmq_resource = {}
  133. }
  134. $resources = merge($controller_resources, $mysql_resource, $rabbitmq_resource)
  135. if ! empty($resources) {
  136. class { 'lma_collector::collectd::pacemaker':
  137. resources => $resources,
  138. notify_resource => $pacemaker_master_resource,
  139. hostname => $::fqdn,
  140. require => Class['lma_collector::collectd::base'],
  141. }
  142. }
  143. if $is_controller {
  144. # Configure OpenStack plugins
  145. $openstack_service_config = {
  146. user => 'nova',
  147. password => $nova['user_password'],
  148. tenant => 'services',
  149. keystone_url => "http://${management_vip}:5000/v2.0",
  150. pacemaker_master_resource => $pacemaker_master_resource,
  151. require => Class['lma_collector::collectd::base'],
  152. }
  153. $openstack_services = {
  154. 'nova' => $openstack_service_config,
  155. 'nova_services' => $openstack_service_config,
  156. 'cinder' => $openstack_service_config,
  157. 'cinder_services' => $openstack_service_config,
  158. 'glance' => $openstack_service_config,
  159. 'keystone' => $openstack_service_config,
  160. 'neutron' => $openstack_service_config,
  161. 'neutron_agents' => $openstack_service_config,
  162. }
  163. create_resources(lma_collector::collectd::openstack, $openstack_services)
  164. # FIXME(elemoine) use the special attribute * when Fuel uses a Puppet version
  165. # that supports it.
  166. class { 'lma_collector::collectd::openstack_checks':
  167. user => $openstack_service_config[user],
  168. password => $openstack_service_config[password],
  169. tenant => $openstack_service_config[tenant],
  170. keystone_url => $openstack_service_config[keystone_url],
  171. pacemaker_master_resource => $openstack_service_config[pacemaker_master_resource],
  172. require => Class['lma_collector::collectd::base'],
  173. }
  174. # FIXME(elemoine) use the special attribute * when Fuel uses a Puppet version
  175. # that supports it.
  176. class { 'lma_collector::collectd::hypervisor':
  177. user => $openstack_service_config[user],
  178. password => $openstack_service_config[password],
  179. tenant => $openstack_service_config[tenant],
  180. keystone_url => $openstack_service_config[keystone_url],
  181. pacemaker_master_resource => $openstack_service_config[pacemaker_master_resource],
  182. # Fuel sets cpu_allocation_ratio to 8.0 in nova.conf
  183. cpu_allocation_ratio => 8.0,
  184. require => Class['lma_collector::collectd::base'],
  185. }
  186. class { 'lma_collector::collectd::haproxy':
  187. socket => $haproxy_socket,
  188. # Ignore internal stats ('Stats' for 6.1, 'stats' for 7.0), lma proxies and
  189. # Nova EC2
  190. proxy_ignore => ['Stats', 'stats', 'lma', 'nova-api-1'],
  191. proxy_names => {
  192. 'ceilometer' => 'ceilometer-api',
  193. 'cinder-api' => 'cinder-api',
  194. 'glance-api' => 'glance-api',
  195. 'glance-registry' => 'glance-registry-api',
  196. 'heat-api' => 'heat-api',
  197. 'heat-api-cfn' => 'heat-cfn-api',
  198. 'heat-api-cloudwatch' => 'heat-cloudwatch-api',
  199. 'horizon' => 'horizon-web',
  200. 'horizon-ssl' => 'horizon-https',
  201. 'keystone-1' => 'keystone-public-api',
  202. 'keystone-2' => 'keystone-admin-api',
  203. 'murano' => 'murano-api',
  204. 'mysqld' => 'mysqld-tcp',
  205. 'neutron' => 'neutron-api',
  206. # starting with Mitaka (and later)
  207. 'nova-api' => 'nova-api',
  208. # before Mitaka
  209. 'nova-api-2' => 'nova-api',
  210. 'nova-novncproxy' => 'nova-novncproxy-websocket',
  211. 'nova-metadata-api' => 'nova-metadata-api',
  212. 'sahara' => 'sahara-api',
  213. 'swift' => 'swift-api',
  214. },
  215. require => Class['lma_collector::collectd::base'],
  216. }
  217. if $ceph_enabled {
  218. class { 'lma_collector::collectd::ceph_mon':
  219. require => Class['lma_collector::collectd::base'],
  220. }
  221. }
  222. class { 'lma_collector::collectd::memcached':
  223. host => get_network_role_property('mgmt/memcache', 'ipaddr'),
  224. require => Class['lma_collector::collectd::base'],
  225. }
  226. # Enable the Apache status module
  227. class { 'fuel_lma_collector::mod_status': }
  228. class { 'lma_collector::collectd::apache':
  229. require => Class['lma_collector::collectd::base'],
  230. }
  231. # Check local endpoint
  232. $cinder_api = get_network_role_property('cinder/api', 'ipaddr')
  233. $glance_api = get_network_role_property('glance/api', 'ipaddr')
  234. $heat_api = get_network_role_property('heat/api', 'ipaddr')
  235. $keystone_api = get_network_role_property('keystone/api', 'ipaddr')
  236. $neutron_api = get_network_role_property('neutron/api', 'ipaddr')
  237. $nova_api = get_network_role_property('nova/api', 'ipaddr')
  238. $swift_api = get_network_role_property('swift/api', 'ipaddr')
  239. if $fuel_version < 9.0 {
  240. $cinder_expected_code = 200
  241. } else {
  242. # Since Mitaka, Cinder returns 300 instead of 200 in previous releases
  243. $cinder_expected_code = 300
  244. }
  245. class { 'lma_collector::collectd::check_local_endpoint':
  246. urls => {
  247. 'cinder-api' => "http://${cinder_api}:8776",
  248. 'glance-api' => "http://${glance_api}:9292",
  249. 'heat-api' => "http://${heat_api}:8004",
  250. 'heat-cfn-api' => "http://${heat_api}:8000",
  251. 'keystone-public-api' => "http://${keystone_api}:5000",
  252. 'neutron-api' => "http://${neutron_api}:9696",
  253. 'nova-api' => "http://${nova_api}:8774",
  254. 'swift-api' => "http://${swift_api}:8080/info",
  255. },
  256. expected_codes => {
  257. 'cinder-api' => $cinder_expected_code,
  258. 'glance-api' => 300,
  259. 'heat-api' => 300,
  260. 'heat-cfn-api' => 300,
  261. 'keystone-public-api' => 300,
  262. 'neutron-api' => 200,
  263. 'nova-api' => 200,
  264. 'swift-api' => 200,
  265. },
  266. timeout => 1,
  267. max_retries => 3,
  268. require => Class['lma_collector::collectd::base'],
  269. }
  270. $influxdb_server = hiera('lma::collector::influxdb::server')
  271. $influxdb_port = hiera('lma::collector::influxdb::port')
  272. class { 'lma_collector::collectd::http_check':
  273. urls => {
  274. 'influxdb-cluster' => "http://${influxdb_server}:${influxdb_port}/ping",
  275. },
  276. expected_codes => {
  277. 'influxdb-cluster' => 204
  278. },
  279. timeout => 1,
  280. max_retries => 3,
  281. pacemaker_master_resource => $pacemaker_master_resource,
  282. require => Class['lma_collector::collectd::base'],
  283. }
  284. }
  285. # Compute
  286. if $is_compute {
  287. class { 'lma_collector::collectd::libvirt':
  288. require => Class['lma_collector::collectd::base'],
  289. }
  290. class { 'lma_collector::collectd::libvirt_check':
  291. require => Class['lma_collector::collectd::base'],
  292. }
  293. }
  294. # Ceph OSD
  295. if $is_ceph_osd {
  296. class { 'lma_collector::collectd::ceph_osd':
  297. require => Class['lma_collector::collectd::base'],
  298. }
  299. }
  300. # InfluxDB
  301. if $is_influxdb_node {
  302. class { 'lma_collector::collectd::influxdb':
  303. username => 'root',
  304. password => hiera('lma::collector::influxdb::root_password'),
  305. address => hiera('lma::collector::influxdb::listen_address'),
  306. port => hiera('lma::collector::influxdb::influxdb_port', 8086),
  307. require => Class['lma_collector::collectd::base'],
  308. }
  309. }
  310. # Elasticsearch
  311. if $is_elasticsearch_node {
  312. class { 'lma_collector::collectd::elasticsearch':
  313. address => hiera('lma::collector::elasticsearch::listen_address'),
  314. port => hiera('lma::collector::elasticsearch::rest_port', 9200),
  315. require => Class['lma_collector::collectd::base'],
  316. }
  317. }
  318. if $is_influxdb_node or $is_elasticsearch_node {
  319. class { 'lma_collector::collectd::haproxy':
  320. socket => $haproxy_socket,
  321. require => Class['lma_collector::collectd::base'],
  322. }
  323. }
  324. }