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

Commit

Permalink
Nmon external issue - manage metrics collection into a dedicated file #…
Browse files Browse the repository at this point in the history
  • Loading branch information
guilhemmarchand committed Jun 4, 2017
1 parent 4d91432 commit fa3856f
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 19 deletions.
13 changes: 9 additions & 4 deletions TA-nmon/bin/fifo_consumer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
# Guilhem Marchand 2017/05/23, Integrate new fifo mode from parsers, fixed hard coded arguments
# Guilhem Marchand 2017/05/29, error in rotated files naming for purge rm command
# Guilhem Marchand 2017/05/30, improvements to prevent gaps in data
# Guilhem Marchand 2017/06/04, manage nmon external metrics in dedicated file

# Version 1.0.07
# Version 1.0.8

# For AIX / Linux / Solaris

Expand Down Expand Up @@ -130,12 +131,14 @@ nmon_header=$SPLUNK_HOME/var/log/nmon/var/nmon_repository/$FIFO/nmon_header.dat
nmon_timestamp=$SPLUNK_HOME/var/log/nmon/var/nmon_repository/$FIFO/nmon_timestamp.dat
nmon_data=$SPLUNK_HOME/var/log/nmon/var/nmon_repository/$FIFO/nmon_data.dat
nmon_data_tmp=$SPLUNK_HOME/var/log/nmon/var/nmon_repository/$FIFO/nmon_data_tmp.dat
nmon_external=$SPLUNK_HOME/var/log/nmon/var/nmon_repository/$FIFO/nmon_external.dat

# rotated
nmon_config_rotated=$SPLUNK_HOME/var/log/nmon/var/nmon_repository/$FIFO/nmon_config.dat.rotated
nmon_header_rotated=$SPLUNK_HOME/var/log/nmon/var/nmon_repository/$FIFO/nmon_header.dat.rotated
nmon_timestamp_rotated=$SPLUNK_HOME/var/log/nmon/var/nmon_repository/$FIFO/nmon_timestamp.dat.rotated
nmon_data_rotated=$SPLUNK_HOME/var/log/nmon/var/nmon_repository/$FIFO/nmon_data.dat.rotated
nmon_external_rotated=$SPLUNK_HOME/var/log/nmon/var/nmon_repository/$FIFO/nmon_external.dat.rotated

# manage rotated data if existing, prevent any data loss

Expand All @@ -150,10 +153,10 @@ if [ -s $nmon_config_rotated ] && [ -s $nmon_header_rotated ] && [ -s $nmon_data
# and the parser will raise an error
if [ -f $nmon_timestamp_rotated ]; then
tail -1 $nmon_timestamp_rotated >$temp_file
cat $nmon_config_rotated $nmon_header_rotated $temp_file $nmon_data_rotated | $SPLUNK_HOME/bin/splunk cmd $APP/bin/nmon2csv.sh $nmon2csv_options
cat $nmon_config_rotated $nmon_header_rotated $temp_file $nmon_data_rotated $nmon_external_rotated | $SPLUNK_HOME/bin/splunk cmd $APP/bin/nmon2csv.sh $nmon2csv_options
fi
else
cat $nmon_config_rotated $nmon_header_rotated $nmon_data_rotated | $SPLUNK_HOME/bin/splunk cmd $APP/bin/nmon2csv.sh $nmon2csv_options
cat $nmon_config_rotated $nmon_header_rotated $nmon_data_rotated $nmon_external_rotated | $SPLUNK_HOME/bin/splunk cmd $APP/bin/nmon2csv.sh $nmon2csv_options
fi

# remove rotated
Expand Down Expand Up @@ -204,9 +207,11 @@ if [ -s $nmon_config ] && [ -s $nmon_header ] && [ -s $nmon_data ]; then

# copy content
cat $nmon_data > $nmon_data_tmp
cat $nmon_external >> $nmon_data_tmp

# empty the nmon_data file
# empty the nmon_data file & external
> $nmon_data
> $nmon_external

# Ensure the first line of nmon_data starts by the relevant timestamp, if not add it
head -1 $nmon_data_tmp | grep 'ZZZZ,T' >/dev/null
Expand Down
15 changes: 4 additions & 11 deletions TA-nmon/bin/nmon_external_cmd/nmon_external_snap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
# Guilhem Marchand 2017/03/18, initial version

# 2017/04/29, Guilhem Marchand: - AIX compatibility issues, detach the commands in background
# 2017/06/04, Guilhem Marchand: - Manage nmon external data in a dedicated file

# Version 1.0.1
# Version 1.0.2

# For AIX / Linux / Solaris

Expand All @@ -24,21 +25,13 @@
# - 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_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

# 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_FIFO_PATH &
echo "PROCCOUNT,$1,`ps -ef | wc -l`" >>NMON_FIFO_PATH/nmon_external.dat &

# Uptime information (uptime command output)
echo "UPTIME,$1,\"`uptime | sed 's/^\s//g' | sed 's/,/;/g'`\"" >>NMON_FIFO_PATH &
echo "UPTIME,$1,\"`uptime | sed 's/^\s//g' | sed 's/,/;/g'`\"" >>NMON_FIFO_PATH/nmon_external.dat &
8 changes: 5 additions & 3 deletions TA-nmon/bin/nmon_helper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,10 @@
# - Allows activating / deactivating fifo mode
# 2017/05/24, Guilhem Marchand:
# - Bad variable name introduced in 1.3.47 changes
# 2017/06/04, Guilhem Marchand:
# - Manage nmon external data in a dedicated file

# Version 1.3.48
# Version 1.3.49

# For AIX / Linux / Solaris

Expand Down Expand Up @@ -969,13 +971,13 @@ 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"
cat ${APP}/bin/nmon_external_cmd/nmon_external_snap.sh | sed "s|NMON_FIFO_PATH|$NMON_EXTERNAL_DIR|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"
cat ${APP}/bin/nmon_external_cmd/nmon_external_snap.sh | sed "s|NMON_FIFO_PATH|$NMON_EXTERNAL_DIR|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
Expand Down
2 changes: 1 addition & 1 deletion TA-nmon/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.20
version = 1.3.21
Binary file renamed TA-nmon_1320.tgz → TA-nmon_1321.tgz
Binary file not shown.
1 change: 1 addition & 0 deletions docs/releasenotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ V1.3.20:
========

- fix: AIX issue - fifo_reader regex match some monitors into header #29
- fix: Nmon external issue - manage metrics collection into a dedicated file #30

========
V1.3.19:
Expand Down

0 comments on commit fa3856f

Please sign in to comment.