Browse Source

* update jail stats fmt

master
Alex 'AdUser' Z 4 years ago
parent
commit
d1c5f25042
  1. 30
      src/jail.c

30
src/jail.c

@ -535,17 +535,20 @@ f2b_jail_stop(f2b_jail_t *jail) {
void void
f2b_jail_cmd_status(char *res, size_t ressize, f2b_jail_t *jail) { f2b_jail_cmd_status(char *res, size_t ressize, f2b_jail_t *jail) {
const char *fmt = char buf[1024] = "";
const char *fmt1 =
"name: %s\n" "name: %s\n"
"banscore: %d\n" "banscore: %d\n"
"flags:\n" "flags:\n"
" enabled: %s\n" " enabled: %s\n"
" state: %s\n" " state: %s\n"
" filter: %s\n" " filter: %s\n";
const char *fmt2 =
"times:\n" "times:\n"
" bantime: %.1f hrs (+%d%%)\n" " bantime: %.1f hrs (+%d%%)\n"
" findtime: %.1f min (+%d%%)\n" " findtime: %.1f min (+%d%%)\n"
" expiretime: %.1f min (+%d%%)\n" " expiretime: %.1f hrs (+%d%%)\n";
const char *fmt3 =
"stats:\n" "stats:\n"
" hosts: %d\n" " hosts: %d\n"
" matches: %d\n" " matches: %d\n"
@ -554,17 +557,24 @@ f2b_jail_cmd_status(char *res, size_t ressize, f2b_jail_t *jail) {
assert(res != NULL); assert(res != NULL);
assert(jail != NULL); assert(jail != NULL);
snprintf(res, ressize, fmt, jail->name, snprintf(res, ressize, fmt1,
jail->banscore, jail->name, jail->banscore,
jail->flags & JAIL_ENABLED ? "yes" : "no", jail->flags & JAIL_ENABLED ? "yes" : "no",
jail->flags & JAIL_HAS_STATE ? "yes" : "no", jail->flags & JAIL_HAS_STATE ? "yes" : "no",
jail->flags & JAIL_HAS_FILTER ? "yes" : "no", jail->flags & JAIL_HAS_FILTER ? "yes" : "no"
jail->bantime / 3600, (int) jail->bantime_extend * 100, );
jail->findtime / 60, (int) jail->findtime_extend * 100, snprintf(buf, sizeof(buf), fmt2,
jail->expiretime / 60, (int) jail->expiretime_extend * 100, (float) jail->bantime / 3600, (int) (jail->bantime_extend * 100),
(float) jail->findtime / 60, (int) (jail->findtime_extend * 100),
(float) jail->expiretime / 3600, (int) (jail->expiretime_extend * 100)
);
strlcat(res, buf, ressize);
snprintf(buf, sizeof(buf), fmt3,
jail->stats.hosts, jail->stats.hosts,
jail->stats.matches, jail->stats.matches,
jail->stats.bans); jail->stats.bans
);
strlcat(res, buf, ressize);
} }
void void

Loading…
Cancel
Save