Skip to content

sys

3 posts with the tag “sys”

How to resolve openssl error when loading shared libraries libssl.so.1.1

1. The purpose of this post

After install openssl, we run the below command:

Terminal window
openssl version

to verity the installation, but sometimes we would get this error:

Terminal window
[root@node1 openssl-1.1.0f]# openssl version
openssl: error while loading shared libraries: libssl.so.1.1: cannot open shared object file: No such file or directory

2. Environments

The linux system is:

Terminal window
[root@node1 openssl-1.0.0f]# uname -a
Linux node1 3.10.0-862.14.4.el7.x86_64 #1 SMP Wed Sep 26 15:12:11 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

3. Debug

We try to find the file named libssl.so.1.1 as follows:

Terminal window
[root@localhost openssl-1.1.0f]# ll /usr/lib64/libssl*
-rwxr-xr-x. 1 root root 315096 8m 7 2017 /usr/lib64/libssl3.so
lrwxrwxrwx. 1 root root 16 7m 9 2009 /usr/lib64/libssl.so.10 -> libssl.so.1.0.2k
-rwxr-xr-x. 1 root root 470336 8m 4 2017 /usr/lib64/libssl.so.1.0.2k
[root@localhost openssl-1.1.0f]# ll /usr/local/lib64
Total 8984
drwxr-xr-x. 2 root root 39 11m 8 11:30 engines-1.1
-rw-r--r--. 1 root root 4967326 11m 8 11:30 libcrypto.a
lrwxrwxrwx. 1 root root 16 11m 8 11:30 libcrypto.so -> libcrypto.so.1.1
-rwxr-xr-x. 1 root root 2934272 11m 8 11:30 libcrypto.so.1.1
-rw-r--r--. 1 root root 766182 11m 8 11:30 libssl.a
lrwxrwxrwx. 1 root root 13 11m 8 11:30 libssl.so -> libssl.so.1.1
-rwxr-xr-x. 1 root root 521384 11m 8 11:30 libssl.so.1.1
drwxr-xr-x. 2 root root 61 11m 8 11:22 pkgconfig

We can find that the libcrypto.so.1.1 is located in the /usr/local/lib64, But openssl try to find the .so libraries in the LD_LIBRARY_PATH:

Terminal window
[root@localhost ~]# echo $LD_LIBRARY_PATH
/usr/lib64:/usr/local/lib64

So the solution is try to tell openssl where the library is.

4. Resolve it

There are two methods to resolve this problem:

4.1 Method 1: Change the LD_LIBRARY_PATH

Terminal window
export LD_LIBRARY_PATH = /usr/local/lib64:$LD_LIBRARY_PATH
Terminal window
[root@localhost openssl-1.1.0f]# ln -s /usr/local/lib64/libssl.so.1.1 /usr/lib64/libssl.so.1.1
[root@localhost openssl-1.1.0f]# ln -s /usr/local/lib64/libcrypto.so.1.1 /usr/lib64/libcrypto.so.1.1

5. More about the LD_LIBRARY_PATH

As the linux documents shown:

Final Words + More Resources

My intention with this article was to help others who might be considering solving such a problem. So I hope that’s been the case here. If you still have any questions, don’t hesitate to ask me by email: Email me

Here are also the most important links from this article along with some further resources that will help you in this scope:

Oh, and if you found these resources useful, don’t forget to support me by starring the repo on GitHub!

How to install wrk on linux system?

1. Purpose

In this post, I will demo how to install wrk, a web url performance test tool on linux/unix/mac systems.

2. The solution

2.1 How to install wrk?

On linux systems, to ensures that your package manager (APT) has the most up-to-date information about available packages, versions, and dependencies, we should update the local cache first:

Terminal window
root@launch-advisor-20191120:/etc/nginx# apt update
....

Then we install the wrk tool using apt install command:

root@launch-advisor-20191120:/etc/nginx# apt install wrk
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package wrk

You can see that we got an error E: Unable to locate package wrk, why?

And wrk can only run on Unix-like systems. Such as linux, mac, solaris, etc. It can only be compiled on these systems.

So we can install it from source:

Download wrk source code:

Terminal window
sudo apt-get install build-essential libssl-dev git -y
git clone https://github.com/wg/wrk.git wrk

Then build it:

Terminal window
cd wrk
sudo make

Then we can use the binary:

Terminal window
# move the wrk executable to your PATH
sudo cp wrk /usr/local/bin

2.2 Verify the installation of wrk

Terminal window
root@launch-advisor-20191120:~/wrk# wrk
Usage: wrk <options> <url>
Options:
-c, --connections <N> Connections to keep open
-d, --duration <T> Duration of test
-t, --threads <N> Number of threads to use
-s, --script <S> Load Lua script file
-H, --header <H> Add header to request
--latency Print latency statistics
--timeout <T> Socket/request timeout
-v, --version Print version details
Numeric arguments may include a SI unit (1k, 1M, 1G)
Time arguments may include a time unit (2s, 2m, 2h)
root@launch-advisor-20191120:~/wrk#

It works.

3. Summary

In this post, I demonstrated how to install wrk , a great performance test tool . That’s it, thanks for your reading.

Final Words + More Resources

My intention with this article was to help others who might be considering solving such a problem. So I hope that’s been the case here. If you still have any questions, don’t hesitate to ask me by email: Email me

Here are also the most important links from this article along with some further resources that will help you in this scope:

Oh, and if you found these resources useful, don’t forget to support me by starring the repo on GitHub!

How to solve 'BPF' object has no attribute 'get_syscall_fnname'?

This post will show you how to solve ‘BPF’ object has no attribute ‘get_syscall_fnname’ when run bpf program in linux ?

Problem

When you run a python bpf_program in linux, you run this command:

For example, if our bpf program’s name is example.py:

Terminal window
python example.py

The example.py content is:

example.py
from bcc import BPF
bpf_source = """
#include <uapi/linux/ptrace.h>
int do_sys_execve(struct pt_regs *ctx) {
char comm[16];
bpf_get_current_comm(&comm, sizeof(comm));
bpf_trace_printk("executing program: %s\\n", comm);
return 0;
}
"""
bpf = BPF(text=bpf_source)
execve_function = bpf.get_syscall_fnname("execve")
bpf.attach_kprobe(event=execve_function, fn_name="do_sys_execve")
bpf.trace_print()

You get this error:

Terminal window
root@launch:~/linux-observability-with-bpf/code/chapter-4/kprobes# python example.py
Traceback (most recent call last):
File "example.py", line 15, in <module>
execve_function = bpf.get_syscall_fnname("execve")
AttributeError: 'BPF' object has no attribute 'get_syscall_fnname'

The error AttributeError: 'BPF' object has no attribute 'get_syscall_fnname' indicates that the BPF class from the bcc module does not have a method named get_syscall_fnname.

Environment

You check your os version by this command:

Terminal window
root@launch:~# cat /etc/os-release
NAME="Ubuntu"
VERSION="16.04.6 LTS (Xenial Xerus)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 16.04.6 LTS"

Python version:

Terminal window
Python 2.7.17 (default, Apr 15 2020, 17:20:14)
[GCC 7.5.0] on linux2

Solution: Install the bcc dependencies

According to python bcc documents, you should install the libbcc and python bcc into system.

Terminal window
# add key server
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys D4284CDD
# add iovisor to repo
echo "deb https://repo.iovisor.org/apt/bionic bionic main" | sudo tee /etc/apt/sources.list.d/iovisor.list
# update the repo
sudo apt-get update
# install libbcc
sudo apt-get install libbcc
# install python-bcc
sudo apt-get install python-bcc

what is libbcc?

and what is python-bcc:

After all done, you can run the python bpf script again:

Terminal window
root@launch:~/linux-observability-with-bpf/code/chapter-4/kprobes# python example.py
bash-12522 [001] .... 330817.825407: 0x00000001: executing program: bash

It works!

Final Words + More Resources

My intention with this article was to help others who might be considering solving such problem. So I hope that’s been the case here. If you still have any questions, don’t hesitate to ask me by email: Email me

Here are also the most important links from this article along with some further resources that will help you in this scope:

Oh, and if you found these resources useful, don’t forget to support me by starring the repo on GitHub!