Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    NRPE and captiveportal check

    Scheduled Pinned Locked Moved pfSense Packages
    1 Posts 1 Posters 1.4k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • J
      jfgatineau
      last edited by

      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

      1 Reply Last reply Reply Quote 0
      • First post
        Last post
      Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.