BASH kullanarak Nagios eklenti hizmet tanımında değişiklik yapmak için bir komut dosyası üzerinde çalışıyorum. Kişi grubu adı satırını eklemem gerekiyor, ancak yalnızca belirli hizmet tanımları için. Bununla başlayayım diye.
define service {
use sites-service
host_name my_host
service_description check_reboot_os_updates
check_command check_reboot_os_updates
contact_groups contactgroup1
servicegroups MyGroup
}
define service {
use linux-service
host_name my_host
service_description other_description
check_command other_command
contact_groups contactgroup1
servicegroups MyGroup
}
Ve sadece seçili kişi grubu satırlarını eklemek istiyorum. Bu yüzden, bunun gibi Linux hizmetlerine ek bir iletişim grubu eklemek istediğimi varsayalım.
define service {
use sites-service
host_name my_host
service_description check_reboot_os_updates
check_command check_reboot_os_updates
contact_groups contactgroup1
servicegroups MyGroup
}
define service {
use linux-service
host_name my_host
service_description other_description
check_command other_command
contact_groups contactgroup1, contactgroup2
servicegroups MyGroup
}
Bunu sed veya awk veya başka bir şey kullanarak yapabilmemin bir yolu var mı?