mysql help

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
User avatar
BanditBBS
Posts: 2474
Joined: Tue May 31, 2011 12:57 pm
Location: Scio, OH
Contact:

mysql help

Post 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!
2 of XI5.6.14 Prod/DR/DEV - Nagios LogServer 2 Nodes
See my projects on the Exchange at BanditBBS - Also check out my Nagios stuff on my personal page at Bandit's Home and at github
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: mysql help

Post 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.
Former Nagios employee
jdalrymple
Skynet Drone
Posts: 2620
Joined: Wed Feb 11, 2015 1:56 pm

Re: mysql help

Post 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.
User avatar
BanditBBS
Posts: 2474
Joined: Tue May 31, 2011 12:57 pm
Location: Scio, OH
Contact:

Re: mysql help

Post by BanditBBS »

So are you guys saying this isn't supported? I just want to be sure :lol:

I can be 100% sure it won't exist anywhere else, so JR's line will work great! Lock this sucker up!
2 of XI5.6.14 Prod/DR/DEV - Nagios LogServer 2 Nodes
See my projects on the Exchange at BanditBBS - Also check out my Nagios stuff on my personal page at Bandit's Home and at github
Locked