@@ -26,13 +26,13 @@ class ServiceChecker(HealthChecker):
26
26
CRITICAL_PROCESSES_PATH = 'etc/supervisor/critical_processes'
27
27
28
28
# Command to get merged directory of a container
29
- GET_CONTAINER_FOLDER_CMD = [ 'docker' , ' inspect' , '' , ' --format' , "{{.GraphDriver.Data.MergedDir}}" ]
29
+ GET_CONTAINER_FOLDER_CMD = 'docker inspect {} --format "{{{{ .GraphDriver.Data.MergedDir}}}}"'
30
30
31
31
# Command to query the status of monit service.
32
- CHECK_MONIT_SERVICE_CMD = [ 'systemctl' , ' is-active' , ' monit.service']
32
+ CHECK_MONIT_SERVICE_CMD = 'systemctl is-active monit.service'
33
33
34
34
# Command to get summary of critical system service.
35
- CHECK_CMD = [ 'monit' , ' summary' , ' -B']
35
+ CHECK_CMD = 'monit summary -B'
36
36
MIN_CHECK_CMD_LINES = 3
37
37
38
38
# Expect status for different system service category.
@@ -186,8 +186,7 @@ def _update_container_critical_processes(self, container, critical_process_list)
186
186
self .need_save_cache = True
187
187
188
188
def _get_container_folder (self , container ):
189
- ServiceChecker .GET_CONTAINER_FOLDER_CMD [2 ] = str (container )
190
- container_folder = utils .run_command (ServiceChecker .GET_CONTAINER_FOLDER_CMD )
189
+ container_folder = utils .run_command (ServiceChecker .GET_CONTAINER_FOLDER_CMD .format (container ))
191
190
if container_folder is None :
192
191
return container_folder
193
192
@@ -353,7 +352,7 @@ def check_process_existence(self, container_name, critical_process_list, config,
353
352
# We are using supervisorctl status to check the critical process status. We cannot leverage psutil here because
354
353
# it not always possible to get process cmdline in supervisor.conf. E.g, cmdline of orchagent is "/usr/bin/orchagent",
355
354
# however, in supervisor.conf it is "/usr/bin/orchagent.sh"
356
- cmd = [ 'docker' , ' exec' , str ( container_name ), ' bash' , '-c' , "supervisorctl status" ]
355
+ cmd = 'docker exec {} bash -c "supervisorctl status"' . format ( container_name )
357
356
process_status = utils .run_command (cmd )
358
357
if process_status is None :
359
358
for process_name in critical_process_list :
0 commit comments