How can I read an attribute value from a file in check_http
Posted: Tue Dec 19, 2017 2:15 am
I have written a bash script to get the authorization header token to be written to the /usr/local/nagios/etc/resource.cfg file. The bash script works fine and in the resource.cfg the token value is saved as below,
ACCESS_TOKEN="Authorization: Bearer 38255d19-724a-4e2c-b8bc-1234retff13"
When configuring the nagios service I need to read the authorization header from the above file.
This seems not to be working, can anyone guide me on how I can access the header value in the command by reading the file?
ACCESS_TOKEN="Authorization: Bearer 38255d19-724a-4e2c-b8bc-1234retff13"
When configuring the nagios service I need to read the authorization header from the above file.
Code: Select all
define command{
command_name check_post_https_with_args
command_line /usr/local/nagios/libexec/check_http -H $HOSTADDRESS$ -S -u $ARG1$ -k /usr/local/nagios/etc/resource.cfg echo $ACCESS_TOKEN --method=POST --post $ARG2$ -T 'application/json'
}
Code: Select all
define service{
use generic-service
host_name www.cardgen.com
service_description post request checker
is_volatile 0
check_period 24x7
check_interval 1
max_check_attempts 3
normal_check_interval 1
retry_check_interval 1
contact_groups admin_group
notification_interval 120
notification_period 24x7
notification_options w,u,c,r
check_command check_post_https_with_args!/api/load/validatereadDetails=true!'{\"referenceId:145\",\"amount:500\"}'
}