How can I collect performance data similar as pidstat using lttng? - lttng

By the performance data I mean like cpu, memory and disk usages for each process. I'm using Ubuntu 14.04 LTS, ans I installed the PPA version, but follow the instruction about how to use lttngTop I couldn't get it run: it always return error like "can't open trace file". Is there any other way to collect these data or could anyone tell me where I got wrong? Thanks.

Which commands did you use to setup your LTTng session? Did you enable the required event contexts? It's not immediately obvious, but lttngtop needs some event contexts that are not enabled by default. From the man page:
LTTngTop requires that the pid, procname, tid and ppid context
information are enabled during tracing.
This means you should issue a command like this before lttng start:
lttng add-context -k -t pid -t procname -t tid -t ppid

Related

Running a server application process along with "logger"

I received an application code that can be run on Linux kernel 4.4.60 as below cmd - per their app note :-
/usr/sbin/server_application | logger -t tag &
If I run the server_application with just "server_application &" (in the background), then the socket which the process attempts to create fails the initiation. And obviously the client_application (run separately of course) times out.
From my info, the linux logger utilities only make entries in the system log.
Q. -- What is it the application might need which requires the application to log the tag entries in the syslog?
I am trying to reverse engineer as to why it needs logger specifically.
Any thoughts on this would be greatly appreciated.
Thanks in advance.
If you run the server_application in background the process might not have standard output at all opened to anything and any writes to stdout will fail. If you create a pipeline piping the standard output to a program then the server_application will have different characteristics for its stdout.
You could also try to figure out the difference by running these two with strace, for example:
strace -o /tmp/syscall.log /usr/sbin/server_application &
strace -o /tmp/syscall.log /usr/sbin/server_application | logger -t tag &
and by reading the /tmp/syscall.log looking for failed system calls near the end of the run for the former and then comparing them with the calls from the latter.

Processes running on a particular core

I used taskset to pin a process to a particular core but there are other processes as well which share that core. Is it possible to know which processes share which cores explicitly? For example to get an information like "core 0 has processes 1, 202, 4043, etc.. running on it" .
ps has a way to display processor associated with every number. You must use the custom output option '-o' and give it the psr format that will display core id.
For instance
ps -A -o pid,psr,args
displays process pid, core and args of all running processes.
There are many options available to -o. See ps man page for details.
AFAIK, there is no option to get information on process running on a specific core, but you can use something like
ps -A -o psr,pid,args | grep '^ *3'
to get the list of processes running on core #3.

How can the strace logs of the ever running binary from rcS can be logged?

I am trying to do a profiling on my embedded Linux box. This is running a software.
I want to do a profiling on my software using strace.
The application is the main software that keeps running forever.
How can I run the strace and log the outputs to a file.
In my rcS script.
I run the application like this
./my_app
Now, with strace.
strace ./my_app -> I want to log these outputs on a file, and I should be able to access the file without killing the application. Remember this application never terminates.
Please help!
Instead of a target filename, use the -p option to strace to specify the process ID of an already running process you wish to attach to.
Chris is actually right. Strace takes the -p option, which enables you to attach to a running process just by specifying the processes PID.
Let's say your 'my_app' process runs with PID 2301 (you can see the PID by logging into your device and us 'ps'). Try doing 'strace -p 2301', and you will see all system calls for that PID. You can throw it to a file by redirecting everywhere: 'strace -p 2301 > /tmp/my_app-strace'.
Hope this helps.

How to examine processes in OS X's Terminal?

I’d like to view information for processes running in OS X. Running ps in the terminal just lists the open Terminal windows. How can I see all processes that are running?
Say I’m running a web browser, terminal and text editor. I’d like to see information for the text editor and web browser.
Running ps -e does the trick. Found the answer here.
You can just use top
It will display everything running on your OSX
Using top and ps is okay, but I find that using htop is far better & clearer than the standard tools Mac OS X uses. My fave use is to hit the T key while it is running to view processes in tree view (see screenshot). Shows you what processes are co-dependent on other processes.
You can install it from Homebrew using:
brew install htop
And if you have Xcode and related tools such as git installed on your system and you want to install the latest development code from the official source repository—just follow these steps.
First clone the source code from the htop GitHub repository:
git clone git#github.com:hishamhm/htop.git
Now go into the repository directory:
cd htop
Run autogen.sh:
./autogen.sh
Run this configure command:
./configure
Once the configure process completes, run make:
make
Finally install it by running sudo make install:
sudo make install
Try ps -ef. man ps will give you all the options.
-A Display information about other users' processes, including those without controlling terminals.
-e Identical to -A.
-f Display the uid, pid, parent pid, recent CPU usage, process start time, controlling tty, elapsed CPU usage, and the associated command. If the -u option is also used, display
the user name rather then the numeric uid. When -o or -O is used to add to the display following -f, the command field is not truncated as severely as it is in other formats.
Try the top command. It's an interactive command that will display the running processes.
You may also use the Apple's "Activity Monitor" application (located in /Applications/Utilities/).
It provides an actually quite nice GUI. You can see all the running processes, filter them by users, get extended informations about them (CPU, memory, network, etc), monitor them, etc...
Probably your best choice, unless you want to stick with the terminal (in such a case, read the top or ps manual, as those commands have a bunch of options).
To sort by cpu usage: top -o cpu
if you are using ps, you can check the manual
man ps
there is a list of keywords allowing you to build what you need. for example to show, userid / processid / percent cpu / percent memory / work queue / command :
ps -e -o "uid pid pcpu pmem wq comm"
-e is similar to -A (all inclusive; your processes and others), and -o is to force a format.
if you are looking for a specific uid, you can chain it using awk or grep such as :
ps -e -o "uid pid pcpu pmem wq comm" | grep 501
this should (almost) show only for userid 501. try it.
The slightly GUI way
if you are a cli (ui) fan. I recommend trying https://github.com/clementtsang/bottom which shows not only processes, but also temperature, disk usage and network. Screenshot is running from kitty (terminal) as an example, I use it on OSX default terminal and the color shows up a bit different, but still amazing.
The tree way
As described here : https://en.wikipedia.org/wiki/Pstree will give a better connection on the hierarchy of the processes
brew install pstree # if you need to install it
pstree
pstree -u <user> # show only processes by your user
pstree -s <string> # show only processes with string
pstree -help # show help

JMeter load test thread dump

I am using JMeter for load testing and some of my threads just hang. I want to do a thread dump but none of the following work from my linux machine
First get JMeter process id using
jps -l
Then did
sudo -u <username> jstack <pid>
and get the following msg
15141: Unable to open socket file: target process not responding or HotSpot VM not loaded
The -F option can be used when the target process is not responding
even
kill -3 15141
comes up with nothing
After lot of googling and trial and error found the solution
To take thread dumps, start JMeter using command line.
Open terminal (A)
$ cd /media/9260C06E60C05A9D/Downloads/jakarta-jmeter-2.4/bin
$ ./jmeter > temp
In another terminal (B)
Get the process id of JMeter
$ jps -l
$ kill -QUIT 21735
Now check temp file for thread dump.
In order to use jstack make sure the user and group user are the same as the user running jstack

Resources