forked from alhazred/solaris-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
kernel_values.sh
135 lines (124 loc) · 6.37 KB
/
kernel_values.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#!/sbin/sh
# Last Author: Matthew Miller
# Original Author: Matthew Miller
#
# Email: matthew.miller@digex.com
# Script name: kernel_values.sh
# Descriptions: Tool views/modifies active kernel objects
# Version: 1.3
# Tested on: Solaris 8,9 (Not to be run on a non-Solaris system)
# Permissions: Requires root access
#
# [Usage]: kernel_values.sh <object variable>
# kernel_values.sh <object variable> w <new value in decimal>
# kernel_values.sh listobjvalues
# kernel_values.sh listobjects
#
# Syntax description:
#
# kernel_values.sh <object variable>
# Give the value in decimal
# of the kernel object variable
#
# kernel_values.sh <object variable> w <new value in decimal>
# Modifies the kernel variable
# using adb
#
# kernel_values.sh listobjvalues Lists kernel object variables
# and its corresponding value.
#
# (Once started, ^D / ^C will not stop it)
#
# kernel_values.sh listobjects
# Displays kernel object
# variables, no values
#
# Example:
#
# Viewing a kernel value
#
# # ./kernel_values.sh maxusers
# (32bit) maxusers: 500
#
# Modifing the value in realtime
# * change will not be effective after reboot, unless set in /etc/system
#
# # ./kernel_values.sh maxusers w 510
# Before: (32bit) maxusers: 500
# After: (32bit) maxusers: 510
#
#
# License: Agreement discussed in version 2.0 of the GPL
#
#
# Disclaimer: I hope that this script is valuable as a part of your
# systems administration toolkit. Your use of the script contained,
# however, is at your sole risk. All information and use is provided
# "as -is", without any warranty, whether express or implied, of its
# accuracy, completeness, fitness for a particular purpose, and title.
# In short, this authored project is not guaranteed or supported in
# any manner by the author. Use at own risk.
# ~~~ ~~~~~~
#
########################################################################
#
# Friendly advise: When making kernel modifications to objects, use
# sunsolve.sun.com and docs.sun.com as a reference and remember this
# important rule ... its not can you ... its should you.
#
# functions
usage () {
echo " [Usage]: kernel_values.sh <object variable>"
echo " kernel_values.sh <object variable> w <new value in decimal>"
echo " kernel_values.sh listobjvalues"
echo " kernel_values.sh listobjects"
}
# main logic module
case "$2" in
'w')
case "$3" in
'')
usage
;;
*)
/usr/ccs/bin/nm /dev/ksyms | /usr/bin/grep "\|OBJT" | /usr/bin/grep -v "\|_" | /usr/bin/awk -F\| '{printf "%s\n",$8}' | /usr/bin/grep "^$1$" > /dev/null || exit;
BEFORE_VAR=`/usr/ccs/bin/nm /dev/ksyms | /usr/bin/grep "\|OBJT" | /usr/bin/grep -v "\|_" | /usr/bin/awk -F\| '{printf "%s %s\n",$3*1,$8}' | /usr/bin/grep " $1$" | /usr/bin/nawk '{if ($1 == "2") {printf "(%sbit) ",$1*8;system("echo "$2"/d | /usr/bin/adb -k | /usr/bin/grep : | /usr/bin/tail -1");} if ($1 == "4") {printf "(%sbit) ",$1*8;system("echo "$2"/D | /usr/bin/adb -k | /usr/bin/grep : | /usr/bin/tail -1");} if ($1 == "8") {printf "(%sbit) ",$1*8;system("echo "$2"/E | /usr/bin/adb -k | /usr/bin/grep : | /usr/bin/tail -1");}}'`
echo $BEFORE_VAR | /usr/bin/grep 16bit > /dev/null&&echo "$1/w 0t$3" | /usr/bin/adb -kw > /dev/null
echo $BEFORE_VAR | /usr/bin/grep 32bit > /dev/null&&echo "$1/W 0t$3" | /usr/bin/adb -kw > /dev/null
echo $BEFORE_VAR | /usr/bin/grep 64bit > /dev/null&&echo "$1/Z 0t$3" | /usr/bin/adb -kw > /dev/null
AFTER_VAR=`/usr/ccs/bin/nm /dev/ksyms | /usr/bin/grep "\|OBJT" | /usr/bin/grep -v "\|_" | /usr/bin/awk -F\| '{printf "%s %s\n",$3*1,$8}' | /usr/bin/grep " $1$" | /usr/bin/nawk '{if ($1 == "2") {printf "(%sbit) ",$1*8;system("echo "$2"/d | /usr/bin/adb -k | /usr/bin/grep : | /usr/bin/tail -1");} if ($1 == "4") {printf "(%sbit) ",$1*8;system("echo "$2"/D | /usr/bin/adb -k | /usr/bin/grep : | /usr/bin/tail -1");} if ($1 == "8") {printf "(%sbit) ",$1*8;system("echo "$2"/E | /usr/bin/adb -k | /usr/bin/grep : | /usr/bin/tail -1");}}'`
/usr/bin/printf "Before: ";
echo $BEFORE_VAR;
/usr/bin/printf " After: ";
echo $AFTER_VAR;
;;
esac
;;
*)
case "$1" in
'')
usage
;;
'listobjvalues')
/usr/ccs/bin/nm /dev/ksyms | /usr/bin/grep "\|OBJT" | /usr/bin/grep -v "\|_" | /usr/bin/awk -F\| '{printf "%s %s\n",$3*1,$8}' | /usr/bin/nawk '{if ($1 == "2") {printf "(%sbit) ",$1*8;system("echo "$2"/d | /usr/bin/adb -k | /usr/bin/grep : | /usr/bin/tail -1");} if ($1 == "4") {printf "(%sbit) ",$1*8;system("echo "$2"/D | /usr/bin/adb -k | /usr/bin/grep : | /usr/bin/tail -1");} if ($1 == "8") {printf "(%sbit) ",$1*8;system("echo "$2"/E | /usr/bin/adb -k | /usr/bin/grep : | /usr/bin/tail -1");}}'
;;
'listobjects')
/usr/ccs/bin/nm /dev/ksyms | /usr/bin/grep "\|OBJT" | /usr/bin/grep -v "\|_" | /usr/bin/awk -F\| '{printf "%s %s\n",$3*1,$8}' | /usr/bin/nawk '{if ($1 == "2") {printf "(%sbit) %s\n",$1*8,$2;} if ($1 == "4") {printf "(%sbit) %s\n",$1*8,$2;} if ($1 == "8") {printf "(%sbit) %s\n",$1*8,$2;}}'
;;
*)
/usr/ccs/bin/nm /dev/ksyms | /usr/bin/grep "\|OBJT" | /usr/bin/grep -v "\|_" | /usr/bin/awk -F\| '{printf "%s %s\n",$3*1,$8}' | /usr/bin/grep " $1$" | /usr/bin/nawk '{if ($1 == "2") {printf "(%sbit) ",$1*8;system("echo "$2"/d | /usr/bin/adb -k | /usr/bin/grep : | /usr/bin/tail -1");} if ($1 == "4") {printf "(%sbit) ",$1*8;system("echo "$2"/D | /usr/bin/adb -k | /usr/bin/grep : | /usr/bin/tail -1");} if ($1 == "8") {printf "(%sbit) ",$1*8;system("echo "$2"/E | /usr/bin/adb -k | /usr/bin/grep : | /usr/bin/tail -1");}}'
;;
esac
;;
esac
##############################################################################
### This script is submitted to BigAdmin by a user of the BigAdmin community.
### Sun Microsystems, Inc. is not responsible for the
### contents or the code enclosed.
###
###
### Copyright 2008 Sun Microsystems, Inc. ALL RIGHTS RESERVED
### Use of this software is authorized pursuant to the
### terms of the license found at
### http://www.sun.com/bigadmin/common/berkeley_license.html
##############################################################################