1 /*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
7 * with the License.
8 *
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
13 *
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 *
20 * CDDL HEADER END
21 */
22 /*
23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 */
26
27 #pragma ident "%Z%%M% %I% %E% SMI"
28
29 #include <fmadm.h>
30
31 /*ARGSUSED*/
32 static int
config_modinfo(const fmd_adm_modinfo_t * ami,void * unused)33 config_modinfo(const fmd_adm_modinfo_t *ami, void *unused)
34 {
35 const char *state;
36
37 if (ami->ami_flags & FMD_ADM_MOD_FAILED)
38 state = "failed";
39 else
40 state = "active";
41
42 (void) printf("%-24s %-7s %-6s %s\n",
43 ami->ami_name, ami->ami_vers, state, ami->ami_desc);
44
45 return (0);
46 }
47
48 /*ARGSUSED*/
49 int
cmd_config(fmd_adm_t * adm,int argc,char * argv[])50 cmd_config(fmd_adm_t *adm, int argc, char *argv[])
51 {
52 if (argc != 1)
53 return (FMADM_EXIT_USAGE);
54
55 (void) printf("%-24s %-7s %-6s %s\n",
56 "MODULE", "VERSION", "STATUS", "DESCRIPTION");
57
58 if (fmd_adm_module_iter(adm, config_modinfo, NULL) != 0)
59 die("failed to retrieve configuration");
60
61 return (FMADM_EXIT_SUCCESS);
62 }
63
64 int
cmd_rotate(fmd_adm_t * adm,int argc,char * argv[])65 cmd_rotate(fmd_adm_t *adm, int argc, char *argv[])
66 {
67 if (argc != 2)
68 return (FMADM_EXIT_USAGE);
69
70 if (fmd_adm_log_rotate(adm, argv[1]) != 0)
71 die("failed to rotate %s", argv[1]);
72
73 note("%s has been rotated out and can now be archived\n", argv[1]);
74 return (FMADM_EXIT_SUCCESS);
75 }
76