summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2016-01-24 11:47:19 -0500
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2016-01-24 11:49:31 -0500
commitce262e5760a22ccbf2430ef8d4c3c7e48a67fd85 (patch)
treed81e0f3a2df725e90c1683640d4015515add9dc6
parent3a79e301e8304609a173b86237d6cc6b6e37a5ce (diff)
parent2f1acf6f1321e00c8e48ca8f161c4d7883ffad63 (diff)
Merge pull request #2425 from yuwata/journal-remote-v4
ZJS: remove unnecessary oom check after strdupa().
-rw-r--r--man/systemd-journal-remote.xml15
-rw-r--r--src/journal-remote/journal-remote.c46
2 files changed, 43 insertions, 18 deletions
diff --git a/man/systemd-journal-remote.xml b/man/systemd-journal-remote.xml
index ebaca2657f..3899f175d4 100644
--- a/man/systemd-journal-remote.xml
+++ b/man/systemd-journal-remote.xml
@@ -293,15 +293,24 @@ journalctl -o export | systemd-journal-remote -o /tmp/dir -
</programlisting>
</para>
- <para>Retrieve events from a remote
+ <para>Retrieve all available events from a remote
<citerefentry><refentrytitle>systemd-journal-gatewayd</refentrytitle><manvolnum>8</manvolnum></citerefentry>
instance and store them in
- <filename>/var/log/journal/some.host/remote-some~host.journal</filename>:
+ <filename>/var/log/journal/remote/remote-some.host.journal</filename>:
<programlisting>
systemd-journal-remote --url http://some.host:19531/
</programlisting>
</para>
- </refsect1>
+
+ <para>Retrieve current boot events and wait for new events from a remote
+ <citerefentry><refentrytitle>systemd-journal-gatewayd</refentrytitle><manvolnum>8</manvolnum></citerefentry>
+ instance, and store them in
+ <filename>/var/log/journal/remote/remote-some.host.journal</filename>:
+ <programlisting>
+systemd-journal-remote --url http://some.host:19531/entries?boot&amp;follow
+ </programlisting>
+ </para>
+</refsect1>
<refsect1>
<title>See Also</title>
diff --git a/src/journal-remote/journal-remote.c b/src/journal-remote/journal-remote.c
index e7003da9c1..cfe111fd91 100644
--- a/src/journal-remote/journal-remote.c
+++ b/src/journal-remote/journal-remote.c
@@ -150,7 +150,7 @@ static int spawn_curl(const char* url) {
return r;
}
-static int spawn_getter(const char *getter, const char *url) {
+static int spawn_getter(const char *getter) {
int r;
_cleanup_strv_free_ char **words = NULL;
@@ -159,10 +159,6 @@ static int spawn_getter(const char *getter, const char *url) {
if (r < 0)
return log_error_errno(r, "Failed to split getter option: %m");
- r = strv_extend(&words, url);
- if (r < 0)
- return log_error_errno(r, "Failed to create command line: %m");
-
r = spawn_child(words[0], words);
if (r < 0)
log_error_errno(r, "Failed to spawn getter %s: %m", getter);
@@ -897,18 +893,32 @@ static int remoteserver_init(RemoteServer *s,
fd);
}
- if (arg_url) {
- const char *url, *hostname;
+ if (arg_getter) {
+ log_info("Spawning getter %s...", arg_getter);
+ fd = spawn_getter(arg_getter);
+ if (fd < 0)
+ return fd;
+
+ r = add_source(s, fd, (char*) arg_output, false);
+ if (r < 0)
+ return r;
+ }
- url = strjoina(arg_url, "/entries");
+ if (arg_url) {
+ const char *url;
+ char *hostname, *p;
- if (arg_getter) {
- log_info("Spawning getter %s...", url);
- fd = spawn_getter(arg_getter, url);
- } else {
- log_info("Spawning curl %s...", url);
- fd = spawn_curl(url);
+ if (!strstr(arg_url, "/entries")) {
+ if (endswith(arg_url, "/"))
+ url = strjoina(arg_url, "entries");
+ else
+ url = strjoina(arg_url, "/entries");
}
+ else
+ url = strdupa(arg_url);
+
+ log_info("Spawning curl %s...", url);
+ fd = spawn_curl(url);
if (fd < 0)
return fd;
@@ -917,7 +927,13 @@ static int remoteserver_init(RemoteServer *s,
startswith(arg_url, "http://") ?:
arg_url;
- r = add_source(s, fd, (char*) hostname, false);
+ hostname = strdupa(hostname);
+ if ((p = strchr(hostname, '/')))
+ *p = '\0';
+ if ((p = strchr(hostname, ':')))
+ *p = '\0';
+
+ r = add_source(s, fd, hostname, false);
if (r < 0)
return r;
}