Skip to content
This repository has been archived by the owner on Aug 28, 2021. It is now read-only.

Commit

Permalink
AIX nmon external issue
Browse files Browse the repository at this point in the history
  • Loading branch information
guilhemmarchand committed Mar 31, 2017
1 parent 877295c commit caaa576
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 25 deletions.
11 changes: 7 additions & 4 deletions bin/nmon_external_cmd/nmon_external_snap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,21 @@
# - nmon_external: manage any number of fields without transposition
# - nmon_external_transposed: manage any number of fields with a notion of device / value

# Do no try to do anything unless the NMON_EXTERNAL_DIR variable has been correctly set
# Do no try to do anything unless the NMON_FIFO_PATH exists
# we exit without any error code, the situation is not expected but we do not want to generate bad data in nmon data

if [ "$NMON_EXTERNAL_DIR" = "" ]
# note: the NMON_FIFO_PATH is a pattern that will be replaced by the nmon_helper.sh script in a copy of this script
# that lives for the time to live of the nmon process started

if [ ! -p NMON_FIFO_PATH ]
then
exit 0
fi

# CAUTION: ensure your custom command does not output any comma within the field name and value

# Number of running processes
echo "PROCCOUNT,$1,`ps -ef | wc -l`" >>$NMON_EXTERNAL_DIR/nmon.fifo
echo "PROCCOUNT,$1,`ps -ef | wc -l`" >>NMON_FIFO_PATH

# Uptime information (uptime command output)
echo "UPTIME,$1,\"`uptime | sed 's/^\s//g' | sed 's/,/;/g'`\"" >>$NMON_EXTERNAL_DIR/nmon.fifo
echo "UPTIME,$1,\"`uptime | sed 's/^\s//g' | sed 's/,/;/g'`\"" >>NMON_FIFO_PATH
11 changes: 7 additions & 4 deletions bin/nmon_external_cmd/nmon_external_start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,21 @@
# - nmon_external: manage any number of fields without transposition
# - nmon_external_transposed: manage any number of fields with a notion of device / value

# Do no try to do anything unless the NMON_EXTERNAL_DIR variable has been correctly set
# Do no try to do anything unless the NMON_FIFO_PATH exists
# we exit without any error code, the situation is not expected but we do not want to generate bad data in nmon data

if [ "$NMON_EXTERNAL_DIR" = "" ]
# note: the NMON_FIFO_PATH is a pattern that will be replaced by the nmon_helper.sh script in a copy of this script
# that lives for the time to live of the nmon process started

if [ ! -p NMON_FIFO_PATH ]
then
exit 0
fi

# CAUTION: ensure your custom command does not output any comma within the field name and value

# number of running processes
echo "PROCCOUNT,Process Count,nb_running_processes" >>$NMON_EXTERNAL_DIR/nmon.fifo
echo "PROCCOUNT,Process Count,nb_running_processes" >>NMON_FIFO_PATH

# uptime information
echo "UPTIME,Server Uptime and load,uptime_stdout" >>$NMON_EXTERNAL_DIR/nmon.fifo
echo "UPTIME,Server Uptime and load,uptime_stdout" >>NMON_FIFO_PATH
66 changes: 50 additions & 16 deletions bin/nmon_helper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,10 @@
# - prevent AIX error messages related to LIBPATH and rpm
# - PowerLinux binaries identification failures
# 2017/03/29, Guilhem Marchand: - nmon command not correctly displayed in nmon_helper.sh output
# 2017/03/30, Guilhem Marchand: - nmon_external improvement for AIX
# 2017/03/30, Guilhem Marchand: - AIX issue with nmon_external
# 2017/03/30, Guilhem Marchand: - AIX issue with nmon_external (act II !)

# Version 1.3.39
# Version 1.3.40

# For AIX / Linux / Solaris

Expand Down Expand Up @@ -153,10 +154,6 @@ esac
\cp -pf ${APP}/default/app.conf ${APP_VAR}/app.conf > /dev/null 2>&1
\cp -rpf ${APP}/bin ${APP_VAR}/ > /dev/null 2>&1
}
# Only relevant for Linux and Solaris, binaries caching management
case $UNAME in

Linux | SunOS )

# To prevents binaries overwrites during upgrades and sh cluster deployment issues, cache the bin directory
# Binaries will be launched from the cache directory
Expand Down Expand Up @@ -185,9 +182,6 @@ else

fi

;;
esac

###
### Legacy options for nmon writing to regular files (these values are used by the TA-nmon not using fifo files)
###
Expand Down Expand Up @@ -932,6 +926,28 @@ esac
# functions
############################################

# create snap scripts for nmon_external

create_nmon_external () {

# fifo_started variable is exported by the function start_fifo_reader
case $fifo_started in
"fifo1")
cat ${APP}/bin/nmon_external_cmd/nmon_external_start.sh | sed "s|NMON_FIFO_PATH|$NMON_EXTERNAL_FIFO|g" > "${APP_VAR}/bin/nmon_external_cmd/nmon_external_start_fifo1.sh"
chmod +x "${APP_VAR}/bin/nmon_external_cmd/nmon_external_start_fifo1.sh"
cat ${APP}/bin/nmon_external_cmd/nmon_external_snap.sh | sed "s|NMON_FIFO_PATH|$NMON_EXTERNAL_FIFO|g" > "${APP_VAR}/bin/nmon_external_cmd/nmon_external_snap_fifo1.sh"
chmod +x "${APP_VAR}/bin/nmon_external_cmd/nmon_external_snap_fifo1.sh"
;;
"fifo2")
cat ${APP}/bin/nmon_external_cmd/nmon_external_start.sh | sed "s|NMON_FIFO_PATH|$NMON_EXTERNAL_FIFO|g" > "${APP_VAR}/bin/nmon_external_cmd/nmon_external_start_fifo2.sh"
chmod +x "${APP_VAR}/bin/nmon_external_cmd/nmon_external_start_fifo2.sh"
cat ${APP}/bin/nmon_external_cmd/nmon_external_snap.sh | sed "s|NMON_FIFO_PATH|$NMON_EXTERNAL_FIFO|g" > "${APP_VAR}/bin/nmon_external_cmd/nmon_external_snap_fifo2.sh"
chmod +x "${APP_VAR}/bin/nmon_external_cmd/nmon_external_snap_fifo2.sh"
;;
esac

}

# For AIX / Linux, the -p option when launching nmon will output the instance pid in stdout

start_nmon () {
Expand All @@ -944,41 +960,59 @@ case $UNAME in
unset LIBPATH

# nmon_external
# nb: for AIX there is no bin cache, as Splunk Enterprise is not supported anymore, we can safety run them
# directly from the TA-nmon directory
export NMON_START="${APP}/bin/nmon_external_cmd/nmon_external_start.sh"
export NMON_SNAP="${APP}/bin/nmon_external_cmd/nmon_external_snap.sh"
export NMON_EXTERNAL_DIR="${APP_VAR}/var/nmon_repository/${fifo_started}"
export NMON_EXTERNAL_FIFO="${APP_VAR}/var/nmon_repository/${fifo_started}/nmon.fifo"
export TIMESTAMP=0
export NMON_ONE_IN=1
unset NMON_END

# fifo_started variable is exported by the function start_fifo_reader
case $fifo_started in
"fifo1")
# nmon_external
create_nmon_external
export NMON_START="${APP_VAR}/bin/nmon_external_cmd/nmon_external_start_fifo1.sh"
export NMON_SNAP="${APP_VAR}/bin/nmon_external_cmd/nmon_external_snap_fifo1.sh"
export TIMESTAMP=0
export NMON_ONE_IN=1
unset NMON_END
echo "`date`, ${HOST} INFO: starting nmon : ${nmon_command_fifo1} in ${NMON_EXTERNAL_DIR}"
${nmon_command_fifo1} > ${PIDFILE} ;;
"fifo2")
# nmon_external
create_nmon_external
export NMON_START="${APP_VAR}/bin/nmon_external_cmd/nmon_external_start_fifo2.sh"
export NMON_SNAP="${APP_VAR}/bin/nmon_external_cmd/nmon_external_snap_fifo2.sh"
export TIMESTAMP=0
export NMON_ONE_IN=1
unset NMON_END
echo "`date`, ${HOST} INFO: starting nmon : ${nmon_command_fifo2} in ${NMON_EXTERNAL_DIR}"
${nmon_command_fifo2} > ${PIDFILE} ;;
esac
;;

Linux )

# nmon_external
export NMON_START="${APP_VAR}/bin/nmon_external_cmd/nmon_external_start.sh"
export NMON_SNAP="${APP_VAR}/bin/nmon_external_cmd/nmon_external_snap.sh"
# nmon_external
export NMON_EXTERNAL_DIR="${APP_VAR}/var/nmon_repository/${fifo_started}"
export NMON_EXTERNAL_FIFO="${APP_VAR}/var/nmon_repository/${fifo_started}/nmon.fifo"
export TIMESTAMP=0
export NMON_ONE_IN=1
unset NMON_END

# fifo_started variable is exported by the function start_fifo_reader
case $fifo_started in
"fifo1")
# nmon_external
create_nmon_external
export NMON_START="${APP_VAR}/bin/nmon_external_cmd/nmon_external_start_fifo1.sh"
export NMON_SNAP="${APP_VAR}/bin/nmon_external_cmd/nmon_external_snap_fifo1.sh"
nmon_command=${nmon_command_fifo1} ;;
"fifo2")
# nmon_external
create_nmon_external
export NMON_START="${APP_VAR}/bin/nmon_external_cmd/nmon_external_start_fifo2.sh"
export NMON_SNAP="${APP_VAR}/bin/nmon_external_cmd/nmon_external_snap_fifo2.sh"
nmon_command=${nmon_command_fifo2} ;;
esac

Expand Down
2 changes: 1 addition & 1 deletion default/app.conf
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ label = TA-nmon
[launcher]
author = Guilhem Marchand
description = Technical Addon for Nmon Performance Monitor
version = 1.3.08
version = 1.3.09

0 comments on commit caaa576

Please sign in to comment.