Updated API to pull quick latency stats if available

dev
Eric Loyd 1 year ago
parent 293b51ddcf
commit 0c8482ae01

@ -1,8 +1,24 @@
api.sh.gz: api.sh
gzip -9 --keep api.sh
chmod 644 api.sh.gz
scp api.sh.gz ssd:eloyd/
gzip -f -9 --keep $<
chmod 644 $@
scp $@ ssd:eloyd/
nagios:
gzip -9 --keep nlog
scp nlog root@192.168.1.19:/usr/local/bin/nlog
gzip -f -9 --keep nlog
rsync -avu nlog api.sh root@192.168.1.19:/usr/local/bin/
test: api.sh
@echo "### Checking HGM:"
./api.sh -t hgm -hg arrs -o i -o h -v | head -5
@echo ""
@echo "### Checking -Q -f .output:"
./api.sh -Q -f .output | head -5
@echo ""
@echo "Checking file sizes for current and save/file:"
./api.sh --save asdhjadkajthksdfga.json -v | head -5
./api.sh | wc
./api.sh --file asdhjadkajthksdfga.json | wc
rm -f asdhjadkajthksdfga.json
@echo ""
@echo "Checking stats:"
./api.sh --stats

@ -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;;

Loading…
Cancel
Save