Hello,
We are relatively new to Nagios and Nagios Xi.
We recently encounter an issue that we are not sure how to correct. It is more specific to Nagios Xi than Nagios Core.
We deployed a number of hosts with WMI checks using our Template. After deployment we noticed that we mistyped a password, so all WMI checks are failing. This was in test environment, and we could easily reset everything. But in production environment we will do periodic password change, so we need to have a process in place to address it.
In Nagios we could bulk edit config files, but how do you do it in Nagios Xi that stores everything in database?
What we tried was going to "Bulk Modifications" in CCM and tried to changed $ARG2$ with new password, while selecting affected services. But we end up with configuration that removed everything but updated $ARG2$.
Do we have to do it by each Service copying all $ARG$ or there is other way we not aware of?
Thank you
Steve.
is there a way to bulk change a password for WMI check?
Re: is there a way to bulk change a password for WMI check?
One way is to go into the services dir, grep the password, and copy all the files with the password to the import dir. Then go to the import dir, search and replace the password in all the files, and finally run the reconfigure script or Apply Configuration in the GUI.
Here's a crappy search_n_replace script I wrote a million years ago...
search_n_replace.sh old new *
Here's a crappy search_n_replace script I wrote a million years ago...
search_n_replace.sh old new *
Code: Select all
cat search_n_replace.sh
#!/bin/sh
S_TEXT=$1
R_TEXT=$2
shift 2
FILES=$@
OLD=.org
##############################################################
if ! [ $# -gt 0 ]
then
echo Usage: $0 \<text_to_replace\> \<replacement_text\> \<[path]/file_name\>
echo Example: $0 SMS_TYP SMP_TYP /global/views/all/file.vie
exit 1
fi
##############################################################
# make sure we are root
if [ `whoami` != root ]
then
echo You must run this script as root
exit 1
fi
##############################################################
for FNAME in $FILES
do
cp -p $FNAME $FNAME$OLD
sed "s/$S_TEXT/$R_TEXT/g" $FNAME$OLD > $FNAME
mv $FNAME$OLD /tmp
done
exit $?
Last edited by gormank on Fri Apr 01, 2016 6:34 pm, edited 1 time in total.
Re: is there a way to bulk change a password for WMI check?
Or in shellspeak...
cd /usr/local/nagios/etc/services
grep <password> * | awk -F : '{print "cp " $1 " ../import/"}' | sh
cd ../import
search_n_replace.sh oldpw newpw *
cd /usr/local/nagiosxi/scripts
./reconfigure_nagios.sh
For a general solution, look into /usr/local/nagios/etc/resource.cfg
cd /usr/local/nagios/etc/services
grep <password> * | awk -F : '{print "cp " $1 " ../import/"}' | sh
cd ../import
search_n_replace.sh oldpw newpw *
cd /usr/local/nagiosxi/scripts
./reconfigure_nagios.sh
For a general solution, look into /usr/local/nagios/etc/resource.cfg
Re: is there a way to bulk change a password for WMI check?
Thank you, gormank!
https://assets.nagios.com/downloads/nag ... Macros.pdf
@ stf_792, if you set up your passwords in the "resource.cfg", you will have to change them in one place only, which would make your life easier. Review our documentation on understanding user macros here:For a general solution, look into /usr/local/nagios/etc/resource.cfg
https://assets.nagios.com/downloads/nag ... Macros.pdf
Be sure to check out our Knowledgebase for helpful articles and solutions!
Re: is there a way to bulk change a password for WMI check?
Thank you.
I completely forgot about resource.cfg
That method is much preferred, as "Nagios Operators" will not be able to see privileged passwords, while still able to modify records.
I completely forgot about resource.cfg
That method is much preferred, as "Nagios Operators" will not be able to see privileged passwords, while still able to modify records.
Re: is there a way to bulk change a password for WMI check?
Great! Is it safe to lock this thread, and mark it as "resolved"?
Be sure to check out our Knowledgebase for helpful articles and solutions!