TSP Posted January 22, 2016 Posted January 22, 2016 I'm trying to investigate frequent downtime periods that happens fairly daily, but still not with a clear interval between each time. In doing that I'm trying to now look over whether any of the tasks cause this. The problem I have with that is that there are no log entries for when each task has actually been executed, so I can't see if any of the previous execution times for tasks corresponds to the times our servers tend to go down.
emilhem Posted January 24, 2016 Posted January 24, 2016 I would also like to know how to make tasks more expressive when they are run or not (i.e. logs in task log).
TSP Posted January 27, 2016 Author Posted January 27, 2016 And you should log how long time the task spent. I've added some custom code to log this myself now in system/Task/Task.php public function runAndLog() { # HW_CUSTOM log task runnings \IPS\Log::i( LOG_NOTICE )->write( "Start to run task {$this->id}($this->key)", 'taskRunLog' ); $start = microtime( true ); $result = NULL; $error = FALSE; try { $result = $this->run(); } catch ( \IPS\Task\Exception $e ) { $result = $e->getMessage(); $error = 1; } $end_time = round( microtime( true ) - $start, 5 ); \IPS\Log::i( LOG_NOTICE )->write( "Task {$this->id}($this->key) was finished in {$end_time} seconds", 'taskRunLog' ); if ( $error !== FALSE or $result !== NULL ) { \IPS\Db::i()->insert( 'core_tasks_log', array( 'task' => $this->id, 'error' => $error, 'log' => json_encode( $result ), 'time' => time() ) ); } } But I feel you should log this information to the database table.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.