Prenosy sharujicich IPcek jsou nyni rozkliknutelne (pomoci JQuery)
[svn/Prometheus-QoS/.git] / prometheus.c
index 5420588d352e8d6550e0c430305926ea2e33bfc2..0ea9378bb4406bc4cabcdfe2b3c489754fc373b7 100644 (file)
@@ -7,7 +7,7 @@
 /*  Credit: CZFree.Net,Martin Devera,Netdave,Aquarius,Gandalf  */\r
 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  */\r
 \r
-/* Modified by: xChaos, 20110428\r
+/* Modified by: xChaos, 20111130\r
                  ludva, 20080415\r
  \r
    Prometheus QoS is free software; you can redistribute it and/or\r
@@ -33,7 +33,7 @@
 \r
 #include "cll1-0.6.2.h"\r
 \r
-const char *version = "0.8.3"; \r
+const char *version = "0.8.3-b";\r
 \r
 /* Version numbers: 0.8.3 is development releases ("beta"), 0.8.4 will be "stable" */\r
 /* Debian(RPM) package versions/patchlevels: 0.7.9-2, 0.8.0-1, 0.8.0-2, etc. */\r
@@ -1511,6 +1511,7 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version);
   printf("Sorting data and generating statistics page %s ...\n",ptr);\r
   /*-----------------------------------------------------------------*/\r
 \r
+  fputs("<script type=\"text/javascript\" src=\"/jquery.js\"></script>\n",f);\r
   fputs("<table border>\n<tr><th align=\"right\">#</th><th align=\"right\">group</th><th align=\"right\">IPs</th><th align=\"right\">requested</th>\n",f);\r
   fprintf(f,"<th colspan=\"%d\">data limits</th>\n",keywordcount);\r
   fputs("</tr>\n",f);\r
@@ -1525,7 +1526,7 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version);
 \r
    for_each(keyword,keywords)\r
    {\r
-    fprintf(f,"<td align=\"right\"><font color=\"#%s\">%d M</font></td>",keyword->html_color,group->min*keyword->data_limit);\r
+    fprintf(f,"<td align=\"right\"><span style=\"color:#%s\">%d M</span></td>",keyword->html_color,group->min*keyword->data_limit);\r
    }   \r
    i+=group->desired; \r
    total+=group->count;\r
@@ -1554,11 +1555,12 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version);
  {\r
   unsigned long long total_traffic=0, total_direct=0, total_proxy=0, total_upload=0, tmp_sum=0;\r
   int active_classes=0;\r
-  int colspan;\r
+  int colspan=11;\r
   FILE *iplog;\r
   struct Sum {unsigned long long l; int i; list(Sum);} *sum,*sums=NULL;\r
+  int limit_count=0, prio_count=0;\r
+  int popup_button=0;\r
 \r
-  colspan=11;\r
   if(qos_proxy)\r
   {\r
    colspan++;\r
@@ -1594,19 +1596,38 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version);
    char *f1="", *f2="";\r
    if(ip->max<ip->desired)\r
    {\r
-    f1="<font color=\"red\">";\r
-    f2="</font>";\r
+    f1="<span style=\"color:red\">";\r
+    f2="</span>";\r
+    limit_count++;\r
    }\r
    else if(ip->prio>highest_priority+1)\r
    {\r
-    f1="<font color=\"brown\">";\r
-    f2="</font>";\r
+    f1="<span style=\"color:brown\">";\r
+    f2="</span>";\r
+    prio_count++;\r
    }\r
 \r
 #ifdef DEBUG\r
    printf("%03d. %-22s %10Lu (%d/%d)\n",i ,ip->name, ip->traffic, ip->min, ip->max); \r
 #endif\r
-   fprintf(f,"<tr><td align=\"right\"><a name=\"%s\"></a>%d</td><td><a href=\"%s%s.log\">%s</a></td>\n", ip->name, i, log_url, ip->name, ip->name);\r
+   /* hostnames -------------------------------------- */\r
+   fprintf(f,"<tr><td align=\"right\"><a name=\"%s\"></a>%d</td><td><a href=\"%s%s.log\">%s</a>\n", ip->name, i, log_url, ip->name, ip->name);   \r
+   fprintf(f,"<span id=\"sharing_%d\" style=\"display:none\">",i);\r
+   popup_button=0;\r
+   for_selected(sharedip,ips,eq(ip->name,sharedip->sharing))\r
+   {\r
+    fprintf(f,"<br /><a href=\"%s%s.log\">%s</a>\n", log_url, sharedip->name, sharedip->name);\r
+    popup_button=1;\r
+   }\r
+   fputs("</span>\n",f);\r
+   if(popup_button)\r
+   {\r
+    fprintf(f,"<span id=\"toggle_%d\">[<a href=\"#\" onClick=\"$(\'#toggle_%d\').remove();$(\'#sharing_%d\').show();$(\'#download_%d\').show();$(\'#upload_%d\').show();return(false);\" style=\"cursor: pointer; text-decoration:none;\">+</a>]</span>",\r
+              i, i, i, i, i);\r
+   }\r
+   fputs("</td>\n",f);\r
+   /* ----------------------------------------------- */\r
+\r
    if(found_lmsid)\r
    {\r
     fputs("<td align=\"right\">",f);\r
@@ -1619,17 +1640,38 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version);
     {\r
      fputs("-------",f);\r
     }\r
-    fputs("</td>\n",f);    \r
+    fputs("</td>\n",f);\r
    }\r
    fprintf(f,"<td align=\"right\">%Lu M</td>\n", ip->credit);\r
-   fprintf(f,"<td align=\"right\"><font color=\"#%s\">%Lu M</font></td>",\r
-             ip->keyword->html_color, ip->credit+(ip->min*ip->keyword->data_limit+(ip->keyword->fixed_limit<<20)));\r
-   fprintf(f,"<td align=\"right\">%s%Lu M%s</td><td align=\"right\">%Lu M</td>\n", f1, ip->traffic, f2, ip->direct);\r
+   fprintf(f,"<td align=\"right\"><span style=\"color:#%s\">%Lu M</span></td>",\r
+             ip->keyword->html_color,\r
+             ip->credit+(ip->min*ip->keyword->data_limit+(ip->keyword->fixed_limit<<20)));\r
+   fprintf(f,"<td align=\"right\">%s%Lu M%s",f1, ip->traffic, f2);\r
+\r
+   /* download --------------------------------------- */\r
+   fprintf(f,"</td><td align=\"right\">%Lu M", ip->direct);\r
+   fprintf(f,"<span id=\"download_%d\" style=\"display:none\">",i);\r
+   for_selected(sharedip,ips,eq(ip->name,sharedip->sharing))\r
+   {\r
+    fprintf(f,"<br />%Lu M", sharedip->direct);\r
+   }\r
+   fputs("</span></td>\n",f);\r
+   /* ----------------------------------------------- */\r
+\r
    if(qos_proxy)\r
    {\r
     fprintf(f,"<td align=\"right\">%Lu M</td>\n", ip->proxy);\r
    }\r
-   fprintf(f,"<td align=\"right\">%Lu M</td>\n", ip->upload);\r
+   /* upload ---------------------------------------- */\r
+   fprintf(f,"<td align=\"right\">%Lu M", ip->upload);\r
+   fprintf(f,"<span id=\"upload_%d\" style=\"display:none\">",i);\r
+   for_selected(sharedip,ips,eq(ip->name,sharedip->sharing))\r
+   {\r
+    fprintf(f,"<br />%Lu M", sharedip->upload);\r
+   }\r
+   fputs("</span></td>\n",f);\r
+   /* ----------------------------------------------- */\r
+\r
    fprintf(f,"<td align=\"right\">%d k</td><td align=\"right\">%d k</td><td align=\"right\">%s%d k%s</td><td>%s%d%s</td></tr>\n",\r
              ip->min,ip->desired,f1,ip->max,f2,f1,ip->prio,f2);\r
    total_traffic+=ip->traffic;\r
@@ -1661,14 +1703,13 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version);
    }\r
   }\r
   fprintf(f,"<tr><th colspan=\"%d\" align=\"left\">SUMMARY:</td>",colspan-7);\r
-  fprintf(f,"<th align=\"right\">%Lu M</th>\\r
-  <th align=\"right\">%Lu M</th>\n", total_traffic, total_direct);\r
+  fprintf(f,"<th align=\"right\">%Lu M</th><th align=\"right\">%Lu M</th>\n", total_traffic, total_direct);\r
   if(qos_proxy)\r
   {\r
    fprintf(f,"<th align=\"right\">%Lu M</th>\n", total_proxy);\r
   }\r
   fprintf(f,"<th align=\"right\">%Lu M</th>", total_upload);\r
-  fputs("<td colspan=\"4\"></td></th>\n</table>\n",f);\r
+  fprintf(f,"<th colspan=\"4\"><span style=\"color:red\">FUP-LIMIT %dx</span> <span style=\"color:brown\">LOW-PRIO %dx</span></th></tr>\n</table>\n",limit_count,prio_count);\r
 \r
   if(active_classes>10)\r
   {\r
@@ -1743,8 +1784,9 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version);
     iplog=fopen(str,"a");\r
     if(iplog)\r
     {\r
-     fprintf(iplog,"%ld\t%d\t%d %%\t%Lu M\t%Ld %%\t%d\t%Lu M\t%d\t%s",\r
-                    time(NULL), top20_count, top20_perc1, top20_sum, top20_perc2, active_classes, total_traffic, total, d); /* d = date*/\r
+     fprintf(iplog,"%ld\t%d\t%d %%\t%Lu M\t%Ld %%\tACTIVE %d\tTRAFFIC %Lu M\tCLASSES %d\tFUP-LIMIT %d\tLOW-PRIO %d\t%s",\r
+                   time(NULL), top20_count, top20_perc1, top20_sum, top20_perc2, \r
+                   active_classes, total_traffic, total, limit_count, prio_count, d); /* d = date*/\r
      fclose(iplog);\r
     }\r
    }\r
This page took 0.155225 seconds and 4 git commands to generate.