scripts/jvm-jstat-get
author Tomas Zeman <tomas@functionals.cz>
Tue, 21 Feb 2023 13:03:45 +0100
changeset 40 8c421321123d
parent 11 ab5293025139
permissions -rwxr-xr-x
run-cron-zabbix

#!/bin/sh

# Companion to jvm-stat-make to obtain actual value from dumped statistics.
# Invocation:
# jvm-jstat-get <name> <stat> <field>
#	where	name is symbolic name (service name etc.),
#		stat is statistic name (stats file) and
#		field number (from 1) to be returned

if [ -z "$1" -o -z "$2" -o -z "$3" ]; then
	echo -e "Missing service name, stat or field"
	exit 1
fi

UID=`id -u`
N=$1
STAT=$2
FIELD=$3

D=/tmp/jvm-jstat-$UID-$N

[ -d $D ] || exit 1;

tail -1 $D/$STAT | awk '{print $'$FIELD'}'