Bulk import - parent

When doing bulk import, is there a way to also specify the parent field?
With 1000+ hosts we van easily provide this info in the CSV file.
Can I adjust the interpretation for bulk import to also accept a PARENT input field?

Sadly, it looks like this is currently not possible.
According to the inline help for a CSV import, the currently available attributes are:

  • ‐ (Don’t import)
  • host_name (Hostname)
  • alias (Alias)
  • site (Monitored on site)
  • ipaddress (IPv4 Address)
  • ipv6address (IPv6 Address)
  • snmp_community (SNMP Community)
  • tag_criticality (Tag: Criticality)
  • tag_networking (Tag: Networking Segment)
  • tag_agent (Tag: Check_MK Agent)
  • tag_piggyback (Tag: Piggyback)
  • tag_snmp_ds (Tag: SNMP)
  • tag_address_family (Tag: IP Address Family)

Depending on your host and folder hierarchy, perhaps you can set the parent in the top folder and have most of the sub-folders inherit the value, so you only have a few hosts/folders left where you need to set it explicitely?
Perhaps the network discovery feature also helps?
Or you can edit the resulting hosts.mk file to add the parent later on?

But I agree that it would be nice to be able to also set the parent attribute in a CSV import.

(edit: removed my custom-added tag attributes)

Hi,
as @martin.schwarz wrote, it’s not possible in the GUI. You can use the web API for this.

Example CSV file:

web021;berlin/network;10.0.0.10;hamburg;localhost;os_w10
mail006;kiel/infrastructure;10.0.0.11;hamburg;;os_debian

Example shell script:

#!/bin/bash
while IFS=';' read HOST FOLDER IP SITE PARENT OS
 do
  curl "http://CMKSERVER/YOURSITE/check_mk/webapi.py?action=add_host&_username=YOURAUTOMATIONUSER&    _secret=YOURSECRET" -d\
 'request={"hostname":"'"$HOST"'","folder":"'"$FOLDER"'","attributes":{"ipaddress":"'"$IP"'","site":"'"$SITE"'","parents":["'"$PARENT"'"],"tag_Betriebssystem":"'"$OS"'"},"create_folders":"1"}'
  done < import.csv

Karl

2 Likes