Hmmm,
It will be a little work doing it in Perl (I'm not a good programmer
:-p) , but it's a good solution. Thanks.
Marcos Roberto
Paul Taylor wrote:
> This works for the captive portal (though I'm using the local
> database...
>
> 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 }
> end
> end
>
> 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!
> $client_count++;
> $fw_data[$client_count]['ip'] = $tmp;
> $fw_data[$client_count]['mac'] =
> strtoupper(str_replace(' ','',trim($raw_data_split[$x+1])));
> $fw_data[$client_count]['session_start'] =
> trim($raw_data_split[$x+2]);
> $fw_data[$client_count]['download'] =
> convert_bytes(trim($raw_data_split[$x+3]));
> $fw_data[$client_count]['upload'] =
> convert_bytes(trim($raw_data_split[$x+4]));
> $fw_data[$client_count]['username'] =
> str_replace(' ','',trim($raw_data_split[$x+5]));
> 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'] =
> $dhcp_data[$fw_data[$client_count]['ip']];
> }
> }
> $x = $x + 5;
> }
> }
> }
>
> The $fw_data variable ends up containing the IP address, MAC, Session
> start time, Download, Upload, and Username.
>
> Paul
>
> -----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
> Monowall.
>
> 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
Murphy
----------------------------------------------------- |