Plugin Icinga2 com saída de várias linhas

2

Eu estou tentando escrever um plugin personalizado para Icinga2 que obtém informações de licença de um produto que fornecemos aos nossos clientes. É um script muito simples, mas existem várias linhas de saída e estou tentando reunir os dados e tê-los formatados sob os serviços para um host específico.

Aqui está a saída dos dados:

Users of product1, Total issued=10, Total used=0
Users of product2, Total issued=10, Total used=0
Users of product3, Total issued=10, Total used=0
Users of product4, Total issued=10, Total used=0
Users of product5, Total issued=50, Total used=11
Users of product6, Total issued=10, Total used=0
Users of product7, Total issued=771, Total used=0
Users of product8, Total issued=771, Total used=8
Users of product9, Total issued=771, Total used=0
Users of product10, Total issued=60, Total used=0

Aqui está o que eu acho que deve ser passado para Icinga2:

COMSOL CHECK OK : Users of=product1, Total issued=10, Total used=0| UsersOf=product1;;;; TotalIssued=10;;;; TotalUsed=0;;;;
COMSOL CHECK OK : Users of=product2, Total issued=10, Total used=0| UsersOf=product2;;;; TotalIssued=10;;;; TotalUsed=0;;;;
COMSOL CHECK OK : Users of=product3, Total issued=10, Total used=0| UsersOf=product3;;;; TotalIssued=10;;;; TotalUsed=0;;;;
COMSOL CHECK OK : Users of=product4, Total issued=10, Total used=0| UsersOf=product4;;;; TotalIssued=10;;;; TotalUsed=0;;;;
COMSOL CHECK OK : Users of=product5, Total issued=50, Total used=11| UsersOf=product5;;;; TotalIssued=50;;;; TotalUsed=11;;;;
COMSOL CHECK OK : Users of=product6, Total issued=10, Total used=0| UsersOf=product6;;;; TotalIssued=10;;;; TotalUsed=0;;;;
COMSOL CHECK OK : Users of=product7, Total issued=771, Total used=0| UsersOf=product7;;;; TotalIssued=771;;;; TotalUsed=0;;;;
COMSOL CHECK OK : Users of=product8, Total issued=771, Total used=8| UsersOf=product8;;;; TotalIssued=771;;;; TotalUsed=8;;;;
COMSOL CHECK OK : Users of=product9, Total issued=771, Total used=0| UsersOf=product9;;;; TotalIssued=771;;;; TotalUsed=0;;;;
COMSOL CHECK OK : Users of=product10, Total issued=60, Total used=0| UsersOf=product10;;;; TotalIssued=60;;;; TotalUsed=0;;;;

Aqui está o meu script:

#!/bin/bash
license=$(/opt/licenses/comsol/lmstat -a |grep 'Users of' |sed 's/://g' |head -10| awk '{print "COMSOL CHECK OK : Users of="$3", Total issued="$6", Total used="$11 "| UsersOf="$3";;;; TotalIssued="$6";;;; TotalUsed="$11";;;;" }') 

printf "${license}\n"

Como você pode ver, é muito simples, mas eu recebo os seguintes erros no Icinga desta configuração ...

Plugin Output
sed: couldn't write 85 items to stdout: Broken pipe
grep: write error: Broken pipe
COMSOL CHECK OK : Users of=product1, Total issued=10, Total used=0
COMSOL CHECK OK : Users of=product2, Total issued=10, Total used=0
COMSOL CHECK OK : Users of=product3, Total issued=10, Total used=0
COMSOL CHECK OK : Users of=product4, Total issued=10, Total used=0
COMSOL CHECK OK : Users of=product5, Total issued=50, Total used=10
COMSOL CHECK OK : Users of=product6, Total issued=10, Total used=0
COMSOL CHECK OK : Users of=product7, Total issued=771, Total used=0
COMSOL CHECK OK : Users of=product8, Total issued=771, Total used=8
COMSOL CHECK OK : Users of=product9, Total issued=771, Total used=0
COMSOL CHECK OK : Users of=product10, Total issued=60, Total used=0

Eu até tentei passar tudo para uma linha, então a saída é assim:

COMSOL CHECK OK : Users of=product1, Total issued=10, Total used=0| UsersOf=product1;;;; TotalIssued=10;;;; TotalUsed=0;;;; Users of=product2, Total   issued=10, Total used=0| UsersOf=product2;;;; TotalIssued=10;;;; TotalUsed=0;;;; Users of=product3, Total issued=10, Total used=0| UsersOf=product3;;;; TotalIssued=10;;;; TotalUsed=0;;;; Users of=product4, Total issued=10, Total used=0| UsersOf=product4;;;; TotalIssued=10;;;; TotalUsed=0;;;; Users of=product5, Total issued=50, Total used=10| UsersOf=product5;;;; TotalIssued=50;;;; TotalUsed=10;;;; Users of=product6, Total issued=10, Total used=0| UsersOf=product6;;;; TotalIssued=10;;;; TotalUsed=0;;;; Users of=product7, Total issued=771, Total used=0| UsersOf=product7;;;; TotalIssued=771;;;; TotalUsed=0;;;; Users of=product8, Total issued=771, Total used=8| UsersOf=product8;;;; TotalIssued=771;;;; TotalUsed=8;;;; Users of=product9, Total issued=771, Total used=0| UsersOf=product9;;;; TotalIssued=771;;;; TotalUsed=0;;;; Users of=product10, Total issued=60, Total used=0| UsersOf=product10;;;; TotalIssued=60;;;; TotalUsed=0;;;;

Alguma idéia de como fazer isso funcionar ... Funcionará?

Obrigado! Joe

    
por Joeg1484 30.03.2016 / 21:04

1 resposta

-1

Os valores dos dados de desempenho precisam ser um número inteiro. Consulte o link .

    
por 13.03.2018 / 23:41

Tags