Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added event for container_checker #20

Merged
merged 3 commits into from
Sep 12, 2022
Merged
Changes from 1 commit
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
Prev Previous commit
Publish events for ctr not running
renukamanavalan committed Sep 12, 2022
commit 9e375aa201573623b24e839359cab99f3ccd2b9f
15 changes: 15 additions & 0 deletions files/image_config/monit/container_checker
Original file line number Diff line number Diff line change
@@ -22,6 +22,9 @@ import sys
from sonic_py_common import multi_asic, device_info
from swsscommon import swsscommon

EVENTS_PUBLISHER_SOURCE = "sonic-events-host"
EVENTS_PUBLISHER_TAG = "event-container"

def get_expected_running_containers():
"""
@summary: This function will get the expected running & always-enabled containers by following the rule:
@@ -150,6 +153,17 @@ def get_current_running_containers(always_running_containers):
return current_running_containers


def publish_events(lst):
events_handle = swsscommon.events_init_publisher(EVENTS_PUBLISHER_SOURCE)
params = swsscommon.FieldValueMap()

for ctr in lst:
params["name"] = ctr;
swsscommon.event_publish(events_handle, EVENTS_PUBLISHER_TAG, params)

swsscommon.events_deinit_publisher(events_handle)


def main():
"""
@summary: This function will compare the difference between the current running containers
@@ -162,6 +176,7 @@ def main():
expected_running_containers |= always_running_containers
not_running_containers = expected_running_containers.difference(current_running_containers)
if not_running_containers:
publish_events(not_running_containers)
print("Expected containers not running: " + ", ".join(not_running_containers))
sys.exit(3)