command line - Remove CGroup from systemctl status output - Ask Ubuntu


i have php7.0-fpm running 125 start servers, , check status after restarting it. systemctl status, of course produces on 130 lines of output, making difficult read quickly.

root@web2:/etc/php/7.0/fpm/pool.d# systemctl --no-pager --full status php7.0-fpm ● php7.0-fpm.service - php 7.0 fastcgi process manager    loaded: loaded (/lib/systemd/system/php7.0-fpm.service; enabled; vendor preset: enabled)    active: active (running) since thu 2016-10-27 13:38:29 cdt; 13min ago   process: 5961 execstartpre=/usr/lib/php/php7.0-fpm-checkconf (code=exited, status=0/success)  main pid: 5971 (php-fpm7.0)    status: "processes active: 0, idle: 125, requests: 12, slow: 0, traffic: 0req/sec"     tasks: 126    memory: 294.2m       cpu: 728ms    cgroup: /system.slice/php7.0-fpm.service            ├─5971 php-fpm: master process (/etc/php/7.0/fpm/php-fpm.conf)            ├─5974 php-fpm: pool www            ├─5975 php-fpm: pool www            ├─5976 php-fpm: pool www            ├─5977 php-fpm: pool www            ├─5978 php-fpm: pool www            ├─5979 php-fpm: pool www            ├─5980 php-fpm: pool www            ├─5981 php-fpm: pool www            ├─5982 php-fpm: pool www            ├─5983 php-fpm: pool www            ├─5984 php-fpm: pool www            ├─5985 php-fpm: pool www            ├─5986 php-fpm: pool www            ├─5987 php-fpm: pool www            ├─5988 php-fpm: pool www            ├─5989 php-fpm: pool www            ├─5990 php-fpm: pool www            ├─5991 php-fpm: pool www            ├─5992 php-fpm: pool www            ├─5993 php-fpm: pool www            ├─5994 php-fpm: pool www            ├─5995 php-fpm: pool www            ├─5996 php-fpm: pool www            ├─5997 php-fpm: pool www            ├─5998 php-fpm: pool www            ├─5999 php-fpm: pool www            ├─6000 php-fpm: pool www            ├─6001 php-fpm: pool www            ├─6002 php-fpm: pool www            ├─6003 php-fpm: pool www            ├─6004 php-fpm: pool www            ├─6005 php-fpm: pool www            ├─6006 php-fpm: pool www            ├─6007 php-fpm: pool www            ├─6008 php-fpm: pool www            ├─6009 php-fpm: pool www            ├─6010 php-fpm: pool www            ├─6011 php-fpm: pool www            ├─6012 php-fpm: pool www            ├─6013 php-fpm: pool www            ├─6014 php-fpm: pool www            ├─6015 php-fpm: pool www            ├─6016 php-fpm: pool www            ├─6017 php-fpm: pool www            ├─6018 php-fpm: pool www            ├─6019 php-fpm: pool www            ├─6020 php-fpm: pool www            ├─6021 php-fpm: pool www            ├─6022 php-fpm: pool www            ├─6023 php-fpm: pool www            ├─6024 php-fpm: pool www            ├─6025 php-fpm: pool www            ├─6026 php-fpm: pool www            ├─6027 php-fpm: pool www            ├─6028 php-fpm: pool www            ├─6029 php-fpm: pool www            ├─6030 php-fpm: pool www            ├─6031 php-fpm: pool www            ├─6032 php-fpm: pool www            ├─6033 php-fpm: pool www            ├─6034 php-fpm: pool www            ├─6035 php-fpm: pool www            ├─6036 php-fpm: pool www            ├─6037 php-fpm: pool www            ├─6038 php-fpm: pool www            ├─6039 php-fpm: pool www            ├─6040 php-fpm: pool www            ├─6041 php-fpm: pool www            ├─6042 php-fpm: pool www            ├─6043 php-fpm: pool www            ├─6044 php-fpm: pool www            ├─6045 php-fpm: pool www            ├─6046 php-fpm: pool www            ├─6047 php-fpm: pool www            ├─6048 php-fpm: pool www            ├─6049 php-fpm: pool www            ├─6050 php-fpm: pool www            ├─6051 php-fpm: pool www            ├─6052 php-fpm: pool www            ├─6053 php-fpm: pool www            ├─6054 php-fpm: pool www            ├─6055 php-fpm: pool www            ├─6056 php-fpm: pool www            ├─6057 php-fpm: pool www            ├─6058 php-fpm: pool www            ├─6059 php-fpm: pool www            ├─6060 php-fpm: pool www            ├─6061 php-fpm: pool www            ├─6062 php-fpm: pool www            ├─6063 php-fpm: pool www            ├─6064 php-fpm: pool www            ├─6065 php-fpm: pool www            ├─6066 php-fpm: pool www            ├─6067 php-fpm: pool www            ├─6068 php-fpm: pool www            ├─6069 php-fpm: pool www            ├─6070 php-fpm: pool www            ├─6071 php-fpm: pool www            ├─6072 php-fpm: pool www            ├─6073 php-fpm: pool www            ├─6074 php-fpm: pool www            ├─6075 php-fpm: pool www            ├─6076 php-fpm: pool www            ├─6077 php-fpm: pool www            ├─6078 php-fpm: pool www            ├─6079 php-fpm: pool www            ├─6080 php-fpm: pool www            ├─6081 php-fpm: pool www            ├─6082 php-fpm: pool www            ├─6083 php-fpm: pool www            ├─6084 php-fpm: pool www            ├─6085 php-fpm: pool www            ├─6086 php-fpm: pool www            ├─6087 php-fpm: pool www            ├─6088 php-fpm: pool www            ├─6089 php-fpm: pool www            ├─6090 php-fpm: pool www            ├─6091 php-fpm: pool www            ├─6092 php-fpm: pool www            ├─6093 php-fpm: pool www            ├─6094 php-fpm: pool www            ├─6095 php-fpm: pool www            ├─6096 php-fpm: pool www            ├─6097 php-fpm: pool www            └─6098 php-fpm: pool www  oct 27 13:38:29 web2 systemd[1]: starting php 7.0 fastcgi process manager... oct 27 13:38:29 web2 systemd[1]: started php 7.0 fastcgi process manager. 

i don't need cgroup info outputs. want quick status , few log lines @ bottom. can filter output this:

root@web2:/etc/php/7.0/fpm/pool.d# systemctl --no-pager status php7.0-fpm | grep -v "php-fpm: pool www" ● php7.0-fpm.service - php 7.0 fastcgi process manager    loaded: loaded (/lib/systemd/system/php7.0-fpm.service; enabled; vendor preset: enabled)    active: active (running) since thu 2016-10-27 13:38:29 cdt; 19min ago   process: 5961 execstartpre=/usr/lib/php/php7.0-fpm-checkconf (code=exited, status=0/success)  main pid: 5971 (php-fpm7.0)    status: "processes active: 0, idle: 125, requests: 16, slow: 0, traffic: 0req/sec"     tasks: 126    memory: 295.5m       cpu: 737ms    cgroup: /system.slice/php7.0-fpm.service            ├─5971 php-fpm: master process (/etc/php/7.0/fpm/php-fpm.conf)                        oct 27 13:38:29 web2 systemd[1]: starting php 7.0 fastcgi process manager... oct 27 13:38:29 web2 systemd[1]: started php 7.0 fastcgi process manager. 

but lose colored formatting in bash useful quick status check.

is there way in systemctl or similar command status info without cgroup?

i don't think possible color if process output in way. systemctl detects when output isn't tty , doesn't produce colored output. default behavior since that's want.

as workaround, here's little script parses out cgroup info, , adds color on:

perl -mterm::ansicolor -ne 'next if /^cgroup/ || /├─/;      s/(?>: )active/color("bold green").$&.color("reset")/e; print' 

pass systemctl output through , word active green:

systemctl --no-pager status php7.0-fpm |     perl -mterm::ansicolor -ne 'next if /^cgroup/ || /├─/;      s/(?>: )active/color("bold green").$&.color("reset")/e; print' 

if edit question , add different output (i don't have service installed don't know else should colored), can extend other possible outputs.


Comments

Popular posts from this blog

download - Firefox cannot save files (most of the time), how to solve? - Super User

windows - "-2146893807 NTE_NOT_FOUND" when repair certificate store - Super User