@ -123,8 +123,11 @@ class ServiceView(MethodView):
out = server_mod . ssh_command ( server . ip , cmd )
out = out . replace ( ' \n ' , ' ' )
out1 = out . split ( ' \r ' )
out1 [ 0 ] = out1 [ 0 ] . split ( ' / ' ) [ 1 ]
out1 [ 1 ] = out1 [ 1 ] . split ( ' ; ' ) [ 1 ]
try :
out1 [ 0 ] = out1 [ 0 ] . split ( ' / ' ) [ 1 ]
out1 [ 1 ] = out1 [ 1 ] . split ( ' ; ' ) [ 1 ]
except IndexError :
return ErrorResponse ( error = ' NGINX service not found ' ) . model_dump ( mode = ' json ' ) , 404
try :
data = {
" Version " : out1 [ 0 ] ,
@ -164,11 +167,21 @@ class ServiceView(MethodView):
except Exception as e :
data = ErrorResponse ( error = str ( e ) ) . model_dump ( mode = ' json ' )
elif service == ' keepalived ' :
try :
os_info = server_sql . select_os_info ( server_id )
except RoxywiResourceNotFound :
raise RoxywiResourceNotFound ( ' Cannot find system information ' )
if " CentOS " in os_info or " Redhat " in os_info :
kp_proc_name = ' keepalived -D '
else :
kp_proc_name = ' keepalived --dont-fork '
cmd = ( " sudo /usr/sbin/keepalived -v 2>&1|head -1|awk ' { print $2} ' && sudo systemctl status keepalived |grep -e ' Active ' "
" |awk ' { print $2, $9$10$11$12$13} ' && ps ax |grep ' keepalived -D ' |grep -v grep |wc -l " )
f" |awk ' {{ print $2, $9$10$11$12$13 }} ' && ps ax |grep ' { kp_proc_name } ' |grep -v grep |wc -l " )
try :
out = server_mod . ssh_command ( server . ip , cmd )
out1 = out . split ( )
if out1 [ 0 ] . split ( ' \r ' ) [ 0 ] == ' /usr/sbin/keepalived: ' :
return ErrorResponse ( error = ' Keepalived service not found ' ) . model_dump ( mode = ' json ' ) , 404
data = { " Version " : out1 [ 0 ] . split ( ' \r ' ) [ 0 ] , " Uptime " : out1 [ 2 ] , " Process " : out1 [ 3 ] , ' Status ' : self . _service_status ( out1 [ 3 ] ) }
except IndexError :
return ErrorResponse ( error = ' Keepalived service not found ' ) . model_dump ( mode = ' json ' ) , 404