Class: Sidekiq::Mcp::Tools::WorkersCountTool
- Inherits:
-
Sidekiq::Mcp::Tool
- Object
- Sidekiq::Mcp::Tool
- Sidekiq::Mcp::Tools::WorkersCountTool
- Defined in:
- lib/sidekiq/mcp/tools/workers_count_tool.rb
Instance Method Summary collapse
Methods inherited from Sidekiq::Mcp::Tool
arguments, #call, description, schema_to_json_schema, to_tool_definition
Instance Method Details
#perform ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/sidekiq/mcp/tools/workers_count_tool.rb', line 16 def perform processes = Sidekiq::ProcessSet.new total_workers = 0 busy_workers = 0 processes_info = [] processes.each do |process| process_workers = process["concurrency"] || 0 process_busy = process["busy"] || 0 total_workers += process_workers busy_workers += process_busy processes_info << { hostname: process["hostname"], pid: process["pid"], concurrency: process_workers, busy: process_busy, utilization: process_workers > 0 ? ((process_busy.to_f / process_workers) * 100).round(2) : 0, started_at: process["started_at"] } end { total_processes: processes.size, total_workers: total_workers, busy_workers: busy_workers, idle_workers: total_workers - busy_workers, overall_utilization: total_workers > 0 ? ((busy_workers.to_f / total_workers) * 100).round(2) : 0, processes: processes_info }.to_json end |