0N/A * The contents of this file are subject to the terms of the 0N/A * Common Development and Distribution License (the "License"). 0N/A * You may not use this file except in compliance with the License. 0N/A * You can obtain a copy of the license at CDDL.LICENSE. 0N/A * See the License for the specific language governing permissions 0N/A * and limitations under the License. 0N/A * When distributing Covered Code, include this CDDL HEADER in each 0N/A * file and include the License file at CDDL.LICENSE. 0N/A * If applicable, add the following below this CDDL HEADER, with the 0N/A * fields enclosed by brackets "[]" replaced with your own identifying 0N/A * information: Portions Copyright [yyyy] [name of copyright owner] 0N/A * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 0N/A * Use is subject to license terms. 0N/A * Generate a dot file for the SMF dependency graph on this machine. 0N/A * We operate in two modes: with and without -L. Without -L, we print nodes 0N/A * for each instance and edges for each dependency. Fortunately dot allows 0N/A * forward references, so we can do this in one pass. Options are 0N/A * -s width,height Size, in inches, that the graph should be limited to. 0N/A * -l legend.ps PostScript file which should be used as the legend. 0N/A * -x opts Simplify the graph. opts should be a comma-separated 0N/A * omit_net_deps Omit most of the dependencies on 0N/A * allowable_net_dep().) 0N/A * consolidate_inetd_svcs Consolidate services which only depend on 0N/A * consolidate_rpcbind_svcs Consolidate services which only depend on 0N/A * Other hard-coded graph settings (rankdir, nodesep, margin) were intended 0N/A * for a 42" plotter. 0N/A * -L causes the program to print a dot file for use as a legend. It 0N/A * currently consists of eight nodes which demonstrate the color scheme and 0N/A * the dependency types. The nodes are enclosed in a box which is labeled 0N/A/* Private libscf function */ 0N/A * We color nodes by FMRI and enabledness. For each class we specify 0N/A * a foreground color, which will be the color of the text and the outline, 0N/A * and a background color, which will fill the node. 0N/A * In this scheme we'll color services who's FMRIs begin with "system" orange, 0N/A * "network" blue, "milestone" green, and other services light gray. For each 0N/A * category we'll color the disabled services a faded shade of their enabled 0N/A * counterparts. The foreground of the enabled services will all be black, 0N/A * and the backgrounds will be 0N/A * To make disabled services appear faded, I took the above colors and halved 0N/A/* Graph simplification options, for use with getsubopt(). */ 0N/A "consolidate_inetd_svcs",
0N/A "consolidate_rpcbind_svcs",
0N/A/* Consolidation strings */ 0N/A/* Scratch libscf objects, to save time. */ 0N/A * Return 1 if inst is enabled, 0 otherwise. Uses g_pg, g_prop, and g_val. 0N/A * Fill in buf with the restarter of instance i. Uses g_pg, g_prop, and 0N/A "Usage: %1$s [-s width,height] [-l legend.ps] [-x opts]\n" 0N/A "Where opts is a comma-separated list of\n");
0N/A * Make name suitable for dot. 0N/A * Print an edge for a dependency. port should be the name of the dependency 0N/A * Choose a coloring for the given service. Returns a pointer to an array of 0N/A * two string pointers, the first being the text color and the second being 0N/Astatic const char *
const *
0N/A * Print a node for a service. dependencies should either be an empty string 0N/A * or a string of "<dependency port name> dependency name" strings joined by 0N/A (
void)
printf(
"\"%s\" [shape=record,color=\"%s\",style=filled," 0N/A "fillcolor=\"%s\",fontcolor=\"%s\"," 0N/A (
void)
printf(
"\"%s\" [shape=record,color=\"%s\",style=filled," 0N/A "fillcolor=\"%s\",fontcolor=\"%s\",label=\"%s\"];\n",
0N/A * Print some fake service nodes in a box to demonstrate the coloring and the 0N/A "node [fontname=\"Helvetica\",fontsize=11];\n" 0N/A "label=\"legend\";\n" 0N/A "color=\"black\";\n");
0N/A "label=\"optional_all\",style=dashed",
1);
0N/A "label=\"exclude_all\",arrowtail=odot",
1);
0N/A * dependents, which would produce a bad graph.) 0N/A/* dependency name accumulator */ 0N/A /* Append sprintf("<%s> %s|", str, str) */ 0N/A * For the given instance, generate a node and the appropriate edges. 0N/A * Node generation: Collect the name, restarter, dependency names, and 0N/A * enabled status and call print_service_node(). The dependency names 0N/A * will be accumulated in allpgs. 0N/A * Edges: One for the restarter, if it is not the default (svc.startd) 0N/A * (denoted by an empty string), and one for each dependency service. 0N/A * Remember that dependency groups can name multiple services, and 0N/A * each service can have multiple instances. 0N/A /* The grouping will dictate how we draw the edge */ 0N/A /* ENTITIES holds the FMRIs of the dependencies */ 0N/A * This will fail if the dependency is on a file:, 0N/A * which is legitimate, but we'll skip. 0N/A * This function leaves sname & iname pointing into 0N/A * depname_copy, which may be modified. 0N/A * This is a service dependency. Look up the 0N/A * service and output edges connecting that 0N/A * service node to each of its instances. 0N/A * If requested, print the legend. Otherwise print some graph settings and 0N/A * call process_instance() for each service instance in the repository. 0N/A (
void)
printf(
"node [shape=box,fontname=\"Helvetica\",fontsize=11];\n");
0N/A * The legend is just a node with the given PostScript as its 0N/A * shape. dot will put it on the highest rank. It usually 0N/A * particular); avoid that with a sufficiently large margin. 0N/A * (See expand.awk .) 0N/A "legend [shape=epsf,shapefile=\"%s\",label=\"\"];\n",
0N/A /* Otherwise this shows up as an unconnected node. */ 0N/A (
void)
fputs(
"process_instance() failed",
0N/A "<restarter> restarter | <rpcbind> rpcbind",