Last active
December 13, 2015 02:52
-
-
Save stephen-soltesz/f14386979b3eaf2520cd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
( | |
vserver iupui_ndt exec bash <<\EOF | |
ps ax -opid,args \ | |
| grep ndtd \ | |
| grep -v grep \ | |
| awk 'BEGIN { | |
start_time_index = 22 ; | |
# Read the start_time of the awk process. | |
# All older processes will have an earlier (smaller) start_time. | |
"cat /proc/self/stat" |& getline result ; split(result, proc) ; | |
awk_start = proc[start_time_index] ; | |
} | |
{ | |
# Read the start_time of each NDT process. | |
sprintf("cat /proc/%d/stat", $1) |& getline result ; split(result, proc) ; | |
t_diff = awk_start - proc[start_time_index] ; | |
# Report all processes that have run for more than 60 seconds. | |
# This will always apply to the parent ndtd. If there is more than | |
# 1, they are in a hung state. | |
# /proc/<pid>/stat starttime increments sysconf(_SC_CLK_TCK) every | |
# second. This is 100 on M-Lab (and most systems); | |
# So, 60 seconds will be 6000 ticks. | |
if (t_diff > 6000) { | |
print result ; | |
} | |
}' | |
EOF | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Append a "|wc -l" for an answer that is easy to read?