Fixed typos and rearranged help a bit

dev
Eric Loyd 1 year ago
parent d178ceaa79
commit d776a8e239

10
napi

@ -34,7 +34,7 @@ APIinfo["config/servicegroup"]=".[]"
APIinfo["config/command"]=".[]" APIinfo["config/command"]=".[]"
APIinfo["config/contact"]=".contact[]" APIinfo["config/contact"]=".contact[]"
APIinfo["config/contactgroup"]=".[]" APIinfo["config/contactgroup"]=".[]"
APIinfo["config/timeperiod"]="" APIinfo["config/timeperiod"]=".[]"
APIinfo["objects/hoststatus"]=".hoststatus[]" APIinfo["objects/hoststatus"]=".hoststatus[]"
APIinfo["objects/servicestatus"]=".servicestatus[]" APIinfo["objects/servicestatus"]=".servicestatus[]"
@ -139,15 +139,15 @@ print_help() {
Ex: name=in:localhost,nagios,testhost - Displays any matching name with the comma-separated list. 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 Note: Multiple --col selectors are not valid at this time
-cnn current_notification_number=<n> -cnn current_notification_number=<n>
--cname command_name]=<...> --cname command_name=<...>
--cline command_line]=<...> --cline command_line=<...>
--ctrace Take the --cname given, get its --cline, and replace arguments to show a valid command (whew!) --ctrace Take the --cname given, get its --cline, and replace arguments to show a valid command (whew!)
-cg|--contactgroup contact_groups=<value> -cg|--contactgroup contact_groups=<value>
-cn|--configname config_name=<value> -cn|--configname config_name=<value>
... comment | downtime | contact | host | service | hostgroup | ... ... comment | downtime | contact | host | service | hostgroup | ...
--create doCreate="true" --create doCreate="true"
--apply If we're creating something, then Apply Configuration --apply If we're creating something, then Apply Configuration
-D <Nagios Config Directive>=<value> -D <Nagios Config Directive>=<value> This will take anything listed as a Nagios configuration directive and search for it
-f|--fields JQ-valid list of fields to show=<value> -f|--fields JQ-valid list of fields to show=<value>
--file load JSON from=<value> --file load JSON from=<value>
--helpopt Show help for command options --helpopt Show help for command options
@ -178,8 +178,6 @@ print_help() {
--stype 0, 1 (SOFT or HARD) --stype 0, 1 (SOFT or HARD)
--test Don't call the API, just show what would happen --test Don't call the API, just show what would happen
-v|--verbose verbose=\$((\$verbose + 1)) -v|--verbose verbose=\$((\$verbose + 1))
[...] [...]=<...> NOTE: This will take anything listed as a Nagios configuration directive and search for it
HELP_EOF HELP_EOF
exit exit
} }

@ -8,6 +8,7 @@ message=""
tag="exclamation" tag="exclamation"
priority="3" priority="3"
state="" state=""
testMode=""
case "$NAGIOS_NOTIFICATIONTYPE" in case "$NAGIOS_NOTIFICATIONTYPE" in
PROBLEM) tag="bangbang";; PROBLEM) tag="bangbang";;
@ -45,10 +46,21 @@ do_service() {
while [ -n "$1" ]; do while [ -n "$1" ]; do
case "$1" in case "$1" in
-t|--type) alertType="$2"; shift 2;; -t|--type) alertType="$2"; shift 2;;
--test) testMode="true"; shift 1;;
*) shift 1;; *) shift 1;;
esac esac
done done
if [ -n "$testMode" ]; then
NAGIOS_NOTIFICATIONTYPE="Test"
NAGIOS_HOSTNAME="FakeHost"
NAGIOS_HOSTSTATE="OK"
NAGIOS_SERVICEDESC="FakeService"
NAGIOS_HOSTALIAS="FakeHostAlias"
NAGIOS_SERVICESTATE="OK"
NAGIOS_LONGDATETIME="Today"
fi
case "$alertType" in case "$alertType" in
h|host|host) do_host;; h|host|host) do_host;;
s|svc|service) do_service;; s|svc|service) do_service;;

Loading…
Cancel
Save