password change script discards output from elasticsearch

This support forum board is for support questions relating to Nagios Log Server, our solution for managing and monitoring critical log data.
Locked
ananke
Posts: 21
Joined: Fri Jun 03, 2016 3:14 pm

password change script discards output from elasticsearch

Post by ananke »

Currently /usr/local/nagioslogserver/scripts/reset_nagiosadmin_password.sh does not check for any kind of result, and always claims success. Specifically these lines:
# Save new password into elasticsearch
curl -XPOST http://localhost:9200/nagioslogserver/user/1/_update -d "$update" > /dev/null 2>&1
curl -XPOST http://localhost:9200/nagioslogserver/_refresh > /dev/null 2>&1

printf "The password has been set for nagiosadmin user.\n"
I'm not familiar enough with elasticsearch to know what the proper output may consist of, but it may be useful to not send everything to /dev/null, otherwise it gives false sense of success. We ran into this issue when trying to reset password on an installation that wasn't cleaned up fully, and there was no user with ID 1.


Perhaps using jq and parsing out the output could be a way to find out the actual results, eg:

Working user:

Code: Select all

curl -s -XPOST http://localhost:9200/nagioslogserver/user/1/_update -d '{"doc":{"password":"hash"}}' | jq .error
null
Non-existing user, possibly other problems:

Code: Select all

curl -s -XPOST http://localhost:9200/nagioslogserver/user/1000/_update -d '{"doc":{"password":"hash"}}' | jq .error
"DocumentMissingException[[nagioslogserver][0] [user][1000]: document missing]"
User avatar
hsmith
Agent Smith
Posts: 3539
Joined: Thu Jul 30, 2015 11:09 am
Location: 127.0.0.1
Contact:

Re: password change script discards output from elasticsearc

Post by hsmith »

Thank you, I'll file a bug report for this.
Former Nagios Employee.
me.
Locked