[ previous ] [ next ] [ threads ]
 From:  "Paul Taylor" <PaulTaylor at winn dash dixie dot com>
 To:  "Roberto Greiner" <mrgreiner at gmail dot com>, "Monowall Support List" <m0n0wall at lists dot m0n0 dot ch>
 Subject:  RE: [m0n0wall] Getting the current users list
 Date:  Tue, 7 Aug 2007 09:09:41 -0400
This works for the captive portal (though I'm using the local

This Ruby code will grab the page:

require 'net/http'
require 'net/https'

uri = URI.parse("https://yourmonoIPhere")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true 
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
http.start do |http| 
	request = Net::HTTP::Get.new('/status_captiveportal.php') 
	request.basic_auth 'adminUsername', 'adminPassword' 
	response = http.request(request) 
	puts response.code 
	puts response.body 
	if response.code.to_i == 200
		open('\pathtoyourdata\fw.dat','w') { |f| f <<
response.body }

I'm sure there's some pretty easy PHP code to do the same, or probably
even wget or curl.  I did it in Ruby because it was part of another
program gathering info from multiple devices, so I can consolidate it
all to one view.

To parse it, I did this quick 'n dirty PHP:

// Parse FW file
$file = 'fw.dat';
$raw_data = readfiletostr($file);

$raw_data = strip_tags($raw_data);

$raw_data_split = explode("\n",$raw_data);
$processing = 0;
$client_count = 0;
for ($x=0; $x < count($raw_data_split); $x++) {
    $line = $raw_data_split[$x];
    $pos = strpos($line,"Username");
    if ($pos > -1) {
        // Start Processing
        $processing = 1;
    if ($processing == 1) {
        $pos = strpos($line,"Manuel Kasper");
        if ($pos > -1) {
            // Done Processing
            $processing = 0;
    // Ok, are we really ready to process?!  Yes!
    if ($processing == 1) {
        $tmp = trim($line);
        if (is_ipaddr($tmp)) {
            // Found an IP Address!
            $fw_data[$client_count]['ip'] = $tmp;
            $fw_data[$client_count]['mac'] =
            $fw_data[$client_count]['session_start'] =
            $fw_data[$client_count]['download'] =
            $fw_data[$client_count]['upload'] =
            $fw_data[$client_count]['username'] =
            if (strlen($fw_data[$client_count]['mac']) < 10) {
                // Mac is unknown - Check DHCP data
                if (isset($dhcp_data[$fw_data[$client_count]['ip']])) {
                    $fw_data[$client_count]['mac'] =
            $x = $x + 5;

The $fw_data variable ends up containing the IP address, MAC, Session
start time, Download, Upload, and Username.   


-----Original Message-----
From: Roberto Greiner [mailto:mrgreiner at gmail dot com] 
Sent: Tuesday, August 07, 2007 8:44 AM
To: Monowall Support List
Subject: [m0n0wall] Getting the current users list

I'm having a small problem with my authentication system and Monowall.
When Monowall is rebooted (seldom, but happens), many users are not
properly cleared in the radius box (Freeradius 1.1.6 with Debian Etch),
giving me problems when I try to run a control with the
"Simultaneous-Use" option.

Freeradius has a tool to check if a user is really connected to the NAS
(checkrad), but there is no option available in that tool to work with

Checkrad usually uses SNMP (it can use other tools, like telnet), but
I've checked the SNMP results from monowall, and there is no entry
listing the connected users (at least not in Monowall 1.23). Is there
any other way to remotely get the current user list from Monowall?

Thank you for your help,

Marcos Roberto Greiner

                Marcos Roberto Greiner

   Os otimistas acham que estamos no melhor dos mundos
    Os pessimistas tem medo de que isto seja verdade

To unsubscribe, e-mail: m0n0wall dash unsubscribe at lists dot m0n0 dot ch
For additional commands, e-mail: m0n0wall dash help at lists dot m0n0 dot ch