date int64 1,220B 1,719B | question_description stringlengths 28 29.9k | accepted_answer stringlengths 12 26.4k | question_title stringlengths 14 159 |
|---|---|---|---|
1,336,906,003,000 |
This is a simple problem but the first time I've ever had to actually fix it: finding which specific files/inodes are the targets of the most I/O. I'd like to be able to get a general system overview, but if I have to give a PID or TID I'm alright with that.
I'd like to go without having to do a strace on the program ... |
There are several aspects to this question which have been addressed partially through other tools, but there doesn't appear to be a single tool that provides all the features you're looking for.
iotop
This tools shows which processes are consuming the most I/O. But it lacks options to show specific file names.
$ sudo... | Determining Specific File Responsible for High I/O |
1,336,906,003,000 |
Is there a way to show the connections of a process? Something like that:
show PID
in which show is a command to do this, and PID is the ID of the process.
The output that I want is composed of all the connections of the process (in real-time). For example, if the process tries to connect to 173.194.112.151 the outpu... |
You're looking for strace!
I found this answer on askubuntu, but it's valid for Unix:
To start and monitor an new process:
strace -f -e trace=network -s 10000 PROCESS ARGUMENTS
To monitor an existing process with a known PID:
strace -p $PID -f -e trace=network -s 10000
Otherwise, but that's specific to Linux, you ... | Show network connections of a process |
1,336,906,003,000 |
I have seen this answer:
You should consider using inotifywait, as an example:
inotifywait -m /path -e create -e moved_to |
while read path action file; do
echo "The file '$file' appeared in directory '$path' via '$action'"
# do something with the file
done
The above script watches a directo... |
how do I modify the inotifywait command to report only when a file of
certain type/extension is created
Please note that this is untested code since I don't have access to inotify right now. But something akin to this ought to work with bash:
inotifywait -m /path -e create -e moved_to |
while read -r directory a... | How to use inotifywait to watch a directory for creation of files of a specific extension |
1,336,906,003,000 |
Three files have suddenly appeared in my home directory, called "client_state.xml", "lockfile", and "time_stats_log". The last two are empty. I'm wondering how they got there. It's not the first time it has happened, but the last time was weeks ago; I deleted the files and nothing broke or complained. I haven't been a... |
I don't believe there is a way to determine which program created a file.
For your alternative question:
You can watch for the file to be recreated, though, using inotify. inotifywait is a command-line interface for the inotify subsystem; you can tell it to look for create events in your home directory:
$ (sleep 5; to... | Is it possible to find out what program or script created a given file? |
1,336,906,003,000 |
How can I open a text file and let it update itself? Similar to the way top works.
I want to open a log file and watch it update itself on the fly.
I have just tried:
$ tail error.log
But just realised, that it just shows you the lines in the log file.
I am using RHEL 5.10
|
You're looking for tail -f error.log (from man tail):
-f, --follow[={name|descriptor}]
output appended data as the file grows; -f, --follow, and --fol‐
low=descriptor are equivalent
That will let you watch a file and see any changes made to it.
| Open a text file and let it update itself |
1,336,906,003,000 |
We have one central server which functions as an internet gateway. This server is connected to the internet, and using iptables we forward traffic and share the internet connection among all computers in the network. This works just fine.
However, sometimes internet gets really slow. Most likely one of the users is d... |
ntop is probably the best solution for doing this. It is designed to run long term and capture exactly what you're looking for.
It can show you which clients are receiving/sending the most traffic, where they're receiving/sending to, what protocols and ports are being used etc.
It then uses a web GUI to navigate and d... | Find out network traffic per IP |
1,336,906,003,000 |
I would like to see what's happening in my app server folders, i.e. which files are changed by process x or which *.war files have been changed (replaced/created) in the last x minutes.
Is there a tool in Linux to help with this?
|
Depending on your exact needs, you might want to look into inotify and/or FAM/GAMIN solutions.
| monitoring file changes + process access to files |
1,336,906,003,000 |
Is there some way I can check which of my processes the kernel has killed? Sometimes I log onto my server and find that something that should've run all night just stopped 8 hours in and I'm unsure if it's the applications doing or the kernels.
|
If the kernel killed a process (because the system ran out of memory), there will be a kernel log message. Check in /var/log/kern.log (on Debian/Ubuntu, other distributions might send kernel logs to a different file, but usually under /var/log under Linux).
Note that if the OOM-killer (out-of-memory killer) triggered,... | Where can I see a list of kernel killed processes? |
1,336,906,003,000 |
There is a directory A whose contents are changed frequently by other people.
I have made a personal directory B where I keep all the files that have ever been in A.
Currently, I just occasionally run rsync to get the files to be backed up from A to B. However, I fear the possibility that some files will get added in ... |
If you have inotify-tools installed you can use inotifywait to trigger an action if a file or directory is written to:
#!/bin/sh
dir1=/path/to/A/
while inotifywait -qqre "attrib,modify,close_write,move,move_self,create,delete,delete_self" "$dir1"; do
/run/backup/to/B
done
Where the -qq switch is completely silent... | How to run a command when a directory's contents are updated? |
1,336,906,003,000 |
Is there a Unix/Linux equivalent of Process Monitor, whether GUI or CUI?
If it makes a difference, I'm looking at Ubuntu, but if there's an equivalent for other systems (Mac, other Linux variants like Fedora, etc.) then knowing any of those would be useful too.
Edit:
Process Monitor is for monitoring system calls (suc... |
The console standby for this is top, but there are alternatives like my favorite htop that give you a little more display flexibility and allow you a few more operations on the processes.
A less interactive view that is better for use in scripts would be the ps program and all it's relatives.
Edit: Based on your clari... | Process Monitor equivalent for Linux? |
1,336,906,003,000 |
I want to monitor memory usage of a process, and I want this data to be logged. Does such a tool exist?
|
I have written a script to do exactly this.
It basically samples ps at specific intervals, to build up a profile of a particular process. The process can be launched by the monitoring tool itself, or it can be an independent process (specified by pid or command pattern).
| Is there a tool that allows logging of memory usage? |
1,336,906,003,000 |
I don't understand iotop output: it shows ~1.5 MB/s of disk write (top right), but all programs have 0.00 B/s. Why?
The video was taken as I was deleting the content of a folder with a few millions of files using perl -e 'for(<*>){((stat)[9]<(unlink))}', on Kubuntu 14.04.3 LTS x64.
iotop was launched using sudo iotop... |
The information shown by iotop isn't gathered in the same way for individual processes and for the system as a whole. The “actual” global figures are not the sum of the per-process figures (that's what “total” is).
All information is gathered from the proc filesystem.
For each process, iotop reads data from /proc/PID... | iotop showing 1.5 MB/s of disk write, but all programs have 0.00 B/s |
1,336,906,003,000 |
Until recently I thought the load average (as shown for example in top) was a moving average on the n last values of the number of process in state "runnable" or "running". And n would have been defined by the "length" of the moving average: since the algorithm to compute load average seems to trigger every 5 sec, n w... |
This difference dates back to the original Berkeley Unix, and stems from the fact that the kernel can't actually keep a rolling average; it would need to retain a large number of past readings in order to do so, and especially in the old days there just wasn't memory to spare for it. The algorithm used instead has th... | Why isn't a straightforward 1/5/15 minute moving average used in Linux load calculation? |
1,336,906,003,000 |
In a Ubuntu 14.04 server I am experiencing a massive hard disk activity which has no apparent justification: it comes as a burst, it lasts a few minutes and then disappears. It consumes system resources and slows down the whole system.
Is there a (command-line) tool which can be used to monitor the disk activity, lis... |
For checking I/O usage I usually use iotop.
It's not installed by default on the distro, but you can easily get it with:
sudo apt-get install iotop
Then launch it with root priviledges:
sudo iotop --only
The --only option will show only the processes currently accessing the I/O.
| Monitor hard disk activity [duplicate] |
1,336,906,003,000 |
I started hosting sites a while back using Cherokee. For external sources (FastCGI, etc) it has an option to launch the process if it can't find one running on the designated socket or port. This is great because it means if PHP or a Django site falls over (as they occasionally do) it restarts it automatically.
On a n... |
How about daemontools and specifically the supervise tool
supervise monitors a service. It starts the service and restarts the service if it dies. Setting up a new service is easy: all supervise needs is a directory with a run script that runs the service.
| Ensure a process is always running |
1,336,906,003,000 |
I use Ubuntu Server 10.10 and I would like to see what processes are running. I know that PostgreSQL is running on my machine but I can not see it with the top or ps commands, so I assume that they aren't showing all of the running processes. Is there another command which will show all running processes or is there a... |
From the ps man page:
-e Select all processes. Identical to -A.
Thus, ps -e will display all of the processes. The common options for "give me everything" are ps -ely or ps aux, the latter is the BSD-style. Often, people then pipe this output to grep to search for a process, as in xenoterracide's answe... | How can I see what processes are running? |
1,336,906,003,000 |
First of all, I found a similar question but it doesn't really solve my problem. I am trying to discover if the USB bus for a device I am using is the bottleneck in my program.
How can I monitor a USB bus (similar to how gnome-system-monitor works) to show bus utilization? Basically I want to identify when the bus is ... |
Since usbmon provides the length of each packet transferred, I would approach this by writing a quick program to parse the 0u file (which has data for all USB devices.) It would pick out the USB bus and device numbers, then keep a running total of the packet length field in both directions for each device.
This will ... | USB performance/traffic monitor? |
1,336,906,003,000 |
I find the output of the shell command top to be a simple and familiar way to get a rough idea of the health of a machine. I'd like to serve top's output (or something very similar to it) from a tiny web server on a machine for crude monitoring purposes.
Is there a way to get top to write its textual output exactly o... |
In Linux, you can try this:
top -bn1 > output.txt
From man top:
-b : Batch-mode operation
Starts top in 'Batch' mode, which could be useful for sending
output from top to other programs or to a file. In this
mode, top will not accept input and runs until the iterations
... | Is there a way to get "top" to run exactly once and exit? |
1,336,906,003,000 |
Instead of doing wc -l /proc/net/tcp, is there a faster way of doing it?
I just need a total count of tcp connections.
|
If you just want to get the number and don't need any details you can read the data from /proc/net/sockstat{,6}. Please keep in mind that you have to combine both values to get the absolute count of connections.
If you want to get the information from the kernel itself you can use NETLINK_INET_DIAG to get the informa... | Getting current TCP connection count on a system |
1,336,906,003,000 |
I've switched from GNU Screen to tmux. They're both similar, except that tmux is still maintained.
GNU Screen has a C-a _ ("silence") command. This command makes GNU Screen monitor the current window and alert me when there's been 30 seconds of inactivity. This is quite useful: for example, GNU Screen can watch a lon... |
The manpage reveals the answer. You will need tmux 1.4 (released Dec. 2010) or better.
Press Ctrl+B then enter the command:
:setw monitor-silence 30
To identify all quiet windows in the session, apply the setting to all windows:
:setw -g monitor-silence 30
| How can I make tmux monitor a window for inactivity? |
1,336,906,003,000 |
Background : I need to receive an alert when my server is down. When the server is down, maybe the Sysload collector will not be able to send any alert. To receive an alert when the server is down, I have an external source (server) to detect it.
Question : Is there any way (i prefer bash script) to detect when my se... |
If you have a separate server to run your check script on, something like this would do a simple Ping test to see if the server is alive:
#!/bin/bash
SERVERIP=192.168.2.3
[email protected]
ping -c 3 $SERVERIP > /dev/null 2>&1
if [ $? -ne 0 ]
then
# Use your favorite mailer here:
mailx -s "Server $SERVERIP is do... | Bash script to detect when my server is down or offline |
1,336,906,003,000 |
There's an application on my system which keeps creating an empty ~/Desktop directory again and again. I can't stand capital letters in my home, nor I can stand this “desktop” thingy. So, as picky as I am, I remove the directory each time I see it. I'd really like to know which application is responsible for that (pro... |
This directory might be created by any application that follows the Freedesktop userdirs standard. That potentially includes all Gnome or KDE applications.
If you want to know which application creates the file, you can use the LoggedFS filesystem or the Linux audit subsystem. See Is it possible to find out what progr... | Which application should I blame for compulsively creating a directory again and again? |
1,336,906,003,000 |
I have a hypothesis: sometimes TCP connections arrive faster than my server can accept() them. They queue up until the queue overflows and then there are problems.
How can I confirm this is happening?
Can I monitor the length of the accept queue or the number of overflows? Is there a counter exposed somewhere?
|
To check if your queue is overflowing use either netstat or nstat
[centos ~]$ nstat -az | grep -i listen
TcpExtListenOverflows 3518352 0.0
TcpExtListenDrops 3518388 0.0
TcpExtTCPFastOpenListenOverflow 0 0.0
[centos ~]$ netstat -s | grep -i LISTEN
3518352 times the li... | How can I monitor the length of the accept queue? |
1,336,906,003,000 |
Using Fedora for a small Samba and development server.
|
They're kernel threads.
[jbd2/%s] are used by JBD2 (the journal manager for ext4) to periodically flush journal commits and other changes to disk.
[kdmflush] is used by Device Mapper to process deferred work that it has queued up from other contexts where doing immediately so would be problematic.
| What is [jbd2/dm-3-8] and [kdmflush]? And why are they constantly on iotop? |
1,336,906,003,000 |
Just for fun:
Is there a way to monitor/capture/dump whatever is being written to /dev/null?
On Debian, or FreeBSD, if it matters, any other OS specific solutions are also welcome.
|
Making /dev/null a named pipe is probably the easiest way. Be warned that some programs (sshd, for example) will act abnormally or fail to execute when they find out that it isn't a special file (or they may read from /dev/null, expecting it to return EOF).
# Remove special file, create FIFO and read from it
rm /dev/n... | Monitor what is being sent to /dev/null? |
1,336,906,003,000 |
Searching for what one can monitor with perf_events on Linux, I cannot find what Kernel PMU event are?
Namely, with perf version 3.13.11-ckt39 the perf list shows events like:
branch-instructions OR cpu/branch-instructions/ [Kernel PMU event]
Overall there are:
Tracepoint event
Software event
Hardware event
Hardwa... |
Googling and ack-ing is over! I've got some answer.
But firstly let me clarify the aim of the question a little more:
I want clearly distinguish independent processes in the system and their performance counters. For instance, a core of a processor, an uncore device (learned about it recently), kernel or user applicat... | What are Kernel PMU event-s in perf_events list? |
1,336,906,003,000 |
Often in network monitoring tools there are three values for one measure.
Ex
rx: 2.0 kb/s 40 kb/s 10 kb/s
Are these similar to how cpu load works, they are taken at different length time spans. So one is every two seconds, then four seconds..
Thanks in advance.
One example program would be iftop.
|
Generally speaking, you can't asume the output of different tools have the same meaning. You have to RTM.
Specifically, these three columns in iftop are the average traffic during the last 2, 10 and 40 seconds.
Some similar output on another software could mean something else (like, minimum, average and maximum).
| What do the three values mean on network monitoring tools |
1,336,906,003,000 |
I want to see a list of all outgoing HTTP requests from my desktop. I think it should be possible to monitor HTTPS hostnames as well for local clients using Server Name Indication (SNI).
OS X has a nice GUI utility called Little Snitch, which is a per-app HTTP monitor and firewall rule front-end.
I would settle for a ... |
You can use lsof and watch to do this, like so:
$ watch -n1 lsof -i TCP:80,443
Example output
dropbox 3280 saml 23u IPv4 56015285 0t0 TCP greeneggs.qmetricstech.local:56003->snt-re3-6c.sjc.dropbox.com:http (ESTABLISHED)
thunderbi 3306 saml 60u IPv4 56093767 0t0 TCP greeneggs.qmetricstech.local:3... | Monitor outgoing web requests as they’re happening |
1,336,906,003,000 |
I run a web server (Debian Squeeze on a VPS), and the graphs provided by the hosting company show consistently that around twice as much traffic is incoming to the server compared to the outgoing traffic. I am a little confused by this, so I would like to run some kind of logging utility on the machine that will not ... |
ntop is probably your best solution for doing this. It is designed to run long term and capture exactly what youre looking for.
It can show you what remote destinations are being used the most, how much traffic sent to/from, what protocols and ports were being used etc. It can do the same for the source hosts if you r... | What can I use to monitor and log incoming/outgoing traffic to/from remote hosts? |
1,336,906,003,000 |
In the iostat manpage I have found these two similar columns:
await
The average time (in milliseconds) for I/O requests issued to the device to be served. This
includes the time spent by the requests in queue and the time spent servicing them.
svctm
The average service time (in milliseconds) for I/O r... |
On linux iostat, the await column (average wait) is showing the average time spent by an I/O request computed from its very beginning toward its end.
The svctm column (service time) should display the average time spent servicing the request, i.e. the time spent "outside" the OS. It should be equal or smaller than the... | iostat: await vs. svctm |
1,336,906,003,000 |
So recently I found that someone has been using my computer without consent, browsing folders, etc....
I could change all my passwords straight away, but I'm curious as the what the intruding party was looking for. So I would like to set up a trap ( evil grin ).
What software will monitor any activity on my computer?... |
You could use in-kernel mechanism inotify for monitoring accessed files.
First you should check if inotify is turned on in kernel:
pbm@tauri ~ $ zcat /proc/config.gz | grep CONFIG_INOTIFY
CONFIG_INOTIFY=y
CONFIG_INOTIFY_USER=y
Next thing to do is install inotify-tools. Instructions for various distributions you could... | Monitoring activity on my computer. |
1,336,906,003,000 |
If myfile is increasing over time, I can get the number of line per second using
tail -f | pv -lr > /dev/null
It gives instantaneous speed, not average.
How can I get the average speed (i.e the integral of the speed function v(t) over the monitoring time).
|
With pv 1.2.0 (December 2010) and above, it's with the -a option:
Here with both current and average, line-based:
$ find / 2> /dev/null | pv -ral > /dev/null
[6.28k/s] [70.1k/s]
With 1.3.8 (October 2012) and newer, you can also use -F/--format with %a:
$ find / 2> /dev/null | pv -lF 'current: %r, average: %a' > /dev... | How to get an average pipe flow speed |
1,336,906,003,000 |
I've found a nice monitor which allows me to log a variety of runtime data of a single process. I'm looking for an equivalent that does the same for bandwidth usage. Ideally, the command should look like bwmon --pid 1 --log init.log. Is there such? Can it run without admin privileges?
|
something to get you started (just in case you want to write it yourself):
#!/bin/bash
#
# usage: bwmon PID
IN=0; OUT=0; TIME=0
get_traffic() {
t=`awk '/eth0:/ { printf("%s,%d,%d\n",strftime("%s"),$2,$10); }' < /proc/$1/net/dev`
IN=${t#*,}; IN=${IN%,*}
OUT=${t##*,};
TIME=${t%%,*};
}
get_traffic $1
w... | Is there a tool that can monitor bandwidth usage of a single process? |
1,336,906,003,000 |
A few years ago, a coworker came up with an elegant solution for a watchdog program. The program ran on Windows and used Windows Event objects to monitor the process handles (PID’s) of several applications. If any one of the processes terminated unexpectedly, its process handle would no longer exist and his watchdog w... |
The traditional, portable, commonly-used way is that the parent process watches over its children.
The basic primitives are the wait and waitpid system calls. When a child process dies, the parent process receives a SIGCHLD signal, telling it it should call wait to know which child died and its exit status. The parent... | Linux: Writing a watchdog to monitor multiple processes |
1,481,570,115,000 |
I have these commands compiled and running but their contents are a bit of a mystery to me.
The processes from intel-gpu-overlay read something like: 15R, 16B, 41ms waits. What is an R, what is a B, what does that wait time indicate?
It has CPU: 152% (I'd guess this is the same as what I get from top). render: 32%,... |
Taken from the link given in the comments in OP.
I was curious as well, so here are just a few things I could grab from the reference manuals. Also of interest is the intel-gpu-tools source, and especially lib/instdone.c which describes what can appear in all Intel GPU models. This patch was also hugely helpful in tra... | How do I interpret the output of intel-gpu-top and intel-gpu-overlay? |
1,481,570,115,000 |
Does the hard drive need to be accessed or is everything done in memory? Basically I would like to constantly get updated values from meminfo and cpuinfo.
Do I need to reopen the file and then reread in order to get an updated value or can I just reread? I don't have access to a Linux install at the moment.
|
When you read from /proc, the kernel generates content on the fly. There is no hard drive involved.
What you're doing is similar to what any number of monitoring programs do, so I advise you to look at what they're doing. For example, you can see what top does:
strace top >/dev/null
The trace shows that top opens /pr... | What happens when I open and read from /proc? [duplicate] |
1,481,570,115,000 |
My laptop (no VM, just plain Ubuntu with encrypted home) freezes for 3 minutes a few times per day. During these 3 minutes, the disk LED indicates intense disk activity, and I can't even move the mouse or press CTRL-ALT-F1.
I want to use iotop to find out which process is causing this.
The problem with iotop is that i... |
Not exactly what I was looking for but close: iotop -o
So I will use:
sudo nice -20 sudo iotop -tbod10 > ~/iotop.log
| Make iotop show only the most disk-intensive item |
1,481,570,115,000 |
Is it possible to forcibly add a timing alias (for lack of a better way to phrase it) to every command in bash?
For example, I would like to have a specific user who, whenever a command is run, it is always wrapped either with date before and after, or time.
Is this possible, and, if so, how?
|
You can record the time a command line is started and the time a prompt is displayed. Bash already keeps track of the starting date of each command line in its history, and you can note the time when you display the next prompt.
print_command_wall_clock_time () {
echo Wall clock time: \
$(($(date +%s) - $(HISTTI... | Forcing an 'added' alias to every command |
1,481,570,115,000 |
When I run several jobs on a head node, I like to monitor the progress using the command top.
However, when I'm using PBS to run several jobs on a cluster, top will of course not show these jobs, and I have resorted to using 'qstat'. However the qstat command needs to be run repeatedly in order to continue monitoring ... |
If you want to be a super-boss, you can always use 'pbstop'
It's basically a PBS cluster version of what 'htop' is for local processes.
(Note that your cluster may not have this installed. Ask the admins for it!)
(Also, supports interactive filtering by user, queue, etc)
EG:
| PBS equivalent of 'top' command: avoid running 'qstat' repeatedly |
1,481,570,115,000 |
I have a script which produces a file 'Detail.out'. I know that the script is completed whenever the file contains a certain number of lines (roughly 21025). So I find myself sitting at the command prompt running:
[me@somewhere myDir]$ wc -l */Detail.out
21025 A/Detail.out
21025 B/Detail.out
21025 C/Detail.out... |
Try the watch command, although I suspect just about everyone has written their own version at one time or another. (The cheapie version is while :; do clear; "$@"; sleep 5; done.)
| Is it possible to follow a command (run repeatedly)? as one would follow a file using tail -f? |
1,481,570,115,000 |
I wonder how to log GPU load. I use Nvidia graphic cards with CUDA.
Not a duplicate: I want to log.
|
It's all there. You just didn't read carefuly :) Use the following python script which uses an optional delay and repeat like iostat and vmstat:
https://gist.github.com/matpalm/9c0c7c6a6f3681a0d39d
You can also use nvidia-settings:
nvidia-settings -q GPUUtilization -q useddedicatedgpumemory
...and wrap it up with so... | How to log GPU load? [duplicate] |
1,481,570,115,000 |
I need to execute a script as soon as my raspberry pi gets connected to the Internet. However I was wondering if there was a better way than just pinging Google every minute or so.
My problem is that my Internet connection drops 1-2 times during the day so I need a way to log such events.
It's just the ADSL dropping d... |
you can make a check on:
cat /sys/class/net/wlan0/carrier
where wlan0 is my internet interface. you can use whatever interface you are using , such as eth0 , eth1 , wlan0 for internet connectivity. if the output of that command is 1 then you are connected. otherwise not.so you may write script like this:
#!/bin/bash
... | How to log Internet connection drops |
1,481,570,115,000 |
There are scripts that will send an e-mail when a server process is finished.
However, I do not want to check my email every so often just to see whether a job has finished. Therefore I'd like to get an SMS message.
My question is similar to this one, just exchange SMS with all occurrences of "e-mail": Is there a prog... |
There are 3 ways to accomplish the sending of an SMS message from a server and/or application.
Setup your own gateway
If you google for "sms gateway" you'll find a large list of applications that you can setup which will provide this capability. You can also take an old cell phone and a PC and set them up using this... | Possible to get SMS/text message notification when process ends or is killed? |
1,481,570,115,000 |
I have two Linux systems communicating over sockets (Desktop and ARM-based development board).
I want to restart (or reset) my client application (running on a development board) when server sends a particular predefined message. I don't want to restart (reboot) Linux, I just want that client application restart itse... |
The normal way to do this is to let your program exit, and use a monitoring system to restart it. The init program offers such a monitoring system. There are many different init programs (SysVinit, BusyBox, Systemd, etc.), with completely different configuration mechanisms (always writing a configuration file, but the... | How to restart (or reset) a running process in linux |
1,481,570,115,000 |
I've got a few processes with a known name that all write to files in a single directory. I'd like to log the number of disk block reads and writes over a period (not just file access) to test whether a parameter change reduces the amount of I/O significantly. I'm currently using iostat -d -p, but that is limited to t... |
I realize this is going to sound both simplistic and absurd, but if you have
control over the apps in question (maybe in a test environment) you could
mount ONLY that directory on a partition of its own, then iostat, etc. would
tell you only about it, and nothing else on that spot.
If there are physical drives involv... | How can I monitor disk I/O in a particular directory? |
1,481,570,115,000 |
I have been having an overheating issue which makes my laptop shutdown immediately. Is there anyway to monitor the temperature from the sensor and scale down the CPU frequency to avoid that problem? Is there any existing software or shell script that can handle that job?
|
You should have a look at cpufreq-set and cpufreq-info. On Debian and derived distros they are in the cpufrequtils package. For example, on an old laptop with a bad fan that I use as a file server at home I have made these settings:
sudo cpufreq-set -c 0 -g ondemand -u 800000
sudo cpufreq-set -c 1 -g ondemand -u 80000... | Overheating results in system shutdown |
1,481,570,115,000 |
What software is there that will play an alert (PC speaker) when there isn't any internet connectivity for 5 minutes?
My switch/router seems to disconnect every few days, and I want to reset it when it happens.
PC -- TP-Link switch/router -- FO
192.168.x.1 -- 192.168.x.2 / x.y.z.a -- a.b.c.d
|
You can use a modified version of this script to do what you want:
#!/bin/bash
downTime=0
lastAccessTime=$(date +"%s")
while [ true ]; do
if ! ping -c1 google.com >& /dev/null; then
downTime=$(( $(date +"%s") - $lastAccessTime ))
else
downTime=0
lastAccessTime=$(date +"%s")
fi
sleep 15
if [ $downTime -g... | Internet connection drop alert |
1,481,570,115,000 |
Is there tool or a command that helps capture the bandwidth consumption of specific process (PID), just like the System Monitor does, but for a single specific process, as shows the following screenshot
I will be happy with a command line tool that at least exports such history to files. (I'm on Ubuntu 16.04)
Update ... |
So since I didn't find any easy/clear/"hit the ground running" solution, I had to made a modest one, fixes, refactoring and more options to come.
-> https://github.com/AymenDaoudi/NeTraf
| Linux tool to monitor bandwidth consumption of a specific process (PID) |
1,481,570,115,000 |
From the question here, the OP wants to repeatedly poll the pid of a process using pidof in a shell script. Of course this is inefficient as a new process must be started for the pidof program multiple times per second (I don't know that this is the cause of the CPU spikes in the question, but it seems likely).
Usuall... |
Linux-specific answer:
perf-tools contains an execsnoop that does exactly this. It uses various Linux-specific features such as ftrace. On Debian, its in the perf-tools-unstable package.
Example of me running man cat in another terminal:
root@Zia:~# execsnoop
TIME PID PPID ARGS
17:24:26 14189 12878 man cat... | Print pids and names of processes as they are created |
1,481,570,115,000 |
I don't understand why the sum of % in the cpu column in top doesn't match the total CPU % row:
Text version with slightly different values:
ubuntu@server:~$ top
top - 23:20:21 up 5:18, 3 users, load average: 10.28, 10.36, 10.20
Tasks: 299 total, 11 running, 288 sleeping, 0 stopped, 0 zombie
%Cpu(s): 41.7 us... |
It can be that top is reading the whole usage of the physical CPUs, not of the virtual CPUs.
It is also possible, that there are some processess running, that are hidden for the ubuntu user.
Also try running ps aux.
You can type the 1 number while running top to get detailed information about the CPUs usages.
Here is ... | The sum of % in the CPU column doesn't match the total CPU % row [duplicate] |
1,481,570,115,000 |
My document management software is doing a lot of IO and I would like to know which files it is accessing the most.
Is there a Linux tool that would give me the list of the top IO consuming files, like iotop but for files, every few seconds?
That could look like:
$ thetool
THRPUT R/W/SWP FILE
40MB/s write /usr/a... |
I think your "number of bytes" metric is the wrong one. Consider two accesses. One reads 10MB from a file. The other reads every 512th byte of the file for the first 10MB. The "number of bytes" will be 512 times higher for the first access compared to the second. Yet they will both put precisely the same load on the I... | How can I list the top IO consuming files? |
1,481,570,115,000 |
Is there a way to watch what commands are being executed in another shell, as they're being executed? Both shells are bash, and I have root access, if that matters. I can't install any extra software, and I don't want the other shell to have to do anything special like run screen.
Situation: I'm remotely logged into a... |
Since you're root, you could always strace -f -e execve -p her_bash_pid. The -f is necessary because her shell will fork a new process before the exec, but this also means that you'll see anything that the child processes execute as well.
| How to see the commands executed in another shell? |
1,481,570,115,000 |
I want to move large file created by external process as soon as it's closed.
Is this test command correct?
if lsof "/file/name"
then
# file is open, don't touch it!
else
if [ 1 -eq $? ]
then
# file is closed
mv /file/name /other/file/name
else
... |
From the lsof man page
Lsof returns a one (1) if any error was detected, including the failure
to locate command names, file names, Internet addresses or files, login
names, NFS files, PIDs, PGIDs, or UIDs it was asked to list. If the -V
option is specified, lsof will indicate the search i... | Move file but only if it's closed |
1,481,570,115,000 |
Is there a linux program that allows you to look into your current download traffic? Something that can list all the addresses I am currently connected to and downloading from.
|
check iftop and nload
iftop does for network usage what top(1) does for CPU usage. It listens to network traffic on a named interface and displays a table of current bandwidth usage by pairs of hosts. Handy for answering the question "why is our ADSL link so slow?".
nload is a console application which monitors n... | Linux program to look into what you're downloading |
1,481,570,115,000 |
I want to get the current Bandwidth of an interface say "eth0" from the terminal. It better be as simple as possible. Say
up 10 dn 30.
Instead of giving out a lot of text like "vnstat" does.
Edit: I need this for a command line program for auto-monitoring, not to view it manually.
|
There are several tools that can do this.
Bmon
One that should be in most repositories for various distros is bmon.
It can be run in a condensed view too.
If you're looking for something else I'd suggest taking a look at this Linuxaria article titled: Monitor your bandwidth from the Linux shell. It a... | How do I get the current bandwidth speed of an interface from the terminal? |
1,481,570,115,000 |
Having a system for collecting performance statistics can be extremely useful. In the past, I've used Munin for this, and it has been invaluable in analyzing bottlenecks and various other issues. I was recently made aware of collectd, which seems very similar to Munin.
What monitoring applications are available and sh... |
Munin is a data collector and visualizer (grapher) tool. It is easy to set up. Easy to use, but it uses too much resources and does not scale well. The default collection interval is 5min and it is not easy to change that, because it will overload your machine and some plugin has problems if you do that anyway. The pl... | How do you choose which monitoring application to use? |
1,481,570,115,000 |
Sometimes, when I have numerous tabs open in Firefox, one of those tabs will start consuming a lot of CPU%, and I want to know which tab is the culprit. Doing this is a very manual process for which I'd like to find automation.
I wish I had an application that could monitor firefox exclusively in a manner that produce... |
You can type about:performance in the address bar of firefox. Then you will get a table where there will be pid of each tab of firefox with Resident Set size and Unique Set Size. And below this there will be some lines explaining the performance of each tab (like performing well) and if a tab is not performing well th... | Monitoring CPU% of Tabs in Firefox |
1,481,570,115,000 |
I need to monitor the I/O statistics of a process that writes to disk. The purpose is to avoid write rates too high for long periods.
I know there's iostat tool to accomplish this task on a system-wide perspective.
Is there something similar to monitor single process disk usage?
|
What you want is iotop. Most distributions have a package for it, usually called (logically enough) iotop.
One very cool command (at least, on a system that isn't very busy) is iotop -bo. This will show I/O as it occurs. It also has options to only monitor specific processes or processes owned by specified users.
| Getting disk i/o statistics for single process in Linux |
1,481,570,115,000 |
I would like to figure out which processes are communicating with which websites over a period of time. All what I found programs like ss that list the connections that open this instant and then exit.
What I, actually, want is something like wireshark, but one that would log process names.
Is there really no such a p... |
If you have a recent kernel (preferably at least 4.9, but apparently some things work at 4.2), then you can take advantage of the new dtrace facility that allows you to intercept every tcp connect() call in the kernel and show the process id, remote ip address and port.
Since this does not poll, you will not miss any... | Is there a program that can log network traffic by the process and domain names? |
1,481,570,115,000 |
I would like to use tcpflow to monitor https requests. I have read tutorials on how to monitor http traffic but when I connect to a host using https the output is garbled. I am using tcpflow in the following manner:
sudo tcpflow -s -c -i eth0 src or dst host api.linkedin.com
|
If you have a copy of the key you can use ssldump which uses a syntax almost identical to tcpdump.
It won't be quite as pretty as tcpflow, but you can get at the encrypted content.
| Monitoring HTTPS traffic using tcpflow |
1,481,570,115,000 |
In different screenshots of people's Linux desktops, I've seen different apps that overlay the desktop with information about their computer. Often this gadget/app shows CPU and HDD information. Sometimes it has network and temperature information as well. I've seen these a lot but they often have different looks and ... |
I use conky to display date, battery, cpu, ram and swap information. You can find my conky file here or take a look at a thread about conky configs in the arch-linux forum. There you find many different configs and screenshots of conky in use.
| Desktop overlay program showing CPU, HDD, etc. stats |
1,481,570,115,000 |
This is for academic purpose. I want to know which commands are executed when we do something in GUI, for example creating a folder. I want to show that both the mkdir shell command and create folder option from GUI does the same thing.
|
You can observe what the process does with the strace command. Strace shows the system calls performed by a process. Everything¹ a process that affects its environment is done through system calls. For example, creating a directory can only be done by ultimately calling the mkdir system call. The mkdir shell command i... | How to know which commands are executed when I do something in GUI |
1,481,570,115,000 |
I was wondering if there are any tools to keep track of the access history of a file. I know of stat, but as far as I understand, it only returns information about the last time the file was accessed.
|
Logging access times is already a fairly heavy requirement (by filesystem performance standards), because it requires a write operation for every read operation. Logging other things would be even costlier. The feature is not present in typical filesystems.
LoggedFS is a stackable filesystem that provides a view of a ... | Access history of a file [duplicate] |
1,481,570,115,000 |
It is occasionally useful for me to know when my machine (Debian wheezy) was last touched. To be precise, I mean the more recent of the times I typed on the keyboard or moved the mouse. When I currently try to do this, I adopt ad-hoc means, like checking the last modification times of files that I was editing. However... |
There is an xprintidle utility (available as a package, at least in Debian and Ubuntu) that will do this. It gives you the number of milliseconds since last keyboard or mouse activity. Of course, if you type that in a terminal and run it, the result will be near-0.
Alternatively, there is a Perl module.
C code (appare... | When was my machine last touched? |
1,481,570,115,000 |
I am one of the n users of a shared unix machine. For reasons unknown, the machine is not "responsive" enough. For example, it is slow on interactive commands, it takes few noticeable moments for any action (e.g. mouse movement, editor (e.g. gvim) keystrokes) to be visible. The problem is, the people supposedly respon... |
This isn't strictly speaking the same as "responsiveness", but one metric you should probably check is the system load average; uptime will show the average over the last 1/5/15 minutes:
$ uptime
02:30:33 up 6 days, 6:30, 12 users, load average: 0.85, 0.65, 0.57
A high enough load will perceptibly slow the syst... | Quantify unix responsiveness |
1,481,570,115,000 |
We have a server where another script sFTPs and downloads files everyday.
Question: Is it possible to detect that the file was downloaded and then for me to automatically archive the file after they are done?
To clarify - We host the files and someone else comes and downloads it.
This is the script they use:
let $co... |
There are 3 avenues that I can conceive of that might provide you with a solution.
1. Custom sftp Subsystem
You could wrap the sftp-server daemon via sshd_config and "override" it with your own script that could then intercept what sftp-server is doing, and then act when you see that a file was downloaded. Overriding ... | Is it possible to detect when a file has been downloaded? |
1,495,746,973,000 |
vmstat 1
Above will print virtual memory statistics each seconds. It will also show the CPU utilization for last second.
I have a web server at hand which runs httpd and MySQL. I need to find how much CPU httpd consumed in last second. Like vmstat particularly for httpd.
I tried this :
ps -e -o %mem,%cpu,cmd | grep ... |
You could use top -b -d 1 to achieve that for CPU usage. top displays process CPU usage relative to the last output.
| Linux : See CPU usage by a process for the last second |
1,495,746,973,000 |
I use Ubuntu 12.04.1 Linux. I see a difference between %CPU and C output format of ps command for a process. It is not clearly noted in the ps man page.
Man pages says:
CODE HEADER DESCRIPTION
%cpu %CPU cpu utilization of the process in "##.#" format. Currently,
it is the CPU... |
The %cpu and C columns are showing almost, but not quite, the same thing. If you look at the source for ps in ps/output.c you can see the differences between pr_c and pr_cpu
C is the integer value for %cpu as you can guess. The odd difference is that C is clamped to a maximum of 99 while %cpu is not (there's a check f... | What is the difference in CPU utilization between 'ps aux' and 'ps -ef'? |
1,495,746,973,000 |
I know how to monitor a process. Commands like top and so forth can monitor the CPU time and memory usage for a given process instance.
But say I expect a given executable to be run several times in the next hour, and I want to measure how many times it is run and the CPU time it has consumed. What's a command for tha... |
You could do something like:
mv my-executable my-executable.bin
And create my-executable as a wrapper script that does:
#! /bin/bash -
{ time "$0.bin" "$@" 2>&3 3>&-; } 3>&2 2>> /tmp/times.log
The script could add more information to the log like the time it was started, by whom, the arguments it was passed...
BSD p... | How to monitor all executions of an executable over a time period |
1,495,746,973,000 |
I have a hypothetical situation:
Let us say we have two strace processes S1 & S2, which are simply monitoring each other.
How can this be possible?
Well, in the command-line options for strace, -p PID is the way to pass the required PID, which (in our case) is not yet known when we issue the strace command. We could ... |
I will answer for Linux only.
Surprisingly, in newer kernels, the ptrace system call, which is used by strace in order to actually perform the tracing, is allowed to trace the init process. The manual page says:
EPERM The specified process cannot be traced. This could be because
the tracer has insuff... | How can strace monitor itself? |
1,495,746,973,000 |
How can I see the raw memory data used by an application ? Like , suppose I have a file name something.sh . Now I run the command ./something.sh , and then I want see all the data its accessing in ram and all the files its accessing in my filesystem,network data or connection its using.May be the hex dump of the memor... |
How can I see the raw memory data used by an application...
Once you have obtained the process' PID (using ps(1) or pidof(8) for instance), you may access the data in its virtual address space using /proc/PID/maps and /proc/PID/mem. Gilles wrote a very detailled answer about that here.
... and all the files its acc... | How do see the memory used by a program in ubuntu? |
1,495,746,973,000 |
I would like to know if there is a tool that would enable you to watch how the program output changes live. Something like tail -f but instead of monitoring the file changes, it would repeatedly call some executable and display it live.
For example, if the tool is caled foobar and I would call foobar 'ps -Al', it woul... |
Try watch. From the manpage:
Name
watch - execute a program periodically, showing output fullscreen
Synopsis
watch [-dhvt] [-n <seconds>] [--differences[=cumulative]] [--help] [--interval=<seconds>] [--no-title] [--version] <command>
Description
watch runs command repeatedly, displaying its output (the first screenf... | Live program output monitoring tool |
1,495,746,973,000 |
I'm using the Linux "top" command to monitor %CPU of particular process. As the values keep on changing every few seconds, is there any way to keep track of values in a separate file or as a graphical representation? Is it possible to do it using any shell scripts?
|
The answer to this question can range from a simple command, to complex monitoring tools, depending on your needs.
You can start by simply running top -b -n 1 >> file.txt (-b for batch mode, -n 1 for running a single iteration of top) and store the output (appended) in the file.txt. You can filter also "top" output li... | In Linux 'top' command, is there any way to keep track of values? |
1,495,746,973,000 |
I'm currently changing the permissions and ownership on a 4TB HDD filled with files. Is it even possible to monitor the progress of commands such as chmod and chown?
|
You can attach to the running process and see what it's doing now. This will give you an idea of where it's at.
strace -p1234
where 1234 is the process ID of the chmod process. Note that many systems restrict non-root users to monitoring child processes only, so you'd have to do this as root; see after upgrade gdb wo... | Monitor chmod progress |
1,495,746,973,000 |
I want to know the amount of the network traffic (inbound and outbound) in a time period, generated a specific process and all subprocesses that it spawns.
I have developed a software that contains a "job manager" that runs forever and generates no network traffic on its own. It instead spawns child "workers" that doe... |
Probably the easiest way is to put the job manager in a network namespace. All child processes will also be in that namespace. Connect up the namespace via veth or macvlan, measure traffic on that interface.
| Monitor network traffic of a process and its entire subprocesses tree |
1,495,746,973,000 |
I have a process in a Linux installation that at some point has some kind of spike and passes the max allowed number of threads/processes allowed by the system. I found this by checking ps -elfT | wc -l repeatedly.
But what I don't know is what exactly is it that causes this spike.
The output of ps -elfT has a lot o... |
ps -eo nlwp,pid,args --sort nlwp
Would show a list of processes sorted by their number of threads.
For a top-like view of that, you can always do:
watch -n 1 'ps -eo nlwp,pid,args --sort -nlwp | head'
Or you could use... top.
press f to select the fields to display.
locate nTH (the number of threads) and press d to... | Figure out which process forks too many threads |
1,495,746,973,000 |
Recently I got an load-too-high issue on our server. I watched top for like half an hour to find out that it was Nagios that forked a lot of short-lived processes. After bouncing Nagios, everything was back to normal.
My question here is, how to find out the root process that forks a lot like this more quickly?
Thanks... |
If you run an OS that supports dtrace, this script will help you identifying what processes are launching short lived processes:
#!/usr/sbin/dtrace -qs
proc:::exec
{
self->parent=stringof((unsigned char*)curpsinfo->pr_psargs);
}
proc:::exec-success
/self->parent != NULL/
{
printf("%s -> %s\n",self->parent,curpsi... | How to find out the process(es) that forks a lot? |
1,495,746,973,000 |
I have a daemon that monitors various things using the GPIO ports. I have used python to write the code for this using the RPi.GPIO module.
I would like to ensure that the daemon is always running, i.e., restart it after a crash and start it when the system boots (crucially before any user logs in -- this Pi runs head... |
That shell wrapper looks like an init script, but apparently it isn't (hence you need to use sudo there; scripts run by init would not require this).
This seems to be a very clumsy way to do this; the shell wrapper does not serve any purpose that could not be better served by the python program itself. Get rid of tha... | Running daemon involving GPIO on Pi |
1,495,746,973,000 |
Say, I have a program, and I want to monitor its filesystem activity (what files/directories are created/modified/deleted etc.) This program may be capable of spawning further processes, and thus, I would like to get the activity of these spawned processes too.
How should I go about doing this?
|
You can use strace for this:
strace -f -e trace=file command args...
strace traces system calls and prints a description of them to standard error as they occur. The -f option tells it to track child processes and threads as well. -e lets you modify the calls it will track: -e trace=file will log every use of open, u... | Monitoring filesystem activity |
1,495,746,973,000 |
I'm configuring monit on Ubuntu 11.04. In monitrc, the following setting controls the interval at which the monit daemon monitors services...
set daemon 120
Is this a global setting? If I want to check different services, such as permissions on a directory and an http service, how can I configure monit to check direct... |
You can set the per-test interval in cycles.
See this similar ServerFault.com question for some more information.
ie: if your interval is 300 seconds you could run an http check every cycle while running the weekly check every 2016 cycles.
| Monit daemon interval setting...global or service-level? |
1,495,746,973,000 |
Underneath the Mac OS X directory /audit I have certain files which users can access and chmod to their liking.
I need to audit any chmod done on any files by recording the time, user and file being chmod, especially the latter.
I can dtrace -n 'syscall::chmod:entry' and detect the events, how do I read the first argu... |
The argument's in arg0, but that's the caller's userspace address rather than the actual string. You need to wrap it with a copyinstr() as well:
dtrace -n 'syscall::chmod:entry { printf("%d %s", uid, copyinstr(arg0)); }'
| DTrace to trap any chmod applied to certain files |
1,495,746,973,000 |
I have machine on which the files are uploaded by ftp. From this machine I would like to run cronjob and scp/rsync (simply copy them) to different machine in the same network.
The problem is I don't want to copy files which are not coplete (still during transfer)
Is there a possibility to check whether a file is comp... |
You can use lsyncd:
Lsyncd watches a local directory trees event monitor interface
(inotify or fsevents). It aggregates and combines events for a few
seconds and then spawns one (or more) process(es) to synchronize the
changes. By default this is rsync.
You can specify the time out after which a file has chang... | Operations only on complete files [duplicate] |
1,495,746,973,000 |
Kernel version: 2.6.31-22
I wish to monitor the USB traffic to and from a device. I've searched, but different sites seem to give different information and I'm confused.
Some sites suggest that I need to recompile the kernel, while others suggest that all I need to do is install the latest wireshark. Do I need to rec... |
You need to recompile kernel/load module. It is present in 2.6.32 (LTS) kernel - probably 2.6.31 as well. less /usr/src/linux/Documentation/usb/usbmon.txt. Format is "well known" and it acts like character devince. It can dump in text format as well.
Wireshark can provide live stream and/or read file from USB as far a... | Monitoring USB traffic |
1,495,746,973,000 |
I need to see whole HTTP packets sent and recieved by an application for debugging purposes. How can this be done in command-line?
|
Use tcpdump.
tcpdump -w httpdebug.pcap -i eth0 port 80 will sniff all packets heading to or from port 80 on the eth0 interface and output them to httpdebug.pcap, which you can then read at your leisure, either with tcpdump again (with multiple -x options, refer to the tcpdump manpage ) in console if you're feeling mas... | How can I see dumps of wholе HTTP packets? |
1,495,746,973,000 |
How can I run a script-based tool which will process files continuously downloaded to given directory as they arrive? I'd like to minimize delay (~1 second is OK), script can have own infinite loop.
I know a few ways, like:
autologin user with .bashrc or .profile calling my script
fork script from cron, then ignore ... |
Assuming your script is to run under Linux, you can use inotifywait from an init script. You will probably want a recursive search through the entire download tree (option -r). Bear in mind that each node to watch can eat up to 1kB of kernel memory.
The main advantage of inotify is to prevent a costly polling loop. It... | How can I start a file-processing daemon? [closed] |
1,495,746,973,000 |
Similar to my last question: Open a text file and let it update itself; is there a way I could do the same but for a folder instead?
As I have a log folder, can I use tail -f with a folder?
i.e.
$ tail -f /tmp/logs/
I know that this won't work, but is there an alternative?
I am using RHEL 5.10
|
Yes there is an alternative, after a bit of research, I saw that you can use:
$ watch "ls -l"
You need to be in the folder you want to watch.
Also, you can use tail -10 at the end:
$ watch "ls -l | tail -10"
The command types ls every 2 seconds and filters the output to the last 10 files.
If you read the reference l... | Open a directory and let it update itself using "tail -f" |
1,495,746,973,000 |
Is there some performace monitoring tool which would run in background gathering info about all system activity? Somethimes my system (Arch linux, 32 bit) slows down terribly and the top utility doesn't show anything.
I imagine some daemon which would gather info and log it, so when the slowdown pass away I would be a... |
How about sar?
| performance monitoring |
1,495,746,973,000 |
I'm basically looking for a utility that displays which processes are using how much bandwidth, similar to how top displays which processes use how much resources.
|
NetHogs is the best tool I have found so far that fulfills my need, but sadly needs to be run as root. (via)
| Network monitoring tool |
1,495,746,973,000 |
I would like to monitor a log file for errors and then send an email to administrators.
The log file contains data like below
11 Aug 02:30 Service1 restarted
11 Aug 05:35 Service1 restarted
11 Aug 08:43 Service2 restarted
11 Aug 11:20 Service1 restarted
11 Aug 14:53 Service2 restarted
I would like to create a script... |
Start by making a five minute crontab:
*/5 * * * * myscript.sh
Which runs myscript.sh (in $HOME dir)
#!/bin/bash
tail -1 /path/to/file.log > /some/dir/after
if cmp -s /some/dir/after /some/dire/before
then
cat /some/dir/after | mail -s "restart" [email protected]
cp /some/dir/after /some/dir/before
fi
... | Log monitoring using shell script |
1,495,746,973,000 |
We're moving websites from one server configuration to a new configuration and the websites will live in different paths than previously. We're planning to diligently go through and replace old paths with new paths, but in case we miss any, is there some way to monitor for any processes trying to access the old paths... |
You can use this little systemtap script :
#!/usr/bin/stap
function proc:string() { return sprintf("PID(%d) UID(%d) PROC(%s)", pid(), uid(), execname()) }
probe syscall.open.return, syscall.stat.return,
syscall.open64.return ?, syscall.stat64.return ? {
filename = user_string($filename)
if ($return < 0) {
p... | Monitor processes trying to access non-existent file or directory |
1,495,746,973,000 |
I want to monitor memory usage for several processes and came up with a command like this:
ps aux |grep -e postgres -e unicorn -e nginx|cut -d' ' -f2|for i in $(xargs); do echo $i; done
16112
16113
...
How can I change the bit after the last pipe to feed arguments into top -p $i, so I get an of overall idea of memor... |
How about something like
pids=( $(pgrep 'postgres|unicorn|nginx') )
to put the PIDs in an array, and then
top "${pids[@]/#/-p }"
to spit them back out into top, prepending each with -p
| monitor multiple pids with top |
1,495,746,973,000 |
I'd like to monitor my network traffic of an specific interface to file.
Then I would like to stop the interface if the traffic counts over 60mb total.
Is there a possible way to do that?
|
dumpcap, the low-level traffic capture program of Wireshark, can be instructed to stop capturing after certain conditions with the option -a. You can stop capturing after writing 60MB. This isn't the same thing as measuring traffic, since it depends on the file encoding, but it should be close enough for most purposes... | Stop writing to a capture file after it reaches a specific size |
1,495,746,973,000 |
A tool such as this might on the surface appear to serve no real useful purpose, but people that take care of systems like to brag, and uptime is just one of those things that they like to brag about right after how much RAM or CPUs their systems have.
Additionally, how many times have you had a system mysteriously re... |
uptimed
One such tool that I came across many years ago is called uptimed. The project site is here: http://podgorny.cz/moin/Uptimed.
This is a pretty straightforward install, given uptimed appears to be in most of the major distros' repositories.
Installation
$ sudo yum install uptimed
Once installed the service nee... | Is there a tool for tracking uptimes across reboots? |
1,495,746,973,000 |
I've written some multi-thread test, and now I want to be sure that the highest CPU usage of this test is equal to 100 * CPU_NUMBER of current machine. Is it possible to do?
UPD 0: I'm talking about Linux system.
|
I think that you're looking for sar. SAR stands for System Activty Report. It's used in unix-like operating systems to report about CPU, memory and IO usage, collected by sysstat.
Then, sysatat can be configured to
Monitor individual processes. Link
How often it collects, and how long sar keeps reports is decided on ... | How to detect process's highest cpu usage during it's life |
1,495,746,973,000 |
I have been looking through the documentation for /proc and the "stack" object being a new'ish object in proc, I have also looked through the kernel commit to create it -- however the documentation does not detail exactly what is in the /proc/self/stack file -- and since I intuitively expected it to be the actual stac... |
The file /proc/$pid/stacks shows kernel stacks. On your system, memory addresses of the form ffffffff8xxxxxxx are in the space that's reserved for the kernel. There's not much documentation, you can check the source code. In contracst, the pstack program shows user-space stacks (using its knowledge of executable forma... | What is the difference between /proc/self/stack and output from pstack? |
1,495,746,973,000 |
Is it possible to automatically run "source .bashrc" every time when I edit the bashrc file and save it?
|
One way, as another answer points out, would be to make a function that replaces your editor call to .bashrc with a two-step process that
opens your editor on .bashrc
sources .bashrc
such as:
vibashrc() { vi $HOME/.bashrc; source $HOME/.bashrc; }
This has some shortcomings:
it would require you to remember to type... | How to run "source .bashrc" automatically after I edit and save it? |
1,495,746,973,000 |
I want to create a service that monitors the existence of a certain process. I wrote the following shell script:
#!/bin/sh
while :
do
w=`ps u -A | grep -P ".+Sl.+/usr/local/MySource/endpoint" -c`
sleep 10
if [ $w -lt 2 ]
then
echo 0 > /sys/class/leds/alix\:2/brightness
killall -9 /usr/local/MySource/endpoint
nohup /u... |
It is failing because you run ps u. From man ps:
u Display user-oriented format.
This means that ps will only list processes owned by the current user. When you run the script manually, that user is you so your process is listed correctly.
(As @Gilles very correctly pointed out, the use of -A will cause... | Monitor a process in Debian |
1,495,746,973,000 |
I have a Monitor connected to my machine through HDMI.
Now if anyone were to switch off the Monitor, through either the Soft Buttons on it, or by removing it's Power Cord, I wish to be notified and run a Shell Script.
I tried many ways to identify when a monitor is switched on or off (It's always connected). The only... |
I don't see anything wrong with parsing the output of ddccontrol. DDC is the right way to get the information you want. Unlike with VGA, where DDC was created, the HDMI connector was designed to include DDC from the start. They even went back and modified the DDC standard to add more features for HDMI, calling it E-DD... | Detect if HDMI Monitor is switched off |
1,500,035,950,000 |
According to Monit link :
No environment variables are used by Monit. However, when Monit executes a start/stop/restart program or an exec action, it will set several environment variables which can be utilised by the executable to get information about the event, which triggered the action.
Is it possible to use th... |
Yes, there be wrongness. The monit exec appears to perform an exec(3) style execution of the given string, and not a system(3) call; this means shell syntax (redirections and whatnot) are not supported as the supplied data is not being run through a shell. Instead, write suitable code that uses the monit environment v... | How to use Monit Environment variables? |
1,500,035,950,000 |
I am working on software that communicates with a PCI card through direct memory access (DMA) transactions. My programs use a suit of drivers and a library that handles the DMA. Everything runs on a Red Hat Linux.
To test and measure the performance of my programs I would like to trace the start and end of the DMA tra... |
Encouraged by the comment from @dirkt, I looked better at the drivers and found the PCI MSI interrupts that correspond to these DMA transactions.
The driver enables these interrupts with a call
pci_enable_msix(.., msixTable,..)
that sets up the struct msix_entry msixTable[MAXMSIX]. Then it asings them to the handler ... | How to trace DMA? |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.