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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  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_services' => $openstack_service_config,
  155. 'cinder_services' => $openstack_service_config,
  156. 'keystone' => $openstack_service_config,
  157. 'neutron_agents' => $openstack_service_config,
  158. }
  159. $nova_polling = {
  160. 'polling_interval' => 60,
  161. 'pagination_limit' => 500,
  162. }
  163. $cinder_polling = {
  164. 'polling_interval' => 60,
  165. 'pagination_limit' => 500,
  166. }
  167. $glance_polling = {
  168. 'polling_interval' => 60,
  169. 'pagination_limit' => 25,
  170. }
  171. $neutron_polling = {
  172. 'polling_interval' => 60,
  173. 'pagination_limit' => 100,
  174. }
  175. $openstack_resources = {
  176. 'nova' => merge($openstack_service_config, $nova_polling),
  177. 'cinder' => merge($openstack_service_config, $cinder_polling),
  178. 'glance' => merge($openstack_service_config, $glance_polling),
  179. 'neutron' => merge($openstack_service_config, $neutron_polling),
  180. }
  181. create_resources(lma_collector::collectd::openstack, $openstack_services)
  182. create_resources(lma_collector::collectd::openstack, $openstack_resources)
  183. # FIXME(elemoine) use the special attribute * when Fuel uses a Puppet version
  184. # that supports it.
  185. class { 'lma_collector::collectd::openstack_checks':
  186. user => $openstack_service_config[user],
  187. password => $openstack_service_config[password],
  188. tenant => $openstack_service_config[tenant],
  189. keystone_url => $openstack_service_config[keystone_url],
  190. pacemaker_master_resource => $openstack_service_config[pacemaker_master_resource],
  191. require => Class['lma_collector::collectd::base'],
  192. }
  193. # FIXME(elemoine) use the special attribute * when Fuel uses a Puppet version
  194. # that supports it.
  195. class { 'lma_collector::collectd::hypervisor':
  196. user => $openstack_service_config[user],
  197. password => $openstack_service_config[password],
  198. tenant => $openstack_service_config[tenant],
  199. keystone_url => $openstack_service_config[keystone_url],
  200. pacemaker_master_resource => $openstack_service_config[pacemaker_master_resource],
  201. # Fuel sets cpu_allocation_ratio to 8.0 in nova.conf
  202. cpu_allocation_ratio => 8.0,
  203. require => Class['lma_collector::collectd::base'],
  204. }
  205. class { 'lma_collector::collectd::haproxy':
  206. socket => $haproxy_socket,
  207. # Ignore internal stats ('Stats' for 6.1, 'stats' for 7.0), lma proxies and
  208. # Nova EC2
  209. proxy_ignore => ['Stats', 'stats', 'lma', 'nova-api-1'],
  210. proxy_names => {
  211. 'ceilometer' => 'ceilometer-api',
  212. 'cinder-api' => 'cinder-api',
  213. 'glance-api' => 'glance-api',
  214. 'glance-registry' => 'glance-registry-api',
  215. 'heat-api' => 'heat-api',
  216. 'heat-api-cfn' => 'heat-cfn-api',
  217. 'heat-api-cloudwatch' => 'heat-cloudwatch-api',
  218. 'horizon' => 'horizon-web',
  219. 'horizon-ssl' => 'horizon-https',
  220. 'keystone-1' => 'keystone-public-api',
  221. 'keystone-2' => 'keystone-admin-api',
  222. 'murano' => 'murano-api',
  223. 'mysqld' => 'mysqld-tcp',
  224. 'neutron' => 'neutron-api',
  225. # starting with Mitaka (and later)
  226. 'nova-api' => 'nova-api',
  227. # before Mitaka
  228. 'nova-api-2' => 'nova-api',
  229. 'nova-novncproxy' => 'nova-novncproxy-websocket',
  230. 'nova-metadata-api' => 'nova-metadata-api',
  231. 'sahara' => 'sahara-api',
  232. 'swift' => 'swift-api',
  233. },
  234. require => Class['lma_collector::collectd::base'],
  235. }
  236. if $ceph_enabled {
  237. class { 'lma_collector::collectd::ceph_mon':
  238. require => Class['lma_collector::collectd::base'],
  239. }
  240. }
  241. class { 'lma_collector::collectd::memcached':
  242. host => get_network_role_property('mgmt/memcache', 'ipaddr'),
  243. require => Class['lma_collector::collectd::base'],
  244. }
  245. # Enable the Apache status module
  246. class { 'fuel_lma_collector::mod_status': }
  247. class { 'lma_collector::collectd::apache':
  248. require => Class['lma_collector::collectd::base'],
  249. }
  250. # Check local endpoint
  251. $cinder_api = get_network_role_property('cinder/api', 'ipaddr')
  252. $glance_api = get_network_role_property('glance/api', 'ipaddr')
  253. $heat_api = get_network_role_property('heat/api', 'ipaddr')
  254. $keystone_api = get_network_role_property('keystone/api', 'ipaddr')
  255. $neutron_api = get_network_role_property('neutron/api', 'ipaddr')
  256. $nova_api = get_network_role_property('nova/api', 'ipaddr')
  257. $swift_api = get_network_role_property('swift/api', 'ipaddr')
  258. if $fuel_version < 9.0 {
  259. $cinder_expected_code = 200
  260. } else {
  261. # Since Mitaka, Cinder returns 300 instead of 200 in previous releases
  262. $cinder_expected_code = 300
  263. }
  264. class { 'lma_collector::collectd::check_local_endpoint':
  265. urls => {
  266. 'cinder-api' => "http://${cinder_api}:8776",
  267. 'glance-api' => "http://${glance_api}:9292",
  268. 'heat-api' => "http://${heat_api}:8004",
  269. 'heat-cfn-api' => "http://${heat_api}:8000",
  270. 'keystone-public-api' => "http://${keystone_api}:5000",
  271. 'neutron-api' => "http://${neutron_api}:9696",
  272. 'nova-api' => "http://${nova_api}:8774",
  273. 'swift-api' => "http://${swift_api}:8080/info",
  274. },
  275. expected_codes => {
  276. 'cinder-api' => $cinder_expected_code,
  277. 'glance-api' => 300,
  278. 'heat-api' => 300,
  279. 'heat-cfn-api' => 300,
  280. 'keystone-public-api' => 300,
  281. 'neutron-api' => 200,
  282. 'nova-api' => 200,
  283. 'swift-api' => 200,
  284. },
  285. timeout => 1,
  286. max_retries => 3,
  287. require => Class['lma_collector::collectd::base'],
  288. }
  289. $influxdb_server = hiera('lma::collector::influxdb::server')
  290. $influxdb_port = hiera('lma::collector::influxdb::port')
  291. class { 'lma_collector::collectd::http_check':
  292. urls => {
  293. 'influxdb-cluster' => "http://${influxdb_server}:${influxdb_port}/ping",
  294. },
  295. expected_codes => {
  296. 'influxdb-cluster' => 204
  297. },
  298. timeout => 1,
  299. max_retries => 3,
  300. pacemaker_master_resource => $pacemaker_master_resource,
  301. require => Class['lma_collector::collectd::base'],
  302. }
  303. }
  304. # Compute
  305. if $is_compute {
  306. class { 'lma_collector::collectd::libvirt':
  307. require => Class['lma_collector::collectd::base'],
  308. }
  309. class { 'lma_collector::collectd::libvirt_check':
  310. require => Class['lma_collector::collectd::base'],
  311. }
  312. }
  313. # Ceph OSD
  314. if $is_ceph_osd {
  315. class { 'lma_collector::collectd::ceph_osd':
  316. require => Class['lma_collector::collectd::base'],
  317. }
  318. }
  319. # InfluxDB
  320. if $is_influxdb_node {
  321. class { 'lma_collector::collectd::influxdb':
  322. username => 'root',
  323. password => hiera('lma::collector::influxdb::root_password'),
  324. address => hiera('lma::collector::influxdb::listen_address'),
  325. port => hiera('lma::collector::influxdb::influxdb_port', 8086),
  326. require => Class['lma_collector::collectd::base'],
  327. }
  328. }
  329. # Elasticsearch
  330. if $is_elasticsearch_node {
  331. class { 'lma_collector::collectd::elasticsearch':
  332. address => hiera('lma::collector::elasticsearch::listen_address'),
  333. port => hiera('lma::collector::elasticsearch::rest_port', 9200),
  334. require => Class['lma_collector::collectd::base'],
  335. }
  336. }
  337. if $is_influxdb_node or $is_elasticsearch_node {
  338. class { 'lma_collector::collectd::haproxy':
  339. socket => $haproxy_socket,
  340. require => Class['lma_collector::collectd::base'],
  341. }
  342. }
  343. }