Skip to content

Instantly share code, notes, and snippets.

@stephen-soltesz
Last active December 13, 2015 02:52
Show Gist options
  • Save stephen-soltesz/f14386979b3eaf2520cd to your computer and use it in GitHub Desktop.
Save stephen-soltesz/f14386979b3eaf2520cd to your computer and use it in GitHub Desktop.
(
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
)
@salarcon215
Copy link

Append a "|wc -l" for an answer that is easy to read?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment