From 93071b06f40956e5c5bbc00192c5f7de23aecbb5 Mon Sep 17 00:00:00 2001 From: Jeewon Chae Date: Wed, 14 Aug 2024 08:40:50 -0700 Subject: [PATCH] Add heartbeat log to munki Differential Revision: D61227682 fbshipit-source-id: d433509e146a594885ea844acb7a1a138546e69a --- .../cpe_munki/files/default/munki_preflight.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/itchef/cookbooks/cpe_munki/files/default/munki_preflight.py b/itchef/cookbooks/cpe_munki/files/default/munki_preflight.py index f21f2d07..9e96a0d7 100644 --- a/itchef/cookbooks/cpe_munki/files/default/munki_preflight.py +++ b/itchef/cookbooks/cpe_munki/files/default/munki_preflight.py @@ -11,6 +11,7 @@ MUNKI_PAUSE_TRIGGER = "/Users/Shared/.pause_munki" MUNKI_PAUSE_RECEIPT = "/Library/CPE/tags/.munki_has_been_paused" +HEARTBEAT = "/opt/facebook/bin/heartbeat" def check_munki_pause() -> None: @@ -52,8 +53,23 @@ def check_munki_pause() -> None: print(f"Unable to clear pause receipt: {e}") +def send_heartbeat() -> None: + cmd = [ + HEARTBEAT, + "--tag", + "munki_runs", + "-token_file", + "/Library/CPE/var/heartbeat_token.txt", + "&>/dev/null", + ] + proc = subprocess.run(cmd, stdout=subprocess.PIPE) + + def main() -> None: + print("Gathering run data...") + if os.path.exists(HEARTBEAT): + send_heartbeat() # Verify munki pause check_munki_pause() print("Preflight completed successfully.")