[27859] in Source-Commits
lert-compat commit: Display lert messages correctly
daemon@ATHENA.MIT.EDU (Victor Vasiliev)
Fri Mar 14 21:37:20 2014
Date: Fri, 14 Mar 2014 21:37:01 -0400
From: Victor Vasiliev <vasilvv@MIT.EDU>
Message-Id: <201403150137.s2F1b1XZ022104@drugstore.mit.edu>
To: source-commits@MIT.EDU
https://github.com/mit-athena/lert-compat/commit/e907629675c6442dd0225957b8498562c09abf0a
commit e907629675c6442dd0225957b8498562c09abf0a
Author: Victor Vasiliev <vasilvv@mit.edu>
Date: Fri Mar 14 21:19:42 2014 -0400
Display lert messages correctly
Turns out, lert server just tells us the suffix for the file in AFS with
the message in question instead of the message itself.
lert | 9 ++++++++-
1 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/lert b/lert
index 2cf23ee..39bec24 100755
--- a/lert
+++ b/lert
@@ -23,6 +23,7 @@ LERT_TIMEOUT = 1
LERT_SERVICE = 'daemon'
LERT_PORT = 3717
LERT_MAX_PACKET_SIZE = 2048
+LERT_MESSAGE_PATH_BASE = '/afs/athena/system/config/lert/lert'
LERT_BAD = '0'
LERT_FREE = '1'
@@ -88,7 +89,9 @@ def lert(server, acknowledge):
if response_code == LERT_SICK:
raise LertError("lert server is malfunctioning")
if response_code == LERT_MSG:
- return response[2:]
+ file_suffix = response[2:]
+ with open(LERT_MESSAGE_PATH_BASE + file_suffix, 'r') as f:
+ return f.read().strip()
if response_code == LERT_FREE:
return ""
raise LertError("lert server returned invalid status code")
@@ -123,6 +126,10 @@ def main(args):
try:
message = lert(server, args.no)
if message:
+ header_path = LERT_MESSAGE_PATH_BASE + ('1' if args.no else '0')
+ with open(header_path, 'r') as f:
+ print f.read().strip()
+ print
print message
except Exception as err:
if not args.quiet: