Add host using a script
Posted: Fri Nov 15, 2024 5:49 am
Hello,
I am trying to code bash script which basically add a host to nagios.
It creates a .cfg file into the repertory where all hosts .cfg file are located after asking some input such as the host_name, ip address etc ...
It does work, but not totally. I mean, it does appear on Nagios web interface after a restart however there's some troubleshooting
If I am looking for the host created by my script through the web interface, it's okay.
However if I am looking at it from Core Config Manager, it doesn't appear anymore and cannot be edited from the web interface
I am wondering if I missed anything> My script is quite simple and does something like this (Can not copy paste)
echo "define host {
(tab) host_name $HOST_NAME
...
}" >> /etc/loca/nagios/etc/hosts/${HOST_NAME}.cfg
I am trying to code bash script which basically add a host to nagios.
It creates a .cfg file into the repertory where all hosts .cfg file are located after asking some input such as the host_name, ip address etc ...
It does work, but not totally. I mean, it does appear on Nagios web interface after a restart however there's some troubleshooting
If I am looking for the host created by my script through the web interface, it's okay.
However if I am looking at it from Core Config Manager, it doesn't appear anymore and cannot be edited from the web interface
I am wondering if I missed anything> My script is quite simple and does something like this (Can not copy paste)
echo "define host {
(tab) host_name $HOST_NAME
...
}" >> /etc/loca/nagios/etc/hosts/${HOST_NAME}.cfg