X-Git-Url: http://git.harvie.cz/?a=blobdiff_plain;f=prometheus.c;h=d8eaef2d44f4dee405ef9d603ce9b082cffdca43;hb=b1b59b3a2f8b0ced214ac4a832966bd3239a8610;hp=28d9894da561e8e115575bfd776de66902212fa5;hpb=70c65cfe58aa1ca614dc1acc7fa7eff03350e6c3;p=svn%2FPrometheus-QoS%2F.git diff --git a/prometheus.c b/prometheus.c index 28d9894..d8eaef2 100644 --- a/prometheus.c +++ b/prometheus.c @@ -7,8 +7,8 @@ /* Credit: CZFree.Net,Martin Devera,Netdave,Aquarius,Gandalf */ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -/* Modified: xChaos, 20080407 - ludva, 20071227 +/* Modified: xChaos, 20080422 + ludva, 20080415 Prometheus QoS is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -33,9 +33,14 @@ #include "cll1-0.6.h" -const char *version="0.7.9.1"; /*0.7.9 will be last development, 0.8.0 first stable */ +const char *version="0.7.9-c"; -/* ======= All path names are defined hear (for RPM patch) ======= */ +/* Version numbers: 0.7.9 will be last development ("beta"), 0.8.0 first stable */ +/* Debian(RPM) package versions/patchlevels: 0.7.9-2, 0.8.0-1, 0.8.0-2, etc. */ +/* C source code development versions ("beta"): 0.7.9-a, 0.8.1-b, etc. */ +/* C source code release versions: 0.8.0, 0.8.2, 0.8.4, etc. */ + +/* ======= All path names are defined here (for RPM patch) ======= */ char *tc = "/sbin/tc"; /* requires tc with HTB support */ char *iptables = "/sbin/iptables"; /* requires iptables utility */ @@ -435,7 +440,7 @@ void get_config(char *config_filename) /* are supplied values meaningful ?*/ if(line<=0 || up<=0) { - puts("Illegal value of wan bandwidth: 0 kbps."); + puts("Illegal value of LAN or WAN bandwidth: 0 kbps."); reject_config_and_exit(config_filename); } } @@ -683,6 +688,7 @@ void parse_ip_log(int argc, char **argv) sprintf(str,"%s %s/*.log",ls,log_dir); shell(str); + input(str,STRLEN) { ptr=strrchr(str,'\n'); @@ -697,12 +703,19 @@ void parse_ip_log(int argc, char **argv) { case 2: name=ptr;break; case 3: traffic=atol(ptr);break; - case 7: valid_columns(ptr2,ptr,' ',col2) switch(col2) + /* column number - was 7, now 9...*/ + case 7: + case 8: + case 9: if (isalnum(*ptr)) /* alphanumeric string = date, just one*/ { - case 2: if(any_month || eq(ptr2,month)) m_ok=1; break; - case 5: if(eq(ptr2,year)) y_ok=1; break; + valid_columns(ptr2,ptr,' ',col2) switch(col2) + { + case 2: if(any_month || eq(ptr2,month)) m_ok=1; break; + case 5: if(eq(ptr2,year)) y_ok=1; break; + } } } + if(y_ok && m_ok) { traffic_month+=traffic; @@ -710,6 +723,7 @@ void parse_ip_log(int argc, char **argv) } } done; + if(accept_month) { create(iplog,IpLog); @@ -755,7 +769,9 @@ program int parent=1; int just_flush=0; int nodelay=0; - int just_preview=0; /* preview - generate just stats */ + int just_preview=0; /* preview - generate just stats */ + int just_logs=0; /* just parse logs */ + char *chain_forward, *chain_postrouting; char *althosts=NULL; @@ -776,9 +792,9 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version); argument("-9") { just_flush=9; } argument("-p") { just_preview=1; } argument("-n") { nodelay=1; } - argument("-l") { just_preview=666; } - argument("-m") { just_preview=666; } - argument("-y") { just_preview=666; } + argument("-l") { just_logs=1; } + argument("-m") { just_logs=1; } + argument("-y") { just_logs=1; } argument("-?") { help(); exit(0); } argument("--help") { help(); exit(0); } argument("-v") { exit(0); } @@ -795,10 +811,10 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version); /*-----------------------------------------------------------------*/ get_config(config); - if(just_preview == 666) + if(just_logs) { - parse_ip_log(argc,argv); - exit(0); + parse_ip_log(argc,argv); + exit(0); } if(althosts) hosts=althosts; @@ -1373,8 +1389,8 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version); iplog=fopen(str,"a"); if(iplog) { - fprintf(iplog,"%ld\t%s\t%Lu\t%Lu\t%Lu\t%Lu\t%d\t%d\t%s", - time(NULL),ip->name,ip->traffic,ip->direct,ip->proxy,ip->upload,ip->min,ip->max,d); /* d = date*/ + fprintf(iplog,"%ld\t%s\t%Lu\t%Lu\t%Lu\t%Lu\t%d\t%d\t%d\t%s", + time(NULL),ip->name,ip->traffic,ip->direct,ip->proxy,ip->upload,ip->min,ip->max,ip->desired,d); /* d = date*/ fclose(iplog); } }