-rw-r--r-- | configure.ac | 18 | ||||
-rw-r--r-- | src/graph.c | 1 | ||||
-rw-r--r-- | src/html.gram.y | 34 | ||||
-rw-r--r-- | src/html.lex.l | 10 | ||||
-rw-r--r-- | src/log.c | 16 | ||||
-rw-r--r-- | src/main.c | 77 | ||||
-rw-r--r-- | src/readconfig.c | 32 | ||||
-rw-r--r-- | src/report.c | 40 | ||||
-rw-r--r-- | src/stat.c | 65 | ||||
-rw-r--r-- | src/tagr.h | 5 |
10 files changed, 167 insertions, 131 deletions
diff --git a/configure.ac b/configure.ac index a622998..70e0c79 100644 --- a/configure.ac +++ b/configure.ac | |||
@@ -74,8 +74,26 @@ AC_CHECK_HEADERS(gdbm.h, | |||
74 | AC_CHECK_LIB([gdbm], [gdbm_open], | 74 | AC_CHECK_LIB([gdbm], [gdbm_open], |
75 | , | 75 | , |
76 | [AC_MSG_ERROR([libgdbm not found])]) | 76 | [AC_MSG_ERROR([libgdbm not found])]) |
77 | 77 | ||
78 | ## Default syslog facility | ||
79 | LOG_FACILITY="LOG_DAEMON" | ||
80 | |||
81 | AC_ARG_VAR([LOG_FACILITY], | ||
82 | [Default syslog facility]) | ||
83 | if test -n "$LOG_FACILITY"; then | ||
84 | logfacility=`echo $LOG_FACILITY | tr a-z A-Z` | ||
85 | case $logfacility in | ||
86 | USER|DAEMON|AUTH|AUTHPRIV|MAIL|CRON|LOCAL[[0-7]]) | ||
87 | LOG_FACILITY=LOG_$logfacility;; | ||
88 | LOG_USER|LOG_DAEMON|LOG_AUTH|LOG_AUTHPRIV|LOG_MAIL|LOG_CRON|LOG_LOCAL[[0-7]]) | ||
89 | LOG_FACILITY=$logfacility;; | ||
90 | *) AC_MSG_ERROR([Invalid value of LOG_FACILITY]);; | ||
91 | esac | ||
92 | fi | ||
93 | AC_DEFINE_UNQUOTED([LOG_FACILITY],$LOG_FACILITY, | ||
94 | [Default syslog facility.]) | ||
95 | |||
78 | AC_CONFIG_FILES([Makefile | 96 | AC_CONFIG_FILES([Makefile |
79 | gnu/Makefile | 97 | gnu/Makefile |
80 | grecs/Makefile | 98 | grecs/Makefile |
81 | grecs/src/Makefile | 99 | grecs/src/Makefile |
diff --git a/src/graph.c b/src/graph.c index bfd00cb..1464e8b 100644 --- a/src/graph.c +++ b/src/graph.c | |||
@@ -53,8 +53,9 @@ int graph_ysize = 100; | |||
53 | 53 | ||
54 | int graph_h_margin[2] = { 100, 14 }; | 54 | int graph_h_margin[2] = { 100, 14 }; |
55 | int graph_v_margin[2] = { 14, 35 }; | 55 | int graph_v_margin[2] = { 14, 35 }; |
56 | 56 | ||
57 | /* FIXME: I18N?? */ | ||
57 | char *rate_unit = "Bytes per Second"; | 58 | char *rate_unit = "Bytes per Second"; |
58 | 59 | ||
59 | #define make_color_index(g, ar) \ | 60 | #define make_color_index(g, ar) \ |
60 | gdImageColorAllocate (g, (ar)[0], (ar)[1], (ar)[2]) | 61 | gdImageColorAllocate (g, (ar)[0], (ar)[1], (ar)[2]) |
diff --git a/src/html.gram.y b/src/html.gram.y index fae64ff..e488494 100644 --- a/src/html.gram.y +++ b/src/html.gram.y | |||
@@ -112,9 +112,9 @@ expr : value | |||
112 | || $3.type == unspecified_value) | 112 | || $3.type == unspecified_value) |
113 | init_value (&$$, unspecified_value, NULL); | 113 | init_value (&$$, unspecified_value, NULL); |
114 | else if ($1.type != $3.type) | 114 | else if ($1.type != $3.type) |
115 | { | 115 | { |
116 | yyerror ("type mismatch in addition"); | 116 | yyerror (_("type mismatch in addition")); |
117 | init_value (&$$, unspecified_value, NULL); | 117 | init_value (&$$, unspecified_value, NULL); |
118 | } | 118 | } |
119 | else | 119 | else |
120 | { | 120 | { |
@@ -144,14 +144,14 @@ expr : value | |||
144 | || $3.type == unspecified_value) | 144 | || $3.type == unspecified_value) |
145 | init_value (&$$, unspecified_value, NULL); | 145 | init_value (&$$, unspecified_value, NULL); |
146 | else if ($1.type != $3.type) | 146 | else if ($1.type != $3.type) |
147 | { | 147 | { |
148 | yyerror ("type mismatch in subtraction"); | 148 | yyerror (_("type mismatch in subtraction")); |
149 | init_value (&$$, unspecified_value, NULL); | 149 | init_value (&$$, unspecified_value, NULL); |
150 | } | 150 | } |
151 | else if ($1.type == string_value) | 151 | else if ($1.type == string_value) |
152 | { | 152 | { |
153 | yyerror ("subtraction not defined for strings"); | 153 | yyerror (_("subtraction not defined for strings")); |
154 | init_value (&$$, unspecified_value, NULL); | 154 | init_value (&$$, unspecified_value, NULL); |
155 | } | 155 | } |
156 | else | 156 | else |
157 | { | 157 | { |
@@ -166,14 +166,14 @@ expr : value | |||
166 | || $3.type == unspecified_value) | 166 | || $3.type == unspecified_value) |
167 | init_value (&$$, unspecified_value, NULL); | 167 | init_value (&$$, unspecified_value, NULL); |
168 | else if ($1.type != $3.type) | 168 | else if ($1.type != $3.type) |
169 | { | 169 | { |
170 | yyerror ("type mismatch in multiplication"); | 170 | yyerror (_("type mismatch in multiplication")); |
171 | init_value (&$$, unspecified_value, NULL); | 171 | init_value (&$$, unspecified_value, NULL); |
172 | } | 172 | } |
173 | else if ($1.type == string_value) | 173 | else if ($1.type == string_value) |
174 | { | 174 | { |
175 | yyerror ("multiplication not defined for strings"); | 175 | yyerror (_("multiplication not defined for strings")); |
176 | init_value (&$$, unspecified_value, NULL); | 176 | init_value (&$$, unspecified_value, NULL); |
177 | } | 177 | } |
178 | else | 178 | else |
179 | { | 179 | { |
@@ -188,19 +188,19 @@ expr : value | |||
188 | || $3.type == unspecified_value) | 188 | || $3.type == unspecified_value) |
189 | init_value (&$$, unspecified_value, NULL); | 189 | init_value (&$$, unspecified_value, NULL); |
190 | else if ($1.type != $3.type) | 190 | else if ($1.type != $3.type) |
191 | { | 191 | { |
192 | yyerror ("type mismatch in division"); | 192 | yyerror (_("type mismatch in division")); |
193 | init_value (&$$, unspecified_value, NULL); | 193 | init_value (&$$, unspecified_value, NULL); |
194 | } | 194 | } |
195 | else if ($1.type == string_value) | 195 | else if ($1.type == string_value) |
196 | { | 196 | { |
197 | yyerror ("division not defined for strings"); | 197 | yyerror (_("division not defined for strings")); |
198 | init_value (&$$, unspecified_value, NULL); | 198 | init_value (&$$, unspecified_value, NULL); |
199 | } | 199 | } |
200 | else if (fabs ($3.v.number) < 1.0e-5) | 200 | else if (fabs ($3.v.number) < 1.0e-5) |
201 | { | 201 | { |
202 | yyerror ("division by zero"); | 202 | yyerror (_("division by zero")); |
203 | init_value (&$$, unspecified_value, NULL); | 203 | init_value (&$$, unspecified_value, NULL); |
204 | } | 204 | } |
205 | else | 205 | else |
206 | { | 206 | { |
@@ -214,9 +214,9 @@ expr : value | |||
214 | if ($2.type == unspecified_value) | 214 | if ($2.type == unspecified_value) |
215 | init_value (&$$, unspecified_value, NULL); | 215 | init_value (&$$, unspecified_value, NULL); |
216 | else if ($2.type == string_value) | 216 | else if ($2.type == string_value) |
217 | { | 217 | { |
218 | yyerror ("unary minus not defined for strings"); | 218 | yyerror (_("unary minus not defined for strings")); |
219 | init_value (&$$, unspecified_value, NULL); | 219 | init_value (&$$, unspecified_value, NULL); |
220 | } | 220 | } |
221 | else | 221 | else |
222 | { | 222 | { |
@@ -229,9 +229,9 @@ expr : value | |||
229 | if ($2.type == unspecified_value) | 229 | if ($2.type == unspecified_value) |
230 | init_value (&$$, unspecified_value, NULL); | 230 | init_value (&$$, unspecified_value, NULL); |
231 | else if ($2.type == string_value) | 231 | else if ($2.type == string_value) |
232 | { | 232 | { |
233 | yyerror ("unary plus not defined for strings"); | 233 | yyerror (_("unary plus not defined for strings")); |
234 | init_value (&$$, unspecified_value, NULL); | 234 | init_value (&$$, unspecified_value, NULL); |
235 | } | 235 | } |
236 | else | 236 | else |
237 | { | 237 | { |
@@ -272,9 +272,9 @@ create_html (pp_tab_t *tab, char *file, char *dest) | |||
272 | 272 | ||
273 | tmp_file = fopen (tmp_file_name, "w"); | 273 | tmp_file = fopen (tmp_file_name, "w"); |
274 | if (!tmp_file) | 274 | if (!tmp_file) |
275 | { | 275 | { |
276 | logmsg (L_ERR, "cannot open output file `%s': %s", | 276 | logmsg (L_ERR, _("cannot open output file `%s': %s"), |
277 | file, strerror (errno)); | 277 | file, strerror (errno)); |
278 | html_close (); | 278 | html_close (); |
279 | return 1; | 279 | return 1; |
280 | } | 280 | } |
@@ -285,16 +285,16 @@ create_html (pp_tab_t *tab, char *file, char *dest) | |||
285 | if (rc == 0) | 285 | if (rc == 0) |
286 | { | 286 | { |
287 | if (unlink (dest) && errno != ENOENT) | 287 | if (unlink (dest) && errno != ENOENT) |
288 | { | 288 | { |
289 | logmsg (L_ERR, "cannot unlink file `%s': %s", | 289 | logmsg (L_ERR, _("cannot unlink file `%s': %s"), |
290 | dest, strerror (errno)); | 290 | dest, strerror (errno)); |
291 | rc = 1; | 291 | rc = 1; |
292 | } | 292 | } |
293 | 293 | ||
294 | if (rename (tmp_file_name, dest)) | 294 | if (rename (tmp_file_name, dest)) |
295 | { | 295 | { |
296 | logmsg (L_ERR, "cannot rename `%s' to `%s': %s", | 296 | logmsg (L_ERR, _("cannot rename `%s' to `%s': %s"), |
297 | tmp_file_name, dest, | 297 | tmp_file_name, dest, |
298 | strerror (errno)); | 298 | strerror (errno)); |
299 | rc = 1; | 299 | rc = 1; |
300 | } | 300 | } |
@@ -493,18 +493,18 @@ read_symtab (pp_tab_t **tab, const char *name) | |||
493 | p = buf; | 493 | p = buf; |
494 | cmd = *p++; | 494 | cmd = *p++; |
495 | if (*p != ' ' || !(isascii (*++p) && isalpha (*p))) | 495 | if (*p != ' ' || !(isascii (*++p) && isalpha (*p))) |
496 | { | 496 | { |
497 | logmsg (L_ERR, "%s:%u: invalid input: %s", | 497 | logmsg (L_ERR, _("%s:%u: invalid input: %s"), |
498 | name, line, buf); | 498 | name, line, buf); |
499 | status = 1; | 499 | status = 1; |
500 | break; | 500 | break; |
501 | } | 501 | } |
502 | var = p; | 502 | var = p; |
503 | p = strchr (var, ' '); | 503 | p = strchr (var, ' '); |
504 | if (!p) | 504 | if (!p) |
505 | { | 505 | { |
506 | logmsg (L_ERR, "%s:%u: invalid input: %s", | 506 | logmsg (L_ERR, _("%s:%u: invalid input: %s"), |
507 | name, line, buf); | 507 | name, line, buf); |
508 | status = 1; | 508 | status = 1; |
509 | break; | 509 | break; |
510 | } | 510 | } |
@@ -522,9 +522,9 @@ read_symtab (pp_tab_t **tab, const char *name) | |||
522 | char *p; | 522 | char *p; |
523 | double num = strtod (value, &p); | 523 | double num = strtod (value, &p); |
524 | if (*p) | 524 | if (*p) |
525 | { | 525 | { |
526 | logmsg (L_ERR, "%s:%u: invalid numeric value: %s", | 526 | logmsg (L_ERR, _("%s:%u: invalid numeric value: %s"), |
527 | name, line, value); | 527 | name, line, value); |
528 | status = 1; | 528 | status = 1; |
529 | } | 529 | } |
530 | else | 530 | else |
@@ -532,9 +532,9 @@ read_symtab (pp_tab_t **tab, const char *name) | |||
532 | } | 532 | } |
533 | break; | 533 | break; |
534 | 534 | ||
535 | default: | 535 | default: |
536 | logmsg (L_NOTICE, "%s:%u: ignoring unknown command %#03o", | 536 | logmsg (L_NOTICE, _("%s:%u: ignoring unknown command %#03o"), |
537 | name, line, cmd); | 537 | name, line, cmd); |
538 | } | 538 | } |
539 | } | 539 | } |
540 | free (buf); | 540 | free (buf); |
diff --git a/src/html.lex.l b/src/html.lex.l index 931bfc1..0e0d423 100644 --- a/src/html.lex.l +++ b/src/html.lex.l | |||
@@ -42,18 +42,18 @@ N [0-9]+ | |||
42 | } | 42 | } |
43 | \${NAME} { | 43 | \${NAME} { |
44 | if (find_value (yytext+1, &yylval.value)) | 44 | if (find_value (yytext+1, &yylval.value)) |
45 | { | 45 | { |
46 | yyerror ("unknown identifier"); | 46 | yyerror (_("unknown identifier")); |
47 | init_value (&yylval.value, unspecified_value, NULL); | 47 | init_value (&yylval.value, unspecified_value, NULL); |
48 | } | 48 | } |
49 | return IDENT; | 49 | return IDENT; |
50 | } | 50 | } |
51 | \$\({NAME}\) { | 51 | \$\({NAME}\) { |
52 | yytext[yyleng-1] = 0; | 52 | yytext[yyleng-1] = 0; |
53 | if (find_value (yytext+2, &yylval.value)) | 53 | if (find_value (yytext+2, &yylval.value)) |
54 | { | 54 | { |
55 | yyerror ("unknown identifier"); | 55 | yyerror (_("unknown identifier")); |
56 | init_value (&yylval.value, unspecified_value, NULL); | 56 | init_value (&yylval.value, unspecified_value, NULL); |
57 | } | 57 | } |
58 | return IDENT; | 58 | return IDENT; |
59 | } | 59 | } |
@@ -61,9 +61,9 @@ N [0-9]+ | |||
61 | char *p = strchr (yytext, ':'); | 61 | char *p = strchr (yytext, ':'); |
62 | *p = 0; | 62 | *p = 0; |
63 | if (find_value (yytext+2, &yylval.value)) | 63 | if (find_value (yytext+2, &yylval.value)) |
64 | { | 64 | { |
65 | yyerror ("unknown identifier"); | 65 | yyerror (_("unknown identifier")); |
66 | init_value (&yylval.value, unspecified_value, NULL); | 66 | init_value (&yylval.value, unspecified_value, NULL); |
67 | } | 67 | } |
68 | else | 68 | else |
69 | { | 69 | { |
@@ -76,9 +76,9 @@ N [0-9]+ | |||
76 | char *p = strchr (yytext, ':'); | 76 | char *p = strchr (yytext, ':'); |
77 | *p++ = 0; | 77 | *p++ = 0; |
78 | if (find_value (yytext+2, &val)) | 78 | if (find_value (yytext+2, &val)) |
79 | { | 79 | { |
80 | yyerror ("unknown identifier"); | 80 | yyerror (_("unknown identifier")); |
81 | init_value (&yylval.value, unspecified_value, NULL); | 81 | init_value (&yylval.value, unspecified_value, NULL); |
82 | } | 82 | } |
83 | else | 83 | else |
84 | { | 84 | { |
@@ -129,9 +129,9 @@ html_open (char *file) | |||
129 | { | 129 | { |
130 | yyin = fopen (file, "r"); | 130 | yyin = fopen (file, "r"); |
131 | if (!yyin) | 131 | if (!yyin) |
132 | { | 132 | { |
133 | logmsg (L_ERR, "cannot open input file `%s': %s", | 133 | logmsg (L_ERR, _("cannot open input file `%s': %s"), |
134 | file, strerror (errno)); | 134 | file, strerror (errno)); |
135 | return 1; | 135 | return 1; |
136 | } | 136 | } |
137 | html_input_file = file; | 137 | html_input_file = file; |
@@ -28,9 +28,9 @@ | |||
28 | #include <syslog.h> | 28 | #include <syslog.h> |
29 | #include <argp.h> | 29 | #include <argp.h> |
30 | #include <tagr.h> | 30 | #include <tagr.h> |
31 | 31 | ||
32 | int log_facility = LOGFACILITY; | 32 | int log_facility = LOG_FACILITY; |
33 | char *log_tag; | 33 | char *log_tag; |
34 | int log_print_severity; /* FIXME: not used */ | 34 | int log_print_severity; /* FIXME: not used */ |
35 | 35 | ||
36 | void | 36 | void |
@@ -50,23 +50,23 @@ int syslog_level[] = { | |||
50 | LOG_CRIT, | 50 | LOG_CRIT, |
51 | }; | 51 | }; |
52 | 52 | ||
53 | char *level_str[] = { | 53 | char *level_str[] = { |
54 | "debug", | 54 | N_("debug"), |
55 | "info", | 55 | N_("info"), |
56 | "notice", | 56 | N_("notice"), |
57 | "warning", | 57 | N_("warning"), |
58 | "error", | 58 | N_("error"), |
59 | "CRITICAL", | 59 | N_("CRITICAL"), |
60 | }; | 60 | }; |
61 | 61 | ||
62 | 62 | ||
63 | void | 63 | void |
64 | vlogmsg (int level, const char *fmt, va_list ap) | 64 | vlogmsg (int level, const char *fmt, va_list ap) |
65 | { | 65 | { |
66 | if (grecs_log_to_stderr) | 66 | if (grecs_log_to_stderr) |
67 | { | 67 | { |
68 | fprintf (stderr, "%s: %s: ", log_tag, level_str[level]); | 68 | fprintf (stderr, "%s: %s: ", log_tag, gettext (level_str[level])); |
69 | vfprintf (stderr, fmt, ap); | 69 | vfprintf (stderr, fmt, ap); |
70 | fprintf (stderr, "\n"); | 70 | fprintf (stderr, "\n"); |
71 | } | 71 | } |
72 | else | 72 | else |
@@ -79,10 +79,10 @@ static char *check_mode = 0; | |||
79 | static char *user_option = NULL; | 79 | static char *user_option = NULL; |
80 | static char *html_template_option = NULL; | 80 | static char *html_template_option = NULL; |
81 | 81 | ||
82 | const char *program_version = "tagr (" PACKAGE_STRING ")"; | 82 | const char *program_version = "tagr (" PACKAGE_STRING ")"; |
83 | static char doc[] = "tagr -- traffic analyzer and grapher"; | 83 | static char doc[] = N_("tagr -- traffic analyzer and grapher"); |
84 | static char args_doc[] = ""; | 84 | static char args_doc[] = "[FILES or DIRS...]"; |
85 | 85 | ||
86 | enum { | 86 | enum { |
87 | OPT_IMPORT = 256, | 87 | OPT_IMPORT = 256, |
88 | OPT_TEST_TEMPLATE, | 88 | OPT_TEST_TEMPLATE, |
@@ -111,9 +111,9 @@ static struct argp_option options[] = { | |||
111 | {"import", OPT_IMPORT, NULL, 0, | 111 | {"import", OPT_IMPORT, NULL, 0, |
112 | N_("import old (mrtg-style) log files from DIR (or the basedir, if not given)"), | 112 | N_("import old (mrtg-style) log files from DIR (or the basedir, if not given)"), |
113 | GRID+1 }, | 113 | GRID+1 }, |
114 | {"read", OPT_READ, NULL, 0, | 114 | {"read", OPT_READ, NULL, 0, |
115 | N_("read statistics from the given file or standard input") }, | 115 | N_("read statistics from given FILEs or standard input") }, |
116 | {"rebuild", 'b', NULL, 0, | 116 | {"rebuild", 'b', NULL, 0, |
117 | N_("rebuild graphs using existing statistics"), GRID+1}, | 117 | N_("rebuild graphs using existing statistics"), GRID+1}, |
118 | {"list", 'l', NULL, 0, N_("list contents of the rate database"), GRID+1}, | 118 | {"list", 'l', NULL, 0, N_("list contents of the rate database"), GRID+1}, |
119 | {"show-defaults", OPT_SHOW_DEFAULTS, NULL, 0, | 119 | {"show-defaults", OPT_SHOW_DEFAULTS, NULL, 0, |
@@ -186,14 +186,14 @@ static struct argp_option options[] = { | |||
186 | 186 | ||
187 | static void | 187 | static void |
188 | show_defaults () | 188 | show_defaults () |
189 | { | 189 | { |
190 | printf ("Configuration file: %s\n", TAGR_CONFIGFILE); | 190 | printf (_("Configuration file: %s\n"), TAGR_CONFIGFILE); |
191 | printf ("Page template file: %s\n", TAGR_TEMPLATE); | 191 | printf (_("Page template file: %s\n"), TAGR_TEMPLATE); |
192 | printf ("PID file: %s\n", TAGR_PIDFILE); | 192 | printf (_("PID file: %s\n"), TAGR_PIDFILE); |
193 | printf ("DB file name: %s\n", TAGR_DBNAME); | 193 | printf (_("DB file name: %s\n"), TAGR_DBNAME); |
194 | printf ("DB file permissions: %#o\n", TAGR_DBMODE); | 194 | printf (_("DB file permissions: %#o\n"), TAGR_DBMODE); |
195 | printf ("Syslog facility number: %d\n", LOGFACILITY); | 195 | printf (_("Syslog facility number: %d\n"), LOG_FACILITY); |
196 | } | 196 | } |
197 | 197 | ||
198 | static void | 198 | static void |
199 | add_check_mode (int c) | 199 | add_check_mode (int c) |
@@ -334,9 +334,9 @@ change_privs (uid_t uid, gid_t gid) | |||
334 | /* Reset group permissions */ | 334 | /* Reset group permissions */ |
335 | emptygidset[0] = gid ? gid : getegid (); | 335 | emptygidset[0] = gid ? gid : getegid (); |
336 | if (geteuid () == 0 && setgroups (1, emptygidset)) | 336 | if (geteuid () == 0 && setgroups (1, emptygidset)) |
337 | { | 337 | { |
338 | logmsg (L_ERR, "setgroups(1, %lu) failed: %s", | 338 | logmsg (L_ERR, _("setgroups(1, %lu) failed: %s"), |
339 | (u_long) emptygidset[0], strerror (errno)); | 339 | (u_long) emptygidset[0], strerror (errno)); |
340 | rc = 1; | 340 | rc = 1; |
341 | } | 341 | } |
342 | 342 | ||
@@ -344,27 +344,28 @@ change_privs (uid_t uid, gid_t gid) | |||
344 | be reset first */ | 344 | be reset first */ |
345 | 345 | ||
346 | #if defined(HAVE_SETEGID) | 346 | #if defined(HAVE_SETEGID) |
347 | if ((rc = setegid (gid)) < 0) | 347 | if ((rc = setegid (gid)) < 0) |
348 | logmsg (L_ERR, "setegid(%lu) failed: %s", (u_long) gid, strerror (errno)); | 348 | logmsg (L_ERR, _("setegid(%lu) failed: %s"), |
349 | (u_long) gid, strerror (errno)); | ||
349 | #elif defined(HAVE_SETREGID) | 350 | #elif defined(HAVE_SETREGID) |
350 | if ((rc = setregid (gid, gid)) < 0) | 351 | if ((rc = setregid (gid, gid)) < 0) |
351 | logmsg (L_ERR, "setregid(%lu,%lu) failed: %s", | 352 | logmsg (L_ERR, _("setregid(%lu,%lu) failed: %s"), |
352 | (u_long) gid, (u_long) gid, strerror (errno)); | 353 | (u_long) gid, (u_long) gid, strerror (errno)); |
353 | #elif defined(HAVE_SETRESGID) | 354 | #elif defined(HAVE_SETRESGID) |
354 | if ((rc = setresgid (gid, gid, gid)) < 0) | 355 | if ((rc = setresgid (gid, gid, gid)) < 0) |
355 | logmsg (L_ERR, "setresgid(%lu,%lu,%lu) failed: %s", | 356 | logmsg (L_ERR, _("setresgid(%lu,%lu,%lu) failed: %s"), |
356 | (u_long) gid, (u_long) gid, (u_long) gid, strerror (errno)); | 357 | (u_long) gid, (u_long) gid, (u_long) gid, strerror (errno)); |
357 | #endif | 358 | #endif |
358 | 359 | ||
359 | if (rc == 0 && gid != 0) | 360 | if (rc == 0 && gid != 0) |
360 | { | 361 | { |
361 | if ((rc = setgid (gid)) < 0 && getegid () != gid) | 362 | if ((rc = setgid (gid)) < 0 && getegid () != gid) |
362 | logmsg (L_ERR, "setgid(%lu) failed: %s", | 363 | logmsg (L_ERR, _("setgid(%lu) failed: %s"), |
363 | (u_long) gid, strerror (errno)); | 364 | (u_long) gid, strerror (errno)); |
364 | if (rc == 0 && getegid () != gid) | 365 | if (rc == 0 && getegid () != gid) |
365 | { | 366 | { |
366 | logmsg (L_ERR, "cannot set effective gid to %lu: %s", | 367 | logmsg (L_ERR, _("cannot set effective gid to %lu: %s"), |
367 | (u_long) gid, strerror (errno)); | 368 | (u_long) gid, strerror (errno)); |
368 | rc = 1; | 369 | rc = 1; |
369 | } | 370 | } |
370 | } | 371 | } |
@@ -384,24 +385,24 @@ change_privs (uid_t uid, gid_t gid) | |||
384 | { | 385 | { |
385 | if (setreuid (uid, -1) < 0) | 386 | if (setreuid (uid, -1) < 0) |
386 | { | 387 | { |
387 | logmsg (L_ERR, | 388 | logmsg (L_ERR, |
388 | "setreuid(%lu,-1) failed: %s", | 389 | _("setreuid(%lu,-1) failed: %s"), |
389 | (u_long) uid, strerror (errno)); | 390 | (u_long) uid, strerror (errno)); |
390 | rc = 1; | 391 | rc = 1; |
391 | } | 392 | } |
392 | if (setuid (uid) < 0) | 393 | if (setuid (uid) < 0) |
393 | { | 394 | { |
394 | logmsg (L_ERR, | 395 | logmsg (L_ERR, |
395 | "second setuid(%lu) failed: %s", | 396 | _("second setuid(%lu) failed: %s"), |
396 | (u_long) uid, strerror (errno)); | 397 | (u_long) uid, strerror (errno)); |
397 | rc = 1; | 398 | rc = 1; |
398 | } | 399 | } |
399 | } | 400 | } |
400 | else | 401 | else |
401 | #endif | 402 | #endif |
402 | { | 403 | { |
403 | logmsg (L_ERR, "setuid(%lu) failed: %s", | 404 | logmsg (L_ERR, _("setuid(%lu) failed: %s"), |
404 | (u_long) uid, strerror (errno)); | 405 | (u_long) uid, strerror (errno)); |
405 | rc = 1; | 406 | rc = 1; |
406 | } | 407 | } |
407 | } | 408 | } |
@@ -411,14 +412,14 @@ change_privs (uid_t uid, gid_t gid) | |||
411 | 412 | ||
412 | euid = geteuid (); | 413 | euid = geteuid (); |
413 | if (uid != 0 && setuid (0) == 0) | 414 | if (uid != 0 && setuid (0) == 0) |
414 | { | 415 | { |
415 | logmsg (L_ERR, "seteuid(0) succeeded when it should not"); | 416 | logmsg (L_ERR, _("seteuid(0) succeeded when it should not")); |
416 | rc = 1; | 417 | rc = 1; |
417 | } | 418 | } |
418 | else if (uid != euid && setuid (euid) == 0) | 419 | else if (uid != euid && setuid (euid) == 0) |
419 | { | 420 | { |
420 | logmsg (L_ERR, "cannot drop non-root setuid privileges"); | 421 | logmsg (L_ERR, _("cannot drop non-root setuid privileges")); |
421 | rc = 1; | 422 | rc = 1; |
422 | } | 423 | } |
423 | } | 424 | } |
424 | return rc; | 425 | return rc; |
@@ -433,9 +434,9 @@ change_user () | |||
433 | return; | 434 | return; |
434 | 435 | ||
435 | if (getuid () == 0) | 436 | if (getuid () == 0) |
436 | { | 437 | { |
437 | logmsg (L_NOTICE, "not a superuser: ignoring the `user' statement"); | 438 | logmsg (L_NOTICE, _("not a superuser: ignoring the `user' statement")); |
438 | return; | 439 | return; |
439 | } | 440 | } |
440 | 441 | ||
441 | pwd = getpwnam (user); | 442 | pwd = getpwnam (user); |
@@ -461,18 +462,19 @@ decode_buffer () | |||
461 | reply->n_addr = ntohl (reply->n_addr); | 462 | reply->n_addr = ntohl (reply->n_addr); |
462 | 463 | ||
463 | if (reply->n_addr > MAXADDR) | 464 | if (reply->n_addr > MAXADDR) |
464 | { | 465 | { |
465 | logmsg (L_NOTICE, "got invalid packet: n_addr = %d", reply->n_addr); | 466 | logmsg (L_NOTICE, _("got invalid packet: n_addr = %d"), |
467 | reply->n_addr); | ||
466 | return; | 468 | return; |
467 | } | 469 | } |
468 | reply->timestamp = ntohl (reply->timestamp); | 470 | reply->timestamp = ntohl (reply->timestamp); |
469 | if (verbose_level) | 471 | if (verbose_level) |
470 | { | 472 | { |
471 | char tbuf[sizeof("2009-04-01 00:00:00")]; | 473 | char tbuf[sizeof("2009-04-01 00:00:00")]; |
472 | strftime (tbuf, sizeof tbuf, "%Y-%m-%d %H:%M:%S", | 474 | strftime (tbuf, sizeof tbuf, "%Y-%m-%d %H:%M:%S", |
473 | gmtime (&reply->timestamp)); | 475 | gmtime (&reply->timestamp)); |
474 | logmsg (L_INFO, "Received packet: %d %lu - %s", reply->n_addr, | 476 | logmsg (L_INFO, _("Received packet: %d %lu - %s"), reply->n_addr, |
475 | (unsigned long) reply->timestamp, tbuf); | 477 | (unsigned long) reply->timestamp, tbuf); |
476 | } | 478 | } |
477 | 479 | ||
478 | sp = reply->stat; | 480 | sp = reply->stat; |
@@ -482,9 +484,9 @@ decode_buffer () | |||
482 | pid_t pid = fork (); | 484 | pid_t pid = fork (); |
483 | if (pid > 0) | 485 | if (pid > 0) |
484 | return; | 486 | return; |
485 | else if (pid < 0) | 487 | else if (pid < 0) |
486 | logmsg (L_ERR, "can't fork: %s", strerror (errno)); | 488 | logmsg (L_ERR, _("cannot fork: %s"), strerror (errno)); |
487 | else | 489 | else |
488 | { | 490 | { |
489 | signal (SIGHUP, SIG_IGN); | 491 | signal (SIGHUP, SIG_IGN); |
490 | signal (SIGCHLD, SIG_IGN); | 492 | signal (SIGCHLD, SIG_IGN); |
@@ -496,9 +498,9 @@ decode_buffer () | |||
496 | for (i = 0; i < reply->n_addr; i++, sp++) | 498 | for (i = 0; i < reply->n_addr; i++, sp++) |
497 | { | 499 | { |
498 | sp->in = ntohl (sp->in); | 500 | sp->in = ntohl (sp->in); |
499 | sp->out = ntohl (sp->out); | 501 | sp->out = ntohl (sp->out); |
500 | verbose (1, "Monitor %s: %lu %lu", sp->name, sp->in, sp->out); | 502 | verbose (1, _("Monitor %s: %lu %lu"), sp->name, sp->in, sp->out); |
501 | report (sp, reply->timestamp); | 503 | report (sp, reply->timestamp); |
502 | } | 504 | } |
503 | close_db (); | 505 | close_db (); |
504 | 506 | ||
@@ -524,12 +526,13 @@ read_input (const char *name) | |||
524 | else | 526 | else |
525 | { | 527 | { |
526 | fp = fopen (name, "r"); | 528 | fp = fopen (name, "r"); |
527 | if (!fp) | 529 | if (!fp) |
528 | die (EX_OSERR, "cannot open file `%s': %s", name, strerror (errno)); | 530 | die (EX_OSERR, _("cannot open file `%s': %s"), |
531 | name, strerror (errno)); | ||
529 | } | 532 | } |
530 | 533 | ||
531 | verbose (2, "Reading `%s'", name); | 534 | verbose (2, _("Reading `%s'"), name); |
532 | 535 | ||
533 | open_db (TAGR_DB_WR); | 536 | open_db (TAGR_DB_WR); |
534 | while (getline (&buf, &bufsize, fp) > 0) | 537 | while (getline (&buf, &bufsize, fp) > 0) |
535 | { | 538 | { |
@@ -546,20 +549,20 @@ read_input (const char *name) | |||
546 | i = 0; | 549 | i = 0; |
547 | while (*p && !isspace (*p)) | 550 | while (*p && !isspace (*p)) |
548 | { | 551 | { |
549 | if (i > MAX_NAME_LENGTH) | 552 | if (i > MAX_NAME_LENGTH) |
550 | die (EX_DATAERR, "%s:%lu: ID too long", name, line); | 553 | die (EX_DATAERR, _("%s:%lu: ID too long"), name, line); |
551 | st.name[i++] = *p++; | 554 | st.name[i++] = *p++; |
552 | } | 555 | } |
553 | st.name[i] = 0; | 556 | st.name[i] = 0; |
554 | 557 | ||
555 | if (sscanf (p, " %lu %lu %lu\n", &t, &st.in, &st.out) != 3) | 558 | if (sscanf (p, " %lu %lu %lu\n", &t, &st.in, &st.out) != 3) |
556 | die (EX_DATAERR, "%s:%lu: invalid input line", name, line); | 559 | die (EX_DATAERR, _("%s:%lu: invalid input line"), name, line); |
557 | report (&st, t); | 560 | report (&st, t); |
558 | } | 561 | } |
559 | fclose (fp); | 562 | fclose (fp); |
560 | close_db (); | 563 | close_db (); |
561 | verbose (2, "Finished reading `%s'", name); | 564 | verbose (2, _("Finished reading `%s'"), name); |
562 | } | 565 | } |
563 | 566 | ||
564 | int | 567 | int |
565 | get_port (char *str) | 568 | get_port (char *str) |
@@ -574,9 +577,9 @@ get_port (char *str) | |||
574 | if (s) | 577 | if (s) |
575 | pn = s->s_port; | 578 | pn = s->s_port; |
576 | else | 579 | else |
577 | { | 580 | { |
578 | logmsg (L_ERR, "no such service: %s", str); | 581 | logmsg (L_ERR, _("no such service: %s"), str); |
579 | return 0; | 582 | return 0; |
580 | } | 583 | } |
581 | } | 584 | } |
582 | return pn; | 585 | return pn; |
@@ -593,17 +596,17 @@ enum command command; | |||
593 | 596 | ||
594 | RETSIGTYPE | 597 | RETSIGTYPE |
595 | sig_quit (int sig) | 598 | sig_quit (int sig) |
596 | { | 599 | { |
597 | logmsg (L_INFO, "exiting on signal %d", sig); | 600 | logmsg (L_INFO, _("exiting on signal %d"), sig); |
598 | unlink (pidfile); | 601 | unlink (pidfile); |
599 | exit (0); | 602 | exit (0); |
600 | } | 603 | } |
601 | 604 | ||
602 | RETSIGTYPE | 605 | RETSIGTYPE |
603 | sig_fatal (int sig) | 606 | sig_fatal (int sig) |
604 | { | 607 | { |
605 | logmsg (L_ERR, "FATAL: exiting on signal %d", sig); | 608 | logmsg (L_ERR, _("FATAL: exiting on signal %d"), sig); |
606 | unlink (pidfile); | 609 | unlink (pidfile); |
607 | exit (EX_UNAVAILABLE); | 610 | exit (EX_UNAVAILABLE); |
608 | } | 611 | } |
609 | 612 | ||
@@ -715,9 +718,9 @@ tagr_restart (char **argv) | |||
715 | 718 | ||
716 | #define CHECK_USAGE(cond, opt, mode_opt) \ | 719 | #define CHECK_USAGE(cond, opt, mode_opt) \ |
717 | do \ | 720 | do \ |
718 | if (cond) \ | 721 | if (cond) \ |
719 | die (EX_USAGE, "%s is meaningless with %s", opt, mode_opt);\ | 722 | die (EX_USAGE, _("%s is meaningless with %s"), opt, mode_opt);\ |
720 | while (0) | 723 | while (0) |
721 | 724 | ||
722 | #define CHECK_OPTION(opt, optname) \ | 725 | #define CHECK_OPTION(opt, optname) \ |
723 | do \ | 726 | do \ |
@@ -772,9 +775,9 @@ main (int argc, char **argv) | |||
772 | argc -= index; | 775 | argc -= index; |
773 | argv += index; | 776 | argv += index; |
774 | 777 | ||
775 | if (argc != 0 && !(list_option || import_option)) | 778 | if (argc != 0 && !(list_option || import_option)) |
776 | die (EX_USAGE, "Too many arguments"); | 779 | die (EX_USAGE, _("Too many arguments")); |
777 | 780 | ||
778 | if (readconfig ()) | 781 | if (readconfig ()) |
779 | exit (EX_CONFIG); | 782 | exit (EX_CONFIG); |
780 | 783 | ||
@@ -894,18 +897,18 @@ main (int argc, char **argv) | |||
894 | { | 897 | { |
895 | FILE *fp; | 898 | FILE *fp; |
896 | 899 | ||
897 | if (daemon (0, 0)) | 900 | if (daemon (0, 0)) |
898 | die (EX_OSERR, "cannot become daemon: %s", strerror (errno)); | 901 | die (EX_OSERR, _("cannot become daemon: %s"), strerror (errno)); |
899 | 902 | ||
900 | if ((fp = fopen (pidfile, "w")) != NULL) | 903 | if ((fp = fopen (pidfile, "w")) != NULL) |
901 | { | 904 | { |
902 | fprintf (fp, "%lu\n", (unsigned long) getpid ()); | 905 | fprintf (fp, "%lu\n", (unsigned long) getpid ()); |
903 | fclose (fp); | 906 | fclose (fp); |
904 | } | 907 | } |
905 | else | 908 | else |
906 | { | 909 | { |
907 | logmsg (L_ERR, "can't write pid file %s: %s", | 910 | logmsg (L_ERR, _("cannot write pid file %s: %s"), |
908 | pidfile, strerror (errno)); | 911 | pidfile, strerror (errno)); |
909 | } | 912 | } |
910 | } | 913 | } |
911 | 914 | ||
diff --git a/src/readconfig.c b/src/readconfig.c index e60d335..e4e4e83 100644 --- a/src/readconfig.c +++ b/src/readconfig.c | |||
@@ -380,40 +380,44 @@ static struct grecs_keyword tagr_kw[] = { | |||
380 | NULL, NULL, log_kw }, | 380 | NULL, NULL, log_kw }, |
381 | 381 | ||
382 | { "rate-units", NULL, N_("Name of rate units"), | 382 | { "rate-units", NULL, N_("Name of rate units"), |
383 | grecs_type_string, &rate_unit }, | 383 | grecs_type_string, &rate_unit }, |
384 | { "number-suffixes", N_("suffixes"), NULL /* FIXME */, | 384 | { "number-suffixes", N_("suffixes"), |
385 | N_("Not implemented") /* FIXME */, | ||
385 | grecs_type_string, NULL, 0, cb_number_suffixes }, | 386 | grecs_type_string, NULL, 0, cb_number_suffixes }, |
386 | 387 | ||
387 | { "transparent", NULL, N_("Transparent graphs"), | 388 | { "transparent", NULL, N_("Transparent graphs"), |
388 | grecs_type_bool, &transparent_option }, | 389 | grecs_type_bool, &transparent_option }, |
389 | { "percent", NULL, NULL /* FIXME: descr */, | 390 | { "percent", NULL, |
391 | N_("Draw in/out percent graph (not implemented)"), /* FIXME */ | ||
390 | grecs_type_bool, &percent_option }, | 392 | grecs_type_bool, &percent_option }, |
391 | { "zero-unknown", NULL, NULL /* FIXME: descr */, | 393 | { "zero-unknown", NULL, |
394 | N_("Zero-out missing samples (not implemented)") /* FIXME */, | ||
392 | grecs_type_bool, &zero_unknown_option }, | 395 | grecs_type_bool, &zero_unknown_option }, |
393 | { "fill-incoming", NULL, NULL /* FIXME: descr */, | 396 | { "fill-incoming", NULL, N_("Fill incoming graph"), |
394 | grecs_type_bool, &fill_incoming_option }, | 397 | grecs_type_bool, &fill_incoming_option }, |
395 | 398 | ||
396 | { "color-background", NULL, N_("Set background color"), | 399 | { "color-background", NULL, N_("Set background color"), |
397 | grecs_type_int, color_background, 0, cb_color }, | 400 | grecs_type_int, color_background, 0, cb_color }, |
398 | { "color-light", NULL, NULL /* FIXME: descr */, | 401 | { "color-light", NULL, N_("`Light' color (for the border)"), |
399 | grecs_type_int, color_light, 0, cb_color }, | 402 | grecs_type_int, color_light, 0, cb_color }, |
400 | { "color-dark", NULL, NULL /* FIXME: descr */, | 403 | { "color-dark", NULL, N_("`Dark' color (for the border)"), |
401 | grecs_type_int, color_dark, 0, cb_color }, | 404 | grecs_type_int, color_dark, 0, cb_color }, |
402 | { "color-major", NULL, NULL /* FIXME: descr */, | 405 | { "color-major", NULL, |
406 | N_("`Major' color (boundaries, max. values, zero mark, etc.)"), | ||
403 | grecs_type_int, color_major, 0, cb_color }, | 407 | grecs_type_int, color_major, 0, cb_color }, |
404 | { "color-in", NULL, NULL /* FIXME: descr */, | 408 | { "color-in", NULL, N_("Color for the input graph"), |
405 | grecs_type_int, color_in, 0, cb_color }, | 409 | grecs_type_int, color_in, 0, cb_color }, |
406 | { "color-out", NULL, NULL /* FIXME: descr */, | 410 | { "color-out", NULL, N_("Color for the output graph"), |
407 | grecs_type_int, color_out, 0, cb_color }, | 411 | grecs_type_int, color_out, 0, cb_color }, |
408 | { "color-grid", NULL, NULL /* FIXME: descr */, | 412 | { "color-percent", NULL, N_("Color for the i/o percent graph"), |
413 | grecs_type_int, color_percent, 0, cb_color }, | ||
414 | { "color-grid", NULL, N_("Grid and axes color"), | ||
409 | grecs_type_int, color_grid, 0, cb_color }, | 415 | grecs_type_int, color_grid, 0, cb_color }, |
410 | { "color-in-max", NULL, NULL /* FIXME: descr */, | 416 | { "color-in-max", NULL, N_("Not implemented") /* FIXME */, |
411 | grecs_type_int, color_in_max, 0, cb_color }, | 417 | grecs_type_int, color_in_max, 0, cb_color }, |
412 | { "color-out-max", NULL, NULL /* FIXME: descr */, | 418 | { "color-out-max", NULL, N_("Not implemented") /* FIXME */, |
413 | grecs_type_int, color_out_max, 0, cb_color }, | 419 | grecs_type_int, color_out_max, 0, cb_color }, |
414 | { "color-percent", NULL, NULL /* FIXME: descr */, | ||
415 | grecs_type_int, color_percent, 0, cb_color }, | ||
416 | 420 | ||
417 | /* FIXME */ | 421 | /* FIXME */ |
418 | { NULL } | 422 | { NULL } |
419 | }; | 423 | }; |
diff --git a/src/report.c b/src/report.c index ed8a34d..ed3a81b 100644 --- a/src/report.c +++ b/src/report.c | |||
@@ -52,9 +52,9 @@ open_db (int flag) | |||
52 | flag == TAGR_DB_WR ? GDBM_WRCREAT : GDBM_READER, | 52 | flag == TAGR_DB_WR ? GDBM_WRCREAT : GDBM_READER, |
53 | TAGR_DBMODE, tagr_db_report); | 53 | TAGR_DBMODE, tagr_db_report); |
54 | if (dbf == NULL) | 54 | if (dbf == NULL) |
55 | { | 55 | { |
56 | logmsg (L_ERR, "Cannot open database %s: %s", | 56 | logmsg (L_ERR, _("cannot open database %s: %s"), |
57 | dbname, gdbm_strerror (gdbm_errno)); | 57 | dbname, gdbm_strerror (gdbm_errno)); |
58 | exit (1); | 58 | exit (1); |
59 | } | 59 | } |
60 | } | 60 | } |
@@ -90,12 +90,13 @@ _read_db (datum key, struct traffic_record **tr) | |||
90 | datum content; | 90 | datum content; |
91 | 91 | ||
92 | content = gdbm_fetch (dbf, key); | 92 | content = gdbm_fetch (dbf, key); |
93 | if (content.dptr == NULL) | 93 | if (content.dptr == NULL) |
94 | logmsg (L_NOTICE, "Record for %*.*s not found", key.dsize, key.dsize, key.dptr); | 94 | logmsg (L_NOTICE, _("record for %*.*s not found"), |
95 | key.dsize, key.dsize, key.dptr); | ||
95 | else if (content.dsize != sizeof **tr) | 96 | else if (content.dsize != sizeof **tr) |
96 | { | 97 | { |
97 | logmsg (L_ERR, "Wrong record size for %*.*s: %lu", | 98 | logmsg (L_ERR, _("wrong record size for %*.*s: %lu"), |
98 | key.dsize, key.dsize, key.dptr, content.dsize); | 99 | key.dsize, key.dsize, key.dptr, content.dsize); |
99 | } | 100 | } |
100 | else | 101 | else |
101 | { | 102 | { |
@@ -103,9 +104,9 @@ _read_db (datum key, struct traffic_record **tr) | |||
103 | tr_init (*tr); | 104 | tr_init (*tr); |
104 | return; | 105 | return; |
105 | } | 106 | } |
106 | 107 | ||
107 | logmsg (L_NOTICE, "Creating record for %*.*s", | 108 | logmsg (L_NOTICE, _("creating record for %*.*s"), |
108 | key.dsize, key.dsize, key.dptr); | 109 | key.dsize, key.dsize, key.dptr); |
109 | *tr = xmalloc (sizeof **tr); | 110 | *tr = xmalloc (sizeof **tr); |
110 | memset (*tr, 0, sizeof **tr); | 111 | memset (*tr, 0, sizeof **tr); |
111 | tr_init (*tr); | 112 | tr_init (*tr); |
@@ -135,9 +136,9 @@ write_db (struct monitor *mon, struct traffic_record *tr) | |||
135 | content.dptr = (char *) tr; | 136 | content.dptr = (char *) tr; |
136 | 137 | ||
137 | if (gdbm_store (dbf, key, content, GDBM_REPLACE)) | 138 | if (gdbm_store (dbf, key, content, GDBM_REPLACE)) |
138 | { | 139 | { |
139 | logmsg (L_ERR, "Failed to write data for %s: %s", | 140 | logmsg (L_ERR, _("failed to write data for %s: %s"), |
140 | mon->id, gdbm_strerror (gdbm_errno)); | 141 | mon->id, gdbm_strerror (gdbm_errno)); |
141 | } | 142 | } |
142 | } | 143 | } |
143 | 144 | ||
@@ -146,9 +147,11 @@ print_queue (const char *title, queue_t *q) | |||
146 | { | 147 | { |
147 | int i, count; | 148 | int i, count; |
148 | 149 | ||
149 | count = queue_count (q); | 150 | count = queue_count (q); |
150 | printf ("%s (%d entries):\n", title, count); | 151 | printf (ngettext ("%s (%d entry):\n", "%s (%d entries):\n", |
152 | count), | ||
153 | title, count); | ||
151 | for (i = count - 1; i >= 0; i--) | 154 | for (i = count - 1; i >= 0; i--) |
152 | { | 155 | { |
153 | struct traffic_history *th = queue_get_ptr (q, i); | 156 | struct traffic_history *th = queue_get_ptr (q, i); |
154 | printf("%d %g %g\n", count - i, th->inrate, th->outrate); | 157 | printf("%d %g %g\n", count - i, th->inrate, th->outrate); |
@@ -174,22 +177,23 @@ print_tr (datum key, struct traffic_record *tr) | |||
174 | 177 | ||
175 | tm = localtime (&tr->last.time); | 178 | tm = localtime (&tr->last.time); |
176 | printf ("ID: %*.*s\n", key.dsize, key.dsize, key.dptr); | 179 | printf ("ID: %*.*s\n", key.dsize, key.dsize, key.dptr); |
177 | strftime (buf, sizeof buf, "%c", tm); | 180 | strftime (buf, sizeof buf, "%c", tm); |
178 | printf ("Last sample: %lu (%s) %lu %lu\n", | 181 | printf (_("Last sample: %lu (%s) %lu %lu\n"), |
179 | tr->last.time, buf, tr->last.in, tr->last.out); | 182 | tr->last.time, buf, tr->last.in, tr->last.out); |
180 | 183 | ||
181 | printf ("Last rates: %g %g\n", tr->last_rates.inrate, tr->last_rates.outrate); | 184 | printf (_("Last rates: %g %g\n"), |
182 | print_queue ("Daily rates", &tr->day_hist); | 185 | tr->last_rates.inrate, tr->last_rates.outrate); |
186 | print_queue (_("Daily rates"), &tr->day_hist); | ||
183 | 187 | ||
184 | print_avg ("Weekly average", &tr->week_avg); | 188 | print_avg (_("Weekly average"), &tr->week_avg); |
185 | print_queue ("Weekly rates", &tr->week_hist); | 189 | print_queue (_("Weekly rates"), &tr->week_hist); |
186 | 190 | ||
187 | print_avg ("Monthly average", &tr->month_avg); | 191 | print_avg (_("Monthly average"), &tr->month_avg); |
188 | print_queue ("Monthly rates", &tr->month_hist); | 192 | print_queue (_("Monthly rates"), &tr->month_hist); |
189 | 193 | ||
190 | print_avg ("Yearly average", &tr->year_avg); | 194 | print_avg (_("Yearly average"), &tr->year_avg); |
191 | print_queue ("Yearly rates", &tr->year_hist); | 195 | print_queue (_("Yearly rates"), &tr->year_hist); |
192 | } | 196 | } |
193 | 197 | ||
194 | void | 198 | void |
195 | list_db () | 199 | list_db () |
@@ -231,9 +235,9 @@ report (Stat *stat, time_t timestamp) | |||
231 | write_db (mon, tr); | 235 | write_db (mon, tr); |
232 | free (tr); | 236 | free (tr); |
233 | } | 237 | } |
234 | else | 238 | else |
235 | logmsg (L_WARNING, "%s not found in config", stat->name); | 239 | logmsg (L_WARNING, _("%s not found in config"), stat->name); |
236 | } | 240 | } |
237 | 241 | ||
238 | int | 242 | int |
239 | update_monitor (datum key, time_t timestamp, int force) | 243 | update_monitor (datum key, time_t timestamp, int force) |
@@ -272,9 +276,9 @@ rebuild (int force) | |||
272 | datum key; | 276 | datum key; |
273 | datum content; | 277 | datum content; |
274 | time_t now = time (NULL); | 278 | time_t now = time (NULL); |
275 | 279 | ||
276 | verbose (1, "rebuild initiated"); | 280 | verbose (1, _("rebuild initiated")); |
277 | open_db (TAGR_DB_WR); | 281 | open_db (TAGR_DB_WR); |
278 | key = gdbm_firstkey (dbf); | 282 | key = gdbm_firstkey (dbf); |
279 | while (key.dptr) | 283 | while (key.dptr) |
280 | { | 284 | { |
@@ -283,6 +287,6 @@ rebuild (int force) | |||
283 | free (key.dptr); | 287 | free (key.dptr); |
284 | key = nextkey; | 288 | key = nextkey; |
285 | } | 289 | } |
286 | close_db (); | 290 | close_db (); |
287 | verbose (1, "rebuild finished"); | 291 | verbose (1, _("rebuild finished")); |
288 | } | 292 | } |
@@ -44,9 +44,9 @@ interpolate (queue_t *q, | |||
44 | if (now - last_time <= step) | 44 | if (now - last_time <= step) |
45 | { | 45 | { |
46 | th.inrate = inrate; | 46 | th.inrate = inrate; |
47 | th.outrate = outrate; | 47 | th.outrate = outrate; |
48 | verbose (3, "Insert %lu %g %g", next, th.inrate, th.outrate); | 48 | verbose (3, _("insert %lu %g %g"), next, th.inrate, th.outrate); |
49 | queue_put (q, &th); | 49 | queue_put (q, &th); |
50 | if (ovf) | 50 | if (ovf) |
51 | ovf (&th, tr, now); | 51 | ovf (&th, tr, now); |
52 | return; | 52 | return; |
@@ -57,9 +57,9 @@ interpolate (queue_t *q, | |||
57 | th.inrate = (inrate - last_rates->inrate) * (next - last_time) | 57 | th.inrate = (inrate - last_rates->inrate) * (next - last_time) |
58 | / interval + last_rates->inrate; | 58 | / interval + last_rates->inrate; |
59 | th.outrate = (outrate - last_rates->outrate) * (next - last_time) | 59 | th.outrate = (outrate - last_rates->outrate) * (next - last_time) |
60 | / interval + last_rates->outrate; | 60 | / interval + last_rates->outrate; |
61 | verbose (3, "Insert %lu %g %g", next, th.inrate, th.outrate); | 61 | verbose (3, _("insert %lu %g %g"), next, th.inrate, th.outrate); |
62 | queue_put (q, &th); | 62 | queue_put (q, &th); |
63 | if (ovf) | 63 | if (ovf) |
64 | ovf (&th, tr, now); | 64 | ovf (&th, tr, now); |
65 | } | 65 | } |
@@ -91,9 +91,9 @@ overflow (struct traffic_history *th, | |||
91 | { | 91 | { |
92 | struct traffic_history tmp; | 92 | struct traffic_history tmp; |
93 | tmp.inrate = avg->inrate; | 93 | tmp.inrate = avg->inrate; |
94 | tmp.outrate = avg->outrate; | 94 | tmp.outrate = avg->outrate; |
95 | verbose (3, "Insert %lu %g %g", now, tmp.inrate, tmp.outrate); | 95 | verbose (3, _("insert %lu %g %g"), now, tmp.inrate, tmp.outrate); |
96 | queue_put (q, &tmp); | 96 | queue_put (q, &tmp); |
97 | } | 97 | } |
98 | 98 | ||
99 | avg->inrate = avg->outrate = 0; | 99 | avg->inrate = avg->outrate = 0; |
@@ -107,30 +107,33 @@ overflow (struct traffic_history *th, | |||
107 | 107 | ||
108 | int | 108 | int |
109 | ovf_monthly (struct traffic_history *th, struct traffic_record *tr, time_t now) | 109 | ovf_monthly (struct traffic_history *th, struct traffic_record *tr, time_t now) |
110 | { | 110 | { |
111 | verbose (2, "begin overflow_monthly %lu %g %g", now, th->inrate, th->outrate); | 111 | verbose (2, _("begin overflow_monthly %lu %g %g"), |
112 | now, th->inrate, th->outrate); | ||
112 | overflow (th, tr, now, NULL, &tr->year_avg, &tr->year_hist, | 113 | overflow (th, tr, now, NULL, &tr->year_avg, &tr->year_hist, |
113 | YEAR_COUNT, YEAR_SAMPLE); | 114 | YEAR_COUNT, YEAR_SAMPLE); |
114 | verbose (2, "end overflow_monthly"); | 115 | verbose (2, _("end overflow_monthly")); |
115 | } | 116 | } |
116 | 117 | ||
117 | int | 118 | int |
118 | ovf_weekly (struct traffic_history *th, struct traffic_record *tr, time_t now) | 119 | ovf_weekly (struct traffic_history *th, struct traffic_record *tr, time_t now) |
119 | { | 120 | { |
120 | verbose (2, "begin overflow_weekly %lu %g %g", now, th->inrate, th->outrate); | 121 | verbose (2, _("begin overflow_weekly %lu %g %g"), |
122 | now, th->inrate, th->outrate); | ||
121 | overflow (th, tr, now, ovf_monthly, &tr->month_avg, &tr->month_hist, | 123 | overflow (th, tr, now, ovf_monthly, &tr->month_avg, &tr->month_hist, |
122 | MONTH_COUNT, MONTH_SAMPLE); | 124 | MONTH_COUNT, MONTH_SAMPLE); |
123 | verbose (2, "end overflow_daily"); | 125 | verbose (2, _("end overflow_daily")); |
124 | } | 126 | } |
125 | 127 | ||
126 | int | 128 | int |
127 | ovf_daily (struct traffic_history *th, struct traffic_record *tr, time_t now) | 129 | ovf_daily (struct traffic_history *th, struct traffic_record *tr, time_t now) |
128 | { | 130 | { |
129 | verbose (2, "begin overflow_daily %lu %g %g", now, th->inrate, th->outrate); | 131 | verbose (2, _("begin overflow_daily %lu %g %g"), |
132 | now, th->inrate, th->outrate); | ||
130 | overflow (th, tr, now, ovf_weekly, &tr->week_avg, &tr->week_hist, | 133 | overflow (th, tr, now, ovf_weekly, &tr->week_avg, &tr->week_hist, |
131 | WEEK_COUNT, WEEK_SAMPLE); | 134 | WEEK_COUNT, WEEK_SAMPLE); |
132 | verbose (2, "end overflow_daily"); | 135 | verbose (2, _("end overflow_daily")); |
133 | } | 136 | } |
134 | 137 | ||
135 | void | 138 | void |
136 | update_stats (struct monitor *mon, struct traffic_sample *sample, | 139 | update_stats (struct monitor *mon, struct traffic_sample *sample, |
@@ -143,9 +146,9 @@ update_stats (struct monitor *mon, struct traffic_sample *sample, | |||
143 | 146 | ||
144 | interval = sample->time - tr->last.time; | 147 | interval = sample->time - tr->last.time; |
145 | if (interval == 0) | 148 | if (interval == 0) |
146 | { | 149 | { |
147 | logmsg (L_ERR, "Ignoring zero interval"); | 150 | logmsg (L_ERR, _("ignoring zero interval")); |
148 | return; | 151 | return; |
149 | } | 152 | } |
150 | inrate = (double) sample->in / interval; | 153 | inrate = (double) sample->in / interval; |
151 | outrate = (double) sample->out / interval; | 154 | outrate = (double) sample->out / interval; |
@@ -216,9 +219,9 @@ _convert (queue_t *q, ovf_t ovf, | |||
216 | outrate = (double) hp->out; | 219 | outrate = (double) hp->out; |
217 | 220 | ||
218 | if (interval == 0) | 221 | if (interval == 0) |
219 | { | 222 | { |
220 | logmsg (L_ERR, "Ignoring zero interval"); | 223 | logmsg (L_ERR, _("ignoring zero interval")); |
221 | break; | 224 | break; |
222 | } | 225 | } |
223 | if (lastp) | 226 | if (lastp) |
224 | { | 227 | { |
@@ -251,48 +254,48 @@ _convert (queue_t *q, ovf_t ovf, | |||
251 | static void | 254 | static void |
252 | convert_yearly (struct traffic_record *tr, struct traffic_sample *hp, | 255 | convert_yearly (struct traffic_record *tr, struct traffic_sample *hp, |
253 | size_t count) | 256 | size_t count) |
254 | { | 257 | { |
255 | verbose (2, "begin convert_yearly"); | 258 | verbose (2, _("begin convert_yearly")); |
256 | _convert (&tr->year_hist, NULL, tr, | 259 | _convert (&tr->year_hist, NULL, tr, |
257 | hp, count, YEAR_SAMPLE); | 260 | hp, count, YEAR_SAMPLE); |
258 | compute_avg (&tr->year_avg, &tr->year_hist, &tr->last); | 261 | compute_avg (&tr->year_avg, &tr->year_hist, &tr->last); |
259 | verbose (2, "end convert_yearly"); | 262 | verbose (2, _("end convert_yearly")); |
260 | } | 263 | } |
261 | 264 | ||
262 | static void | 265 | static void |
263 | convert_monthly (struct traffic_record *tr, struct traffic_sample *hp, | 266 | convert_monthly (struct traffic_record *tr, struct traffic_sample *hp, |
264 | size_t count) | 267 | size_t count) |
265 | { | 268 | { |
266 | verbose (2, "begin convert_monthly"); | 269 | verbose (2, _("begin convert_monthly")); |
267 | if (count > MONTH_COUNT+1) | 270 | if (count > MONTH_COUNT+1) |
268 | convert_yearly (tr, hp + MONTH_COUNT + 1, count - (MONTH_COUNT + 1)); | 271 | convert_yearly (tr, hp + MONTH_COUNT + 1, count - (MONTH_COUNT + 1)); |
269 | _convert (&tr->month_hist, ovf_monthly, tr, | 272 | _convert (&tr->month_hist, ovf_monthly, tr, |
270 | hp, MONTH_COUNT + 1, MONTH_SAMPLE); | 273 | hp, MONTH_COUNT + 1, MONTH_SAMPLE); |
271 | compute_avg (&tr->month_avg, &tr->month_hist, &tr->last); | 274 | compute_avg (&tr->month_avg, &tr->month_hist, &tr->last); |
272 | verbose (2, "end convert_monthly"); | 275 | verbose (2, _("end convert_monthly")); |
273 | } | 276 | } |
274 | 277 | ||
275 | static void | 278 | static void |
276 | convert_weekly (struct traffic_record *tr, struct traffic_sample *hp, size_t count) | 279 | convert_weekly (struct traffic_record *tr, struct traffic_sample *hp, size_t count) |
277 | { | 280 | { |
278 | verbose (2, "begin convert_weekly"); | 281 | verbose (2, _("begin convert_weekly")); |
279 | if (count > WEEK_COUNT+1) | 282 | if (count > WEEK_COUNT+1) |
280 | convert_monthly (tr, hp + WEEK_COUNT + 1, count - (WEEK_COUNT + 1)); | 283 | convert_monthly (tr, hp + WEEK_COUNT + 1, count - (WEEK_COUNT + 1)); |
281 | _convert (&tr->week_hist, ovf_weekly, | 284 | _convert (&tr->week_hist, ovf_weekly, |
282 | tr, hp, WEEK_COUNT + 1, WEEK_SAMPLE); | 285 | tr, hp, WEEK_COUNT + 1, WEEK_SAMPLE); |
283 | compute_avg (&tr->week_avg, &tr->week_hist, &tr->last); | 286 | compute_avg (&tr->week_avg, &tr->week_hist, &tr->last); |
284 | verbose (2, "end convert_weekly"); | 287 | verbose (2, _("end convert_weekly")); |
285 | } | 288 | } |
286 | 289 | ||
287 | static void | 290 | static void |
288 | convert_daily (struct traffic_record *tr, struct traffic_sample *hp, size_t count) | 291 | convert_daily (struct traffic_record *tr, struct traffic_sample *hp, size_t count) |
289 | { | 292 | { |
290 | verbose (2, "begin convert_daily"); | 293 | verbose (2, _("begin convert_daily")); |
291 | if (count > DAY_COUNT+1) | 294 | if (count > DAY_COUNT+1) |
292 | convert_weekly (tr, hp + DAY_COUNT + 1, count - (DAY_COUNT + 1)); | 295 | convert_weekly (tr, hp + DAY_COUNT + 1, count - (DAY_COUNT + 1)); |
293 | _convert (&tr->day_hist, ovf_daily, tr, hp, DAY_COUNT + 1, DAY_SAMPLE); | 296 | _convert (&tr->day_hist, ovf_daily, tr, hp, DAY_COUNT + 1, DAY_SAMPLE); |
294 | verbose (2, "end convert_daily"); | 297 | verbose (2, _("end convert_daily")); |
295 | } | 298 | } |
296 | 299 | ||
297 | static void | 300 | static void |
298 | convert_stats (struct monitor *mon, struct traffic_sample *last, | 301 | convert_stats (struct monitor *mon, struct traffic_sample *last, |
@@ -328,17 +331,17 @@ import_log (const char *name) | |||
328 | 331 | ||
329 | fp = fopen (name, "r"); | 332 | fp = fopen (name, "r"); |
330 | if (!fp) | 333 | if (!fp) |
331 | { | 334 | { |
332 | logmsg (L_ERR, "cannot open `%s': %s", name, strerror (errno)); | 335 | logmsg (L_ERR, _("cannot open `%s': %s"), name, strerror (errno)); |
333 | return 1; | 336 | return 1; |
334 | } | 337 | } |
335 | verbose (2, "Importing %s", name); | 338 | verbose (2, _("importing %s"), name); |
336 | 339 | ||
337 | 340 | ||
338 | if (fscanf (fp, "%ld %lu %lu\n", &last.time, &last.in, &last.out) != 3) | 341 | if (fscanf (fp, "%ld %lu %lu\n", &last.time, &last.in, &last.out) != 3) |
339 | { | 342 | { |
340 | logmsg (L_ERR, "%s:1: Unexpected number of fields", name); | 343 | logmsg (L_ERR, _("%s:1: unexpected number of fields"), name); |
341 | fclose (fp); | 344 | fclose (fp); |
342 | return 1; | 345 | return 1; |
343 | } | 346 | } |
344 | cur = last.time; | 347 | cur = last.time; |
@@ -363,9 +366,9 @@ import_log (const char *name) | |||
363 | 366 | ||
364 | hist.time = rd[0]; | 367 | hist.time = rd[0]; |
365 | if (hist.time > cur) | 368 | if (hist.time > cur) |
366 | { | 369 | { |
367 | logmsg (L_WARNING, "%s:%lu: is corrupted", name, line); | 370 | logmsg (L_WARNING, _("%s:%lu: is corrupted"), name, line); |
368 | break; | 371 | break; |
369 | } | 372 | } |
370 | cur = hist.time; | 373 | cur = hist.time; |
371 | hist.in = rd[1]; | 374 | hist.in = rd[1]; |
@@ -398,9 +401,9 @@ import_log (const char *name) | |||
398 | 401 | ||
399 | mon = find_monitor (base); | 402 | mon = find_monitor (base); |
400 | if (!mon) | 403 | if (!mon) |
401 | { | 404 | { |
402 | logmsg (L_ERR, "cannot find monitor `%s'", base); | 405 | logmsg (L_ERR, _("cannot find monitor `%s'"), base); |
403 | rc = 1; | 406 | rc = 1; |
404 | } | 407 | } |
405 | else | 408 | else |
406 | convert_stats (mon, &last, hp, count); | 409 | convert_stats (mon, &last, hp, count); |
@@ -415,12 +418,13 @@ import (const char *dirname) | |||
415 | { | 418 | { |
416 | size_t count = 0; | 419 | size_t count = 0; |
417 | struct stat st; | 420 | struct stat st; |
418 | 421 | ||
419 | verbose (2, "Examining `%s'", dirname); | 422 | verbose (2, _("examining `%s'"), dirname); |
420 | 423 | ||
421 | if (stat (dirname, &st)) | 424 | if (stat (dirname, &st)) |
422 | die (EX_OSERR, "cannot stat file `%s': %s", dirname, strerror (errno)); | 425 | die (EX_OSERR, _("cannot stat file `%s': %s"), |
426 | dirname, strerror (errno)); | ||
423 | else if (S_ISREG (st.st_mode)) | 427 | else if (S_ISREG (st.st_mode)) |
424 | { | 428 | { |
425 | open_db (TAGR_DB_WR); | 429 | open_db (TAGR_DB_WR); |
426 | if (import_log (dirname) == 0) | 430 | if (import_log (dirname) == 0) |
@@ -449,20 +453,21 @@ import (const char *dirname) | |||
449 | close_db (); | 453 | close_db (); |
450 | break; | 454 | break; |
451 | 455 | ||
452 | case GLOB_NOSPACE: | 456 | case GLOB_NOSPACE: |
453 | die (EX_UNAVAILABLE, "cannot scan directory: %s", strerror (ENOMEM)); | 457 | die (EX_UNAVAILABLE, _("cannot scan directory: %s"), |
458 | strerror (ENOMEM)); | ||
454 | 459 | ||
455 | case GLOB_ABORTED: | 460 | case GLOB_ABORTED: |
456 | die (EX_UNAVAILABLE, "scanning aborted"); | 461 | die (EX_UNAVAILABLE, _("scanning aborted")); |
457 | 462 | ||
458 | case GLOB_NOMATCH: | 463 | case GLOB_NOMATCH: |
459 | break; | 464 | break; |
460 | 465 | ||
461 | default: | 466 | default: |
462 | die (EX_UNAVAILABLE, "cannot scan directory `%s'", dirname); | 467 | die (EX_UNAVAILABLE, _("cannot scan directory `%s'"), dirname); |
463 | } | 468 | } |
464 | } | 469 | } |
465 | 470 | ||
466 | verbose (1, "Number of imported log files: %d", count); | 471 | verbose (1, _("number of imported log files: %d"), count); |
467 | } | 472 | } |
468 | 473 | ||
@@ -19,17 +19,18 @@ | |||
19 | #include <xalloc.h> | 19 | #include <xalloc.h> |
20 | #include <sysexits.h> | 20 | #include <sysexits.h> |
21 | #include <grecs.h> | 21 | #include <grecs.h> |
22 | 22 | ||
23 | #define LOGFACILITY LOG_LOCAL5 | ||
24 | #define TAGR_CONFIGFILE SYSCONFDIR "/tagr.conf" | 23 | #define TAGR_CONFIGFILE SYSCONFDIR "/tagr.conf" |
25 | #define TAGR_TEMPLATE SYSCONFDIR "/tagr.tmpl" | 24 | #define TAGR_TEMPLATE SYSCONFDIR "/tagr.tmpl" |
26 | #define TAGR_PIDFILE "/var/run/tagr.pid" | 25 | #define TAGR_PIDFILE "/var/run/tagr.pid" |
27 | #define TAGR_DBNAME "tagr.db" | 26 | #define TAGR_DBNAME "tagr.db" |
28 | #define TAGR_DBMODE 0600 | 27 | #define TAGR_DBMODE 0600 |
29 | 28 | ||
30 | #define _(s) s | 29 | #define _(s) gettext (s) |
31 | #define N_(s) s | 30 | #define N_(s) s |
31 | #define gettext(s) s | ||
32 | #define ngettext(s,p,c) ((c) == 1 ? (s) : (p)) | ||
32 | 33 | ||
33 | struct monitor | 34 | struct monitor |
34 | { | 35 | { |
35 | char *id; | 36 | char *id; |