From: xchaos Date: Thu, 11 Oct 2012 22:49:11 +0000 (+0000) Subject: more information in json output (for mailing system) X-Git-Url: https://git.harvie.cz/?a=commitdiff_plain;h=e48d46c959233c89ccd6ccd411b31704610abb71;p=svn%2FPrometheus-QoS%2F.git more information in json output (for mailing system) git-svn-id: https://dev.arachne.cz/repos/prometheus/trunk@204 251d49ef-1d17-4917-a970-b30cf55b089b --- diff --git a/htmlandlogs.c b/htmlandlogs.c index f624a48..73a3d0f 100644 --- a/htmlandlogs.c +++ b/htmlandlogs.c @@ -225,8 +225,7 @@ void write_htmlandlogs(char *html, char *d, int total, int just_preview) } fprintf(f,"%Lu\n", ip->credit); fprintf(f,"%Lu", - ip->keyword->html_color, - ip->credit+(ip->min*ip->keyword->data_limit+(ip->keyword->fixed_limit<<20))); + ip->keyword->html_color, ip->realquota); fprintf(f,"%s%Lu%s", f1, ip->traffic, f2); /* download --------------------------------------- */ diff --git a/ipstruct.h b/ipstruct.h index 2410047..dcf5bfa 100644 --- a/ipstruct.h +++ b/ipstruct.h @@ -16,6 +16,7 @@ struct IP unsigned long long upload; unsigned long long traffic; unsigned long long credit; + unsigned long long realquota; unsigned long pktsup; unsigned long pktsdown; struct Keyword *keyword; diff --git a/json.c b/json.c index abf8c4e..c9c63f0 100644 --- a/json.c +++ b/json.c @@ -21,8 +21,11 @@ void write_json_traffic(char *json) { fprintf(f, ",\n"); } - fprintf(f, " \"%s\":{ \"lms\": %d, \"ip\":\"%s\", \"total\":%Lu, \"down\":%Lu, \"proxy\":%Lu, \"up\":%Lu, \"min\":%d, \"max\":%d, \"limit\":%d }", - ip->name, ip->lmsid, ip->addr, ip->traffic, ip->direct, ip->proxy, ip->upload, ip->min, ip->desired, ip->max); + fprintf(f, " \"%s\":{ \"lms\": %d, \"ip\":\"%s\", \"total\":%Lu, \"down\":%Lu, \"proxy\":%Lu, \"up\":%Lu,\ + \"min\":%d, \"max\":%d, \"limit\":%d, \"realquota\":%Lu, \"credit\":%Lu, \"dailyquota\":%ld }", + ip->name, ip->lmsid, ip->addr, ip->traffic, ip->direct, ip->proxy, ip->upload, + ip->min, ip->desired, ip->max, ip->realquota, ip->credit, + (ip->min*ip->keyword->data_limit+(ip->keyword->fixed_limit<<20))); jsoncount++; } } diff --git a/prometheus.c b/prometheus.c index e068b8e..2eda259 100644 --- a/prometheus.c +++ b/prometheus.c @@ -980,13 +980,14 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version); for_each(ip, ips) if(ip->min == group->min && ip->max > ip->min) { - if( ip->keyword->data_limit && !ip->fixedprio - && ( ip->traffic>ip->credit - + (ip->min*ip->keyword->data_limit+(ip->keyword->fixed_limit<<20))) ) + ip->realquota=ip->credit+(ip->min*ip->keyword->data_limit+(ip->keyword->fixed_limit<<20)); + if( ip->keyword->data_limit + and not ip->fixedprio + and ip->traffic > ip->realquota ) { - if(group_ratemax) + if(group_rate < ip->max) { - ip->max=group_rate; + ip->max = group_rate; } group_rate+=magic_treshold; ip->prio=lowest_priority;