tanelpoder / 0xtools

0x.Tools: X-Ray vision for Linux systems
https://0x.tools
GNU General Public License v2.0
1.22k stars 99 forks source link

Not working on Fedora 35 #26

Closed bu3ny closed 1 year ago

bu3ny commented 2 years ago

Hi,

I'm getting the following error while trying to use any of the tools:

[root@fedora ~]# git clone https://github.com/tanelpoder/0xtools
Cloning into '0xtools'...
remote: Enumerating objects: 293, done.
remote: Counting objects: 100% (210/210), done.
remote: Compressing objects: 100% (125/125), done.
remote: Total 293 (delta 113), reused 157 (delta 73), pack-reused 83
Receiving objects: 100% (293/293), 133.78 KiB | 1.21 MiB/s, done.
Resolving deltas: 100% (154/154), done.

[root@fedora 0xtools]# make
gcc -I include -Wall -o bin/xcapture src/xcapture.c
[root@fedora 0xtools]# make install 
install -m 0755 bin/xcapture /usr/bin/xcapture
install -m 0755 bin/psn /usr/bin/psn
install -m 0755 bin/schedlat /usr/bin/schedlat
install -m 0755 -d /usr/lib/0xtools
install -m 0644 lib/0xtools/proc.py /usr/lib/0xtools/proc.py
install -m 0644 lib/0xtools/psnreport.py /usr/lib/0xtools/psnreport.py
install -m 0644 lib/0xtools/argparse.py /usr/lib/0xtools/argparse.py

[root@fedora ~]# sudo psn -p "mysqld|kwork" -G syscall,wchan
Traceback (most recent call last):
  File "/usr/bin/psn", line 113, in <module>
    args.sources = [s for s in proc.all_sources if s.name in args.sources.split(',')]
AttributeError: module 'proc' has no attribute 'all_sources'

[root@fedora ~]# uname -a
Linux fedora 5.15.12-200.fc35.x86_64 #1 SMP Wed Dec 29 15:03:38 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
[root@fedora ~]# which python
/usr/bin/python
[root@fedora ~]# python --version
Python 3.10.1
tanelpoder commented 2 years ago

Looks like it's due to clashing module names. I guess you have the python proc package installed and pSnapper imports that instead of its own proc package. I guess I'll change the package name in the future to prevent such clashes, but for now you could either uninstall the python proc package if you don't use it or set up the pythonpath environment variable as a workaround for pSnapper.

# sudo psn -p "mysqld|kwork" -G syscall,wchan
Traceback (most recent call last):
  File "/usr/bin/psn", line 113, in <module>
    args.sources = [s for s in proc.all_sources if s.name in args.sources.split(',')]
AttributeError: module 'proc' has no attribute 'all_sources'

# pip uninstall proc
Found existing installation: proc 1.0
Uninstalling proc-1.0:
  Would remove:
    /usr/local/bin/cron-graceful
    /usr/local/bin/notify-send-headless
    /usr/local/bin/with-gpg-agent
    /usr/local/bin/with-gui-environment
    /usr/local/lib/python3.10/site-packages/proc-1.0.dist-info/*
    /usr/local/lib/python3.10/site-packages/proc/*
Proceed (Y/n)? 
  Successfully uninstalled proc-1.0

# sudo psn -p "mysqld|kwork" -G syscall,wchan
Linux Process Snapper v1.1.0 by Tanel Poder [https://0x.tools]
Sampling /proc/stat, syscall, wchan for 5 seconds...
finished.
=== Active Threads 
query returned no rows
samples: 100
(expected: 100)
total processes: 17, threads: 17
runtime: 5.00, measure time: 0.34
tanelpoder commented 2 years ago

I tried changing the PYTHONPATH, but hit some other errors, a temporary workaround (if you can't remove the clashing proc package) is to rename pSnapper's proc.py to psnproc.py and change imports in 2 files.

  1. mv /usr/lib/0xtools/proc.py mv /usr/lib/0xtools/psnproc.py
  2. change import proc to import psnproc as proc in /usr/lib/0xtools/psnreport.py
  3. change import proc, psnreport to import psnproc as proc, psnreport in /usr/bin/psn

Or just remove the separate clashingproc package with pip uninstall proc as described above.

I'll fix this naming clash in the next release.

bu3ny commented 2 years ago

Hi @tanelpoder

Tried your solution, it worked perfectly fine. I had python proc module installed using pip.

This tool is simply amazing, I think we need to produce an RPM/DEB packages for such great tool !!!

tanelpoder commented 2 years ago

Thanks :-)

There's actually a PR already for RPM generation (#18). But I was the bottleneck last year getting this completed. But I plan to be more active this year (and any help is appreciated).

bu3ny commented 2 years ago

I'll try to open a RFE to include it in upcoming RHEL release.

tanelpoder commented 2 years ago

That would be great! I'd be happy to make any changes to file & directory locations etc and anything that's needed for proper standardized deployment to Fedora/CentOS appstream/RHEL environment.

tanelpoder commented 1 year ago

Fixed in v1.2.3