X-Git-Url: https://git.harvie.cz/?p=svn%2FPrometheus-QoS%2F.git;a=blobdiff_plain;f=prometheus.c;h=e58677c13350faa9af4fe1783fbab7f050fc9cca;hp=f12de1530e477e15cf1fbf45689f2f31aa56f352;hb=105c88bcf2ecbb305ec3003907a376b8d5771f8f;hpb=4f4d182088d6b40224a5475f284a9c756ae604a1
diff --git a/prometheus.c b/prometheus.c
index f12de15..e58677c 100644
--- a/prometheus.c
+++ b/prometheus.c
@@ -7,7 +7,7 @@
/* Credit: CZFree.Net,Martin Devera,Netdave,Aquarius,Gandalf */
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
-/* Modified by: xChaos, 20120516
+/* Modified by: xChaos, 20120610
ludva, 20080415
Prometheus QoS is free software; you can redistribute it and/or
@@ -33,7 +33,7 @@
#include "cll1-0.6.2.h"
-const char *version = "0.8.3-d";
+const char *version = "0.8.3-e";
/* Version numbers: 0.8.3 is development releases ("beta"), 0.8.4 will be "stable" */
/* Debian(RPM) package versions/patchlevels: 0.7.9-2, 0.8.0-1, 0.8.0-2, etc. */
@@ -610,7 +610,7 @@ void get_traffic_statistics(void)
{
printf("(upload) ");
}
- printf("IP %s: %Lu M (%ld pkts)\n", ipaddr, traffic, pkts);
+ printf("IP %s: %Lu MB (%ld pkts)\n", ipaddr, traffic, pkts);
if_exists(ip,ips,eq(ip->addr,ipaddr));
else
@@ -958,7 +958,11 @@ void parse_ip_log(int argc, char **argv)
if_exists(iplog,iplogs,iplog->l>=total/4)
{
fprintf(f,"%s
Top 25%% of traffic | \n", tr_odd_even());
- fprintf(f,"%d | %d %% | %ld G | %d %% | \n",iplog->i,(100*iplog->i+50)/i,iplog->l,(int)((100*iplog->l+50)/total));
+ fprintf(f,"%d | \n\
+%d %% | \n\
+%ld GB | \n\
+%d %% | \n",
+ iplog->i, (100*iplog->i+50)/i, iplog->l, (int)((100*iplog->l+50)/total));
}
if_exists(iplog,iplogs,iplog->i==10)
@@ -966,9 +970,9 @@ void parse_ip_log(int argc, char **argv)
fprintf(f,"%sTop 10 downloaders | \n", tr_odd_even());
fprintf(f,"10 | \n\
%d %% | \n\
-%ld G | \n\
+%ld GB | \n\
%d %% | \n",
- (100*iplog->i+50)/i,iplog->l,(int)((100*iplog->l+50)/total));
+ (100*iplog->i+50)/i, iplog->l, (int)((100*iplog->l+50)/total));
}
if_exists(iplog,iplogs,iplog->l>=total/2)
@@ -976,7 +980,7 @@ void parse_ip_log(int argc, char **argv)
fprintf(f,"%sTop 50%% of traffic | \n", tr_odd_even());
fprintf(f,"%d | \n\
%d %% | \n\
-%ld G | \n\
+%ld GB | \n\
%d %% | \n",
iplog->i,(100*iplog->i+50)/i,iplog->l,(int)((100*iplog->l+50)/total));
}
@@ -986,9 +990,9 @@ void parse_ip_log(int argc, char **argv)
fprintf(f,"%sTop 80%% of traffic | \n",tr_odd_even());
fprintf(f,"%d | \n\
%d %% | \n\
-%ld G | \n\
+%ld GB | \n\
%d %% | \n",
- iplog->i,(100*iplog->i+50)/i,iplog->l,(int)((100*iplog->l+50)/total));
+ iplog->i, (100*iplog->i+50)/i, iplog->l, (int)((100*iplog->l+50)/total));
}
if_exists (iplog,iplogs,iplog->i>=i/5)
@@ -996,15 +1000,19 @@ void parse_ip_log(int argc, char **argv)
fprintf(f,"%sTop 20%% downloaders | \n",tr_odd_even());
fprintf(f,"%d | \n\
%d %% | \n\
-%ld G | \n\
+%ld GB | \n\
%d %% | \n",
- iplog->i,(100*iplog->i+50)/i,iplog->l,(int)((100*iplog->l+50)/total));
+ iplog->i, (100*iplog->i+50)/i, iplog->l, (int)((100*iplog->l+50)/total));
}
if_exists(iplog,iplogs,iplog->i>=i/4)
{
fprintf(f,"%sTop 25%% downloaders | \n", tr_odd_even());
- fprintf(f,"%d | %d %% | %ld G | %d %% | \n",iplog->i,(100*iplog->i+50)/i,iplog->l,(int)((100*iplog->l+50)/total));
+ fprintf(f,"%d | \n\
+%d %% | \n\
+%ld GB | \n\
+%d %% | \n",
+ iplog->i, (100*iplog->i+50)/i, iplog->l, (int)((100*iplog->l+50)/total));
}
if_exists(iplog,iplogs,iplog->i>=i/2)
@@ -1012,19 +1020,25 @@ void parse_ip_log(int argc, char **argv)
fprintf(f,"%sTop 50%% downloaders | \n",tr_odd_even());
fprintf(f,"%d | \n\
%d %% | \n\
-%ld G | %d %% | \n",iplog->i,(100*iplog->i+50)/i,iplog->l,(int)((100*iplog->l+50)/total));
+%ld GB | \n\
+%d %% | \n",
+ iplog->i, (100*iplog->i+50)/i, iplog->l, (int)((100*iplog->l+50)/total));
}
if_exists(iplog,iplogs,iplog->i>=4*i/5)
{
fprintf(f,"%sTop 80%% downloaders | \n",tr_odd_even());
- fprintf(f,"%d | %d %% | %ld G | %d %% | \n",iplog->i,(100*iplog->i+50)/i,iplog->l,(int)((100*iplog->l+50)/total));
+ fprintf(f,"%d | \n\
+%d %% | \n\
+%ld GB | \n\
+%d %% | \n",
+ iplog->i, (100*iplog->i+50)/i, iplog->l, (int)((100*iplog->l+50)/total));
}
fprintf(f,"All users, all traffic | \n", log_url);
fprintf(f,"%d | \n\
100 %% | \n\
-%ld G | \n\
+%ld GB | \n\
100 %% |
\n",i-1,total);
fputs("\n", f);
}
@@ -1639,10 +1653,11 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version);
{
fprintf(f, ",\n");
}
- if(ip->traffic || ip->direct || ip->proxy || ip->upload)
+ if( ip->lmsid > 0
+ && (ip->traffic || ip->direct || ip->proxy || ip->upload))
{
- fprintf(f, " %d:{ \"ip\":\"%s\", \"total\":%Lu, \"down\":%Lu, \"proxy\":%Lu, \"up\":%Lu }",
- ip->lmsid, ip->addr, ip->traffic, ip->direct, ip->proxy, ip->upload);
+ fprintf(f, " \"%s\":{ \"lms\": %d, \"ip\":\"%s\", \"total\":%Lu, \"down\":%Lu, \"proxy\":%Lu, \"up\":%Lu }",
+ ip->name, ip->lmsid, ip->addr, ip->traffic, ip->direct, ip->proxy, ip->upload);
}
jsoncount++;
}
@@ -1924,7 +1939,11 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version);
if_exists(sum,sums,sum->l>=total_traffic/4)
{
fprintf(f,"%sTop 25%% of traffic | \n", tr_odd_even());
- fprintf(f,"%d | %d %% | %Lu M | %Ld %% | \n",sum->i,(100*sum->i+50)/active_classes,sum->l,(100*sum->l+50)/total_traffic);
+ fprintf(f,"%d | \n\
+%d %% | \n\
+%Lu MB | \n\
+%Ld %% | \n",
+ sum->i, (100*sum->i+50)/active_classes, sum->l, (100*sum->l+50)/total_traffic);
}
if_exists(sum,sums,sum->i==10)
@@ -1934,7 +1953,7 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version);
%d %% | \n\
%Lu MB | \n\
%Ld %% | \n",
- (100*sum->i+50)/active_classes,sum->l,(100*sum->l+50)/total_traffic);
+ (100*sum->i+50)/active_classes, sum->l, (100*sum->l+50)/total_traffic);
}
if_exists(sum,sums,sum->l>=total_traffic/2)
@@ -2004,7 +2023,7 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version);
fprintf(f,"All users, all traffic | \n", log_url);
fprintf(f,"%d | \n\
100 %% | \n\
-%Lu M | \n\
+%Lu MB | \n\
100 %% |
\n",active_classes,total_traffic);
fputs("\n", f);
@@ -2165,7 +2184,7 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version);
if(f)
{
- fprintf(f, "%s %d", ip->addr, ip->mark);
+ fprintf(f, "%s %d\n", ip->addr, ip->mark);
}
}
else