Solved

rename host

  • 31 January 2023
  • 2 replies
  • 163 views

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 ?

icon

Best answer by christophe.niel-ACT 31 January 2023, 16:12

View original

2 replies

Userlevel 5
Badge +14

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)

 

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

Reply