X-Git-Url: https://git.harvie.cz/?a=blobdiff_plain;f=prometheus.c;h=b6eeb27beb663cf9a18eed5131cd5b72bd9d766b;hb=6fb3c58ad91b3214a985824e1eb51ecaae442c60;hp=529315d91e32ed97c5cfea649299689f7768c34c;hpb=8e29188ae8234c9bab4ede7d1e8f3abd26eb621a;p=svn%2FPrometheus-QoS%2F.git
diff --git a/prometheus.c b/prometheus.c
index 529315d..b6eeb27 100644
--- a/prometheus.c
+++ b/prometheus.c
@@ -7,7 +7,7 @@
/* Credit: CZFree.Net,Martin Devera,Netdave,Aquarius,Gandalf */
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
-/* Modified by: xChaos, 20120610
+/* Modified by: xChaos, 20120612
ludva, 20080415
Prometheus QoS is free software; you can redistribute it and/or
@@ -57,8 +57,9 @@ char *iptablesfile = "/var/spool/prometheus.iptables"; /* temporary file for
char *credit = "/var/lib/misc/prometheus.credit"; /* credit log file */
char *classmap = "/var/lib/misc/prometheus.classes"; /* credit log file */
char *html = "/var/www/traffic.html"; /* hall of fame - html version */
-char *preview = "/var/www/preview.html"; /* hall of fame preview */
+char *preview = "/var/www/preview.html"; /* hall of fame preview - html version */
char *json = "/var/www/logs/traffic.json"; /* hall of fame - json version */
+char *json_preview = "/var/www/logs/preview.json"; /* hall of fame preview - json version */
char *cmdlog = "/var/log/prometheuslog"; /* command log filename */
char *log_dir = "/var/www/logs/"; /* log directory pathname, ended with slash */
char *log_url = "/logs/"; /* log directory relative URI prefix (partial URL) */
@@ -439,6 +440,7 @@ void get_config(char *config_filename)
option("hall-of-fame-filename",html);
option("json-filename",json);
option("hall-of-fame-preview",preview);
+ option("json-preview",json_preview);
option("log-filename",cmdlog);
option("credit-filename",credit);
option("classmap-filename",classmap);
@@ -1673,13 +1675,14 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version);
}
done; /* ugly macro end */
}
- f=fopen(preview,"w");
- ptr=preview;
+ html=preview;
+ json=json_preview;
}
- else if(!dry_run && !just_flush)
+
+ if(!dry_run && !just_flush)
{
/*-----------------------------------------------------------------*/
- printf("Writing daily statistics %s ... ", json);
+ printf("Writing json overview %s ... ", json);
/*-----------------------------------------------------------------*/
f=fopen(json, "w");
if(f > 0)
@@ -1695,8 +1698,8 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version);
{
fprintf(f, ",\n");
}
- 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);
+ 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);
jsoncount++;
}
}
@@ -1708,17 +1711,16 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version);
{
perror(json);
}
- f=fopen(html,"w");
- ptr=html;
}
- if(f)
+ f=fopen(html,"w");
+ if(f > 0)
{
int count=1;
i=0;
/*-----------------------------------------------------------------*/
- printf("Sorting data and generating statistics page %s ...\n", ptr);
+ printf("Sorting data and generating statistics page %s ...\n", html);
/*-----------------------------------------------------------------*/
if(use_jquery_popups)
@@ -1779,7 +1781,7 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version);
}
i=0;
- if(f)
+ if(f > 0)
{
unsigned long long total_traffic=0, total_direct=0, total_proxy=0, total_upload=0, tmp_sum=0;
int active_classes=0;
@@ -1829,7 +1831,19 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version);
{
char *f1="", *f2="";
i++;
-
+
+ if(ip->max < ip->desired)
+ {
+ f1="";
+ f2="";
+ limit_count++;
+ }
+ else if(ip->prio > highest_priority+1)
+ {
+ f1="";
+ f2="";
+ prio_count++;
+ }
#ifdef DEBUG
printf("%03d. %-22s %10Lu (%d/%d)\n",i ,ip->name, ip->traffic, ip->min, ip->max);
@@ -2214,7 +2228,7 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version);
safe_run(str);
}
- if(f)
+ if(f > 0)
{
fprintf(f, "%s %d\n", ip->addr, ip->mark);
}
@@ -2227,7 +2241,7 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version);
}
i++;
}
- if(f)
+ if(f > 0)
{
puts("done.");
fclose(f);