Patroni plugin not working helllp

CMK version:
Checkmk Raw Edition 2.2.0p6
OS version:
Error message:

Output of “cmk --debug -vvn hostname”: (If it is a problem with checks or plugins)

I created an adaptation of a plugin for several probes for the patroni postgresql solution, here is an example of the script on my agent:

#!/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):
    with urllib.request.urlopen(url) as response:
        data = response.read()
    patroni = json.loads(data)
    return patroni.get("patroni", {}).get("version", "unknown")

def main():
    patroni_version = get_node_patroni_version(PATRONI_NODE_URL)
    print("<<<patroni_node_patroni_version>>>")
    print(f"patroni_version={patroni_version}")

if __name__ == '__main__':
    main()

Exit :

<<<patroni_node_patroni_version>>>
patroni_version=3.2.2

So far everything is OK but by doing a rescan on the server, I have nothing displayed in the HMI :-5
Do you have an idea please??

I don’t know anything about patroni but I know that for the agent output

<<<patroni_node_patroni_version>>>
patroni_version=3.2.2

you would need a check plugin on the server side that recognises the section <<<patroni_node_patroni_version>>> and handles its data.

Do you have such a check plugin installed on your checkmk server?

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.

More details here:

1 Like

THHHHHAAAAAAAAANNNNNNKKKKK you

#!/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()

1 Like

Please, a version number is not a metric. Change the output to

print(f"0 \"My Patroni Version\" - Version is {patroni_version}")

2 Likes

Thank you very much to all

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.