If you want to have those labels in RAW Edition too, this is a Solution:
You need to modify the mail plugin and add the values to the context.
After this the mail plugin runs correctly with the missing host attributes
class SingleEmailContent(EmailContent):
def __init__(self, context_function: Callable[[], dict[str, str]]) -> None:
# gather all options from env
context = context_function()
######KPC PART FOR ADDING HOST ATTRIBUTE SUPPORT IN RAW EDITION___START######
hostattributes=subprocess.getoutput(f"""lq "GET hosts\nColumns: custom_variable_names custom_variable_values\nOutputFormat: json\nFilter: host_name = {context['HOSTNAME']}" """)
hostattributes=json.loads(hostattributes)
#with open('/opt/omd/sites/raw_monitoring/test1.log','a') as file:
#file.write(json.dumps(hostattributes,indent=4))
for k, v in hostattributes:
res = {keys: [i for _, i in sub] for keys, sub in groupby(zip(k, v), key = itemgetter(0))}
res=str(res)
res=res.replace("[","")
res=res.replace("]","")
res=ast.literal_eval(res)
res={f'HOST_{k}': v for k, v in res.items()}
context = context|res
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed. Contact an admin if you think this should be re-opened.