[Check_mk (english)] Setting the parent field in host definition

Good afternoon,

Would it be possible to write a script to add the parents of my hosts without me having to do it manually on all my hosts?

I know we do have the Parent Scan on Check_MK but I’m trying to find a way where I’ll be able to tell who’s the parent of a given host.
I wrote such script, it works just fine with the other features we want but when it comes to the parents, it writes to the host.mk file (following the spacing and syntax of the structure) but is, somehow, removed after I restart my site.

All my other features (alias, agent type, criticality, networking segment, IP address family, etc) stay exactly the same as I had in my .csv file but the parents field is still empty (default value) even when the field in the .csv file is not empty.

Thanks in advance!

Hi Gabriel,

for this to achieve the WATO web api should be the best way. With the method “edit_host” it is possible to set the host attributes and the parent is only a host attribute.

Try to get some information of existing hosts with “get_host” to see how the attributes should look like.

The documentation for the api is not up-to-date but as an example this should help - https://mathias-kettner.de/checkmk_wato_webapi.html

Best regards

Andreas

···

Gabriel Vilela gabrieldvilela@gmail.com schrieb am Mo., 3. Juli 2017 um 19:08 Uhr:

Good afternoon,

Would it be possible to write a script to add the parents of my hosts without me having to do it manually on all my hosts?

I know we do have the Parent Scan on Check_MK but I’m trying to find a way where I’ll be able to tell who’s the parent of a given host.
I wrote such script, it works just fine with the other features we want but when it comes to the parents, it writes to the host.mk file (following the spacing and syntax of the structure) but is, somehow, removed after I restart my site.

All my other features (alias, agent type, criticality, networking segment, IP address family, etc) stay exactly the same as I had in my .csv file but the parents field is still empty (default value) even when the field in the .csv file is not empty.

Thanks in advance!


checkmk-en mailing list

checkmk-en@lists.mathias-kettner.de

http://lists.mathias-kettner.de/mailman/listinfo/checkmk-en

I wrote something similar to set the parent of VMs to the hypervisor they run on.

The script reads the info from the service check "ESX Hostsystem".

You can find it on https://github.com/HeinleinSupport/check_mk/blob/master/helper/vm_parent.py
and the API wrapper on https://github.com/HeinleinSupport/check_mk/blob/master/helper/checkmkapi.py

Regards

···

On 2017-07-03 19:07, Gabriel Vilela wrote:

Would it be possible to write a script to add the parents of my hosts
without me having to do it manually on all my hosts?

--
Robert Sander
Heinlein Support GmbH
Schwedter Str. 8/9b, 10119 Berlin

Tel: 030 / 405051-43
Fax: 030 / 405051-19

Zwangsangaben lt. §35a GmbHG:
HRB 93818 B / Amtsgericht Berlin-Charlottenburg,
Geschäftsführer: Peer Heinlein -- Sitz: Berlin

Hello Andreas,

I didn’t know about such API, was doing everything by one of our scripts and having some issues with it but now things got easier.

I just had to create the automation user, get the automation secret and it seems like things are working just fine for me.

Once again, thanks Andreas!

Best regards,

Gabriel

···

2017-07-03 17:25 GMT-03:00 Andreas Döhler andreas.doehler@gmail.com:

Hi Gabriel,

for this to achieve the WATO web api should be the best way. With the method “edit_host” it is possible to set the host attributes and the parent is only a host attribute.

Try to get some information of existing hosts with “get_host” to see how the attributes should look like.

The documentation for the api is not up-to-date but as an example this should help - https://mathias-kettner.de/checkmk_wato_webapi.html

Best regards

Andreas

Gabriel Vilela gabrieldvilela@gmail.com schrieb am Mo., 3. Juli 2017 um 19:08 Uhr:

Good afternoon,

Would it be possible to write a script to add the parents of my hosts without me having to do it manually on all my hosts?

I know we do have the Parent Scan on Check_MK but I’m trying to find a way where I’ll be able to tell who’s the parent of a given host.
I wrote such script, it works just fine with the other features we want but when it comes to the parents, it writes to the host.mk file (following the spacing and syntax of the structure) but is, somehow, removed after I restart my site.

All my other features (alias, agent type, criticality, networking segment, IP address family, etc) stay exactly the same as I had in my .csv file but the parents field is still empty (default value) even when the field in the .csv file is not empty.

Thanks in advance!


checkmk-en mailing list

checkmk-en@lists.mathias-kettner.de

http://lists.mathias-kettner.de/mailman/listinfo/checkmk-en