Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions iShutdown_detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,21 @@
import re
import tarfile
from datetime import datetime
from termcolor import colored


def count_occurrences(content, target_phrase):
return content.count(target_phrase)


def print_colored(text, color, blink=False):
attrs = ['blink'] if blink else None
print(colored(text, color, attrs=attrs))
def print_colored(text, color):
if color == 'red':
print("\033[91m {}\033[00m" .format(text))
elif color == 'yellow':
print("\033[93m {}\033[00m" .format(text))
elif color == 'green':
print("\033[92m {}\033[00m" .format(text))
else:
print(text)


def find_anomalies_before_sigterm(content, anomaly_phrase, threshold=3):
Expand Down