smp_time module
TIPCommon.smp_time.get_last_success_time
TIPCommon.smp_time.get_last_success_time(siemplify, offset_with_metric, time_format=2, print_value=True, microtime=False)
Get the last success time or datetime.
Parameters | |
---|---|
siemplify |
obj An instance of the SDK
|
offset_with_metric |
dict The metric and value. |
time_format |
int The format of the output time. |
print_value |
Optional
Indicates whether to print
the value or not. |
microtime |
Optional
Indicates whether to return
Unix time including microtime. |
Returns
The last success time.
Return type
Time
TIPCommon.smp_time.is_approaching_action_timeout
TIPCommon.smp_time.is_approaching_action_timeout(action_execution_deadline_in_unix, timeout_threshold_in_sec=10)
Check if the action script is approaching its dedicated script deadline.
Each action script has a specific deadline dedicated to it. This function checks
if the current time is less than the deadline by at least
timeout_threshold_in_sec
seconds. The default is 10 seconds, meaning that if
the action is 10 or less seconds from its script deadline (at the time of the
check) the function returns True
. If the deadline is exceeded, the function
returns False
.
Parameters | |
---|---|
action_execution_deadline_in_unix |
int The deadline for action execution. |
timeout_threshold_in_sec |
int The timeout threshold in seconds. |
Returns
True
if timeout is approaching, False
otherwise.
TIPCommon.smp_time.is_approaching_timeout
TIPCommon.smp_time.is_approaching_timeout(connector_starting_time, python_process_timeout, timeout_threshold=0.9)
Check if a timeout is approaching.
Parameters | |
---|---|
connector_starting_time |
int The time the connector started. |
python_process_timeout |
int The maximum amount of time the connector is allowed to run. |
timeout_threshold |
float The threshold at which the connector is considered
to be approaching a timeout. |
Returns
True
if the connector is approaching a timeout, False
otherwise.
TIPCommon.smp_time.save_timestamp
TIPCommon.smp_time.save_timestamp(siemplify, alerts, timestamp_key='timestamp', incrementation_value=0, log_timestamp=True, convert_timestamp_to_micro_time=False, convert_a_string_timestamp_to_unix=False)
Save the last timestamp for given alerts.
Parameters | |
---|---|
siemplify |
obj An instance of the SDK
|
alerts |
dict The list of alerts to find the last timestamp. |
timestamp_key |
Optional
The key for getting timestamp
from alert. |
incrementation_value |
Optional
The value to increment the
last timestamp in milliseconds. |
log_timestamp |
Optional
Indicates whether to log the
timestamp or not.
|
convert_timestamp_to_micro_time |
Optional
Indicates whether to convert
the timestamp to microtime. |
convert_a_string_timestamp_to_unix |
Optional
Indicates whether to convert
a string timestamp to Unix. |
Returns
Boolean indicating whether the timestamp is updated.
TIPCommon.smp_time.siemplify_fetch_timestamp
TIPCommon.smp_time.siemplify_fetch_timestamp(siemplify, datetime_format=False, timezone=False)
Fetch the timestamp from Siemplify.
Parameters | |
---|---|
siemplify |
obj An instance of the SDK
|
datetime_format |
Optional
Indicates whether to return the timestamp in a |
timezone |
Optional
Indicates whether to return the timestamp in a UTC timezone.
|
Returns
The timestamp.
TIPCommon.smp_time.siemplify_save_timestamp
TIPCommon.smp_time.siemplify_save_timestamp(siemplify, datetime_format=False, timezone=False, new_timestamp=1696256382032)
Save the timestamp to Siemplify.
Parameters | |
---|---|
siemplify |
obj
An instance of the SDK |
datetime_format |
Optional
Indicates whether to save the timestamp in a |
timezone |
Optional
Indicates whether to save the timestamp in a UTC timezone.
|
new_timestamp |
Optional
The new timestamp to save. |
Returns
None
TIPCommon.smp_time.validate_timestamp
TIPCommon.smp_time.validate_timestamp(last_run_timestamp, offset_in_hours, offset_is_in_days=False)
Validates the timestamp in a time range.
Parameters | |
---|---|
last_run_timestamp |
datetime The last run timestamp. |
offset_in_hours |
int The time limit in hours. |
offset_is_in_days |
Optional
Indicates whether the offset is in days.
|
Raises
ValueError
, if the timestamp is not valid.
Returns
The validated timestamp.
Return type
datetime