summaryrefslogtreecommitdiff
path: root/src/journal/journalctl.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2012-09-07 23:20:28 +0200
committerLennart Poettering <lennart@poettering.net>2012-09-07 23:20:28 +0200
commita1a03e3075316e2376176fc54c74e071adc9d71a (patch)
treea9ae636fd1b17047398c0f9eaf8709ecb0a861f5 /src/journal/journalctl.c
parentac59a798f2e9e616872e5c571219374c6d8f010d (diff)
journal: add call to determine current journal file disk usage
Diffstat (limited to 'src/journal/journalctl.c')
-rw-r--r--src/journal/journalctl.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c
index 1a6464d5e7..e2600542fc 100644
--- a/src/journal/journalctl.c
+++ b/src/journal/journalctl.c
@@ -72,7 +72,8 @@ static enum {
ACTION_NEW_ID128,
ACTION_PRINT_HEADER,
ACTION_SETUP_KEYS,
- ACTION_VERIFY
+ ACTION_VERIFY,
+ ACTION_DISK_USAGE,
} arg_action = ACTION_SHOW;
static int help(void) {
@@ -96,6 +97,7 @@ static int help(void) {
"Commands:\n"
" --new-id128 Generate a new 128 Bit ID\n"
" --header Show journal header information\n"
+ " --disk-usage Show total disk usage\n"
#ifdef HAVE_GCRYPT
" --setup-keys Generate new FSS key pair\n"
" --interval=TIME Time interval for changing the FSS sealing key\n"
@@ -118,7 +120,8 @@ static int parse_argv(int argc, char *argv[]) {
ARG_SETUP_KEYS,
ARG_INTERVAL,
ARG_VERIFY,
- ARG_VERIFY_KEY
+ ARG_VERIFY_KEY,
+ ARG_DISK_USAGE
};
static const struct option options[] = {
@@ -141,6 +144,7 @@ static int parse_argv(int argc, char *argv[]) {
{ "interval", required_argument, NULL, ARG_INTERVAL },
{ "verify", no_argument, NULL, ARG_VERIFY },
{ "verify-key", required_argument, NULL, ARG_VERIFY_KEY },
+ { "disk-usage", no_argument, NULL, ARG_DISK_USAGE },
{ NULL, 0, NULL, 0 }
};
@@ -224,6 +228,10 @@ static int parse_argv(int argc, char *argv[]) {
arg_action = ACTION_VERIFY;
break;
+ case ARG_DISK_USAGE:
+ arg_action = ACTION_DISK_USAGE;
+ break;
+
#ifdef HAVE_GCRYPT
case ARG_SETUP_KEYS:
arg_action = ACTION_SETUP_KEYS;
@@ -746,6 +754,19 @@ int main(int argc, char *argv[]) {
goto finish;
}
+ if (arg_action == ACTION_DISK_USAGE) {
+ uint64_t bytes;
+ char sbytes[FORMAT_BYTES_MAX];
+
+ r = sd_journal_get_usage(j, &bytes);
+ if (r < 0)
+ goto finish;
+
+ printf("Journals take up %s on disk.\n", format_bytes(sbytes, sizeof(sbytes), bytes));
+ r = 0;
+ goto finish;
+ }
+
#ifdef HAVE_ACL
if (access("/var/log/journal", F_OK) < 0 && geteuid() != 0 && in_group("adm") <= 0) {
log_error("Unprivileged users can't see messages unless persistent log storage is enabled. Users in the group 'adm' can always see messages.");