diff --git a/cookbooks/prometheus-exporters/files/etc/default/node_exporter b/cookbooks/prometheus-exporters/files/etc/default/node_exporter new file mode 100644 index 0000000..abb1a6b --- /dev/null +++ b/cookbooks/prometheus-exporters/files/etc/default/node_exporter @@ -0,0 +1 @@ +OPTIONS=' --web.listen-address="127.0.0.1:9100" --collector.systemd' diff --git a/cookbooks/prometheus-exporters/files/etc/systemd/system/node_exporter.service b/cookbooks/prometheus-exporters/files/etc/systemd/system/node_exporter.service new file mode 100644 index 0000000..f3b7aa6 --- /dev/null +++ b/cookbooks/prometheus-exporters/files/etc/systemd/system/node_exporter.service @@ -0,0 +1,11 @@ +[Unit] +Description=Node Exporter + +[Service] +User=root +Group=root +EnvironmentFile=-/etc/default/node_exporter +ExecStart=/usr/local/bin/node_exporter $OPTIONS + +[Install] +WantedBy=multi-user.target diff --git a/cookbooks/prometheus-exporters/node_exporter_setup.rb b/cookbooks/prometheus-exporters/node_exporter_setup.rb index c907a3f..7bac76a 100644 --- a/cookbooks/prometheus-exporters/node_exporter_setup.rb +++ b/cookbooks/prometheus-exporters/node_exporter_setup.rb @@ -1,10 +1,18 @@ # Deploy the `supervisord` configuration: -remote_file '/etc/supervisor/conf.d/node_exporter.conf' do +remote_file '/etc/systemd/system/node_exporter.service' do owner 'root' group 'root' mode '644' +end - notifies :restart, 'service[supervisor]' +remote_file '/etc/default/node_exporter' do + owner 'root' + group 'root' + mode '644' +end + +service 'node_exporter' do + action [ :enable, :start] end # Deploy `consul` config for `node_exporter`: