Script does not return complete information

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
fraguillen
Posts: 47
Joined: Fri May 18, 2018 11:40 am

Script does not return complete information

Post by fraguillen »

Good Morning

I have the following script:

#!/bin/sh
grep=/bin/grep
cd=/bin/cd
ls=/bin/ls
awk=/bin/awk
wc=/bin/wc
cat=/bin/cat
ECHO=/bin/echo
STATE_CRITICAL=2
STATE_OK=0
cant=$1
cd /usr/local/nagios/libexec
Mydir="/usr/local/nagios/libexec"
nameLog=check_ocomc_input_event_mz
StatusError=0

:> $Mydir/tmp/$nameLog.tmp
for dir in tel gprs sms mms smsp smsbulk va roaming ; do
#cd /BRMFiles/oracle/data/ocomc/in-ocomc/$dir
if [ "roaming" = "$dir" ] ; then
CantFile=$(ls /BRMFiles/oracle/data/ocomc/in-ocomc/$dir | grep -c .edr$)
else
CantFile=$(ls /BRMFiles/oracle/data/ocomc/in-ocomc/$dir | grep -c .txt$)
fi
if [ $CantFile -ge $cant ] ; then
$ECHO "ERROR: Total archivo en el directorio $dir:$CantFile" >> $Mydir/tmp/$nameLog.tmp
StatusError=1
else
$ECHO "OK: Total archivo en el directorio $dir:$CantFile" >> $Mydir/tmp/$nameLog.tmp
fi
if [ $CantFile -gt 0 ] ; then
$ECHO "Archivo mas antiguo para $dir:$( ls -lrt /BRMFiles/oracle/data/ocomc/in-ocomc/$dir 2>/dev/null | grep -E ".txt$|.edr$" | head -1 | awk 'BEGIN {FS=" "} {print $6,$7,$8,$9}')" >> $Mydir/tmp/$nameLog.tmp
else
$ECHO "Archivo mas antiguo para $dir:No hay archivos pendientes." >> $Mydir/tmp/$nameLog.tmp
fi
TotalGeneral=$(( $TotalGeneral + $CantFile))
done
echo "Total de archivos en la entrada de OCOMC pendiente de procesar:$TotalGeneral" >> $Mydir/tmp/$nameLog.tmp
if [ $StatusError -gt 0 ] ; then
$ECHO "ERROR SE ENCUENTRA UN REZAGO DE ARCHIVOS, VER INFORMACION:";
cat $Mydir/tmp/$nameLog.tmp | $grep ERROR
cat $Mydir/tmp/$nameLog.tmp | $grep OK | $grep -v "No hay rezago en la entrada de los directorios"
Status=$STATE_CRITICAL
else
$ECHO "OK: NO HAY REZAGO EN LA ENTRADA DE LOS DIRECTORIOS DE OCOMC"
cat $Mydir/tmp/$nameLog.tmp | $grep OK
Status=$STATE_OK
fi
$ECHO " "
$ECHO "INFO ADICIONAL:"
$ECHO " "
for dir in tel gprs sms mms smsp smsbulk va roaming ; do
cat $Mydir/tmp/$nameLog.tmp | grep "Archivo mas antiguo para $dir:"
done
cat $Mydir/tmp/$nameLog.tmp | grep "OCOMC"
$ECHO "=======fin======="
exit $Status

The command line is the following:

command[check_ocomc_input_event_mz]=/usr/local/nagios/libexec/check_ocomc_input_event_mz 30

If I run the script directly on the server, I get this result:

[root@prod libexec]# ./check_ocomc_input_event_mz 30
ERROR SE ENCUENTRA UN REZAGO DE ARCHIVOS, VER INFORMACION:
ERROR: Total archivo en el directorio tel:12319
ERROR: Total archivo en el directorio sms:24076
ERROR: Total archivo en el directorio va:40
ERROR: Total archivo en el directorio roaming:112
OK: Total archivo en el directorio gprs:0
OK: Total archivo en el directorio mms:0
OK: Total archivo en el directorio smsp:18
OK: Total archivo en el directorio smsbulk:0

INFO ADICIONAL:

Archivo mas antiguo para tel:Feb 26 21:10 DGR_CTL_CEL_3G_VOZ_HIB_20190226_017815_1692.txt
Archivo mas antiguo para gprs:No hay archivos pendientes.
Archivo mas antiguo para sms:Feb 26 02:10 DGR_CTL_CEL_3G_MSGNAC_GUA_20190226_000015_730.txt
Archivo mas antiguo para mms:No hay archivos pendientes.
Archivo mas antiguo para smsp:Feb 26 10:30 DGR_CTL_CEL_SMS_CORP_20190226103005_000001_1479.txt
Archivo mas antiguo para smsbulk:No hay archivos pendientes.
Archivo mas antiguo para va:Feb 26 10:30 DGR_CTL_PLA_900_POSTPAGO_20190226_000016_798.txt
Archivo mas antiguo para roaming:Feb 26 10:15 MED_V_ARGTPCRICR05049.edr
Total de archivos en la entrada de OCOMC pendiente de procesar:36565
=======fin=======

The correct execution shows the word =======fin=======

But if I run it from Nagios it does not show all the information:

[root@nagios ~]# cat /var/www/html/infoBRM/check_ocomc_input_event_mz
ERROR SE ENCUENTRA UN REZAGO DE ARCHIVOS, VER INFORMACION:
ERROR: Total archivo en el directorio tel:12100
ERROR: Total archivo en el directorio sms:23930
ERROR: Total archivo en el directorio va:39
ERROR: Total archivo en el directorio roaming:112
OK: Total archivo en el directorio gprs:0
OK: Total archivo en el directorio mms:0
OK: Total archivo en el directorio smsp:18
OK: Total archivo en el directorio smsbulk:1

INFO ADICIONAL:

Archivo mas antiguo para tel:Feb 26 21:10 DGR_CTL_CEL_3G_VOZ_HIB_20190226_017815_1692.txt
Archivo mas antiguo para gprs:No hay archivos pendientes.
Archivo mas antiguo para sms:Feb 26 02:10 DGR_CTL_CEL_3G_MSGNAC_GUA_20190226_000015_730.txt
Archivo mas antiguo para mms:No hay archivos pendientes.
Archivo mas antiguo para smsp:Feb 26 10:30 DGR_CTL_CEL_SMS_CORP_20190226103005_000001_1479.txt
Archivo mas antiguo para smsbulk:Feb 27 11:20 DGR_CTL_CEL_3G_MSGNAC_GUA_20190227_000086_730.txt
Archivo mas antiguo para va:Feb 26 10:30 DGR_CTL_PLA_900_POSTPAGO_20190226_000016_798.txt
Archi
[root@nagios ~]#

What should I do to correct this problem?

Best regards...
SteveBeauchemin
Posts: 524
Joined: Mon Oct 14, 2013 7:19 pm

Re: Script does not return complete information

Post by SteveBeauchemin »

Add <BR> to the end of each line in the script. then the GUI will show all the data.

That is what I do where I work.

Steve B
XI 5.7.3 / Core 4.4.6 / NagVis 1.9.8 / LiveStatus 1.5.0p11 / RRDCached 1.7.0 / Redis 3.2.8 /
SNMPTT / Gearman 0.33-7 / Mod_Gearman 3.0.7 / NLS 2.0.8 / NNA 2.3.1 /
NSClient 0.5.0 / NRPE Solaris 3.2.1 Linux 3.2.1 HPUX 3.2.1
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Script does not return complete information

Post by scottwilkerson »

Additionally, it should be noted that in the table view of hosts and services only the first line of output is shown, the additional lines would be in the long output field and only display on the service/host detail page
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
fraguillen
Posts: 47
Joined: Fri May 18, 2018 11:40 am

Re: Script does not return complete information

Post by fraguillen »

SteveBeauchemin wrote:Add <BR> to the end of each line in the script. then the GUI will show all the data.

That is what I do where I work.

Steve B

Good morning

What do you mean by <BR>?

<BR> I think an HTML tag and this is a bash script.

I was not clear.

Best regards....
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Script does not return complete information

Post by scottwilkerson »

I believe he was suggesting adding the <br> to the output which will display properly in the XI UI
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
Locked