Search code examples
monitoringshinken

how work with shinken livestatus API


Good day. I first work with Shinken and similar products in general.So do not judge strictly.
The question is how to get the data through Shinken Livestatus API.
Shinken is installed and running. Livestatus is configured and running on the localhost:50000. Ping is coming.
But I can not understand how to ask something, get some data. The documentation did not shed much light on my question. And whether it is possible through this API to receive metrics which sends CollecD to mod-collectd


Solution

  • After experimenting and studying the source code, I came to this conclusion.
    In the livestatus module, you can open a port or unixsocket, this is understandable. But here you can refer to it from the commands found in the source code mapping.py in the dictionary livestatus_attribute_map.
    The main thing after the request is to put two line breaks !!!

    Example thru HTTP:
    curl -i -X POST  http://host:50000/query -H "Content-Type: text/xml" --data-binary "@/path_to_query/query"
    

    query - this is file, with command.

    Example: cat query
    ----------------------
    GET hosts
    
    
    ----------------------
    

    The main thing is not to forget about the transfer line!