Unix - Associate local IP to pts? - unix

3 ppl (A B C) are connected to a local server (S1) through SSH (putty, or Unix console), with the same username (foobar). Is there a way to associate their own IP to the pts they create ?
For example, a command witch display that :
S1:/root# ls -l /dev/pts
crw------- 1 foobar tty 136, 0 16 apr 10:34 0 <-> 192.168.0.A
crw------- 1 foobar tty 136, 2 16 apr 10:22 2 <-> 192.168.0.B
crw------- 1 foobar tty 136, 3 16 apr 09:26 3 <-> 192.168.0.A
crw------- 1 foobar tty 136, 5 16 apr 09:26 5 <-> 192.168.0.C
Thanks !

"who" command shows you the association between pts-s and hostnames (or ip-s if there is no hostname). You can change the hostnames to IP using 'host' command (if this is a requirement for you).

Related

"Out of memory" in hibrid MPI/OpenMP for GPU acceleration

I have compiled Quantum ESPRESSO (Program PWSCF v.6.7MaX) for GPU acceleration (hibrid MPI/OpenMP) with the next options:
module load compiler/intel/2020.1
module load hpc_sdk/20.9
./configure F90=pgf90 CC=pgcc MPIF90=mpif90 --with-cuda=yes --enable-cuda-env-check=no --with-cuda-runtime=11.0 --with-cuda-cc=70 --enable-openmp BLAS_LIBS='-lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core'
make -j8 pw
Apparently, the compilation ends succesfully. Then, I execute the program:
export OMP_NUM_THREADS=1
mpirun -n 2 /home/my_user/q-e-gpu-qe-gpu-6.7/bin/pw.x < silverslab32.in > silver4.out
Then, the program starts running and print out the next info:
Parallel version (MPI & OpenMP), running on 8 processor cores
Number of MPI processes: 2
Threads/MPI process: 4
...
GPU acceleration is ACTIVE
...
Estimated max dynamical RAM per process > 13.87 GB
Estimated total dynamical RAM > 27.75 GB
But after 2 minutes of execution the job ends with error:
0: ALLOCATE: 4345479360 bytes requested; status = 2(out of memory)
0: ALLOCATE: 4345482096 bytes requested; status = 2(out of memory)
--------------------------------------------------------------------------
Primary job terminated normally, but 1 process returned
a non-zero exit code. Per user-direction, the job has been aborted.
--------------------------------------------------------------------------
--------------------------------------------------------------------------
mpirun detected that one or more processes exited with non-zero status, thus causing
the job to be terminated. The first process to do so was:
Process name: [[47946,1],1]
Exit code: 127
--------------------------------------------------------------------------
This node has > 180GB of available RAM. I check the Memory use with the top command:
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
89681 my_user 20 0 30.1g 3.6g 2.1g R 100.0 1.9 1:39.45 pw.x
89682 my_user 20 0 29.8g 3.2g 2.0g R 100.0 1.7 1:39.30 pw.x
I noticed that the process stops when RES memory reaches 4GB. This are the caracteristics of the node:
(base) [my_user#gpu001]$ numactl --hardware
available: 2 nodes (0-1)
node 0 cpus: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 28 29 30 31 32 33 34 35 36 37 38 39 40 41
node 0 size: 95313 MB
node 0 free: 41972 MB
node 1 cpus: 14 15 16 17 18 19 20 21 22 23 24 25 26 27 42 43 44 45 46 47 48 49 50 51 52 53 54 55
node 1 size: 96746 MB
node 1 free: 70751 MB
node distances:
node 0 1
0: 10 21
1: 21 10
(base) [my_user#gpu001]$ free -lm
total used free shared buff/cache available
Mem: 192059 2561 112716 260 76781 188505
Low: 192059 79342 112716
High: 0 0 0
Swap: 8191 0 8191
The version of MPI is:
mpirun (Open MPI) 3.1.5
This node is a compute node in a cluster, but no matter if I submit the job with SLURM or run it directly on the node, the error is the same.
Note that I compile it on the login node and run it on this GPU node, the difference is that on the login node it has no GPU connected.
I would really appreciate it if you could help me figure out what could be going on.
Thank you in advance!

The Z shell returns "number expected" when I try to remove a directory

Why can't I delete this directory in the Z shell? What number is expected?
I have tried googling "number expected" and z shell to no avail.
drwxr-xr-x 3 me staff 96 Jan 31 09:49 PycharmProjects
drwxr-xr-x+ 3 me staff 96 Apr 21 2015 Sites
drwxr-xr-x# 13 me staff 416 Jul 1 2019 iCloud Drive (Archive)
drwx---rwx# 39 me staff 1248 Dec 5 12:28 iCloud Drive (Archive) 2
me#BigT ~ % rmdir -rf iCloud Drive (Archive)
**zsh: number expected**
My guess is the spaces and parenthesis are making ZSH try to expand / evaluate your expression, which is invalid. Try surrounding the name of the folder with quotes, like so:
rm -rf "iCloud Drive (Archive)"

FIND_LIBRARY does not find existing libraries

In the function findQt4.cmake:
FIND_LIBRARY(QT_QTCORE_LIBRARY_RELEASE
NAMES QtCore QtCore4
HINTS ${QT_LIBRARY_DIR_TMP}
)
if I print:
MESSAGE("HINT PATH " ${QT_LIBRARY_DIR_TMP})
I will get:
~/dev/Libraries/Qt4.8.0/lib
In this directory there are: ~/dev/Libraries/Qt4.8.0/lib$ ls -all libQtCore*
I got:
-rw-r--r-- 1 abc abc 950 Nov 30 13:08 libQtCore.la
-rw-r--r-- 1 abc abc 942 Nov 30 13:07 libQtCore.prl
lrwxrwxrwx 1 abc abc 18 Nov 30 13:07 libQtCore.so -> libQtCore.so.4.8.0
lrwxrwxrwx 1 abc abc 18 Nov 30 13:08 libQtCore.so.4 -> libQtCore.so.4.8.0
lrwxrwxrwx 1 abc abc 18 Nov 30 13:08 libQtCore.so.4.8 -> libQtCore.so.4.8.0
-rwxr-xr-x 1 abc abc 2697932 Nov 30 13:08 libQtCore.so.4.8.0
But why the FIND_LIBRARY function return: QT_QTCORE_LIBRARY_RELEASE = NOT FOUND?
Even, there is no result if I do like this:
FIND_LIBRARY(QT_QTCORE_LIBRARY_RELEASE
NAMES libQtCore.so
HINTS ${QT_LIBRARY_DIR_TMP}
)
Instead of find_library() you can use find_package(). This is the common way for Qt with CMake.
# Find Qt package
find_package(Qt4 REQUIRED)
include(${QT_USE_FILE}) # Add and run Qt CMake modules
add_definitions(${QT_DEFINITIONS}) # Add definitions (if required)
# And later put all together
add_executable( ... )
target_link_libraries( ... ${QT_LIBRARIES}) # Link Qt libraries

How can a process find the pids of processes it communicates with over a pipe?

Let's say I have the following pipeline:
$ generator_process | filter_process | storage_process
Is it possible for filter_process to find out the pid of generator_process and storage_process? If so, how? If not, why?
More generally, how can a process find the pids of processes it communicates with over a pipe?
I'm looking for a portable (POSIX) way to do this, but if it requires some platform-specific trickery, a Linux solution is what I'm looking for. I guess an answer in C would give most detail but if it involves the shell, I'm looking for a bash solution.
Please assume that I can change filter_process but generator_process and storage_process are programs that I have no possibility or desire to alter (they could be standard Unix tools that I don't want to fiddle with). Also, wrapping them in scripts that write their pids to disk is not the solution I'm after.
Note that one end of a pipe might be open in more than one process simultaneously (through fork() or sendmsg file-descriptor transmission), so you might not get just one answer.
In Linux, you can examine /proc/<pid>/fd to see what fds it has open (you need to be root, or the same uid as the target process). I just ran grep a | grep b and got the following output:
/proc/10442/fd:
total 0
dr-x------ 2 nneonneo nneonneo 0 Sep 20 02:19 .
dr-xr-xr-x 7 nneonneo nneonneo 0 Sep 20 02:19 ..
lrwx------ 1 nneonneo nneonneo 64 Sep 20 02:19 0 -> /dev/pts/5
l-wx------ 1 nneonneo nneonneo 64 Sep 20 02:19 1 -> pipe:[100815116]
lrwx------ 1 nneonneo nneonneo 64 Sep 20 02:19 2 -> /dev/pts/5
/proc/10443/fd:
total 0
dr-x------ 2 nneonneo nneonneo 0 Sep 20 02:19 .
dr-xr-xr-x 7 nneonneo nneonneo 0 Sep 20 02:19 ..
lr-x------ 1 nneonneo nneonneo 64 Sep 20 02:19 0 -> pipe:[100815116]
lrwx------ 1 nneonneo nneonneo 64 Sep 20 02:19 1 -> /dev/pts/5
lrwx------ 1 nneonneo nneonneo 64 Sep 20 02:19 2 -> /dev/pts/5
So it follows that by using readlink on your own process's fd, followed by readlink on other process fds you own, you can figure out who is on the other side of the pipe.
Madly hackish way to find out (from within a Bash script) which pids and fds are connected to a particular pipe:
get_fd_target() {
pid=$1
fd=$2
readlink /proc/$pid/fd/$fd
}
find_fd_target() {
target=$1
for i in /proc/*/fd/*; do
if [ "`readlink $i`" == "$target" ]; then
echo $i
fi
done
}
Then, if you want to find out what fds on the system are connected to your script's stdin:
find_fd_target `get_fd_target $$ 0`

why is this rsync command is not syncing?

I am unsure why is this rsync command is not syncing?
rsync -v -e root#ec2-X.compute-1.amazonaws.com:/var/log/apache2/USAGE-log.txt splunk-rync-logs/log.txt
I see this returned after that command which appears OK.
building file list ... done
-rw-r--r-- 0 2012/03/26 19:28:00 log.txt
sent 28 bytes received 12 bytes 80.00 bytes/sec
total size is 0 speedup is 0.00
BUT no data is added to the local file that is supposed to be being synced with the remote file:
ls -al
total 0
drwxr-xr-x 3 bd staff 102 Mar 26 19:28 .
drwxr-xr-x+ 54 bd staff 1836 Mar 26 19:28 ..
-rwxrwxrwx 1 bd staff 0 Mar 26 19:28 log.txt
Any advice?
The syntax for the -e option (rsync version 3.0.8 protocol version 30) is:
-e, --rsh=COMMAND specify the remote shell to use
For use such as -e 'ssh -p 2234'.
Maybe you have a different version, but that's where I'd start looking.

Resources