6

I have supervisorctl running with about 50 processes. Now I want to get the status of these processes on my website. My idea is to use on php exec(“sudo supervisorctl status”) and set the output to a array or something like that. I only need the first 2 colons.

process1                         RUNNING    pid 935, uptime 17386 days, 14:52:25
process2                         RUNNING    pid 936, uptime 17386 days, 14:52:25
process3                         RUNNING    pid 31907, uptime 0:00:09

What is the best way to do this.

Pavel_K
  • 9,658
  • 11
  • 54
  • 152
Lewis
  • 117
  • 2
  • 2
  • 8
  • You mean the two colons in `14:52:25`? – Barmar Aug 08 '17 at 17:43
  • 6
    You can use a regular expression to extract the first two fields in the outpu. Or you could use `supervisorctl status | awk '{print $1, $2}'` – Barmar Aug 08 '17 at 17:45
  • 3
    SO is not a free coding service. You have to make some attempt to solve the problem yourself. If you can't get it working, post what you tried and we'll help you fix it. – Barmar Aug 08 '17 at 17:45
  • 1
    Thanks, supervisorctl status | awk '{print $1, $2}' was the solution. I have now exec("sudo supervisorctl status | awk '{print $1, $2}'", $output); And on $output I have the array that I want. – Lewis Aug 09 '17 at 12:07
  • 1
    `sudo supervisorctl status | awk '{print $1, $2}'` showed me that 8 Laravel workers are running. https://laravel.com/docs/7.x/queues#supervisor-configuration – Ryan Sep 12 '20 at 19:06

1 Answers1

1

You can use a regular expression to extract the first two fields in the outpu. Or you could use supervisorctl status | awk '{print $1, $2}'

Credits to @Barmar

Carlos.V
  • 339
  • 4
  • 12