How to check if maintenance mode is enabled in Drupal 8?
The maintenance mode of the site is a boolean value stored in a state. You can access it like this:

$state = \Drupal::state()-&gt;get('system.maintenance_mode');