NRPE and captiveportal check



  • Hello,
    I have write a NRPE check to know how many users are active on the captive portal.
    Step 1 :Create the file /usr/local/libexec/nagios/check_cpactiveusers with this code :

    #! /bin/sh
    
    PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
    
    PROGNAME=`basename $0`
    PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'`
    REVISION=""
    
    . $PROGPATH/utils.sh
    
    print_usage() {
     echo "Usage: $PROGNAME"
    }
    
    print_help() {
     print_revision $PROGNAME $REVISION
     echo ""
     print_usage
     echo ""
     echo "This plugin checks active users using the Active Portal package."
     echo ""
     support
     exit 0
    }
    
    WC="/usr/bin/wc"
    CPLOGFILE="/var/db/captiveportal.db"
    
    case "$1" in
     --help)
      print_help
      exit 0
      ;;
     -h)
      print_help
      exit 0
      ;;
     --version)
        print_revision $PROGNAME $REVISION
      exit 0
      ;;
     -V)
      print_revision $PROGNAME $REVISION
      exit 0
      ;;
     *)
      #Count the Captive portal Active Users
      count=`$WC -l <$CPLOGFILE`
      if [ "$count" = "0" ]; then # no matches, exit with no error
        $ECHO "No active users found on captive portal\n"
        exit 0
      else # Print total count
        $ECHO "$count active users found on captive portal\n"
        exit 0
      fi
      ;;
    esac
    
    

    Step 2 :Made it executable with

    chmode +x /usr/local/libexec/nagios/check_cpactiveusers
    

    Enjoy

    JF Gatineau


Log in to reply