This file is indexed.

/usr/sbin/scomes is in tuned-utils-systemtap 2.9.0-1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
#!/usr/bin/stap
#
# Copyright (C) 2008-2013 Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#

# ===================================================================
# Do this when we have started
global report_period = 0
# For watch_forked variable:
#    0 = watch only main thread
#    1 = watch forked with same execname as well
#    2 = watch all forked processes
global watch_forked = 2
probe begin {
  if ($# == 1) {
    report_period = $1
  }
  print("Collecting data...\n")
  printf("... for pid %d - %s\n", target(), pid2execname(target()))
}

# ===================================================================
# Define helper function for printing results
function compute_score() {
  # new empirical formula that was proposed by Vratislav Podzimek <vpodzime@redhat.com> in his bachelor thesis
  return syscalls + (poll_timeout + epoll_timeout + select_timeout + itimer_timeout + nanosleep_timeout + futex_timeout + signal_timeout) * 4 + (reads + writes) / 5000 + (ifxmit + ifrecv) * 25
}

function print_status() {
  printf("-----------------------------------\n")
  ###target_set_report()
  printf("Monitored process: %d (%s)\n", target(), pid2execname(target()))
  printf("Number of syscalls: %d\n", syscalls)
  printf("Kernel/Userspace ticks: %d/%d (%d)\n", kticks, uticks, kticks+uticks)
  printf("Read/Written bytes (from/to devices): %d/%d (%d)\n", reads, writes, reads+writes)
  printf("Read/Written bytes (from/to N/A device): %d/%d (%d)\n", reads_c, writes_c, reads_c+writes_c)
  printf("Transmitted/Recived bytes: %d/%d (%d)\n", ifxmit, ifrecv, ifxmit+ifrecv)
  printf("Polling syscalls: %d\n", poll_timeout+epoll_timeout+select_timeout+itimer_timeout+nanosleep_timeout+futex_timeout+signal_timeout)
  printf("SCORE: %d\n", compute_score())
}

# ===================================================================
# Define helper function for comparing if this is relevant pid
# and for watching if our watched pid forked
# ... from http://sourceware.org/systemtap/wiki/systemtapstarters
global PIDS = 1   # as target() is already running
function is_watched(p) {
  if ( (watch_forked == 0 && p == target()) || (watch_forked == 1 && target_set_pid(p) && pid2execname(target()) == pid2execname(p)) || (watch_forked == 2 && target_set_pid(p)) ) {
    #printf("Process %d is relevant to process %d\n", p, target())
    return 1   # yes, we are watching this pid
  } else {
    return 0   # no, we are not watching this pid
  }
}
# Add a relevant forked process to the list of watched processes
probe kernel.function("do_fork") {
  #printf("Fork of %d (%s) detected\n", pid(), execname())
  if (is_watched(pid())) {
    #printf("Proces %d forked\n", pid())
    PIDS = PIDS + 1
    #printf("Currently watching %d pids (1 just added)\n", PIDS)
  }
}
# Remove pid from the list of watched pids and print report when
# all relevant processes ends
probe syscall.exit {
  if (is_watched(pid())) {
    #printf("Removing process %d\n", pid())
    PIDS = PIDS - 1
  }
  #printf("Currently watching %d pids (1 just removed)\n", PIDS)
  if (PIDS == 0) {
    printf("-----------------------------------\n")
    printf("LAST RESULTS:\n")
    print_status()
    exit()
  }
}

# ===================================================================
# Check all syscalls
# ... from syscalls_by_pid.stp
global syscalls
probe syscall.* {
  if (is_watched(pid())) {
    syscalls++
    #printf ("%s(%d) syscall %s\n", execname(), pid(), name)
  }
}

# ===================================================================
# Check read/written bytes
# ... from disktop.stp
global reads, writes, reads_c, writes_c
probe vfs.read.return {
  if (is_watched(pid()) && $return>0) {
    if (devname!="N/A") {
      reads += $return
    } else {
      reads_c += $return
    }
  }
}
probe vfs.write.return {
  if (is_watched(pid()) && $return>0) {
    if (devname!="N/A") {
      writes += $return
    } else {
      writes_c += $return
    }
  }
}

# ===================================================================
# Check kernel and userspace CPU ticks
# ... from thread-times.stp
global kticks, uticks
probe timer.profile {
  if (is_watched(pid())) {
    if (!user_mode())
      kticks++
    else
      uticks++
  }
}

# ===================================================================
# Check polling
# ... from timeout.stp
global poll_timeout, epoll_timeout, select_timeout, itimer_timeout
global nanosleep_timeout, futex_timeout, signal_timeout
global to
probe syscall.poll, syscall.epoll_wait {
  if (timeout) to[pid()]=timeout
}
probe syscall.poll.return {
  if ($return == 0 && is_watched(pid()) && to[pid()] > 0) {
    poll_timeout++
    delete to[pid()]
  }
}
probe syscall.epoll_wait.return {
  if ($return == 0 && is_watched(pid()) && to[pid()] > 0) {
    epoll_timeout++
    delete to[pid()]
  }
}
probe syscall.select.return {
  if ($return == 0 && is_watched(pid())) {
    select_timeout++
  }
}
probe syscall.futex.return {
  if ($return == 0 && is_watched(pid()) && errno_str($return) == "ETIMEDOUT") {
    futex_timeout++
  }
}
probe syscall.nanosleep.return {
  if ($return == 0 && is_watched(pid())) {
    nanosleep_timeout++
  }
}
probe kernel.function("it_real_fn") {
  if (is_watched(pid())) {
    itimer_timeout++
  }
}
probe syscall.rt_sigtimedwait.return {
   if (is_watched(pid()) && errno_str($return) == "EAGAIN") {
     signal_timeout++
   }
}

# ===================================================================
# Check network traffic
# ... from nettop.stp
global ifxmit, ifrecv
probe netdev.transmit {
  if (is_watched(pid()) && dev_name!="lo") {
    ifxmit += length
  }
}
probe netdev.receive {
  if (is_watched(pid()) && dev_name!="lo") {
    ifrecv += length
  }
}

# ===================================================================
# Print report each X seconds
global counter
probe timer.s(1) {
  if (report_period != 0) {
    counter++
    if (counter == report_period) {
      print_status()
      counter = 0
    }
  }
}

# ===================================================================
# Print quit message
probe end {
  printf("-----------------------------------\n")
  printf("LAST RESULTS:\n")
  print_status()
  printf("-----------------------------------\n")
  printf("QUITTING\n")
  printf("-----------------------------------\n")
}