aboutsummaryrefslogtreecommitdiff
path: root/src/stat.c
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2009-04-27 00:50:31 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2009-04-27 00:50:31 +0300
commitfe8f5226e8bc39bdc75e40e1c1ea464e9fc60ad3 (patch)
tree611a7c8505a0eb77a2b84de5dab80b6ca02a14e6 /src/stat.c
parentd50fc04ded36255465184a16c70eb4c50acdb199 (diff)
downloadtagr-fe8f5226e8bc39bdc75e40e1c1ea464e9fc60ad3.tar.gz
tagr-fe8f5226e8bc39bdc75e40e1c1ea464e9fc60ad3.tar.bz2
Provide i18n markers
Diffstat (limited to 'src/stat.c')
-rw-r--r--src/stat.c65
1 files changed, 35 insertions, 30 deletions
diff --git a/src/stat.c b/src/stat.c
index ed4ab8e..85b76d9 100644
--- a/src/stat.c
+++ b/src/stat.c
@@ -42,26 +42,26 @@ interpolate (queue_t *q,
struct traffic_history th;
if (now - last_time <= step)
{
th.inrate = inrate;
th.outrate = outrate;
- verbose (3, "Insert %lu %g %g", next, th.inrate, th.outrate);
+ verbose (3, _("insert %lu %g %g"), next, th.inrate, th.outrate);
queue_put (q, &th);
if (ovf)
ovf (&th, tr, now);
return;
}
for (next = last_time + step; next <= now; next += step)
{
th.inrate = (inrate - last_rates->inrate) * (next - last_time)
/ interval + last_rates->inrate;
th.outrate = (outrate - last_rates->outrate) * (next - last_time)
/ interval + last_rates->outrate;
- verbose (3, "Insert %lu %g %g", next, th.inrate, th.outrate);
+ verbose (3, _("insert %lu %g %g"), next, th.inrate, th.outrate);
queue_put (q, &th);
if (ovf)
ovf (&th, tr, now);
}
}
@@ -89,13 +89,13 @@ overflow (struct traffic_history *th,
ovf, tr);
else
{
struct traffic_history tmp;
tmp.inrate = avg->inrate;
tmp.outrate = avg->outrate;
- verbose (3, "Insert %lu %g %g", now, tmp.inrate, tmp.outrate);
+ verbose (3, _("insert %lu %g %g"), now, tmp.inrate, tmp.outrate);
queue_put (q, &tmp);
}
avg->inrate = avg->outrate = 0;
avg->count = 0;
avg->time = now;
@@ -105,34 +105,37 @@ overflow (struct traffic_history *th,
avg->count++;
}
int
ovf_monthly (struct traffic_history *th, struct traffic_record *tr, time_t now)
{
- verbose (2, "begin overflow_monthly %lu %g %g", now, th->inrate, th->outrate);
+ verbose (2, _("begin overflow_monthly %lu %g %g"),
+ now, th->inrate, th->outrate);
overflow (th, tr, now, NULL, &tr->year_avg, &tr->year_hist,
YEAR_COUNT, YEAR_SAMPLE);
- verbose (2, "end overflow_monthly");
+ verbose (2, _("end overflow_monthly"));
}
int
ovf_weekly (struct traffic_history *th, struct traffic_record *tr, time_t now)
{
- verbose (2, "begin overflow_weekly %lu %g %g", now, th->inrate, th->outrate);
+ verbose (2, _("begin overflow_weekly %lu %g %g"),
+ now, th->inrate, th->outrate);
overflow (th, tr, now, ovf_monthly, &tr->month_avg, &tr->month_hist,
MONTH_COUNT, MONTH_SAMPLE);
- verbose (2, "end overflow_daily");
+ verbose (2, _("end overflow_daily"));
}
int
ovf_daily (struct traffic_history *th, struct traffic_record *tr, time_t now)
{
- verbose (2, "begin overflow_daily %lu %g %g", now, th->inrate, th->outrate);
+ verbose (2, _("begin overflow_daily %lu %g %g"),
+ now, th->inrate, th->outrate);
overflow (th, tr, now, ovf_weekly, &tr->week_avg, &tr->week_hist,
WEEK_COUNT, WEEK_SAMPLE);
- verbose (2, "end overflow_daily");
+ verbose (2, _("end overflow_daily"));
}
void
update_stats (struct monitor *mon, struct traffic_sample *sample,
struct traffic_record *tr)
{
@@ -141,13 +144,13 @@ update_stats (struct monitor *mon, struct traffic_sample *sample,
struct traffic_history *lastp = queue_get_tail (&tr->day_hist);
interval = sample->time - tr->last.time;
if (interval == 0)
{
- logmsg (L_ERR, "Ignoring zero interval");
+ logmsg (L_ERR, _("ignoring zero interval"));
return;
}
inrate = (double) sample->in / interval;
outrate = (double) sample->out / interval;
if (lastp)
{
@@ -214,13 +217,13 @@ _convert (queue_t *q, ovf_t ovf,
interval = hp->time - tr->last.time;
inrate = (double) hp->in;
outrate = (double) hp->out;
if (interval == 0)
{
- logmsg (L_ERR, "Ignoring zero interval");
+ logmsg (L_ERR, _("ignoring zero interval"));
break;
}
if (lastp)
{
interpolate (q,
sample_interval,
@@ -249,52 +252,52 @@ _convert (queue_t *q, ovf_t ovf,
}
static void
convert_yearly (struct traffic_record *tr, struct traffic_sample *hp,
size_t count)
{
- verbose (2, "begin convert_yearly");
+ verbose (2, _("begin convert_yearly"));
_convert (&tr->year_hist, NULL, tr,
hp, count, YEAR_SAMPLE);
compute_avg (&tr->year_avg, &tr->year_hist, &tr->last);
- verbose (2, "end convert_yearly");
+ verbose (2, _("end convert_yearly"));
}
static void
convert_monthly (struct traffic_record *tr, struct traffic_sample *hp,
size_t count)
{
- verbose (2, "begin convert_monthly");
+ verbose (2, _("begin convert_monthly"));
if (count > MONTH_COUNT+1)
convert_yearly (tr, hp + MONTH_COUNT + 1, count - (MONTH_COUNT + 1));
_convert (&tr->month_hist, ovf_monthly, tr,
hp, MONTH_COUNT + 1, MONTH_SAMPLE);
compute_avg (&tr->month_avg, &tr->month_hist, &tr->last);
- verbose (2, "end convert_monthly");
+ verbose (2, _("end convert_monthly"));
}
static void
convert_weekly (struct traffic_record *tr, struct traffic_sample *hp, size_t count)
{
- verbose (2, "begin convert_weekly");
+ verbose (2, _("begin convert_weekly"));
if (count > WEEK_COUNT+1)
convert_monthly (tr, hp + WEEK_COUNT + 1, count - (WEEK_COUNT + 1));
_convert (&tr->week_hist, ovf_weekly,
tr, hp, WEEK_COUNT + 1, WEEK_SAMPLE);
compute_avg (&tr->week_avg, &tr->week_hist, &tr->last);
- verbose (2, "end convert_weekly");
+ verbose (2, _("end convert_weekly"));
}
static void
convert_daily (struct traffic_record *tr, struct traffic_sample *hp, size_t count)
{
- verbose (2, "begin convert_daily");
+ verbose (2, _("begin convert_daily"));
if (count > DAY_COUNT+1)
convert_weekly (tr, hp + DAY_COUNT + 1, count - (DAY_COUNT + 1));
_convert (&tr->day_hist, ovf_daily, tr, hp, DAY_COUNT + 1, DAY_SAMPLE);
- verbose (2, "end convert_daily");
+ verbose (2, _("end convert_daily"));
}
static void
convert_stats (struct monitor *mon, struct traffic_sample *last,
struct traffic_sample *hp, size_t count)
{
@@ -326,21 +329,21 @@ import_log (const char *name)
size_t line = 1;
time_t cur;
fp = fopen (name, "r");
if (!fp)
{
- logmsg (L_ERR, "cannot open `%s': %s", name, strerror (errno));
+ logmsg (L_ERR, _("cannot open `%s': %s"), name, strerror (errno));
return 1;
}
- verbose (2, "Importing %s", name);
+ verbose (2, _("importing %s"), name);
if (fscanf (fp, "%ld %lu %lu\n", &last.time, &last.in, &last.out) != 3)
{
- logmsg (L_ERR, "%s:1: Unexpected number of fields", name);
+ logmsg (L_ERR, _("%s:1: unexpected number of fields"), name);
fclose (fp);
return 1;
}
cur = last.time;
obstack_init (&stk);
@@ -361,13 +364,13 @@ import_log (const char *name)
for (i = 0; i <= 4; i++)
rd[i] = rd[i] < 0 ? 0 : rd[i];
hist.time = rd[0];
if (hist.time > cur)
{
- logmsg (L_WARNING, "%s:%lu: is corrupted", name, line);
+ logmsg (L_WARNING, _("%s:%lu: is corrupted"), name, line);
break;
}
cur = hist.time;
hist.in = rd[1];
hist.out = rd[2];
if (inmax < rd[3])
@@ -396,13 +399,13 @@ import_log (const char *name)
if (p)
*p = 0;
mon = find_monitor (base);
if (!mon)
{
- logmsg (L_ERR, "cannot find monitor `%s'", base);
+ logmsg (L_ERR, _("cannot find monitor `%s'"), base);
rc = 1;
}
else
convert_stats (mon, &last, hp, count);
}
@@ -413,16 +416,17 @@ import_log (const char *name)
void
import (const char *dirname)
{
size_t count = 0;
struct stat st;
- verbose (2, "Examining `%s'", dirname);
+ verbose (2, _("examining `%s'"), dirname);
if (stat (dirname, &st))
- die (EX_OSERR, "cannot stat file `%s': %s", dirname, strerror (errno));
+ die (EX_OSERR, _("cannot stat file `%s': %s"),
+ dirname, strerror (errno));
else if (S_ISREG (st.st_mode))
{
open_db (TAGR_DB_WR);
if (import_log (dirname) == 0)
count++;
close_db ();
@@ -447,22 +451,23 @@ import (const char *dirname)
count++;
globfree (&gl);
close_db ();
break;
case GLOB_NOSPACE:
- die (EX_UNAVAILABLE, "cannot scan directory: %s", strerror (ENOMEM));
+ die (EX_UNAVAILABLE, _("cannot scan directory: %s"),
+ strerror (ENOMEM));
case GLOB_ABORTED:
- die (EX_UNAVAILABLE, "scanning aborted");
+ die (EX_UNAVAILABLE, _("scanning aborted"));
case GLOB_NOMATCH:
break;
default:
- die (EX_UNAVAILABLE, "cannot scan directory `%s'", dirname);
+ die (EX_UNAVAILABLE, _("cannot scan directory `%s'"), dirname);
}
}
- verbose (1, "Number of imported log files: %d", count);
+ verbose (1, _("number of imported log files: %d"), count);
}

Return to:

Send suggestions and report system problems to the System administrator.