API now has all advertised API selectors from the documentation.
This commit is contained in:
@@ -105,8 +105,9 @@ print_helpopt() {
|
||||
all:
|
||||
i Make all string comparisons case-insentitive
|
||||
|
||||
servicestatus:
|
||||
servicestatus|hoststatus:
|
||||
c Show fields selected by -f as quoted CSV
|
||||
C Same as C but also include the fields
|
||||
|
||||
hostgroupmembers:
|
||||
h Only show hosts (not the complete JSON data)
|
||||
@@ -128,6 +129,10 @@ print_help() {
|
||||
--api < o*bjects | c*onfig | s*ystem >
|
||||
-c|--command check_command=<value>
|
||||
-cca current_check_attempt=<value>
|
||||
--col column name=<type>:<value>
|
||||
Ex: name=lk:local - Displays any matching name with 'local' anywhere in the string.
|
||||
Ex: name=in:localhost,nagios,testhost - Displays any matching name with the comma-separated list.
|
||||
Note: Multiple --col selectors are not valid at this time
|
||||
-cnn current_notification_number=<n>
|
||||
--cname command_name]=<...>
|
||||
--cline command_line]=<...>
|
||||
@@ -150,10 +155,12 @@ print_help() {
|
||||
--key APIKEY=<value>
|
||||
--keyfile APIkeyFile=<value>
|
||||
-o|--opt cmdOptions=<value> (endpoint specific options. See --helpopt)
|
||||
--order orderby <column>:<a or d>
|
||||
--output output text=<value>
|
||||
-Q|--quick Sets -f to .host_name,.service_description,.current_state,.state_type,.problem_has_been_acknowledged (assumes servicestatus)
|
||||
-q Same as --quick but add -o c
|
||||
-qq Same as --quick but add -o c but also print the first line of the CSV output (fields)
|
||||
--records records <amount>:<starting at>
|
||||
--save save JSON to=<value>
|
||||
-sg|--servicegroup servicegroup=<value>
|
||||
-sgm servicegroup_members (mainly for creating servicegroups)
|
||||
@@ -210,6 +217,7 @@ while [ -n "$1" ]; do
|
||||
--api) get_myAPI "$2"; shift 2;;
|
||||
-c|--command) myDir[check_command]="$2"; shift 2;;
|
||||
-cca) myDir[current_check_attempt]="$2"; shift 2;;
|
||||
--col) myOptions[Column]="$2"; shift 2;;
|
||||
--cname) myDir[command_name]="$2"; shift 2;;
|
||||
--cline) myDir[command_line]="$2"; shift 2;;
|
||||
--ctrace) myOptions[CommandTrace]="true"; shift 1;;
|
||||
@@ -230,10 +238,12 @@ while [ -n "$1" ]; do
|
||||
--key) apikey="$2"; shift 2;;
|
||||
--keyfile) apikeyfile="$2"; shift 2;;
|
||||
-o|--opt) myOptions[Options]+="$2,"; shift 2;;
|
||||
--order) myOptions[OrderBy]="$2"; shift 2;;
|
||||
--output) myDir[output]="$2"; shift 2;;
|
||||
-q) myOptions[Quick]="true"; myOptions[Options]+="c,"; shift 1;;
|
||||
-qq) myOptions[Quick]="true"; myOptions[Options]+="c,c,"; shift 1;;
|
||||
-qq) myOptions[Quick]="true"; myOptions[Options]+="c,C,"; shift 1;;
|
||||
-Q|--quick) myOptions[Quick]="true"; shift 1;;
|
||||
--records) myOptions[Records]="$2"; shift 2;;
|
||||
--save) myOptions[Save]="$2"; shift 2;;
|
||||
-sg|--servicegroup) myDir[servicegroup_name]="$2"; shift 2;;
|
||||
-sgm) myDir[servicegroup_members]="$2"; shift 2;;
|
||||
@@ -270,10 +280,17 @@ fi
|
||||
do_api() {
|
||||
api_start="$1"
|
||||
api_command="$2"
|
||||
url="${XI_URL}/api/v1/${api_start}/${api_command}?pretty=0"
|
||||
url="${XI_URL}/api/v1/${api_start}/${api_command}?pretty=0&apikey=${APIKEY}"
|
||||
[ -n "${myOptions[Start]}" ] && url+="&starttime=${myOptions[Start]}"
|
||||
[ -n "${myOptions[End]}" ] && url+="&endtime=${myOptions[End]}"
|
||||
url+="&apikey=${APIKEY}"
|
||||
[ -n "${myOptions[Records]}" ] && url+="&records=${myOptions[Records]}"
|
||||
[ -n "${myOptions[OrderBy]}" ] && url+="&orderby=${myOptions[OrderBy]}"
|
||||
if [ -n "${myOptions[Column]}" ]; then
|
||||
colName=`echo "${myOptions[Column]}" | cut -d= -f 1`
|
||||
colVal=`echo "${myOptions[Column]}" | cut -d= -f 2`
|
||||
do_debug 1 "colName=$colName colVal=$colVal"
|
||||
url+="&$colName=$colVal"
|
||||
fi
|
||||
do_debug 2 "start=$1 command=$2"
|
||||
do_debug 1 "Executing: $url"
|
||||
$curl -XGET -k "$url"
|
||||
|
||||
Reference in New Issue
Block a user