Page 1 of 1
mysql help
Posted: Tue Mar 17, 2015 10:16 am
by BanditBBS
Hey,
Anyone that's better at mysql than me want to help me out
I have a list of 233 services that have an IP in their $ARG8$. Can someone show me the proper sql to use to update that field with a different IP. Basically update $ARG8$ with 10.10.10.2 where $ARG8$=10.10.10.1
Thanks!
Re: mysql help
Posted: Tue Mar 17, 2015 10:24 am
by tmcdonald
Heh:
https://github.com/tmcnag/Nagios-Misc/b ... eplace.php
You might need to alter the script a bit to mess with the table names, but I wrote this a month ago to change passwords stored in ARGs.
Edit: As JR mentioned, not strictly supported. But I know that won't stop you :) Just make sure as always to take backups. My script comes with very little safety netting.
Re: mysql help
Posted: Tue Mar 17, 2015 10:31 am
by jdalrymple
Obviously not supported...
That said the arguments aren't stored explicitly in the service's check_command defintion. They are stored in the same fashion they would be in the .cfg file. If you can be certain that a search and replace would work for you without searching and replacing the wrong thing something as simple as this would work:
Code: Select all
update tbl_service set check_command = replace(check_command,'10.10.10.1','10.10.10.2');
If that string is going to be elsewhere in other check_commands on your system (or even elsewhere in the same check_command) you'll have to be a bit more elaborate with a where clause. That where clause depends on what information you have available to narrow the scope.
Again - not supported.
Re: mysql help
Posted: Tue Mar 17, 2015 10:38 am
by BanditBBS
So are you guys saying this isn't supported? I just want to be sure
I can be 100% sure it won't exist anywhere else, so JR's line will work great! Lock this sucker up!