You are on page 1of 1

New Node SCRIPT CATCH EM ALL GET COUNTRY FROM IP

Update Table where Country = $CountryAppenaTrovata, Counter = Counter + 0.001

Set Date

Get Data From Date - 30days Valutare GET Exchange Log

SCP GET Access.Log from N servers export json CRON N minutes : Script Counting IP | Visits CONCAT X && Y coordinates

Put Export.CSV into MYSQL http://www.fail2ban.org/wiki/index.php/ HOWTO_use_geoiplookup cron geoip db update


root@Lupin77:~/geo# cat /var/www/ webgl-globe/globe2/access.log | cut d' ' -f1 | sort | uniq -c | sort -r | awk ' { print $2 } ' | xargs -n 1 geoiplookup -f GeoLiteCity.dat | sort > output.txt

IP | Visits | Country

Cron every N minutes (da vedere di non far coincidere i due cron) Popolare la colonna country con SCRIPT GETCountryFromIP

SCP GET Access.Log from N servers

CRON N minutes : Script Counting IP | Visits

root@Lupin77:~/geo# grep -vwE "(not found|resolve hostname)" output.txt > output2.txt

Nella tabella 2 Counter | Country | Timestamp vanno calcolate le visite per paese sommando le Visits di ogni paese Come si fa???

@6am TRUNCATE T2 & T3

Ottengo Table2 Counter | Country | Timestamp da convertire in JSON ogni tot minuti in CRON

Ogni TOT la pagina PHP si refresha prendendo i nuovi dati JSON Put Export.CSV into MYSQL TABLE1 IP | COUNTRY | VISITS

Insert INTO T2 [Select xxx of T1] troncate t3 Se vuota, come ad es alle 6 am, prende i primi dati del giorno. se piena, aggiunge i nuovi parziali. ci saranno piu' record per country con tutti i parziali

insert into t3 select xxx of T2 prendere i dati e dividerli per 1000 PRIMA TRONCO poi join della T3 con la tabella delle coordinate
select coordinates.country, coordinates.longitude, coordinates.latitude, table3.totale from coordinates, table3 where coordinates.country = table3.country

in questo modo totalizzo i parziali della t2 di tutta la giornata


INSERT into table2(COUNTRY,TOTALE) select COUNTRY, SUM(VISITS) AS TOTALE FROM table1 GROUP BY COUNTRY ORDER BY COUNTRY INSERT into table3(COUNTRY,TOTALE) select COUNTRY, SUM(TOTALE) AS TOTALE FROM table2 GROUP BY COUNTRY ORDER BY COUNTRY

SELECT CONCAT ( "[",

export json

GROUP_CONCAT( CONCAT(LATITUDE,","), CONCAT(LONGITUDE,","), CONCAT(TOTALE)

insert into table4(country, longitude, latitude, totale) select coordinates.country, coordinates.longitude, coordinates.latitude, table3.totale from coordinates, table3 where coordinates.country = table3.country

) , "]" ) AS JSON FROM table4

SELECT CONCAT ( "[", GROUP_CONCAT( CONCAT(LATITUDE,","), CONCAT(LONGITUDE,","), CONCAT(TOTALE/1000) ) , "]" ) AS JSON FROM table4

SELECT CONCAT( "[[\"VISITE\",[", GROUP_CONCAT( CONCAT(LATITUDE,","), CONCAT(LONGITUDE,","), CONCAT(TOTALE/1000) ) , "]]]" ) AS JSON FROM table4

$filename = time() . '.txt'; $fp = fopen($filename,'w'); fputs($fp,$mysql); fclose($fp); If you want the filename with actual date numbering instead of a UNIX timestamp, use this instead: $filename = date('YmdHis').'.txt'; You'll have to get your data into an exportable format of course... the code above assumes that $mysql contains your data and not just a query resource.

INSERT INTO JSON(JSON) SELECT CONCAT( "[[\"VISITE\",[", GROUP_CONCAT( CONCAT(LATITUDE2,","), CONCAT(LONGITUDE2,","), CONCAT(COUNTER2/1000) ) , "]]]" ) AS JSON FROM TABLE_B

You might also like