diff --git a/cookbooks/prometheus/files/etc/supervisor/conf.d/snmp_exporter.conf b/cookbooks/prometheus/files/etc/supervisor/conf.d/snmp_exporter.conf deleted file mode 100644 index 38e00ac..0000000 --- a/cookbooks/prometheus/files/etc/supervisor/conf.d/snmp_exporter.conf +++ /dev/null @@ -1,8 +0,0 @@ -[program:snmp_exporter] -command=/usr/local/bin/snmp_exporter --config.file /etc/prometheus_exporters.d/snmp.yml -stdout_logfile=/var/log/supervisor/snmp_exporter.log -redirect_stderr=true -stdout_logfile_maxbytes=1MB -stdout_logfile_backups=5 -autorestart=true -stopsignal=HUP diff --git a/cookbooks/prometheus/files/etc/systemd/system/snmp_exporter.service b/cookbooks/prometheus/files/etc/systemd/system/snmp_exporter.service new file mode 100644 index 0000000..7e64c7d --- /dev/null +++ b/cookbooks/prometheus/files/etc/systemd/system/snmp_exporter.service @@ -0,0 +1,10 @@ +[Unit] +Description=SNMP Exporter + +[Service] +User=root +Group=root +ExecStart=/usr/local/bin/snmp_exporter --config.file /etc/prometheus_exporters.d/snmp.yml + +[Install] +WantedBy=multi-user.target diff --git a/cookbooks/prometheus/snmp_exporter_setup.rb b/cookbooks/prometheus/snmp_exporter_setup.rb index 5b11a89..e3f99ba 100644 --- a/cookbooks/prometheus/snmp_exporter_setup.rb +++ b/cookbooks/prometheus/snmp_exporter_setup.rb @@ -3,13 +3,15 @@ link '/etc/prometheus_exporters.d/snmp.yml' do to "#{node['snmp_exporter']['storage']}snmp.yml" end -# Deploy `supervisord` config: -remote_file '/etc/supervisor/conf.d/snmp_exporter.conf' do +# Deploy `systemd` config: +remote_file '/etc/systemd/system/snmp_exporter.service' do owner 'root' group 'root' mode '644' +end - notifies :restart, 'service[supervisor]' +service 'snmp_exporter' do + action [:enable, :start] end # Deploy `consul` config: