maintIncludesRoot(); set_error_handler(static fn (): bool => true); ob_start(); try { thold_update_host_status(); } finally { ob_end_clean(); restore_error_handler(); } } /** * A recovered device inside a maintenance window is logged, not alerted. * * @return void */ public function testRecoveringDeviceInMaintenanceIsLoggedNotAlerted(): void { CactiStubs::willReturnFor('db_fetch_assoc', 'plugin_thold_host_failed', [['host_id' => 42]]); CactiStubs::willReturnFor('db_fetch_row_prepared', 'FROM host WHERE id', [ 'id' => 42, 'hostname' => 'dev42', 'description' => 'Device 42', 'status' => HOST_UP, 'snmp_community' => '', 'snmp_username' => '', 'snmp_version' => 0, 'site_id' => 0, 'location' => '', 'notes' => '', 'status_fail_date' => '0000-00-00 00:00:00', 'availability' => 100, 'total_polls' => 1, 'failed_polls' => 0, 'cur_time' => 0, 'avg_time' => 0, 'thold_send_email' => '0', ]); $this->runHostStatus(); $this->assertContains( 'WARNING: Device[42] Hostname[dev42] is recovering! Only logging, maint device', CactiStubs::$log ); } /** * A down device inside a maintenance window is logged, not alerted. * * @return void */ public function testDownDeviceInMaintenanceIsLoggedNotAlerted(): void { CactiStubs::willReturnFor('db_fetch_assoc_prepared', 'availability_method', [[ 'id' => 77, 'hostname' => 'dev77', ]]); $this->runHostStatus(); $this->assertContains( 'WARNING: Device[77] Hostname[dev77] is DOWN. Only logging, maint device', CactiStubs::$log ); } }