vozlt / nginx-module-vts

Nginx virtual host traffic status module
BSD 2-Clause "Simplified" License
3.2k stars 458 forks source link

getting error as "undefined symbol: ngx_stat_accepted" when dynamically loaded ngx_http_vhost_traffic_status_module.so module #218

Open lingarajpatil1991 opened 2 years ago

lingarajpatil1991 commented 2 years ago

Hi, I wanted to load ngx-vts_module dynamically and load the module dynamically I configured the module as ./configure --with-compat --add-dynamic-module=../ngx_vts_module currently using nginx-1.13.12 binary.

and tries to copy ngx_http_vhost_traffic_status_module.so to /etc/nginx/modules/ngx_http_vhost_traffic_status_module.so

when I verified with nginx -t command, I am getting following error:

nginx: [emerg] dlopen() "/etc/nginx/modules/ngx_http_vhost_traffic_status_module.so" failed (/etc/nginx/modules/ngx_http_vhost_traffic_status_module.so: undefined symbol: ngx_stat_accepted) in /etc/nginx/nginx.conf:9

Please let me know how this issue can be resolved.

aminvakil commented 2 years ago

Is there a reason you're using nginx-1.13.12 (not the newer stable versions)?

But I guess your error is because of not passing modules-path (and lots of other necessary stuff) to your nginx configure, for example this is what nginx 1.20.1 on Rocky Linux 8 has been configured with:

--prefix=/usr/share/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/lib/nginx/tmp/client_body --http-proxy-temp-path=/var/lib/nginx/tmp/proxy --http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi --http-uwsgi-temp-path=/var/lib/nginx/tmp/uwsgi --http-scgi-temp-path=/var/lib/nginx/tmp/scgi --pid-path=/run/nginx.pid --lock-path=/run/lock/subsys/nginx --user=nginx --group=nginx --with-compat --with-debug --with-file-aio --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_degradation_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_image_filter_module=dynamic --with-http_mp4_module --with-http_perl_module=dynamic --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-http_xslt_module=dynamic --with-mail=dynamic --with-mail_ssl_module --with-pcre --with-pcre-jit --with-stream=dynamic --with-stream_ssl_module --with-stream_ssl_preread_module --with-threads --with-cc-opt='-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,-E'
lingarajpatil1991 commented 2 years ago

Hi @aminvakil, I tried in the latest version, but the issue is same. Following is the output of nginx -V nginx -V nginx version: nginx/1.13.12 built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44.0.3) (GCC) configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-ld-opt=-Wl,-rpath,/usr/local/lib --without-http_gzip_module --modules-path=/etc/nginx/modules

dgcampea commented 1 year ago

You need nginx built with "--with-http_stub_status_module".

You can find this out with: objdump -T $(which nginx) | grep ngx_stat, it should show something like:

0000000000518230 g    DO .data  0000000000000008  Base        ngx_stat_requests
0000000000518220 g    DO .data  0000000000000008  Base        ngx_stat_reading
0000000000518228 g    DO .data  0000000000000008  Base        ngx_stat_active
0000000000518238 g    DO .data  0000000000000008  Base        ngx_stat_handled
0000000000518218 g    DO .data  0000000000000008  Base        ngx_stat_writing
0000000000518240 g    DO .data  0000000000000008  Base        ngx_stat_accepted
0000000000518210 g    DO .data  0000000000000008  Base        ngx_stat_waiting