X-Git-Url: https://git.harvie.cz/?a=blobdiff_plain;f=prometheus.c;h=529315d91e32ed97c5cfea649299689f7768c34c;hb=8e29188ae8234c9bab4ede7d1e8f3abd26eb621a;hp=59e2759d421023f2219a156c6993a5f1619cd215;hpb=be96b71b6e1c6b1166173ec615e799960a38a909;p=svn%2FPrometheus-QoS%2F.git
diff --git a/prometheus.c b/prometheus.c
index 59e2759..529315d 100644
--- a/prometheus.c
+++ b/prometheus.c
@@ -2,12 +2,12 @@
/* Prometheus QoS - you can "steal fire" from your ISP */
/* "fair-per-IP" quality of service (QoS) utility */
/* requires Linux 2.4.x or 2.6.x with HTB support */
-/* Copyright(C) 2005-2008 Michael Polak (xChaos) */
+/* Copyright(C) 2005-2012 Michael Polak, Arachne Labs */
/* iptables-restore support Copyright(C) 2007-2008 ludva */
/* 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,14 +33,14 @@
#include "cll1-0.6.2.h"
-const char *version = "0.8.3-d";
+const char *version = "0.8.3-f";
/* 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. */
/* 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. */
-const char *stats_html_signature = "Statistics generated by Prometheus QoS version %s
GPL+Copyright(C)2005-2012 Michael Polak, Arachne Labs\n";
+const char *stats_html_signature = "Statistics generated by Prometheus QoS version %s
GPL+Copyright(C)2005-2012 Michael Polak, Arachne Labs\n";
/* ======= All path names are defined here (for RPM patch) ======= */
@@ -58,7 +58,7 @@ 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 *json = "/var/www/traffic.json"; /* hall of fame - json version */
+char *json = "/var/www/logs/traffic.json"; /* hall of fame - 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) */
@@ -89,22 +89,21 @@ void help(void)
{
puts("Command line switches:\n\
\n\
--?, --help this help screen\n\
--v, --version show Version number of this utility and exit\n\
--c filename force alternative /etc/prometheus.Conf filename\n\
--h filename force alternative /etc/Hosts filename (overrides hosts keyword)\n\
--f just Flush iptables and tc classes and exit (stop shaping)\n\
--9 emergency iptables flush (do not read data transfer statistics)\n\
--p just generate Preview of data transfer statistics and exit\n\
--d Dry run (preview tc and iptables commands on stdout)\n\
--r Run (reset all statistics and start shaping)\n\
--n run Now (start shaping without delay - overrides qos-free-delay keyword)\n\
--l Mmm YYYY generate HTML summary of traffic Logs (Mmm=Jan-Dec or Year, YYYY=year)\n\
--m generate HTML summary of traffic logs for yesterday's Month\n\
--y generate HTML summary of traffic logs for yesterday's Year\n");
-/* not yet implemented:
--s start shaping! (keep data transfer statistics - but apply shaping)\n\
-*/
+-d Dry run (preview tc and iptables commands on stdout)\n\
+-r Run (reset all statistics and start shaping - daily usage)\n\
+-p just generate Preview of data transfer statistics and exit (after -r)\n\
+-s start Shaping FUP limits (keeps data transfer stat like -p) (after -r)\n\
+-n run Now (like -r delay - overrides qos-free-delay keyword, after boot)\n\
+-f just Flush iptables and tc classes and exit (stop shaping, no QiS)\n\
+-9 emergency iptables flush (like -f, but dumps data transfer statistics)\n\
+\n\
+-c filename force alternative /etc/prometheus/prometheus.conf filename\n\
+-h filename force alternative /etc/hosts filename (overrides hosts keyword)\n\
+-l Mmm YYYY generate HTML summary of Logged traffic (Mmm=Jan-Dec) (and exit)\n\
+-m generate HTML summary of traffic for yesterday's Month (and exit)\n\
+-y generate HTML summary of traffic for yesterday's Year (and exit)\n\
+-? --help show this help scree (and exit)\n\
+-v --version show Version number of this utility (and exit)\n");
}
/* === Configuraration file values defaults - stored in global variables ==== */
@@ -476,7 +475,7 @@ void get_config(char *config_filename)
perror(config_filename);
puts("Warning - using built-in defaults instead ...");
}
- done;
+ done; /* ugly macro end */
printf("\n");
/* leaf discipline for keywords */
@@ -610,7 +609,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
@@ -656,8 +655,7 @@ void get_traffic_statistics(void)
}
}
}
-
- free(cmd);
+ free(cmd);
}
/* ========== This function executes, logs OR ALSO prints command ========== */
@@ -689,7 +687,7 @@ void run_restore(void)
string(restor,STRLEN);
/*-----------------------------------------------------------------*/
- printf("Running %s <%s ...\n",iptablesrestore,iptablesfile);
+ printf("Running %s <%s ...\n", iptablesrestore, iptablesfile);
/*-----------------------------------------------------------------*/
save_line("COMMIT");
@@ -700,7 +698,7 @@ void run_restore(void)
{
printf("%s\n",_);
}
- done;
+ done; /* ugly macro end */
}
sprintf(restor,"%s <%s",iptablesrestore, iptablesfile);
@@ -881,7 +879,7 @@ void parse_ip_log(int argc, char **argv)
accept_month = 1;
}
}
- done;
+ done; /* ugly macro end */
if(accept_month)
{
@@ -918,13 +916,13 @@ void parse_ip_log(int argc, char **argv)
if(iplog->traffic)
{
fprintf(f, "%s