Skip to main content
Solved

rename host

  • January 31, 2023
  • 2 replies
  • 233 views

amarginier

Hello

how to rename multiple hosts

for example LYON-BP-WA-XXXXX to LYON-WA-XXXXX out of a hundred hosts

Clapi command or script ?

Best answer by christophe.niel-ACT

Hello

you can still use this script I gave you

Hostname configuration | Community (centreon.com)

but you need to code your own “rename rule” by replacing the “NEWHOST” and “NEWALIAS” variables with something more matching your need

but this would need bash knowledge of “if/then”, awk, sed, etc… 

 

alternatively, you could use excel with 2 column, oldname in column A, newname in column B, then on the third column concatenate with this formula:

="centreon -u $CENTUSER -p ""$CENTPASS"" -o HOST -a setparam -v """&A1&";name;"&B1&""""

The ouput should look like that (beware the multiple double quote

centreon -u $CENTUSER -p "$CENTPASS" -o HOST -a setparam -v "OLD;name;NEW"

 

then make a bash starting with that like I did on the previous script :

#!/bin/bash

read -p "Enter Username: " CENTUSER
read -s -p "Enter Password: " CENTPASS
echo
export CENTUSER=$CENTUSER
export CENTPASS=$CENTPASS

then paste all the line you generated in excel, and run the bash file

(you could use the login and password directly in the excel formula and run as is, but that’s your security problem)

 

View original
Did this topic help you find an answer to your question?

Forum|alt.badge.img+17

Hello

you can still use this script I gave you

Hostname configuration | Community (centreon.com)

but you need to code your own “rename rule” by replacing the “NEWHOST” and “NEWALIAS” variables with something more matching your need

but this would need bash knowledge of “if/then”, awk, sed, etc… 

 

alternatively, you could use excel with 2 column, oldname in column A, newname in column B, then on the third column concatenate with this formula:

="centreon -u $CENTUSER -p ""$CENTPASS"" -o HOST -a setparam -v """&A1&";name;"&B1&""""

The ouput should look like that (beware the multiple double quote

centreon -u $CENTUSER -p "$CENTPASS" -o HOST -a setparam -v "OLD;name;NEW"

 

then make a bash starting with that like I did on the previous script :

#!/bin/bash

read -p "Enter Username: " CENTUSER
read -s -p "Enter Password: " CENTPASS
echo
export CENTUSER=$CENTUSER
export CENTPASS=$CENTPASS

then paste all the line you generated in excel, and run the bash file

(you could use the login and password directly in the excel formula and run as is, but that’s your security problem)

 


amarginier

thank you very much i will test with my little linux skills


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings