]>
git.ipfire.org Git - thirdparty/sarg.git/blob - totger.c
2 * AUTHOR: Pedro Lineu Orso pedro.orso@gmail.com
4 * SARG Squid Analysis Report Generator http://sarg.sourceforge.net
7 * please look at http://sarg.sourceforge.net/donations.php
8 * ---------------------------------------------------------------------
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
26 #include "include/conf.h"
27 #include "include/defs.h"
29 int totalger(const char *dirname
, int debug
, const char *outdir
)
32 long long int tnacc
=0;
33 long long int tnbytes
=0;
34 long long int telap
=0;
35 long long int tincache
=0, toucache
=0;
36 char wger
[MAXLEN
], user
[MAXLEN
], nacc
[16], nbytes
[16], url
[MAXLEN
];
37 char ip
[MAXLEN
], hora
[9], data
[11], elap
[16];
38 char incac
[16], oucac
[16];
42 strcat(wger
,"/sarg-general");
44 if((fp_in
=fopen(wger
,"r"))==NULL
) {
45 fprintf(stderr
, "SARG: (totger) %s: %s\n",text
[45],wger
);
49 while(fgets(warea
,sizeof(warea
),fp_in
))
51 //printf("%s\n",warea);
52 if (getword(user
,sizeof(user
),warea
,' ')<0) {
53 printf("SARG: Maybe you have a broken user in your %s file.\n",wger
);
56 if (getword(nacc
,sizeof(nacc
),warea
,' ')<0) {
57 printf("SARG: Maybe you have a broken number of access in your %s file.\n",wger
);
60 if (getword(nbytes
,sizeof(nbytes
),warea
,' ')<0) {
61 printf("SARG: Maybe you have a broken number of bytes in your %s file.\n",wger
);
64 if (getword(url
,sizeof(url
),warea
,' ')<0) {
65 printf("SARG: Maybe you have a broken url in your %s file.\n",wger
);
68 if (getword(ip
,sizeof(ip
),warea
,' ')<0) {
69 printf("SARG: Maybe you have a broken source IP address in your %s file.\n",wger
);
72 if (getword(hora
,sizeof(hora
),warea
,' ')<0) {
73 printf("SARG: Maybe you have a broken time in your %s file.\n",wger
);
76 if (getword(data
,sizeof(data
),warea
,' ')<0) {
77 printf("SARG: Maybe you have a broken date in your %s file.\n",wger
);
80 if (getword(elap
,sizeof(elap
),warea
,' ')<0) {
81 printf("SARG: Maybe you have a broken elapsed time in your %s file.\n",wger
);
84 if (getword(incac
,sizeof(incac
),warea
,' ')<0) {
85 printf("SARG: Maybe you have a broken in cache column in your %s file.\n",wger
);
88 if (getword(oucac
,sizeof(oucac
),warea
,0)<0) {
89 printf("SARG: Maybe you have a broken not in cache column in your %s file.\n",wger
);
92 tnacc
+=my_atoll(nacc
);
93 tnbytes
+=my_atoll(nbytes
);
94 telap
+=my_atoll(elap
);
95 tincache
+=my_atoll(incac
);
96 toucache
+=my_atoll(oucac
);
101 strcpy(wger
,dirname
);
102 strcat(wger
,"/sarg-general");
104 if((fp_ou
=fopen(wger
,"a"))==NULL
) {
105 fprintf(stderr
, "SARG: (totger) %s: %s\n",text
[45],wger
);
111 my_lltoa(tnacc
,val1
,15);
112 my_lltoa(tnbytes
,val2
,15);
113 my_lltoa(telap
,val3
,15);
114 my_lltoa(tincache
,val4
,15);
115 my_lltoa(toucache
,val5
,15);
116 fprintf(fp_ou
,"TOTAL %s %s %s %s %s\n",val1
,val2
,val3
,val4
,val5
);