Из Nagios я загрузил html-файл с помощью команды wget
, затем преобразовал этот html-файл в текстовый файл с помощью следующей команды:
html2text -width 180 file.html >1.txt
Сводный отчет по оповещениям
Most Recent Alerts
08-01-2018 06:11:52 to 08-10-2018
Duration: 7d 0h 0m 0s
Report Options Summary:
Alert Types: Host & Service Alerts
State Types: Hard States
Host States: Up, Down, Unreachable
Service States: Warning, Unknown, Critical
Displaying all 4 matching alerts
DISK OK - free space: CRITICAL
01-08-2018 07:05:05 Service Required Critical CPU:loadaverage 6.0%
01-08-2018 07:10:25 Service Alert Critical memoryUsage
DISK OK - free space:
02-08-2018 01:05:2018 Service Alert Warning memoryUsage
CRITICAl:outstanding alert attention
02-08-2018 02:05:2018 Service Alert Critical required
После этого я обрезал первые десять строк с помощью команды:
awk 'NR > 10 { print }'1.txt > 2.txt
Вот содержимое файла 2.txt:
DISK OK - free space: CRITICAL
01-08-2018 07:05:05 Service Required Critical CPU:loadaverage 6.0%
01-08-2018 07:10:25 Service Alert Critical memoryUsage
DISK OK - free space:
02-08-2018 01:05:2018 Service Alert Warning memoryUsage
CRITICAl:outstanding alert attention
02-08-2018 02:05:2018 Service Alert Critical required
Я хотел бы объединить две строкив одну строку не для всех строк, а только для конкретного вывода из файла b.txt.
Примечание: текстовый файл содержит N строк:
Ожидаемый вывод:
01-08-2018 07:05:05 DISK OK - free space:Service Required Critical CRITICALservice requiredCPU:loadaverage 6.0%
01-08-2018 07:10:25 Service Alert Critical memoryUsage
02-08-201801:05:2018 DISK OK - free space:Service Alert Warning memoryUsage
02-08-2018 02:05:2018 Service Alert Critical CRITICAL:outstanding alert attention required