ricoberger / script_exporter

Prometheus exporter to execute scripts and collect metrics from the output or the exit status.
MIT License
354 stars 82 forks source link

script_exporter's script_exit_code differs from the actual script's exit code #42

Closed ebdxflr closed 3 years ago

ebdxflr commented 3 years ago

When executed from CLI:

# /opt/script_exporter/check_type_current.sh
# echo `$?`
0

=== at the same time, script_exporter shows an exit code of -1 (and success as a False):

#  curl localhost:9469/probe?script=check_type_current
# HELP script_success Script exit status (0 = error, 1 = success).
# TYPE script_success gauge
script_success{script="check_type_current"} 0
# HELP script_duration_seconds Script execution time, in seconds.
# TYPE script_duration_seconds gauge
script_duration_seconds{script="check_type_current"} 0.001040
# HELP script_exit_code The exit code of the script.
# TYPE script_exit_code gauge
script_exit_code{script="check_type_current"} -1

I made sure to check the config.yaml file so it points to the proper script:

# grep check_type_current config.yaml
 - name: 'check_type_current'
   script: /opt/script_exporter/check_type_current.sh
ebdxflr commented 3 years ago

fixed, my script was missing the #!/bin/bash shbang