HEX
Server: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.4.33
System: Linux li317-225.members.linode.com 3.10.0-1062.12.1.el7.x86_64 #1 SMP Tue Feb 4 23:02:59 UTC 2020 x86_64
User: apache (48)
PHP: 7.4.33
Disabled: NONE
Upload Files
File: //usr/share/systemtap/examples/process/thread-business.stp
#!/usr/bin/stap

global activity           // [execname,tid]->syscall-count
global activity2          // [execname,tid]->syscall-name-string-history

global syscall_history_length = 50 // override with stap -Gsyscall_history_length=NNN
global top_threads = 20

probe syscall_any # use tracepoint based syscall_any; we don't need context data
{
  activity[execname(),tid()]<<<1
  history = name." ".activity2[execname(),tid()]
  activity2[execname(),tid()] = substr(history,0,syscall_history_length)
}


probe timer.s(5) 
{
  printf("%16s %6s %5s %-*s\n\n", "execname", "tid", "count", 
                               syscall_history_length, "recent syscalls");
  foreach ([e,t] in activity- limit top_threads) {
    printf("%16s %6d %5d %s", e, t, @count(activity[e,t]), activity2[e,t])
    printf("\n")
  }    
  printf("\n")
  delete activity
  delete activity2
}