Bonjour,
J'ai besoin d'un coup de pouce sur un petit script.
Comment il doit fonctionner :
Un fichier CSV en Source avec 3 champs (HOST;PEER;N) comme variable d'entrée
Une petite boucle qui me génère des commandes de mon choix avec les infos contenus dans le CSV.
Mon script :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35 #!/bin/bash file=`cat /root/peer.csv` echo "{OBJECT_TYPE};{COMMAND};{PARAMETERS}" for line in $file do echo $line HOST=`echo $line | awk -F";" '{print $1}'` PEER=`echo $line | awk -F";" '{print $2}'` N=`echo $line | awk -F";" '{print $3}'` echo "SERVICE;ADD;$1;PEER_$2-BGP;App-Protocols-BGP-Peer-SNMP" echo "SERVICE;setparam;$1;PEER_$2-BGP;service_is_volatile;2" echo "SERVICE;setparam;$1;PEER_$2-BGP;service_active_checks_enabled;2" echo "SERVICE;setparam;$1;PEER_$2-BGP;service_passive_checks_enabled;2" echo "SERVICE;setparam;$1;PEER_$2-BGP;service_parallelize_check;2" echo "SERVICE;setparam;$1;PEER_$2-BGP;service_obsess_over_service;2" echo "SERVICE;setparam;$1;PEER_$2-BGP;service_check_freshness;2" echo "SERVICE;setparam;$1;PEER_$2-BGP;service_event_handler_enabled;2" echo "SERVICE;setparam;$1;PEER_$2-BGP;service_flap_detection_enabled;2" echo "SERVICE;setparam;$1;PEER_$2-BGP;service_process_perf_data;2" echo "SERVICE;setparam;$1;PEER_$2-BGP;service_retain_status_information;2" echo "SERVICE;setparam;$1;PEER_$2-BGP;service_retain_nonstatus_information;2" echo "SERVICE;setparam;$1;PEER_$2-BGP;service_notifications_enabled;2" echo "SERVICE;setparam;$1;PEER_$2-BGP;contact_additive_inheritance;0" echo "SERVICE;setparam;$1;PEER_$2-BGP;cg_additive_inheritance;0" echo "SERVICE;setparam;$1;PEER_$2-BGP;service_inherit_contacts_from_host;1" echo "SERVICE;setparam;$1;PEER_$2-BGP;service_use_only_contacts_from_host;0" echo "SERVICE;setparam;$1;PEER_$2-BGP;service_locked;0" echo "SERVICE;setparam;$1;PEER_$2-BGP;service_register;1" echo "SERVICE;setparam;$1;PEER_$2-BGP;service_activate;1" echo "SERVICE;setmacro;$1;PEER_$2-BGP;peer;$2;;''" echo "SERVICE;setmacro;$1;PEER_$2-BGP;lower;$3;;''" echo "SERVICE;setmacro;$1;PEER_$2-BGP;upper;$3;;''" done
Mon souci : Boucle OK, mais pas de donnée en lieu et place des variables
Quand j'exécute le script j'ai cela :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 {OBJECT_TYPE};{COMMAND};{PARAMETERS} HOST;PEER;N SERVICE;ADD;;PEER_-BGP;App-Protocols-BGP-Peer-SNMP SERVICE;setparam;;PEER_-BGP;service_is_volatile;2 SERVICE;setparam;;PEER_-BGP;service_active_checks_enabled;2 SERVICE;setparam;;PEER_-BGP;service_passive_checks_enabled;2 SERVICE;setparam;;PEER_-BGP;service_parallelize_check;2 SERVICE;setparam;;PEER_-BGP;service_obsess_over_service;2 SERVICE;setparam;;PEER_-BGP;service_check_freshness;2 SERVICE;setparam;;PEER_-BGP;service_event_handler_enabled;2 SERVICE;setparam;;PEER_-BGP;service_flap_detection_enabled;2 SERVICE;setparam;;PEER_-BGP;service_process_perf_data;2 SERVICE;setparam;;PEER_-BGP;service_retain_status_information;2 SERVICE;setparam;;PEER_-BGP;service_retain_nonstatus_information;2 SERVICE;setparam;;PEER_-BGP;service_notifications_enabled;2 SERVICE;setparam;;PEER_-BGP;contact_additive_inheritance;0 SERVICE;setparam;;PEER_-BGP;cg_additive_inheritance;0 SERVICE;setparam;;PEER_-BGP;service_inherit_contacts_from_host;1 SERVICE;setparam;;PEER_-BGP;service_use_only_contacts_from_host;0 SERVICE;setparam;;PEER_-BGP;service_locked;0 SERVICE;setparam;;PEER_-BGP;service_register;1 SERVICE;setparam;;PEER_-BGP;service_activate;1 SERVICE;setmacro;;PEER_-BGP;peer;;;'' SERVICE;setmacro;;PEER_-BGP;lower;;;'' SERVICE;setmacro;;PEER_-BGP;upper;;;''
Une âme charitable pourrait m'aider ?
Un grand merci par avance.
Partager