I'm using Notepad++ and I would like to ask for help to achieve the following.
I have some(several 1000 lines) Nagios/Icinga config that looks like this:
define host {
use generic-host
host_name FakeNameA-748-SomeNameA
alias FakeNameA-748-SomeNameA
address 10.1.1.97
}
define host {
use generic-host
host_name H548-AP02
alias H548-AP02
address 172.19.115.190
}
define host {
use generic-host
host_name FakeNameB-302-SomeNameB
alias FakeNameB-302-SomeNameB
address 192.168.149.1
}
define host {
use generic-host
host_name FakeNameC-902-Acronym
alias FakeNameC-902-Acronym
address 192.168.48.1
}
define host {
use generic-host
host_name H902-AP01
alias H902-AP01
address 192.168.48.190
}
I need to create some hostgroups that contain all the host names, but in two groups.
Like this:
define hostgroup {
hostgroup_name GroupA
alias GroupA
members FakeNameA-748-SomeNameA,FakeNameB-302-SomeNameB,FakeNameC-902-Acronym
}
define hostgroup {
hostgroup_name GroupB
alias GroupB
members H548-AP02,H902-AP01
}
As you can see, if the "host_name" contains "AP" it should go into GroupB and everything else into GroupA(note that they should be comma separated).
Does anyone have some idea of how i could automate this?
Thank you for your time :)