diff options
| author | Bryan Cantrill <bryan@joyent.com> | 2011-01-28 14:19:52 -0800 |
|---|---|---|
| committer | Bryan Cantrill <bryan@joyent.com> | 2011-01-28 14:19:52 -0800 |
| commit | d5c6878f09d369f50900b01afe3c7a03d2398679 (patch) | |
| tree | b49450dcf544ebd0c1debf343248d2472f15fbc6 /usr/src/cmd/svc | |
| parent | 048b02791572fec28722a0c06dec096503552ca7 (diff) | |
| download | illumos-joyent-d5c6878f09d369f50900b01afe3c7a03d2398679.tar.gz | |
945 want easy script access to service log files
Reviewed by: Eric Schrock <eric.schrock@delphix.com>
Reviewed by: Albert Lee <trisk@opensolaris.org>
Reviewed by: Garrett D'Amore <garrett@nexenta.com>
Approved by: Garrett D'Amore <garrett@nexenta.com>
Diffstat (limited to 'usr/src/cmd/svc')
| -rw-r--r-- | usr/src/cmd/svc/svcs/svcs.c | 46 |
1 files changed, 44 insertions, 2 deletions
diff --git a/usr/src/cmd/svc/svcs/svcs.c b/usr/src/cmd/svc/svcs/svcs.c index 44ebfd4e85..049dec9d30 100644 --- a/usr/src/cmd/svc/svcs/svcs.c +++ b/usr/src/cmd/svc/svcs/svcs.c @@ -1872,7 +1872,7 @@ print_usage(const char *progname, FILE *f, boolean_t do_exit) "[-sS col] [-Z | -z zone ]\n [<service> ...]\n" " %1$s -d | -D [-Hpv] [-o col[,col ... ]] [-sS col] " "[-Z | -z zone ]\n [<service> ...]\n" - " %1$s -l [-Z | -z zone] <service> ...\n" + " %1$s [-l | -L] [-Z | -z zone] <service> ...\n" " %1$s -x [-v] [-Z | -z zone] [<service> ...]\n" " %1$s -?\n"), progname); @@ -1896,6 +1896,7 @@ print_help(const char *progname) "\t-D list dependents of the specified service(s)\n" "\t-H omit header line from output\n" "\t-l list detailed information about the specified service(s)\n" + "\t-L list the log file associated with the specified service(s)\n" "\t-o list only the specified columns in the output\n" "\t-p list process IDs and names associated with each service\n" "\t-R list only those services with the specified restarter\n" @@ -2639,6 +2640,34 @@ restarter_common: return (0); } +/* ARGSUSED */ +static int +print_log(void *unused, scf_walkinfo_t *wip) +{ + scf_propertygroup_t *rpg; + char buf[MAXPATHLEN]; + + if ((rpg = scf_pg_create(h)) == NULL) + scfdie(); + + if (scf_instance_get_pg(wip->inst, SCF_PG_RESTARTER, rpg) != 0) { + if (scf_error() != SCF_ERROR_NOT_FOUND) + scfdie(); + + goto out; + } + + if (pg_get_single_val(rpg, SCF_PROPERTY_LOGFILE, + SCF_TYPE_ASTRING, buf, sizeof (buf), 0) == 0) { + (void) printf("%s\n", buf); + } + +out: + scf_pg_destroy(rpg); + + return (0); +} + int qsort_str_compare(const void *p1, const void *p2) { @@ -3426,7 +3455,7 @@ main(int argc, char **argv) int show_header = 1; int show_zones = 0; - const char * const options = "aHpvno:R:s:S:dDl?xZz:"; + const char * const options = "aHpvno:R:s:S:dDlL?xZz:"; (void) setlocale(LC_ALL, ""); @@ -3473,6 +3502,7 @@ main(int argc, char **argv) case 'd': case 'D': case 'l': + case 'L': if (opt_mode != 0) argserr(progname); @@ -3549,6 +3579,7 @@ main(int argc, char **argv) case 'd': case 'D': case 'l': + case 'L': case 'n': case 'x': assert(opt_mode == optopt); @@ -3721,6 +3752,17 @@ again: goto nextzone; } + if (opt_mode == 'L') { + if ((err = scf_walk_fmri(h, argc, argv, SCF_WALK_MULTIPLE, + print_log, NULL, &exit_status, uu_warn)) != 0) { + uu_warn(gettext("failed to iterate over " + "instances: %s\n"), scf_strerror(err)); + exit_status = UU_EXIT_FATAL; + } + + goto nextzone; + } + if (opt_mode == 'n') { print_notify_special(); if ((err = scf_walk_fmri(h, argc, argv, SCF_WALK_MULTIPLE, |
