Page 1 of 1
change switch IP
Posted: Wed May 13, 2020 2:47 pm
by MelsStudios
Hello,
We monitor many switches with nagiosXI,
We are doing some changes on our network and will modify some switches IPs.
If I change the IP for the host within the CCM, the change will not apply to it's services ( ports ) then my dashbord won't be accurate and all.
Is there a way to change the IP in the services configuration ?
I looked into the bulk modification tool but I'm not sure it is what I need, or maybe I do not understant how I can do it with that tool.
Thanks !
Re: change switch IP
Posted: Thu May 14, 2020 12:45 pm
by ssax
The easiest way would be to remove/readd it with the switch wizard again.
If you really want to redo them, this would be the process:
You would need to do four things:
1. Modify the host in
Configure > Core Config Manager > Hosts.
2. Rename the files in /var/lib/mrtg:
- Change all occurrences of X.X.X.X to the old IP, change all occurrences of Y.Y.Y.Y to the new IP
Code: Select all
rename X.X.X.X Y.Y.Y.Y /var/lib/mrtg/*.rrd
3. Modify the MRTG config file for the switch in
/etc/mrtg/conf.d for the device as well to change the IP.
- Change all occurrences of X.X.X.X to the old IP, change all occurrences of Y.Y.Y.Y to the new IP
Code: Select all
sed -i 's/X.X.X.X/Y.Y.Y.Y/g' /etc/mrtg/conf.d/X.X.X.X.cfg
4. Update the bandwidth services to change the $ARG1$ value from:
To:
You can either do that manually or do something like this then apply config:
- Change all occurrences of X.X.X.X to the old IP, change all occurrences of Y.Y.Y.Y to the new IP
NOTE: BEFORE YOU RUN THIS, MAKE SURE YOU HAVE AN XI BACKUP as directly interacting with the DB can cause issues if you're not very careful with the commands.
Code: Select all
mysql -h 127.0.0.1 -uroot -pnagiosxi nagiosql -e 'UPDATE tbl_service SET check_command = REPLACE(check_command, "X.X.X.X", "Y.Y.Y.Y") WHERE check_command LIKE "%X.X.X.X_%.rrd%";'
Note: You can always revert to a config snapshot in Admin > Config Snapshot if you have any issues.
Re: change switch IP
Posted: Thu May 14, 2020 1:40 pm
by MelsStudios
Thanks for you solutions,
I have many dashboards for many users, If I remove / re-add with the switch wizard, will the dashboard get updated with the new IP ? or I will have to re-do every dashboards ?
Thanks !
Re: change switch IP
Posted: Fri May 15, 2020 2:36 pm
by ssax
I think it would only impact it if you also change the hostname (instead of just the address).
If you change hostname or servicename it will impact the historical data and dashboards.
Re: change switch IP
Posted: Tue May 19, 2020 8:36 am
by MelsStudios
All right, Thank you for your help,
that answered my question.
Re: change switch IP
Posted: Tue May 19, 2020 2:49 pm
by benjaminsmith
Hello
@MelsStudios,
All right, Thank you for your help,
Glad we could help. We'll close this thread out. Feel free to open another if you have any new questions.