Contenu | Rechercher | Menus

Annonce

Si vous avez des soucis pour rester connecté, déconnectez-vous puis reconnectez-vous depuis ce lien en cochant la case
Me connecter automatiquement lors de mes prochaines visites.

À propos de l'équipe du forum.

#1 Le 02/05/2024, à 13:40

kaleo

[Résolu] extraire deux mot et les mettre en colonne

Bonjour smile,

J'aimerais extraire deux mots placés à des endroits différents dans une même ligne.

Du premier, s'il est composé de morceaux séparés par des _, on ne gardera que le troisième tronçon après le séparateur _
S'il n'est pas composé de _, alors on ne le modifie pas.

Du second, on ne gardera que le morceau entre 05- et ,

Les deux mots d'une même ligne seront ordonnés en sortie sur une même ligne avec le premier mot à gauche et le second à droite.

Il existe plusieurs lignes dans le fichier.

Le résultat final aura alors plusieurs lignes avec sur chaque ligne le premier et le second mot correspondant à leurs lignes d'origine.

exemple pour le premier mot :

Pour <br>Host visible name: kfughdfv32i<br>Hostgroups: on ne garde que kfughdfv32i

Dans certains cas ce mot peut ressembler à : COCO_SKO_KDQLHDC1DCD01_SDF6T546-3V65-8F48-B8C5-S5DCZ05Q6GH3

Il ne faut garder que KDQLHDC1DCD01

Enfin mettre ce premier mot à gauche du deuxième mot (Linux, WINDOWS ou autre mot à droite de -05 et avant ,) correspondant dans un fichier

exemple :

FGDFGBBB58P WINDOWS
HDFGDFGX84P LINUX

Un cas reproductible minimal :

ping: COCO_SKO_KDQLHDC1DCD01_SDF6T546-3V65-8F48-B8C5-S5DCZ05Q6GH3 is unavailable by ICMP<br>Real Name: HLL9V687-3V65-8F48-B8C5-S5DCZ05Q6GH3<br>SMOX Name: COCO_HLL9V687-3V65-8F48-B8C5-S5DCZ05Q6GH3<br>Host name: HLL9V687-3V65-8F48-B8C5-S5DCZ05Q6GH3<br>Host visible name: COCO_SKO_KDQLHDC1DCD01_SDF6T546-3V65-8F48-B8C5-S5DCZ05Q6GH3<br>Hostgroups: COCO/SKO/VM, COCO_MAINTENANCE, COCO/SKO/NONE, COCO/SKO/DEDI<br>Host IP: 12.68.21.56<br>Customer reference: KDQLHDC1DCD01<br>Item name: ICMP ping<br>Item value: 0<br>Date/Time: 2024.01.09 07:54:32<br>Event State: PROBLEM<br>Trigger Severity: 5<br>Trigger name: ping: COCO_SKO_KDQLHDC1DCD01_SDF6T546-3V65-8F48-B8C5-S5DCZ05Q6GH3 is unavailable by ICMP<br><br>Link to alarm:<br>https://zarbiu.o3s.popiatrium.com/COCO-mtys/zarbiu.php?action=problem.view&triggerids[]=340667&filter_set=1<br>Instruction file=NO_PROCEDURE_FOUND
ping: COCO_SKO_PSKOLMD1DSQ01_658DVS56-8R75-76A5-45ND-45FF4154135D is unavailable by ICMP<br>Real Name: 861DFG12-5F13-47B5-13MQ-54BB2457232F<br>SMOX Name: COCO_861DFG12-5F13-47B5-13MQ-54BB2457232F<br>Host name: 861DFG12-5F13-47B5-13MQ-54BB2457232F<br>Host visible name: COCO_SKO_PSKOLMD1DSQ01_658DVS56-8R75-76A5-45ND-45FF4154135D<br>Hostgroups: COCO/SKO/VM, COCO_MAINTENANCE, COCO/SKO/NONE, COCO/SKO/DEDI<br>Host IP: 53.45.36.458<br>Customer reference: PSKODED1EUW01<br>Item name: ICMP ping<br>Item value: 0<br>Date/Time: 2024.01.09 08:04:33<br>Event State: PROBLEM<br>Trigger Severity: 5<br>Trigger name: ping: COCO_SKO_PSKOLMD1DSQ01_658DVS56-8R75-76A5-45ND-45FF4154135D is unavailable by ICMP<br><br>Link to alarm:<br>https://zarbiu.o3s.popiatrium.com/COCO-mtys/zarbiu.php?action=problem.view&triggerids[]=340694&filter_set=1<br>Instruction file=NO_PROCEDURE_FOUND
ping: COCO_SKO_KDQLHDC1DCD01_SDF6T546-3V65-8F48-B8C5-S5DCZ05Q6GH3 is unavailable by ICMP<br>Real Name: HLL9V687-3V65-8F48-B8C5-S5DCZ05Q6GH3<br>SMOX Name: COCO_HLL9V687-3V65-8F48-B8C5-S5DCZ05Q6GH3<br>Host name: HLL9V687-3V65-8F48-B8C5-S5DCZ05Q6GH3<br>Host visible name: COCO_SKO_KDQLHDC1DCD01_SDF6T546-3V65-8F48-B8C5-S5DCZ05Q6GH3<br>Hostgroups: COCO/SKO/VM, COCO/SKO/NONE, COCO/SKO/DEDI<br>Host IP: 12.68.21.56<br>Customer reference: KDQLHDC1DCD01<br>Item name: ICMP ping<br>Item value: 0<br>Date/Time: 2024.01.11 10:24:32<br>Event State: PROBLEM<br>Trigger Severity: 5<br>Trigger name: ping: COCO_SKO_KDQLHDC1DCD01_SDF6T546-3V65-8F48-B8C5-S5DCZ05Q6GH3 is unavailable by ICMP<br><br>Link to alarm:<br>https://zarbiu.o3s.popiatrium.com/COCO-mtys/zarbiu.php?action=problem.view&triggerids[]=340667&filter_set=1<br>Instruction file=NO_PROCEDURE_FOUND
ping: COCO_SKO_PSKOLMD1DSQ01_658DVS56-8R75-76A5-45ND-45FF4154135D is unavailable by ICMP<br>Real Name: 861DFG12-5F13-47B5-13MQ-54BB2457232F<br>SMOX Name: COCO_861DFG12-5F13-47B5-13MQ-54BB2457232F<br>Host name: 861DFG12-5F13-47B5-13MQ-54BB2457232F<br>Host visible name: COCO_SKO_PSKOLMD1DSQ01_658DVS56-8R75-76A5-45ND-45FF4154135D<br>Hostgroups: COCO/SKO/VM, COCO/SKO/NONE, COCO/SKO/DEDI<br>Host IP: 53.45.36.458<br>Customer reference: PSKODED1EUW01<br>Item name: ICMP ping<br>Item value: 0<br>Date/Time: 2024.01.11 10:24:33<br>Event State: PROBLEM<br>Trigger Severity: 5<br>Trigger name: ping: COCO_SKO_PSKOLMD1DSQ01_658DVS56-8R75-76A5-45ND-45FF4154135D is unavailable by ICMP<br><br>Link to alarm:<br>https://zarbiu.o3s.popiatrium.com/COCO-mtys/zarbiu.php?action=problem.view&triggerids[]=340694&filter_set=1<br>Instruction file=NO_PROCEDURE_FOUND
ping: kfughdfv32i is unavailable by ICMP [Address : 165.15.247.3] [Inst]admin[Inst]<br>Real Name: kfughdfv32i<br>SMOX Name: COCO_kfughdfv32i<br>Host name: kfughdfv32i<br>Host visible name: kfughdfv32i<br>Hostgroups: 00-PERMANENT, 02-PXY-DMZ, 05-LINUX, 06-SITE GROUPE, 01-COCO, 04-RUN, 00-ADM SERV 7 24<br>Host IP: 165.15.247.3<br>Customer reference: <br>Item name: ICMP ping [Default IP Address]<br>Item value: 0<br>Date/Time: 2024.01.15 11:51:36<br>Event State: PROBLEM<br>Trigger Severity: 5<br>Trigger name: ping: kfughdfv32i is unavailable by ICMP [Address : 165.15.247.3] [Inst]admin[Inst]<br><br>Link to alarm:<br>https://zarbiu.o3s.popiatrium.com/COCO-mols/zarbiu.php?action=problem.view&triggerids[]=335446&filter_set=1<br>Instruction file=FAR-COCO-SYSTEM_LINUX
ping: lmdfvncjf36a is unavailable by ICMP [Address : 172.18.253.2] [Inst]admin[Inst]<br>Real Name: lmdfvncjf36a<br>SMOX Name: COCO_lmdfvncjf36a<br>Host name: lmdfvncjf36a<br>Host visible name: lmdfvncjf36a<br>Hostgroups: 00-NORMAL, 02-PXY-DMZ, 05-LINUX, 06-SITE GROUPE, 01-COCO, 04-RUN, 00-ADM SERV 5 12<br>Host IP: 172.18.253.2<br>Customer reference: <br>Item name: ICMP ping [Default IP Address]<br>Item value: 0<br>Date/Time: 2024.01.15 11:50:31<br>Event State: PROBLEM<br>Trigger Severity: 5<br>Trigger name: ping: lmdfvncjf36a is unavailable by ICMP [Address : 172.18.253.2] [Inst]admin[Inst]<br><br>Link to alarm:<br>https://zarbiu.o3s.popiatrium.com/COCO-mols/zarbiu.php?action=problem.view&triggerids[]=335518&filter_set=1<br>Instruction file=FAR-COCO-SYSTEM_LINUX
ping: keoinfsgf02p is unavailable by ICMP [Address : 175.25.251.3] [Inst]admin[Inst]<br>Real Name: KEOINFSGF02P<br>SMOX Name: COCO_KEOINFSGF02P<br>Host name: keoinfsgf02p<br>Host visible name: keoinfsgf02p<br>Hostgroups: 00-PERMANENT, 02-PXY-DMZ, 05-LINUX, 06-SITE GROUPE, 01-COCO, 04-RUN, 00-ADM SERV 7 24<br>Host IP: 175.25.251.3<br>Customer reference: <br>Item name: ICMP ping [Default IP Address]<br>Item value: 0<br>Date/Time: 2024.01.15 11:51:36<br>Event State: PROBLEM<br>Trigger Severity: 5<br>Trigger name: ping: keoinfsgf02p is unavailable by ICMP [Address : 175.25.251.3] [Inst]admin[Inst]<br><br>Link to alarm:<br>https://zarbiu.o3s.popiatrium.com/COCO-mols/zarbiu.php?action=problem.view&triggerids[]=335446&filter_set=1<br>Instruction file=FAR-COCO-SYSTEM_LINUX
ping: hdfgdfgx84p is unavailable by ICMP [Address : 172.18.253.2] [Inst]admin[Inst]<br>Real Name: DFHDFVDH87P<br>SMOX Name: COCO_DFHDFVDH87P<br>Host name: hdfgdfgx84p<br>Host visible name: hdfgdfgx84p<br>Hostgroups: 00-NORMAL, 02-PXY-DMZ, 05-LINUX, 06-SITE GROUPE, 01-COCO, 04-RUN, 00-ADM SERV 5 12<br>Host IP: 172.18.253.2<br>Customer reference: <br>Item name: ICMP ping [Default IP Address]<br>Item value: 0<br>Date/Time: 2024.01.15 11:50:31<br>Event State: PROBLEM<br>Trigger Severity: 5<br>Trigger name: ping: hdfgdfgx84p is unavailable by ICMP [Address : 172.18.253.2] [Inst]admin[Inst]<br><br>Link to alarm:<br>https://zarbiu.o3s.popiatrium.com/COCO-mols/zarbiu.php?action=problem.view&triggerids[]=335518&filter_set=1<br>Instruction file=FAR-COCO-SYSTEM_LINUX
ping: fgdfgbbb58p is unavailable by ICMP [Address : 171.84.151.22] [Inst]admin[Inst]<br>Real Name: SDSHFCJPS78P<br>SMOX Name: COCO_SDSHFCJPS78P<br>Host name: fgdfgbbb58p<br>Host visible name: fgdfgbbb58p<br>Hostgroups: 00-NORMAL, 02-PXY-INT, 06-WINCARB_WINATEL, 01-COCO, 05-WINDOWS, 04-RUN, 06-CITRIX, 00-ADM SERV 5 12<br>Host IP: 171.84.151.22<br>Customer reference: <br>Item name: ICMP ping [Default IP Address]<br>Item value: 0<br>Date/Time: 2024.01.16 12:41:46<br>Event State: PROBLEM<br>Trigger Severity: 5<br>Trigger name: ping: fgdfgbbb58p is unavailable by ICMP [Address : 171.84.151.22] [Inst]admin[Inst]<br><br>Link to alarm:<br>https://zarbiu.o3s.popiatrium.com/COCO-mols/zarbiu.php?action=problem.view&triggerids[]=353572&filter_set=1<br>Instruction file=FAR-COCO-SYSTEM_WINTEL

J'ai posé les même questions dans Chatgpt et chat.mistral pour obtenir un résultat avec les commandes issues de cette discussion :

https://forum.ubuntu-fr.org/viewtopic.php?id=2084875

sed -n '/visible/s/.*>Host visible name: \([^\<]*\).*/\1/p' description_test.txt
sed -En 's/.*<br>Hostgroups:.*05-([^,]*),.*<br>Host IP:.*/\1/p' description_test.txt

Mistral est plus efficace en explication et résultats de commandes :

https://chat.mistral.ai/chat/311afadf-e … 4021ff15bd

Le résulat n'est pas bon.

description_test.txt est le fichier de départ contenant le cas reproductible.

$ paste <(sed -n '/visible/s/.*>Host visible name: \([^\<]*\).*/\1/p' description_test.txt) <(sed -En 's/.*<br>Hostgroups:.*05-([^,]*),.*<br>Host IP:.*/\1/p' description_test.txt)
COCO_SKO_KDQLHDC1DCD01_SDF6T546-3V65-8F48-B8C5-S5DCZ05Q6GH3	LINUX
COCO_SKO_PSKOLMD1DSQ01_658DVS56-8R75-76A5-45ND-45FF4154135D	LINUX
COCO_SKO_KDQLHDC1DCD01_SDF6T546-3V65-8F48-B8C5-S5DCZ05Q6GH3	LINUX
COCO_SKO_PSKOLMD1DSQ01_658DVS56-8R75-76A5-45ND-45FF4154135D	LINUX
kfughdfv32i	WINDOWS
lmdfvncjf36a	
keoinfsgf02p	
hdfgdfgx84p	
fgdfgbbb58p	
$
$ paste <(sed -n '/visible/s/.*>Host visible name: \([^\<]*\).*/\1/p' description_test.txt | cut -d'_' -f3) <(sed -En 's/.*<br>Hostgroups:.*05-([^,]*),.*<br>Host IP:.*/\1/p' description_test.txt)
KDQLHDC1DCD01	LINUX
PSKOLMD1DSQ01	LINUX
KDQLHDC1DCD01	LINUX
PSKOLMD1DSQ01	LINUX
kfughdfv32i	WINDOWS
lmdfvncjf36a	
keoinfsgf02p	
hdfgdfgx84p	
fgdfgbbb58p	
$

Comment obtenir ce résultat ?

KDQLHDC1DCD01
PSKOLMD1DSQ01
KDQLHDC1DCD01
PSKOLMD1DSQ01
kfughdfv32i	LINUX	
lmdfvncjf36a	LINUX
keoinfsgf02p	LINUX
hdfgdfgx84p	LINUX
fgdfgbbb58p	WINDOWS

Merci d'avance pour votre aide smile

Dernière modification par kaleo (Le 11/05/2024, à 12:13)

Hors ligne

#2 Le 04/05/2024, à 15:29

credenhill

Re : [Résolu] extraire deux mot et les mettre en colonne

hello

$ awk '{b=""; a=$2} $2 ~ "_" {split($2, t, "_"); a=t[3]} {for(n=1; n<=NF; n++)if($n ~ "05-"){b=$n; gsub("05-|,", "", b)} }{print a, b}'  ficher
KDQLHDC1DCD01 
PSKOLMD1DSQ01 
KDQLHDC1DCD01 
PSKOLMD1DSQ01 
kfughdfv32i LINUX
lmdfvncjf36a LINUX
keoinfsgf02p LINUX
hdfgdfgx84p LINUX
fgdfgbbb58p WINDOWS

Hors ligne

#3 Le 06/05/2024, à 18:30

kaleo

Re : [Résolu] extraire deux mot et les mettre en colonne

Merci beaucoup smile

La commande awk est plus efficace que sed pour chercher dans ce cas ?
Elle semble plus complexe à construire.
Peut-être une commande plus longue serait plus facile pour moi à reproduire.

Cela ne fonctionne pas dans ce cas

$ awk '{b=""; a=$2} $2 ~ "_" {split($2, t, "_"); a=t[3]} {for(n=1; n<=NF; n++)if($n ~ "05-"){b=$n; gsub("05-|,", "", b)} }{print a, b}' description_test.txt 
KDQLHDC1DCD01 
PSKOLMD1DSQ01 
KDQLHDC1DCD01 
PSKOLMD1DSQ01 
kfughdfv32i LINUX
lmdfvncjf36a LINUX
keoinfsgf02p LINUX
hdfgdfgx84p LINUX
fgdfgbbb58p WINDOWS
 
 
PLSJHFFGHVCU01 
 NETWORK
$

J'ai ajouté deux ligne à la fin du cas reproductible minimal du début pour reproduire l'erreur

PLSJHFFGHVCU01
NETWORK

ping: COCO_SKO_KDQLHDC1DCD01_SDF6T546-3V65-8F48-B8C5-S5DCZ05Q6GH3 is unavailable by ICMP<br>Real Name: HLL9V687-3V65-8F48-B8C5-S5DCZ05Q6GH3<br>SMOX Name: COCO_HLL9V687-3V65-8F48-B8C5-S5DCZ05Q6GH3<br>Host name: HLL9V687-3V65-8F48-B8C5-S5DCZ05Q6GH3<br>Host visible name: COCO_SKO_KDQLHDC1DCD01_SDF6T546-3V65-8F48-B8C5-S5DCZ05Q6GH3<br>Hostgroups: COCO/SKO/VM, COCO_MAINTENANCE, COCO/SKO/NONE, COCO/SKO/DEDI<br>Host IP: 12.68.21.56<br>Customer reference: KDQLHDC1DCD01<br>Item name: ICMP ping<br>Item value: 0<br>Date/Time: 2024.01.09 07:54:32<br>Event State: PROBLEM<br>Trigger Severity: 5<br>Trigger name: ping: COCO_SKO_KDQLHDC1DCD01_SDF6T546-3V65-8F48-B8C5-S5DCZ05Q6GH3 is unavailable by ICMP<br><br>Link to alarm:<br>https://zarbiu.o3s.popiatrium.com/COCO-mtys/zarbiu.php?action=problem.view&triggerids[]=340667&filter_set=1<br>Instruction file=NO_PROCEDURE_FOUND
ping: COCO_SKO_PSKOLMD1DSQ01_658DVS56-8R75-76A5-45ND-45FF4154135D is unavailable by ICMP<br>Real Name: 861DFG12-5F13-47B5-13MQ-54BB2457232F<br>SMOX Name: COCO_861DFG12-5F13-47B5-13MQ-54BB2457232F<br>Host name: 861DFG12-5F13-47B5-13MQ-54BB2457232F<br>Host visible name: COCO_SKO_PSKOLMD1DSQ01_658DVS56-8R75-76A5-45ND-45FF4154135D<br>Hostgroups: COCO/SKO/VM, COCO_MAINTENANCE, COCO/SKO/NONE, COCO/SKO/DEDI<br>Host IP: 53.45.36.458<br>Customer reference: PSKODED1EUW01<br>Item name: ICMP ping<br>Item value: 0<br>Date/Time: 2024.01.09 08:04:33<br>Event State: PROBLEM<br>Trigger Severity: 5<br>Trigger name: ping: COCO_SKO_PSKOLMD1DSQ01_658DVS56-8R75-76A5-45ND-45FF4154135D is unavailable by ICMP<br><br>Link to alarm:<br>https://zarbiu.o3s.popiatrium.com/COCO-mtys/zarbiu.php?action=problem.view&triggerids[]=340694&filter_set=1<br>Instruction file=NO_PROCEDURE_FOUND
ping: COCO_SKO_KDQLHDC1DCD01_SDF6T546-3V65-8F48-B8C5-S5DCZ05Q6GH3 is unavailable by ICMP<br>Real Name: HLL9V687-3V65-8F48-B8C5-S5DCZ05Q6GH3<br>SMOX Name: COCO_HLL9V687-3V65-8F48-B8C5-S5DCZ05Q6GH3<br>Host name: HLL9V687-3V65-8F48-B8C5-S5DCZ05Q6GH3<br>Host visible name: COCO_SKO_KDQLHDC1DCD01_SDF6T546-3V65-8F48-B8C5-S5DCZ05Q6GH3<br>Hostgroups: COCO/SKO/VM, COCO/SKO/NONE, COCO/SKO/DEDI<br>Host IP: 12.68.21.56<br>Customer reference: KDQLHDC1DCD01<br>Item name: ICMP ping<br>Item value: 0<br>Date/Time: 2024.01.11 10:24:32<br>Event State: PROBLEM<br>Trigger Severity: 5<br>Trigger name: ping: COCO_SKO_KDQLHDC1DCD01_SDF6T546-3V65-8F48-B8C5-S5DCZ05Q6GH3 is unavailable by ICMP<br><br>Link to alarm:<br>https://zarbiu.o3s.popiatrium.com/COCO-mtys/zarbiu.php?action=problem.view&triggerids[]=340667&filter_set=1<br>Instruction file=NO_PROCEDURE_FOUND
ping: COCO_SKO_PSKOLMD1DSQ01_658DVS56-8R75-76A5-45ND-45FF4154135D is unavailable by ICMP<br>Real Name: 861DFG12-5F13-47B5-13MQ-54BB2457232F<br>SMOX Name: COCO_861DFG12-5F13-47B5-13MQ-54BB2457232F<br>Host name: 861DFG12-5F13-47B5-13MQ-54BB2457232F<br>Host visible name: COCO_SKO_PSKOLMD1DSQ01_658DVS56-8R75-76A5-45ND-45FF4154135D<br>Hostgroups: COCO/SKO/VM, COCO/SKO/NONE, COCO/SKO/DEDI<br>Host IP: 53.45.36.458<br>Customer reference: PSKODED1EUW01<br>Item name: ICMP ping<br>Item value: 0<br>Date/Time: 2024.01.11 10:24:33<br>Event State: PROBLEM<br>Trigger Severity: 5<br>Trigger name: ping: COCO_SKO_PSKOLMD1DSQ01_658DVS56-8R75-76A5-45ND-45FF4154135D is unavailable by ICMP<br><br>Link to alarm:<br>https://zarbiu.o3s.popiatrium.com/COCO-mtys/zarbiu.php?action=problem.view&triggerids[]=340694&filter_set=1<br>Instruction file=NO_PROCEDURE_FOUND
ping: kfughdfv32i is unavailable by ICMP [Address : 165.15.247.3] [Inst]admin[Inst]<br>Real Name: kfughdfv32i<br>SMOX Name: COCO_kfughdfv32i<br>Host name: kfughdfv32i<br>Host visible name: kfughdfv32i<br>Hostgroups: 00-PERMANENT, 02-PXY-DMZ, 05-LINUX, 06-SITE GROUPE, 01-COCO, 04-RUN, 00-ADM SERV 7 24<br>Host IP: 165.15.247.3<br>Customer reference: <br>Item name: ICMP ping [Default IP Address]<br>Item value: 0<br>Date/Time: 2024.01.15 11:51:36<br>Event State: PROBLEM<br>Trigger Severity: 5<br>Trigger name: ping: kfughdfv32i is unavailable by ICMP [Address : 165.15.247.3] [Inst]admin[Inst]<br><br>Link to alarm:<br>https://zarbiu.o3s.popiatrium.com/COCO-mols/zarbiu.php?action=problem.view&triggerids[]=335446&filter_set=1<br>Instruction file=FAR-COCO-SYSTEM_LINUX
ping: lmdfvncjf36a is unavailable by ICMP [Address : 172.18.253.2] [Inst]admin[Inst]<br>Real Name: lmdfvncjf36a<br>SMOX Name: COCO_lmdfvncjf36a<br>Host name: lmdfvncjf36a<br>Host visible name: lmdfvncjf36a<br>Hostgroups: 00-NORMAL, 02-PXY-DMZ, 05-LINUX, 06-SITE GROUPE, 01-COCO, 04-RUN, 00-ADM SERV 5 12<br>Host IP: 172.18.253.2<br>Customer reference: <br>Item name: ICMP ping [Default IP Address]<br>Item value: 0<br>Date/Time: 2024.01.15 11:50:31<br>Event State: PROBLEM<br>Trigger Severity: 5<br>Trigger name: ping: lmdfvncjf36a is unavailable by ICMP [Address : 172.18.253.2] [Inst]admin[Inst]<br><br>Link to alarm:<br>https://zarbiu.o3s.popiatrium.com/COCO-mols/zarbiu.php?action=problem.view&triggerids[]=335518&filter_set=1<br>Instruction file=FAR-COCO-SYSTEM_LINUX
ping: keoinfsgf02p is unavailable by ICMP [Address : 175.25.251.3] [Inst]admin[Inst]<br>Real Name: KEOINFSGF02P<br>SMOX Name: COCO_KEOINFSGF02P<br>Host name: keoinfsgf02p<br>Host visible name: keoinfsgf02p<br>Hostgroups: 00-PERMANENT, 02-PXY-DMZ, 05-LINUX, 06-SITE GROUPE, 01-COCO, 04-RUN, 00-ADM SERV 7 24<br>Host IP: 175.25.251.3<br>Customer reference: <br>Item name: ICMP ping [Default IP Address]<br>Item value: 0<br>Date/Time: 2024.01.15 11:51:36<br>Event State: PROBLEM<br>Trigger Severity: 5<br>Trigger name: ping: keoinfsgf02p is unavailable by ICMP [Address : 175.25.251.3] [Inst]admin[Inst]<br><br>Link to alarm:<br>https://zarbiu.o3s.popiatrium.com/COCO-mols/zarbiu.php?action=problem.view&triggerids[]=335446&filter_set=1<br>Instruction file=FAR-COCO-SYSTEM_LINUX
ping: hdfgdfgx84p is unavailable by ICMP [Address : 172.18.253.2] [Inst]admin[Inst]<br>Real Name: DFHDFVDH87P<br>SMOX Name: COCO_DFHDFVDH87P<br>Host name: hdfgdfgx84p<br>Host visible name: hdfgdfgx84p<br>Hostgroups: 00-NORMAL, 02-PXY-DMZ, 05-LINUX, 06-SITE GROUPE, 01-COCO, 04-RUN, 00-ADM SERV 5 12<br>Host IP: 172.18.253.2<br>Customer reference: <br>Item name: ICMP ping [Default IP Address]<br>Item value: 0<br>Date/Time: 2024.01.15 11:50:31<br>Event State: PROBLEM<br>Trigger Severity: 5<br>Trigger name: ping: hdfgdfgx84p is unavailable by ICMP [Address : 172.18.253.2] [Inst]admin[Inst]<br><br>Link to alarm:<br>https://zarbiu.o3s.popiatrium.com/COCO-mols/zarbiu.php?action=problem.view&triggerids[]=335518&filter_set=1<br>Instruction file=FAR-COCO-SYSTEM_LINUX
ping: fgdfgbbb58p is unavailable by ICMP [Address : 171.84.151.22] [Inst]admin[Inst]<br>Real Name: SDSHFCJPS78P<br>SMOX Name: COCO_SDSHFCJPS78P<br>Host name: fgdfgbbb58p<br>Host visible name: fgdfgbbb58p<br>Hostgroups: 00-NORMAL, 02-PXY-INT, 06-WINCARB_WINATEL, 01-COCO, 05-WINDOWS, 04-RUN, 06-CITRIX, 00-ADM SERV 5 12<br>Host IP: 171.84.151.22<br>Customer reference: <br>Item name: ICMP ping [Default IP Address]<br>Item value: 0<br>Date/Time: 2024.01.16 12:41:46<br>Event State: PROBLEM<br>Trigger Severity: 5<br>Trigger name: ping: fgdfgbbb58p is unavailable by ICMP [Address : 171.84.151.22] [Inst]admin[Inst]<br><br>Link to alarm:<br>https://zarbiu.o3s.popiatrium.com/COCO-mols/zarbiu.php?action=problem.view&triggerids[]=353572&filter_set=1<br>Instruction file=FAR-COCO-SYSTEM_WINTEL


ping: COCO_MPO_PLSJHFFGHVCU01_7GGS5864-4DFF-5Z45-GD68-4H451S3SFCV4 is unavailable by ICMP<br>Real Name: 7GGS5864-4DFF-5Z45-GD68-4H451S3SFCV4<br>SMOX Name: COCO_7GGS5864-4DFF-5Z45-GD68-4H451S3SFCV4<br>Host name: 7GGS5864-4DFF-5Z45-GD68-4H451S3SFCV4<br>Host visible name: COCO_KBM_PKBMGRLGEUW01_7GGS5864-4DFF-5Z45-GD68-4H451S3SFCV4<br>Hostgroups: COCO/MPO/VM, COCO/MPO/MTICKET, COCO/MPO/NONE<br>Host IP: 11.120.24.38<br>Customer reference: PKBMGRLGEUW01<br>Item name: ICMP ping<br>Item value: 0<br>Date/Time: 2024.03.22 12:54:39<br>Event State: PROBLEM<br>Trigger Severity: 5<br>Trigger name: ping: COCO_KBM_PKBMGRLGEUW01_7GGS5864-4DFF-5Z45-GD68-4H451S3SFCV4 is unavailable by ICMP<br><br>Link to alarm:<br>https://zarbiu-abs.o3s.popiatrium.com/COCO/zarbiu.php?action=problem.view&triggerids[]=440905&filter_set=1<br>Instruction file=NO_PROCEDURE_FOUND
ping: fhdmghf1_new is unavailable by ICMP [Address : 158.23.45.65] [Inst]admin[Inst]<br>Real Name: fhdmghf1_NEW<br>SMOX Name: COCO_fhdmghf1_NEW<br>Host name: fhdmghf1_new<br>Host visible name: fhdmghf1_new<br>Hostgroups: 00-PERMANENT, 02-PXY-DMZ, 05-NETWORK, 01-COCO<br>Host IP: 158.23.45.65<br>Customer reference: sdfghfgf01.fr.ghc.local<br>Item name: ICMP ping [Default IP Address]<br>Item value: 0<br>Date/Time: 2024.03.22 15:19:33<br>Event State: PROBLEM<br>Trigger Severity: 5<br>Trigger name: ping: fhdmghf1_new is unavailable by ICMP [Address : 158.23.45.65] [Inst]admin[Inst]<br><br>Link to alarm:<br>https://zarbiu-abs.o3s.popiatrium.com/COCO/zarbiu.php?action=problem.view&triggerids[]=455487&filter_set=1<br>Instruction file=NO_PROCEDURE_FOUND

La commande awk semble la plus appropriée pour ce type de recherche.

Merci d'avance cool

Dernière modification par kaleo (Le 07/05/2024, à 11:15)

Hors ligne

#4 Le 07/05/2024, à 09:32

credenhill

Re : [Résolu] extraire deux mot et les mettre en colonne

awk permet recherche et modifications
le champ 2 de ton ajout contient un seul  _  et est traité comme si il en contenait 3 ou plus

$ awk '{b=""; a=$2} $2 ~ "_[^_]*_" {split($2, t, "_"); a=t[3]} {for(n=1; n<=NF; n++)if($n ~ "05-"){b=$n; gsub("05-|,", "", b)} }{print a, b}' fichier
KDQLHDC1DCD01 
PSKOLMD1DSQ01 
KDQLHDC1DCD01 
PSKOLMD1DSQ01 
kfughdfv32i LINUX
lmdfvncjf36a LINUX
keoinfsgf02p LINUX
hdfgdfgx84p LINUX
fgdfgbbb58p WINDOWS
 
PLSJHFFGHVCU01 
fhdmghf1_new NETWORK
$ 

Dernière modification par credenhill (Le 07/05/2024, à 12:14)

Hors ligne

#5 Le 07/05/2024, à 13:17

kaleo

Re : [Résolu] extraire deux mot et les mettre en colonne

Merci cool

J'ai ajouté la fonction toupper pour tout mettre en majuscule

https://debian-facile.org/doc:programma … er-tolower

$ awk '{b=""; a=$2} $2 ~ "_[^ _]*_" {split($2, t, "_"); a=t[3]} {for(n=1; n<=NF; n++)if($n ~ "05-"){b=$n; gsub("05-|,", "", b)} }{print toupper(a), toupper(b)}' description_test.txt 
KDQLHDC1DCD01 
PSKOLMD1DSQ01 
KDQLHDC1DCD01 
PSKOLMD1DSQ01 
KFUGHDFV32I LINUX
LMDFVNCJF36A LINUX
KEOINFSGF02P LINUX
HDFGDFGX84P LINUX
FGDFGBBB58P WINDOWS
 
 
PLSJHFFGHVCU01 
FHDMGHF1_NEW NETWORK
$ 

Dernière modification par kaleo (Le 07/05/2024, à 19:19)

Hors ligne