Number of port users logged in - 2.1-RELEASE
-
Thanks, this still works (2.3.4)
I implemented it differently, but using your script. I uploaded the script in the captive portal and my cacti-install gets the value via https from https://pfsensehost:8003/captiveportal-cpcount.php and graphs the output… works great! Finally CP count monitored.
An OID for SNMP would be great though.
-
Hello, here is my version of the script :
<?php require_once("/etc/inc/util.inc"); require_once("/etc/inc/functions.inc"); require_once("/etc/inc/captiveportal.inc"); /* read in captive portal db */ /* determine number of logged in users */ $count_cpusers = 0; /* Is portal activated ? */ if (is_array($config['captiveportal'])) { //only one zone if(isset($_GET["cpzone"])){ $cpzone=$_GET["cpzone"]; $count_cpusers = count(captiveportal_read_db()); } else { /* For every zone, do */ foreach ($config['captiveportal'] as $cpkey => $cp) { /* Sanity check */ if (is_array($config['captiveportal'][$cpkey])) /* Is zone enabled ? */ if (array_key_exists('enable', $config['captiveportal'][$cpkey])) { $cpzone = $cpkey; /* Zone selected -> count users and add */ $count_cpusers += count(captiveportal_read_db()); } } } } echo $count_cpusers; ?>
Here is how i check it with centreon :
#!/bin/bash url=$1 libelle=$2 warningvalue=$3 criticalvalue=$4 if [ $# -eq '4' ] then #get the value value=$(curl -sk $url) # UNKNOWN if [ -z "$value" ] then echo "UNKNOWN - unable to establish the value returned" exit 3 # OK elif [ $value -lt $warningvalue ] then echo "OK - $value $libelle| value=$value" exit 0 # WARNING elif [ $value -gt $warningvalue ] && [ $value -lt $criticalvalue ] then echo "WARNING - $value $libelle| value=$value" exit 1 #CRITICAL else echo "CRITICAL - $value $libelle| value=$value" exit 2 fi else echo "Usage $0 url \"description of the value\" warningvalue criticalvalue" exit 1 fi
this script is used like this :
check_http_value https://10.11.0.1:8005/captiveportal-count-online-users.php?cpzone=captive_portal_r "users connected" 150 200 OK - 127 users connected| value=127
maybe it is possible to improve this with using the $HOSTADRESS$...
and here is the final result in centreon :
Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.