hello
In configuration and Host all my hosts are lowercase, is it possible to rename all to uppercase easily
may be with clapi
hello
In configuration and Host all my hosts are lowercase, is it possible to rename all to uppercase easily
may be with clapi
you are in luck, I developped a script with clapi for that a while ago, use it at your own risk
(I make this kind of script as I don’t like using my login and password in the bash command line)
#!/bin/bash
read -p "Enter Username: " CENTUSER
read -s -p "Enter Password: " CENTPASS
echo
export CENTUSER=$CENTUSER
export CENTPASS=$CENTPASS
IFS=$'\n' my_hosts=( $(centreon -u $CENTUSER -p "$CENTPASS" -o HOST -a show) )
nbhost=${#my_hostst@]}
for host in "${my_hostst@]}:1"
do
HOST=$( echo ${host} | awk -F ";" '{print $2}' )
ALIAS=$( echo ${host} | awk -F ";" '{print $3}' )
NEWHOST=${HOST^^}
NEWALIAS=${ALIAS^^}
echo "$HOST ==> $NEWHOST ; $ALIAS ==> $NEWALIAS"
#centreon -u $CENTUSER -p "$CENTPASS" -o HOST -a setparam -v "${HOST};alias;${NEWALIAS}"
#centreon -u $CENTUSER -p "$CENTPASS" -o HOST -a setparam -v "${HOST};name;${NEWHOST}"
done
run it as is, it will show you the new name and alias on the console.
if you are satisfied with the output, remove the comment on the last 2 lines
it will set the new alias and the hostname in uppercase, using the bash syntax ^^ so PLEASE PARSE THE OUTPUT BEFORE REMOVING COMMENT (I have no idea how it behaves with strange characters)
if you don’t want to change the alias and just the hostname, leave the first comment with NEWALIAS
(worked on centreon 19.x and still work on 22.04)
Many thanks
No account yet? Create an account
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.