In case you only would like to know the version and display it on checkmk server you might better make use of a local check output. For local checks you don’t have to program the backend stuff at the checkmk server side.
Just place your script at ~/<agent_home>/local ( by default /usr/lib/check_mk_agent/local/ )
# NOT NEEDED for Local Check - print("<<<patroni_node_patroni_version>>>")
# Add 0 for OK for local check output
print(f"0 \"My Patroni Version\" patroni_version {patroni_version}")
Now rediscover the system and you should find the version at checkmk.
#!/usr/bin/env python3
import urllib.request
import json
PATRONI_NODE_URL = 'http://X.X.X.X:8008/patroni'
def get_node_patroni_version(url):
try:
with urllib.request.urlopen(url) as response:
data = response.read()
patroni = json.loads(data)
version = patroni.get("patroni", {}).get("version", "unknown")
return version
except Exception as e:
print(f"Error: {e}")
return "unknown"
def main():
patroni_version = get_node_patroni_version(PATRONI_NODE_URL)
# Formater la sortie pour Checkmk en précisant que ce n'est pas une métrique mais une information
print(f'0 "Version Patroni" - Version is {patroni_version}')
if __name__ == '__main__':
main()
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.