mirror of
https://github.com/troglobit/finit.git
synced 2026-11-06 15:51:03 +00:00
initctl: improve log digger in 'status foo' command
Grep in /var/log/syslog, or messages, for both the service identity (not just svc->cmd) and also try to find [PID] for more relevant information. Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
1 parent
fdbd25c1b5
commit
6934ba4dbc
1 file changed
+10
-6
+10
-6
@@ -154,12 +154,16 @@ static int toggle_debug(char *arg)
|
|||||||
return client_send(&rq, sizeof(rq));
|
return client_send(&rq, sizeof(rq));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int do_log(char *svc)
|
static int do_log(svc_t *svc)
|
||||||
{
|
{
|
||||||
char *logfile = "/var/log/syslog";
|
const char *logfile = "/var/log/syslog";
|
||||||
|
char *nm = svc_ident(svc, NULL, 0);
|
||||||
|
pid_t pid = svc->pid;
|
||||||
|
|
||||||
if (!svc || !svc[0])
|
if (!nm || !nm[0]) {
|
||||||
svc = "finit";
|
nm = "finit";
|
||||||
|
pid = 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (!fexist(logfile)) {
|
if (!fexist(logfile)) {
|
||||||
logfile = "/var/log/messages";
|
logfile = "/var/log/messages";
|
||||||
@@ -167,7 +171,7 @@ static int do_log(char *svc)
|
|||||||
return 0; /* bail out, maybe in container */
|
return 0; /* bail out, maybe in container */
|
||||||
}
|
}
|
||||||
|
|
||||||
return systemf("cat %s | grep %s | tail -10", logfile, svc);
|
return systemf("cat %s | grep '\\[%d\\]\\|%s' | tail -10", logfile, pid, nm);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int do_runlevel(char *arg)
|
static int do_runlevel(char *arg)
|
||||||
@@ -864,7 +868,7 @@ static int show_status(char *arg)
|
|||||||
no_cgroup:
|
no_cgroup:
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
return do_log(svc->cmd);
|
return do_log(svc);
|
||||||
}
|
}
|
||||||
|
|
||||||
col_widths();
|
col_widths();
|
||||||
|
|||||||
Reference in new issue
Block a user