smp_time モジュール
TIPCommon.smp_time.change_timezone
TIPCommon.smp_time.change_timezone(dtime: datetime, current_tz: str, new_tz: str)→ datetime
datetime.datetime
オブジェクトのタイムゾーンを変更します。
パラメータ
パラメータ | |
---|---|
dtime |
datetime.datetime タイムゾーンが変更された datetime オブジェクト。 |
current_tz |
str 現在のタイムゾーン。 |
new_tz |
str 変更先のタイムゾーン。 |
戻り値
新しいタイムゾーンの新しい datetime オブジェクト。
戻り値の型
datetime.datetime
発生
ValueError
- タイムゾーンのいずれかが無効な場合。
TIPCommon.smp_time.convert_string_to_timestamp
TIPCommon.smp_time.convert_string_to_timestamp(datetime_string: str)→ int
日時文字列をタイムスタンプに変換します。
パラメータ
パラメータ | |
---|---|
datetime_string |
str 日時文字列。 |
戻り値
タイムスタンプ。
戻り値の型
int
TIPCommon.smp_time.datetime_to_rfc3339
TIPCommon.smp_time.datetime_to_rfc3339(datetime_obj: datetime)→ str
datetime オブジェクトを RFC 3999 表現に変換します。
パラメータ
パラメータ | |
---|---|
datetime_obj |
datetime.datetime 変換する datetime オブジェクト。 |
戻り値
日時の RFC 3339 表現。
戻り値の型
str
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)
最後に成功した時刻または日時を取得します。
パラメータ | |
---|---|
siemplify |
obj SDK |
offset_with_metric |
dict 指標と値。 |
time_format |
int 出力時間の形式。 |
print_value |
Optional
値を出力するかどうかを示します。 |
microtime |
Optional
マイクロタイムを含む Unix 時間を返すかどうかを示します。 |
戻り値
前回の成功日時。
戻り値の型
Time
TIPCommon.smp_time.get_timestamps
TIPCommon.smp_time.get_timestamps(range_string: str, start_time_string: str, end_time_string: str, error_message: str = None, time_in_milliseconds: bool = False)→ tuple[int, int]
開始時刻と終了時刻のタイムスタンプを取得します。
パラメータ
パラメータ | |
---|---|
range_string |
str 期間文字列。 |
start_time_string |
str 開始時間。 |
end_time_string |
str 終了時間。 |
error_message |
str 発生した例外のエラー メッセージ。 デフォルトは |
time_in_milliseconds |
bool 開始時間と終了時間をミリ秒単位で返すかどうかを定義します。 デフォルトは |
戻り値
開始時間と終了時間のタイムスタンプ。
戻り値の型
tuple
TIPCommon.smp_time.get_timestamps_from_range
TIPCommon.smp_time.get_timestamps_from_range(range_string: str, include_timezone: bool = False)→ tuple[datetime, datetime]
範囲から開始時刻と終了時刻のタイムスタンプを取得します。
パラメータ
パラメータ | |
---|---|
range_string |
str 期間文字列。 |
include_timezone |
bool, optional タイムスタンプにタイムゾーン情報を含めるかどうかを定義します。 デフォルトは |
戻り値
開始時間と終了時間のタイムスタンプ。
戻り値の型
tuple
TIPCommon.smp_time.is_approaching_action_timeout
TIPCommon.smp_time.is_approaching_action_timeout(action_execution_deadline_in_unix, timeout_threshold_in_sec=10)
アクション スクリプトが専用スクリプトの期限に近づいているかどうかを確認します。
各アクション スクリプトには、専用の特定の期限があります。この関数は、現在時刻が締め切り時刻より timeout_threshold_in_sec
秒以上早いかどうかを確認します。デフォルトは 10 秒です。つまり、アクションがスクリプトの期限(チェック時)から 10 秒以内である場合、関数は True
を返します。期限を超えると、関数は False
を返します。
パラメータ | |
---|---|
action_execution_deadline_in_unix |
int アクション実行の期限。 |
timeout_threshold_in_sec |
int タイムアウトのしきい値(秒単位)。 |
戻り値
タイムアウトが近づいている場合は True
、それ以外の場合は False
。
TIPCommon.smp_time.is_approaching_timeout
TIPCommon.smp_time.is_approaching_timeout(connector_starting_time, python_process_timeout, timeout_threshold=0.9)
タイムアウトが近づいているかどうかを確認します。
パラメータ | |
---|---|
connector_starting_time |
int コネクタの開始時刻。 |
python_process_timeout |
int コネクタの実行が許可される最大時間。 |
timeout_threshold |
float コネクタがタイムアウトに近づいていると見なされるしきい値。 |
戻り値
コネクタがタイムアウトに近づいている場合は True
、それ以外の場合は False
。
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)
指定されたアラートの最後のタイムスタンプを保存します。
パラメータ | |
---|---|
siemplify |
obj SDK |
alerts |
dict 最後の日時を検索するアラートのリスト。 |
timestamp_key |
Optional
アラートからタイムスタンプを取得するためのキー。 |
incrementation_value |
Optional
最後のタイムスタンプを増分する値(ミリ秒単位)。 |
log_timestamp |
Optional
タイムスタンプを記録するかどうかを示します。 |
convert_timestamp_to_micro_time |
Optional
タイムスタンプをマイクロタイムに変換するかどうかを示します。 |
convert_a_string_timestamp_to_unix |
Optional
文字列のタイムスタンプを Unix に変換するかどうかを示します。 |
戻り値
タイムスタンプが更新されるかどうかを示すブール値。
TIPCommon.smp_time.siemplify_fetch_timestamp
TIPCommon.smp_time.siemplify_fetch_timestamp(siemplify, datetime_format=False, timezone=False)
Siemplify からタイムスタンプを取得します。
パラメータ | |
---|---|
siemplify |
obj SDK |
datetime_format |
Optional
タイムスタンプを |
timezone |
Optional
タイムスタンプを UTC タイムゾーンで返すかどうかを示します。 |
戻り値
タイムスタンプ。
TIPCommon.smp_time.siemplify_save_timestamp
TIPCommon.smp_time.siemplify_save_timestamp(siemplify, datetime_format=False, timezone=False, new_timestamp=1696256382032)
タイムスタンプを Siemplify に保存します。
パラメータ | |
---|---|
siemplify |
obj
SDK |
datetime_format |
Optional
タイムスタンプを |
timezone |
Optional
タイムスタンプを UTC タイムゾーンで保存するかどうかを示します。 |
new_timestamp |
Optional
保存する新しいタイムスタンプ。 |
戻り値
なし
TIPCommon.smp_time.validate_timestamp
TIPCommon.smp_time.validate_timestamp(last_run_timestamp, offset_in_hours, offset_is_in_days=False)
タイムスタンプが時間範囲内にあることを検証します。
パラメータ | |
---|---|
last_run_timestamp |
datetime 前回の実行のタイムスタンプ。 |
offset_in_hours |
int 制限時間(単位: 時間)。 |
offset_is_in_days |
Optional
オフセットが日数で指定されているかどうかを示します。 |
発生
ValueError
- タイムスタンプが無効な場合。
戻り値
検証済みのタイムスタンプ。
戻り値の型
datetime
さらにサポートが必要な場合 コミュニティ メンバーや Google SecOps のプロフェッショナルから回答を得ることができます。