Updated API to pull quick latency stats if available

This commit is contained in:
2024-07-30 11:32:01 -04:00
parent 293b51ddcf
commit 0c8482ae01
2 changed files with 45 additions and 13 deletions
+24 -8
View File
@@ -60,10 +60,10 @@ APIinfo["objects/bpi"]=""
get_myAPI() {
case "$1" in
o*) ${myOptions[API]}="objects";;
c*) ${myOptions[API]}="config";;
s*) ${myOptions[API]}="system";;
*) ${myOptions[API]}="";;
o*) myOptions[API]="objects";;
c*) myOptions[API]="config";;
s*) myOptions[API]="system";;
*) myOptions[API]="";;
esac
}
@@ -156,6 +156,21 @@ HELP_EOF
exit
}
# We're going to do nagiostats instead
do_stats() {
if [ ! -x "/usr/local/nagios/bin/nagiostats" ]; then
echo "Cannot find nagiostats program."
exit 1
fi
/usr/local/nagios/bin/nagiostats --mrtg --data=MINACTHSTLAT,MAXACTHSTLAT,AVGACTHSTLAT | xargs | while read min max avg; do
echo "Active Host Check Latency (min/max/avg in ms): $min / $max / $avg"
done
/usr/local/nagios/bin/nagiostats --mrtg --data=MINACTSVCLAT,MAXACTSVCLAT,AVGACTSVCLAT | xargs | while read min max avg; do
echo "Active Service Check Latency (min/max/avg in ms): $min / $max / $avg"
done
exit
}
while [ -n "$1" ]; do
case "$1" in
--ack) myDir[problem_has_been_acknowledged]="$2"; shift 2;;
@@ -178,15 +193,16 @@ while [ -n "$1" ]; do
--key) APIKEY="$2"; shift 2;;
--keyfile) APIkeyFile="$2"; shift 2;;
-o|--opt) myOptions[Options]+="$2,"; shift 2;;
--output) myDir[Output]="$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;;
-Q|--quick) myOptions[Quick]="true"; shift 1;;
--save) myOptions[Save]="$2"; shift 2;;
-sg|--servicegroup) myDir[servicegroup_name]="$2"; shift 2;;
-s|--service) myDir[Service]="$2"; shift 2;;
--state) myDir[State]="$2"; shift 2;;
--stype) myDir[StateType]="$2"; shift 2;;
-s|--service) myDir[service_description]="$2"; shift 2;;
--stats) do_stats; shift 2;;
--state) myDir[current_state]="$2"; shift 2;;
--stype) myDir[state_type]="$2"; shift 2;;
--test) myOptions[TestMode]="true"; shift 1;;
-t|--object) get_myAPIep "$2"; shift 2;;
--url) XI_URL="$2"; shift 2;;