Возникла следующая задача: необходимо создать конфиг файл nagios по определенному шаблону. Например:
у шаблона такой вид:
define service{ use generic-service ; Name of service template to use host_name @HOST@ service_description @SERVICE@ is_volatile 0 check_period 24x7 max_check_attempts 4 normal_check_interval 1 retry_check_interval 1 contact_groups users notification_options w,u,c,r notification_interval 960 notification_period 24x7 check_command check_@service@ }
serv1
tcp 53
tcp 20000
tcp 35353
serv2
ping
tcp 30000
serv3
и т.д.
В общем на выходе нужен общий файл с соответствующими подстановками, т.е.,например:
define service{ use generic-service ; Name of service template to use host_name serv1 service_description tcp 53 is_volatile 0 check_period 24x7 max_check_attempts 4 normal_check_interval 1 retry_check_interval 1 contact_groups users notification_options w,u,c,r notification_interval 960 notification_period 24x7 check_command check_tcp!53 } define service{ use generic-service ; Name of service template to use host_name serv1 service_description tcp 20000 is_volatile 0 check_period 24x7 max_check_attempts 4 normal_check_interval 1 retry_check_interval 1 contact_groups users notification_options w,u,c,r notification_interval 960 notification_period 24x7 check_command check_tcp!20000 }