HOW PHP - log ?

Does anybody have some simple php code or pages which is capable to read mikrotik log and give out some nice statistic about users .
I need something simple where hotspot users (or other) can see time of conection and how much MB (GB) is download.
Something like popup window after hotspot login , but for longer period …
week or 4 week.
I was think to download log with MT Syslog Daemon v1.15 and put into web server where php and apache can read this log and show some nice statistic.
I was search trought http://www.hotscripts.com/ but there is to much results , I realy have no time to test all this.
Does anbody have some idea or know some ready script which can handle with logs (free prefered)?

Actualy i was looking for something like this example
http://sqnt.sourceforge.net/example/index.html
It was squint … but I canot download , broken link …
http://www.ledge.co.za/software/squint/

Does anybody know for something like this ? (but I preffer scripts in php)

You can use the syslog daemon I’ve made. It has direct output to MySQL database.

  1. Get http://www.mikrotikbalkans.com/mtsyslog.tar.gz
  2. tar -zxf mtsyslog.tar.gz
  3. cd mtsyslog
  4. mysqladmin create syslog
  5. mysql syslog < database.sql
  6. edit listen_syslog.pl and change mysql_user and mysql_pass
  7. /usr/bin/screen -dmS mt_syslog /usr/bin/perl /path/to/listen_syslog.pl

P.S.: must have DBI installed… if not sure use:
perl -MCPAN -e shell
install DBI

Very nice …
I have mysql and apache under windows …
I was create database and make changes to listen_syslog.pl…
now I only need to instal perl and make tests …
Do you have some example page or how to start this script from browser?
Just make link to MTSyslog.pm or listen_syslog.pl?

listen_syslog.pl must be run in background mode… It opens UDP port 514 for listening and starts adding data into the mysql database… I’m using in over Slackware Linux

OK !
I install perl from activestate and it running OK , then I install DBI ok .
I enable .pl files support in apache and also allow in that directory
execution of cgi … actualy I add this lines
Options Indexes FollowSymLinks ExecCGI
and AddHandler cgi-script .pl
test .pl scripts is working.
Also in mikrotik logging I enable logging to this remote host.

But I have some strange errors in apache log
( when I connect to my web http://mydomain.com/script/listen_syslog.pl) like this:
listen_syslog.pl is not executable; ensure interpreted scripts have “#!” first line
Bad file descriptor: don’t know how to spawn child process:
path_to/ listen_syslog.pl

Do I need to make some changes to MTSyslog.pm ?
Or maybe make some changes to listen_syslog.pl (except mysql_user and pass - I make this)?

I’ll repeat… listen_syslog.pl is only for running as a background service… In Linux enviroment you can use screen for this…

OK so how to view result in browser ?

You would have to code some PHP (or whatever language you want to use) that will pull the data out of the MySQL db and spit out a html page with the information you want. Perhaps ASM has something finished to give to you?!

What is ASM ?
Do you know for something already finished?

Ahem, well, ASM is the forum user who posted his syslog daemon above :wink:

OK :smiley:
Hm now litle resume this mtsyslog is some piece of software like mikrotik MT Syslog Daemon , only this is perl based and they only fill mysql database .
So first I must get up this to run in background.
Ok but now when I try to run under command prompt: perl listen_syslog.pl I have folowing error :
Cant locate Net/Dev/Tools/Mtsyslog.pm in <@INC contains: C:/perl/lib C:/perl/site/lib ,> at listen_syslog.pl line 1

Hm probably need some changes in both this scripts to be compatible with perl for windows … Any idea ?

I’ve got some interface and poller scripts, that logs users logins and logouts but I think that everyone must make a script that works best for him

move MTsyslog.pm to C:/perl/lib :slight_smile:

Same error again :
Cant locate Net/Dev/Tools/Mtsyslog.pm in <@INC contains: C:/perl/lib C:/perl/site/lib ,> at listen_syslog.pl line 1

Are you sure that furst line is ok?
Does not first line must be something like:
#!c:/Perl/bin/Perl.exe

Ok
here is partial sukces:
1.perl-must create directories C:\Perl\lib\Net\Dev\Tools
2.perl-copy file MTSyslog.pm to C:\Perl\lib\Net\Dev\Tools
3.mysql - CREATE DATABASE syslog
4.mysql - import tables from database.sql
5.edit listen_syslog.pl for conect to mysql (username - passw)
6.perl- install DBI
7.perl- install DBD-mysql
8.run listen_syslog.pl

And now listen_syslog.pl running without errors , but look that not receiving data.
Also on the same machine MT Syslog Daemon v1.15 does not receive data , only Traffic Counter v1.9 receive data.
Is this maybe related on version of mikrotik ?

My version is 2.8.22 … on mikrotik pages they says that :“Your router must be using MikroTik v2.3 or older routing software. For newer versions, use Traffic Management Utilities”
http://www.mikrotik.com/wirsys/install.htm

Maybe is same thing with perl scripts ? I mean maybe is build for older version of mikrotik…

Oh sorry ! :stuck_out_tongue:
Data is coming … when I search via phpmyadmin I see some logs …
:stuck_out_tongue:
So can somebody can give me some php code or I must do all alone?
:stuck_out_tongue:

ASM do you have some php code which is capable to read this database?
Im have bad php-mysql skills … I have problem with correct reading time culumn …
Can you give some sample code?