Skip to content

Commit

Permalink
Support prometheus >= 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sathieu committed Aug 1, 2017
1 parent 56dbfab commit 651d94a
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 28 deletions.
15 changes: 15 additions & 0 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,21 @@
) {

if $prometheus::init_style {
if( versioncmp($::prometheus::version, '2.0.0') < 0 ){
$daemon_flags = [
"-config.file=${::prometheus::config_dir}/prometheus.yaml",
"-storage.local.path=${::prometheus::localstorage}",
"-web.console.templates=${::prometheus::shared_dir}/consoles",
"-web.console.libraries=${::prometheus::shared_dir}/console_libraries",
]
} else {
$daemon_flags = [
"--config.file=${::prometheus::config_dir}/prometheus.yaml",
"--storage.tsdb.path=${::prometheus::localstorage}",
"--web.console.templates=${::prometheus::shared_dir}/consoles",
"--web.console.libraries=${::prometheus::shared_dir}/console_libraries",
]
}

case $prometheus::init_style {
'upstart' : {
Expand Down
5 changes: 1 addition & 4 deletions templates/prometheus.debian.erb
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@ DESC="Prometheus monitoring framework"
NAME=prometheus
DAEMON=<%= scope.lookupvar('prometheus::bin_dir') %>/$NAME
PIDFILE=/var/run/$NAME/$NAME.pid
DAEMON_ARGS=" -config.file=<%= scope.lookupvar('prometheus::config_dir')+'/prometheus.yaml' %>
-storage.local.path=<%= scope.lookupvar('prometheus::localstorage')%>
-web.console.templates=<%= scope.lookupvar('prometheus::shared_dir') %>/consoles
-web.console.libraries=<%= scope.lookupvar('prometheus::shared_dir') %>/console_libraries
DAEMON_ARGS="<%= @daemon_flags.join("\n ") %>
<%= scope.lookupvar('prometheus::extra_options') %>"
USER=<%= scope.lookupvar('prometheus::user') %>
SCRIPTNAME=/etc/init.d/$NAME
Expand Down
11 changes: 3 additions & 8 deletions templates/prometheus.launchd.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,9 @@
<array>
<string><%= scope.lookupvar('prometheus::bin_dir') %>/prometheus</string>
<string>agent</string>
<string>-config.file=</string>
<string><%= scope.lookupvar('prometheus::config_dir')+'/prometheus.yaml' %></string>
<string>-storage.local.path=</string>
<string><%= scope.lookupvar('prometheus::localstorage')%></string>
<string>-web.console.templates=</string>
<string><%= scope.lookupvar('prometheus::shared_dir') %>/consoles</string>
<string>-web.console.libraries=</string>
<string><%= scope.lookupvar('prometheus::shared_dir') %>/console_libraries</string>
<%- daemon_flags.each |flag| do -%>
<string><%= flag %></string>
<%- end -%>
<% require 'shellwords' %>
<% for extra_option in Shellwords.split(scope.lookupvar('prometheus::extra_options')) %>
<string><%= extra_option %></string>
Expand Down
5 changes: 1 addition & 4 deletions templates/prometheus.sles.erb
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,7 @@ case "$1" in
echo -n "Starting prometheus "
## Start daemon with startproc(8). If this fails
## the return value is set appropriately by startproc.
startproc $PROMETHEUS_BIN -config.file="$CONFIG_FILE" \
-storage.local.path=<%= scope.lookupvar('prometheus::localstorage')%> \
-web.console.templates=<%= scope.lookupvar('prometheus::shared_dir') %>/consoles \
-web.console.libraries=<%= scope.lookupvar('prometheus::shared_dir') %>/console_libraries \
startproc $PROMETHEUS_BIN <%= @daemon_flags.join("\n\\ ") %> \
<%= scope.lookupvar('prometheus::extra_options') %> >> "$LOG_FILE"

# Remember status and be verbose
Expand Down
5 changes: 1 addition & 4 deletions templates/prometheus.systemd.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ After=basic.target network.target
User=<%= scope.lookupvar('prometheus::user') %>
Group=<%= scope.lookupvar('prometheus::group') %>
ExecStart=<%= scope.lookupvar('prometheus::bin_dir') %>/prometheus \
-config.file=<%= scope.lookupvar('prometheus::config_dir')+'/prometheus.yaml' %>\
-storage.local.path=<%= scope.lookupvar('prometheus::localstorage')%> \
-web.console.templates=<%= scope.lookupvar('prometheus::shared_dir') %>/consoles \
-web.console.libraries=<%= scope.lookupvar('prometheus::shared_dir') %>/console_libraries \
<%= @daemon_flags.join("\n\\ ") %> \
<%= scope.lookupvar('prometheus::extra_options') %>
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Expand Down
5 changes: 1 addition & 4 deletions templates/prometheus.sysv.erb
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,7 @@ start() {
[ -f $PID_FILE ] && rm $PID_FILE
daemon --user=<%= scope.lookupvar('prometheus::user') %> \
--pidfile="$PID_FILE" \
"$DAEMON" -log.format logger:stdout -config.file="$CONFIG" \
-storage.local.path=<%= scope.lookupvar('prometheus::localstorage')%> \
-web.console.templates=<%= scope.lookupvar('prometheus::shared_dir') %>/consoles \
-web.console.libraries=<%= scope.lookupvar('prometheus::shared_dir') %>/console_libraries \
"$DAEMON" -log.format logger:stdout <%= @daemon_flags.join("\n\\ ") %> \
<%= scope.lookupvar('prometheus::extra_options') %> >> "$LOG_FILE" &
retcode=$?
mkpidfile
Expand Down
5 changes: 1 addition & 4 deletions templates/prometheus.upstart.erb
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@ script
[ -e $DEFAULTS ] && . $DEFAULTS

export GOMAXPROCS=${GOMAXPROCS:-2}
exec start-stop-daemon -c $USER -g $GROUP -p $PID_FILE -x $PROMETHEUS -S -- -config.file=$CONFIG \
-storage.local.path=<%= scope.lookupvar('prometheus::localstorage')%> \
-web.console.templates=<%= scope.lookupvar('prometheus::shared_dir') %>/consoles \
-web.console.libraries=<%= scope.lookupvar('prometheus::shared_dir') %>/console_libraries \
exec start-stop-daemon -c $USER -g $GROUP -p $PID_FILE -x $PROMETHEUS -S -- <%= @daemon_flags.join("\n\\ ") %> \
<%= scope.lookupvar('prometheus::extra_options') %>
end script

Expand Down

0 comments on commit 651d94a

Please sign in to comment.