New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle incorrect authentication #2

Closed
Napsty opened this Issue Jan 5, 2018 · 1 comment

Comments

Projects
None yet
1 participant
@Napsty
Owner

Napsty commented Jan 5, 2018

Incorrect username/password is not correctly handled by the plugin.

# /usr/lib/nagios/plugins/check_es_system.sh -H myes.example.com -u myesuser -p wrongpass -t disk -d 128
parse error: type 'object' has no elements to extract (arg 2)
expr: syntax error
expr: syntax error
/usr/lib/nagios/plugins/check_es_system.sh: line 147: [: -ge: unary operator expected
/usr/lib/nagios/plugins/check_es_system.sh: line 150: [: -ge: unary operator expected
ES SYSTEM OK - Disk usage is at % ( G from 128 G)|es_disk=B;109951162777;130567005798;;

Debug:

++ grep -i authentication
++ echo '{"error":{"root_cause":[{"type":"security_exception","reason":"action' '[cluster:monitor/stats]' requires 'authentication","header":{"WWW-Authenticate":"Basic' 'realm=\"shield\"' 'charset=\"UTF-8\""}}],"type":"security_exception","reason":"action' '[cluster:monitor/stats]' requires 'authentication","header":{"WWW-Authenticate":"Basic' 'realm=\"shield\"' 'charset=\"UTF-8\""}},"status":401}'
+ [[ -n {"error":{"root_cause":[{"type":"security_exception","reason":"action [cluster:monitor/stats] requires authentication","header":{"WWW-Authenticate":"Basic realm=\"shield\" charset=\"UTF-8\""}}],"type":"security_exception","reason":"action [cluster:monitor/stats] requires authentication","header":{"WWW-Authenticate":"Basic realm=\"shield\" charset=\"UTF-8\""}},"status":401} ]]
+ authlogic
+ [[ -z myesuser ]]
+ [[ -n myesuser ]]
+ [[ -z wrongpass ]]
+ [[ -n wrongpass ]]
+ [[ -z myesuser ]]
curl -s --basic -u ${user}:${pass} $esurl
++ curl -s --basic -u myesuser:wrongpass http://myes.example.com:9200/_cluster/stats
+ esstatus='{"error":{"root_cause":[{"type":"security_exception","reason":"unable to authenticate user [myesuser] for REST request [/_cluster/stats]","header":{"WWW-Authenticate":"Basic realm=\"shield\" charset=\"UTF-8\""}}],"type":"security_exception","reason":"unable to authenticate user [myesuser] for REST request [/_cluster/stats]","header":{"WWW-Authenticate":"Basic realm=\"shield\" charset=\"UTF-8\""}},"status":401}'
echo $esstatus | grep -i authentication
++ echo '{"error":{"root_cause":[{"type":"security_exception","reason":"unable' to authenticate user '[myesuser]' for REST request '[/_cluster/stats]","header":{"WWW-Authenticate":"Basic' 'realm=\"shield\"' 'charset=\"UTF-8\""}}],"type":"security_exception","reason":"unable' to authenticate user '[myesuser]' for REST request '[/_cluster/stats]","header":{"WWW-Authenticate":"Basic' 'realm=\"shield\"' 'charset=\"UTF-8\""}},"status":401}'
++ grep -i authentication
+ [[ -n '' ]]
+ case $checktype in
echo $esstatus | jshon -e indices -e store -e "size_in_bytes"
++ jshon -e indices -e store -e size_in_bytes
++ echo '{"error":{"root_cause":[{"type":"security_exception","reason":"unable' to authenticate user '[myesuser]' for REST request '[/_cluster/stats]","header":{"WWW-Authenticate":"Basic' 'realm=\"shield\"' 'charset=\"UTF-8\""}}],"type":"security_exception","reason":"unable' to authenticate user '[myesuser]' for REST request '[/_cluster/stats]","header":{"WWW-Authenticate":"Basic' 'realm=\"shield\"' 'charset=\"UTF-8\""}},"status":401}'
parse error: type 'object' has no elements to extract (arg 2)
@Napsty

This comment has been minimized.

Show comment
Hide comment
@Napsty

Napsty Jan 5, 2018

Owner

Fixed with commit 0fb6c4c

Owner

Napsty commented Jan 5, 2018

Fixed with commit 0fb6c4c

@Napsty Napsty closed this Jan 5, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment