Description of changes:
The current sample lifecycle configuration only checks for notebook sessions. I have updated it to also monitor terminal sessions. This enhancement is vital as the instance will not stop if there are any non-idle notebook sessions.
Testing Done
[x] Notebook Instance created successfully with the Lifecycle Configuration
[x] Notebook Instance stopped and started successfully
[NA] Documentation in the script around any network access requirements
[NA] Documentation in the script around any IAM permission requirements
[x] CLI commands used to validate functionality on the instance
[NA] New script link and description added to README.md
| 2023-12-12T11:52:04.602+09:00 | [I 2023-12-12 02:51:59.963 ServerApp] New terminal with automatic name: 1
| 2023-12-12T11:52:20.603+09:00 | [I 2023-12-12 02:52:15.685 ServerApp] New terminal with automatic name: 2
| 2023-12-12T11:55:02.391+09:00 | Kernel is not idle. Last activity time = 2023-12-12 02:51:43.955000
| 2023-12-12T11:55:02.391+09:00 | Notebook idle state set as False since no sessions detected.
| 2023-12-12T11:55:02.391+09:00 | {'name': '1', 'last_activity': '2023-12-12T02:53:44.396492Z'}
| 2023-12-12T11:55:02.391+09:00 | Kernel is not idle. Last activity time = 2023-12-12 02:53:44.396492
| 2023-12-12T11:55:02.391+09:00 | {'name': '2', 'last_activity': '2023-12-12T02:53:00.323036Z'}
| 2023-12-12T11:55:02.391+09:00 | Kernel is not idle. Last activity time = 2023-12-12 02:53:00.323036
| 2023-12-12T11:55:06.602+09:00 | Kernel not idle. Pass.
| 2023-12-12T12:00:01.980+09:00 | Kernel is not idle. Last activity time = 2023-12-12 02:51:43.955000
| 2023-12-12T12:00:01.980+09:00 | Notebook idle state set as False since no sessions detected.
| 2023-12-12T12:00:01.980+09:00 | {'name': '1', 'last_activity': '2023-12-12T02:53:44.396492Z'}
| 2023-12-12T12:00:01.980+09:00 | Kernel is not idle. Last activity time = 2023-12-12 02:53:44.396492
| 2023-12-12T12:00:01.980+09:00 | {'name': '2', 'last_activity': '2023-12-12T02:55:38.896191Z'}
| 2023-12-12T12:00:01.980+09:00 | Kernel is not idle. Last activity time = 2023-12-12 02:55:38.896191
| 2023-12-12T12:00:06.602+09:00 | Kernel not idle. Pass.
| 2023-12-12T12:05:02.021+09:00 | Kernel is idle. Last activity time = 2023-12-12 02:51:43.955000
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Issue #, if available: Issue: https://github.com/aws-samples/amazon-sagemaker-notebook-instance-lifecycle-config-samples/issues/90
Description of changes: The current sample lifecycle configuration only checks for notebook sessions. I have updated it to also monitor terminal sessions. This enhancement is vital as the instance will not stop if there are any non-idle notebook sessions.
Testing Done
Idle time is set to 10 minutes.
Logs showing kernel activity:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.