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

Commit

Permalink
versoon 1.3.29
Browse files Browse the repository at this point in the history
  • Loading branch information
guilhemmarchand committed Sep 5, 2017
1 parent e74ee9c commit 8f9632d
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 21 deletions.
23 changes: 15 additions & 8 deletions TA-nmon/bin/nmon_external_cmd/nmon_external_snap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,21 @@ echo "PROCCOUNT,$1,`ps -ef | wc -l`" >>NMON_FIFO_PATH/nmon_external.dat &
echo "UPTIME,$1,\"`uptime | sed 's/^\s//g' | sed 's/,/;/g'`\"" >>NMON_FIFO_PATH/nmon_external.dat &

# df table information
DF_TABLE=`df -k -P | sed '1d' | egrep -v '\s\/proc$|\s/dev$|\s\/run$|^tmpfs.*\/dev.*$|^tmpfs.*\/run.*$|^tmpfs.*\/sys.*$|^tmpfs.*\/var.*$' | awk '{print $6}'`
DF_TABLE=`df -k -P | sed '1d' | egrep -v '\/proc$|/dev$|\/run$|^tmpfs.*\/dev.*$|^tmpfs.*\/run.*$|^tmpfs.*\/sys.*$|^tmpfs.*\/var.*$' | awk '{print $6}'`
for fs in $DF_TABLE; do
echo "DF_STORAGE,$1,`df -k -P $fs | sed '1d' | sed 's/%//g' | sed 's/,/;/g' | awk '{print $1 "," $2 "," $3 "," $4 "," $5 "," $6}'`" >>NMON_FIFO_PATH/nmon_external.dat
# DF_INODES, for AIX and Linux
case `uname` in
"AIX")
echo "DF_INODES,$1,`df -i $fs | sed '1d' | sed 's/%//g' | sed 's/,/;/g' | awk '{print $1 "," $5 "," $6 "," $7}'`" >>NMON_FIFO_PATH/nmon_external.dat ;;
"Linux")
echo "DF_INODES,$1,`df -i -P $fs | sed '1d' | sed 's/%//g' | sed 's/,/;/g' | awk '{print $1 "," $2 "," $3 "," $4 "," $5 "," $6}'`" >>NMON_FIFO_PATH/nmon_external.dat ;;
esac
done

# DF_INODES, for AIX and Linux
case `uname` in
"AIX")
for fs in $DF_TABLE; do
echo "DF_INODES,$1,`df -i $fs | sed '1d' | sed 's/%//g' | sed 's/,/;/g' | awk '{print $1 "," $5 "," $6 "," $7}'`" >>NMON_FIFO_PATH/nmon_external.dat
done
;;
"Linux")
for fs in $DF_TABLE; do
echo "DF_INODES,$1,`df -i -P $fs | sed '1d' | sed 's/%//g' | sed 's/,/;/g' | awk '{print $1 "," $2 "," $3 "," $4 "," $5 "," $6}'`" >>NMON_FIFO_PATH/nmon_external.dat
done
;;
esac
38 changes: 25 additions & 13 deletions TA-nmon/bin/nmon_helper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1088,7 +1088,7 @@ check_duplicated_external_snap () {

# get the list of occurrences
count="0"
count=`ps -ef | grep splunk | grep nmon | grep nmon_external_snap | grep -v grep | wc -l`
count=`ps -ef | grep nmon_external_snap | grep -v grep | wc -l`

if [ $count -gt 0 ]; then
oldPidList=`ps -ef | grep nmon_external_snap | grep -v grep | awk '{print $2}'`
Expand All @@ -1098,22 +1098,34 @@ check_duplicated_external_snap () {
if [ -d /proc/${pid} ]; then
# get the process runtime in seconds
pid_runtime=`ps -p ${pid} -oetime= | tr '-' ':' | awk -F: '{ total=0; m=1; } { for (i=0; i < NF; i++) {total += $(NF-i)*m; m *= i >= 2 ? 24 : 60 }} {print total}'`
if [ ${pid_runtime} -gt 120 ]; then
echo "`log_date`, ${HOST} WARN: fifo nmon external snap script took long and will be killed (SIGTERM): `ps -p ${pid} -ouser,pid,command,etime,args | grep -v PID`"
kill $pid

# Allow some time for the process to end
sleep 1
case ${pid_runtime} in

# re-check the status
ps -p ${pid} -oetime= >/dev/null
''|*[!0-9]*)
echo "`log_date`, ${HOST} WARN: run time identification of processwith pid ${pid} failed, it has been probably terminated"
;;
*)

if [ $? -eq 0 ]; then
echo "`log_date`, ${HOST} WARN, fifo nmon external snap due to `ps -eo user,pid,command,etime,args | grep $pid | grep -v grep` failed to stop, killing (-9) process $pid"
kill -9 $pid
fi
if [ ${pid_runtime} -gt 120 ]; then
echo "`log_date`, ${HOST} WARN: fifo nmon external snap script took long and will be killed (SIGTERM): `ps -p ${pid} -ouser,pid,command,etime,args | grep -v PID`"
kill $pid

# Allow some time for the process to end
sleep 1

# re-check the status
ps -p ${pid} -oetime= >/dev/null

if [ $? -eq 0 ]; then
echo "`log_date`, ${HOST} WARN, fifo nmon external snap due to `ps -eo user,pid,command,etime,args | grep $pid | grep -v grep` failed to stop, killing (-9) process $pid"
kill -9 $pid
fi

fi
;;

esac

fi
fi
done
fi
Expand Down
Binary file modified TA-nmon_1329.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 @@ -20,6 +20,7 @@ V1.3.29:

- fix: Python parser - header detection correction for nmon external monitoring
- feature: Add df information for improved file system monitoring and storage capacity planning
- fix: unexpected operator issue during process identification #48

========
V1.3.28:
Expand Down

0 comments on commit 8f9632d

Please sign in to comment.