0

i have created simple script that uses nmap to collect data from host.

here is the script:

#!/bin/bash

# Return codes:
STATE_OK=0
STATE_WARNING=1
STATE_CRITICAL=2
STATE_UNKNOWN=3

while test $# -ne 0; do
    case "$1" in
        -H)
            shift
            HOST_TO_SCAN=$1
            shift
            ;;
        -t)
            shift
            HOST_TIMEOUT=$1
            shift
            ;;
    esac
done
NMAP_RESULT=`nmap --script /myscript.nse -sU -p 56000 $HOST_TO_SCAN | grep -i "host is up"`
    
    if [ ! -z "$NMAP_RESULT" ]
    then
      echo "OK: $HOST_TO_SCAN - $NMAP_RESULT|"
      exitstatus=$STATE_OK
      exit $exitstatus
    else
      echo "CRITICAL: $HOST_TO_SCAN - $NMAP_RESULT"
      exitstatus=$STATE_CRITICAL
      exit $exitstatus
    fi

When i run this script in shell, my output is:

OK: 10.10.10.1 - Host is up (0.024s latency).

but in Centreon web GUI when i check Resource Status for that host, Information column shows only:

OK: 10.10.10.1 -

How can i have "Host is up (0.024s latency)." visible in Information column?

Thank you

  • 1
    Try run this script in terminal with the same user as Centreon is using. – Rohlik Sep 22 '22 at 21:30
  • 1
    Thanks, that pointed me in right direction. What i ended up doing, was allowing nmap to be run without sudo. [How to Run Nmap without Root or Sudo](https://www.maketecheasier.com/run-nmap-without-root-or-sudo/) – Tomislav Balaž Sep 23 '22 at 10:17

1 Answers1

1

Thanks to rohlik who pointed me in right direction. I have set Nmap to run without sudo and now everything works fine.