summaryrefslogtreecommitdiff
path: root/usr/src/cmd/zoneadm
diff options
context:
space:
mode:
authorJerry Jelinek <jerry.jelinek@joyent.com>2011-02-23 15:07:53 -0800
committerJerry Jelinek <jerry.jelinek@joyent.com>2011-02-23 15:07:53 -0800
commita65ec54347b767214081a3138e19835076062a3f (patch)
tree51f9a6be239a521aa9c1969d83e35db48b3e4e75 /usr/src/cmd/zoneadm
parent63cbce3a5be143acf88e8d06be030d16acafbcf8 (diff)
downloadillumos-joyent-a65ec54347b767214081a3138e19835076062a3f.tar.gz
OS-258 add utility to use dtrace to monitor zones
Diffstat (limited to 'usr/src/cmd/zoneadm')
-rw-r--r--usr/src/cmd/zoneadm/Makefile10
-rwxr-xr-xusr/src/cmd/zoneadm/zonemon.sh143
2 files changed, 150 insertions, 3 deletions
diff --git a/usr/src/cmd/zoneadm/Makefile b/usr/src/cmd/zoneadm/Makefile
index edf84184ed..ce5e76b418 100644
--- a/usr/src/cmd/zoneadm/Makefile
+++ b/usr/src/cmd/zoneadm/Makefile
@@ -21,14 +21,17 @@
#
# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, Joyent, Inc. All rights reserved.
#
PROG= zoneadm
+SCRIPTS= zonemon
MANIFEST= zones.xml resource-mgmt.xml
SVCMETHOD= svc-zones svc-resource-mgmt
include ../Makefile.cmd
+ROOTUSRSBINSCRIPTS= $(SCRIPTS:%=$(ROOTUSRSBIN)/%)
ROOTMANIFESTDIR= $(ROOTSVCSYSTEM)
OBJS= zoneadm.o zfs.o
@@ -40,13 +43,14 @@ LDLIBS += -lzonecfg -lsocket -lgen -lpool -lzfs -luuid -lnvpair -lbrand -ldladm
.KEEP_STATE:
-all: $(PROG)
+all: $(PROG) $(SCRIPTS)
$(PROG): $(OBJS)
$(LINK.c) -o $@ $(OBJS) $(LDLIBS)
$(POST_PROCESS)
-install: all $(ROOTUSRSBINPROG) $(ROOTMANIFEST) $(ROOTSVCMETHOD)
+install: all $(ROOTUSRSBINPROG) $(ROOTUSRSBINSCRIPTS) $(ROOTMANIFEST) \
+ $(ROOTSVCMETHOD)
check: $(PROG).c $(CHKMANIFEST)
$(CSTYLE) -pP $(SRCS:%=%)
@@ -56,7 +60,7 @@ $(POFILE): $(POFILES)
$(CAT) $(POFILES) > $@
clean:
- $(RM) $(OBJS) $(POFILES)
+ $(RM) $(OBJS) $(POFILES) $(SCRIPTS)
lint: lint_SRCS
diff --git a/usr/src/cmd/zoneadm/zonemon.sh b/usr/src/cmd/zoneadm/zonemon.sh
new file mode 100755
index 0000000000..fafbea0a07
--- /dev/null
+++ b/usr/src/cmd/zoneadm/zonemon.sh
@@ -0,0 +1,143 @@
+#!/usr/bin/ksh -p
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+# Copyright 2011 Joyent, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+unset LD_LIBRARY_PATH
+PATH=/usr/bin:/usr/sbin
+export PATH
+
+echo "Current status:"
+echo "::zone" | mdb -k | nawk '{
+ print $0
+ if ($3 == "shutting_down" || $3 == "down")
+ hung[$1]=$2
+} END {
+ for (i in hung) {
+ printf("Zone %d shutting down - references\n", hung[i]);
+ cmd = "echo \"" i "::zone -rv\" | mdb -k"
+ system(cmd);
+ }
+ for (i in hung) {
+ printf("Zone %d shutting down - processes\n", hung[i]);
+ cmd = "echo \"::ps -z\" | mdb -k | nawk -v zid=" hung[i] \
+ " \047{if ($6 == zid) print $0}\047"
+ system(cmd);
+ }
+}'
+
+echo
+echo "Watching:"
+
+/usr/sbin/dtrace -n '
+#pragma D option quiet
+
+fbt::zone_create:entry
+{
+ this->zonename = stringof(copyinstr(arg0));
+ printf("%Y %15s - %s\n", walltimestamp, probefunc, this->zonename);
+}
+
+fbt::zone_create:return
+/errno != 0/
+{
+ printf("%Y %15s - %s failed, errno %d\n", walltimestamp, probefunc,
+ this->zonename, errno);
+ this->zonename=0;
+}
+
+fbt::zone_create:return
+/errno == 0/
+{
+ printf("%Y %15s %3d %s\n", walltimestamp, probefunc, arg1,
+ this->zonename);
+ this->zonename=0;
+}
+
+fbt::zsched:entry
+{
+ printf("%Y %15s %3d\n", walltimestamp, probefunc,
+ ((struct zsched_arg *)args[0])->zone->zone_id);
+}
+
+fbt::zone_start_init:entry
+{
+ printf("%Y %15s %3d\n", walltimestamp, probefunc, curpsinfo->pr_zoneid);
+}
+
+fbt::zone_boot:entry
+{
+ this->zoneid=args[0];
+}
+
+fbt::zone_boot:return
+/errno != 0/
+{
+ printf("%Y %15s %3d failed, errno %d\n", walltimestamp, probefunc,
+ this->zoneid, errno);
+ this->zoneid=0;
+}
+
+fbt::zone_boot:return
+/errno == 0/
+{
+ printf("%Y %15s %3d\n", walltimestamp, probefunc, this->zoneid);
+ this->zoneid=0;
+}
+
+fbt::zone_empty:entry
+{
+ this->zoneid=((zone_t *)args[0])->zone_id;
+ printf("%Y %15s %3d start\n", walltimestamp, probefunc,
+ this->zoneid);
+}
+
+fbt::zone_empty:return
+{
+ printf("%Y %15s %3d return\n", walltimestamp, probefunc, this->zoneid);
+ this->zoneid=0;
+}
+
+fbt::zone_shutdown:entry,
+fbt::zone_destroy:entry
+{
+ printf("%Y %15s %3d\n", walltimestamp, probefunc, args[0]);
+ this->zoneid=args[0];
+}
+
+fbt::zone_shutdown:return,
+fbt::zone_destroy:return
+/errno != 0/
+{
+ printf("%Y %15s %3d failed, errno %d\n", walltimestamp, probefunc,
+ this->zoneid, errno);
+ this->zoneid=0;
+}
+
+fbt::zone_shutdown:return,
+fbt::zone_destroy:return
+/errno == 0/
+{
+ this->zoneid=0;
+}
+'