karafka / karafka-web

Web UI for monitoring and managing Karafka consumers
Other
55 stars 8 forks source link

Can't start karafka server due to error sampler.rb error #137

Closed rafeequl closed 1 year ago

rafeequl commented 1 year ago

I tried to install karafka-web ui and managed to complete all the steps written in the docs. I also manage to view the database via localhost:3000/karafka But when i try to run karafka server by running bundle exec karafka server i got error :

gems/karafka-web-0.7.3/lib/karafka/web/tracking/consumers/sampler.rb:253:in `memory_threads_ps': undefined method `split' for nil:NilClass (NoMethodError)

                                 .split("\n")
                                 ^^^^^^

Its weird since i can run this on my terminal :

❯ ps -A -o rss=,thcount,pid
ps: thcount: keyword not found
         PID
 18784     1
 16160    80
  7296    82
  1120    84
  5600    85
  7056    89
  7072    91

but in rails console :

irb(main):001> @shell = Karafka::Web::Tracking::MemoizedShell.new
=> #<Karafka::Web::Tracking::MemoizedShell:0x0000000113c3bea0 @accu={}>
irb(main):002> @shell.call('ps -A -o rss=,thcount,pid')
ps: thcount: keyword not found
ps: thcount: keyword not found
ps: thcount: keyword not found
ps: thcount: keyword not found
=> nil
irb(main):003> 

Expected behavior

Karafka server run without problem

Actual behavior

exception thrown and karafka server not working

Steps to reproduce the problem

Your setup details

karafka info

Karafka version: 2.2.4
Ruby version: ruby 3.2.2 (2023-03-30 revision e51014f9c0) [arm64-darwin22]
Rdkafka version: 0.13.5
Consumer groups count: 2
Subscription groups count: 2
Workers count: 5
Application client id: example_app
Boot file: /Users/177209.rafeequl/Projects/POS/KLG.Phoenix.Services/karafka.rb
Environment: development
License: LGPL-3.0

Quickfix

I tried to modify sampler.rb and it works, heres the snippet :

# Loads our ps results into memory so we can extract from them whatever we need
          def memory_threads_ps
            @memory_threads_ps = case RUBY_PLATFORM
                                 when /darwin|bsd|linux/
                                   @shell
                                 .call('ps -A -o rss=,pid')
                                 .split("\n")
                                 .map { |row| row.strip.split(' ').map(&:to_i) }
                                 else
                                   @memory_threads_ps = false
                                 end
          end

the difference is in the call method, i removed the thcount

mensfeld commented 1 year ago

@rafeequl can you ps --version for me pretty please? :pray:

mensfeld commented 1 year ago

Nvmd. It seems I used an alternative ps version for mac to test it. I will write a patch shortly.