to check the progress of the index optimise job I have this script below, that can be useful for you.
check it out:
SELECT
[Server Name] = @@servername
,s.host_name
,TheUser = s.original_login_name
,r.session_id
, r.command
,[Percent Complete] = CONVERT(NUMERIC(6,2), r.percent_complete)
,total_elapsed_time = CAST( (r.total_elapsed_time/1000.00) AS VARCHAR(30)) + ' Seconds'
,estimated_completion_time = CAST( (r.estimated_completion_time/1000.00) AS VARCHAR(30)) + ' Seconds'
,[Start time] = CONVERT(VARCHAR(30), r.start_time ,113)
,[ETA Completion Time] = CONVERT(VARCHAR(30), DATEADD(ms,r.estimated_completion_time,GetDate()),113)
,sdest.Query
FROM sys.dm_exec_requests r WITH(NOLOCK)
INNER JOIN sys.dm_exec_sessions s WITH(NOLOCK)
ON r.session_id = s.session_id
OUTER APPLY (
SELECT COALESCE((
SELECT TEXT AS [processing-instruction(_)]
FROM sys.dm_exec_sql_text(r.sql_handle)
FOR XML PATH('')
,TYPE
), '') AS Query
FROM sys.dm_exec_sql_text(r.sql_handle)
) sdest
WHERE 1=1
AND r.command IN ('RESTORE DATABASE',
'BACKUP DATABASE',
'DbccFilesCompact',
'DbccSpaceReclaim',
'RESTORE LOG',
'ALTER INDEX')