Strace is a useful diagnostic, instructional, and debugging tool. System administrators, diagnosticians and trouble-shooters will find it invaluable for solving problems with programs for which the source is not readily available since they do not need to be recompiled in order to trace them. Students, hackers and the overly-curious will find that a great deal can be learned about a system and its system calls by tracing even ordinary programs. And programmers will find that since system calls and signals are events that happen at the user/kernel interface, a close examination of this boundary is very useful for bug isolation, sanity checking and attempting to capture race conditions.
Debugging why some process isn’t connecting to a remote server can be exceedingly frustrating. DNS can fail, connect can hang, the server might send something unexpected back etc. You can use tcpdump to analyze a lot of that, and that too is a very nice tool, but a lot of the time strace will give you less chatter, simply because it will only ever return data related to the syscalls generated by “your” process. If you’re trying to figure out what one of hundreds of running processes connecting to the same database server does for example (where picking out the right connection with tcpdump is a nightmare), strace makes life a lot easier.
Continue reading “Strace – trace system calls and signals.”
Category: Troubleshooting
Waiting for LDAP server to be ready – OES11
If you got this error while booting OES11: Waiting for LDAP server to be ready or namcd cannot connect to LDAP server in /var/log/messages please follow these steps:
cat /etc/nam.conf
--cut
base-name=o=users
workstation-context=o=servers
admin-fdn=cn=admin,o=users
preferred-server=172.16.10.77
--cut
and replace preferred-server to a correct IP, after change:
cat /etc/nam.conf
--cut
base-name=o=users
workstation-context=o=servers
admin-fdn=cn=admin,o=users
preferred-server=172.16.10.84
--cut
and then:
/var/lib/novell-lum # l
total 92
drwxr-xr-x 2 root root 4096 Nov 11 16:52 ./
drwxr-xr-x 43 root root 4096 Oct 30 10:15 ../
-rw-r--r-- 1 root root 1324 Oct 29 16:47 .172.16.10.77.der
-rw-r--r-- 1 root root 1324 Oct 30 10:29 .172.16.10.83.der
delete an old IP address
rm /var/lib/novell-lum/.172.166.10.77.der
and then refresh namcd:
namconfig cache_refresh
rcnamcd restart
Get a hardware information using a CLI.
Dmidecode is a tool for dumping a computer’s DMI (some say SMBIOS) table contents in a human-readable format. This table contains a description of the system’s hardware components, as well as other useful pieces of information such as serial numbers and BIOS revision. Thanks to this table, you can retrieve this information without having to probe for the actual hardware. While this is a good point in terms of report speed and safe‐ness, this also makes the presented information possibly unreliable.
dmidecode |grep -i product
Ping with a timestamp.
ping some_IP | while read ping; do echo "$(date): $ping"; done > ping_output.txt
How to check the health of a hard drive.
The SATA drive started clicking and I was unable to access the data. To check the health of a hard drive on a Linux box just type:
smartctl -a /dev/sda
Disable the system beep during the shutdown -h +time.
To disable the system beep during the shutdown -h +time, sysfinit has to be downloaded into your machine.
apt-get source sysvinit
vim sysvinit-2.88dsf/src/shutdown.c
then find a “void warn(int mins)” function and there change
wall(buf, 0); to /*wall(buf, 0);*/
then run ./configure make etc. or make a package. Also you can use this:
rmmod pcspeaker
Surely there is another way to off the beep which I do not know 😉
Using the dd command to determine sequential I/O speed.
The dd command provides a simple way to measure sequential I/O performance. The following shows a sequential read of 1GB (1024MB). There are 1024 1MB (1024KB) reads:
root:~# time -p dd if=/dev/zero of=2delete.file bs=1024k count=1024
1024+0 records in
1024+0 records out
1073741824 bytes (1.1 GB) copied, 17.5714 seconds, 61.1 MB/s
real 17.91
user 0.00
sys 2.62
The megabytes per second can be calculated as follows:
root:~: echo 1024 / 17.91 | bc
57
1GB/17.91 sec = 57 MBps
Find out who is connected to which service and which user and process owns a port.
Here are some useful utilities. Netstat or Ss is a command that will list both the open ports and who is connected to your system. You should run it like this:
root:~# netstat -an
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:45982 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:2049 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:994 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN
or
root:~# ss -an
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 :::443 :::*
LISTEN 0 50 :::445 :::*
LISTEN 0 128 *:45982 *:*
LISTEN 0 64 :::993 :::*
LISTEN 0 64 *:2049 *:*
LISTEN 0 128 *:994 *:*
LISTEN 0 50 127.0.0.1:3306 *:*
This way you can find out who is connected to which service.
Another interesting command is the fuser program. This program can tell you which user and process owns a
port. For example, the following command will tell you who owns port 22:
root:~# fuser -v -n tcp 22
USER PID ACCESS COMMAND
22/tcp: root 1743 F.... sshd
root 12184 f.... sshd
user 12207 F.... sshd
or
root:~# lsof -i tcp:22
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
sshd 1743 ssh 3u IPv4 5861 0t0 TCP *:ssh (LISTEN)
sshd 1743 ssh 4u IPv6 5864 0t0 TCP *:ssh (LISTEN)
sshd 12184 ssh 3u IPv4 957477 0t0 TCP server:ssh->193.120.51.186:39516 (ESTABLISHED)
sshd 12207 user 3u IPv4 957477 0t0 TCP server:ssh->193.120.51.186:39516 (ESTABLISHED)