{"id":3288,"date":"2014-07-01T23:58:48","date_gmt":"2014-07-01T15:58:48","guid":{"rendered":"http:\/\/rmohan.com\/?p=3288"},"modified":"2014-07-01T23:58:48","modified_gmt":"2014-07-01T15:58:48","slug":"solaris-grep","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=3288","title":{"rendered":"Solaris Grep"},"content":{"rendered":"<div class=\"day\" style=\"font: 12px\/16.79px Verdana, Tahoma, Arial, sans-serif; margin: 0px; padding: 0px; color: #4c5863; text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; white-space: normal; background-color: #ffffff; -webkit-text-stroke-width: 0px;\">\n<div class=\"entry\" style=\"margin: 0px; padding: 0px; border-bottom-color: #cdcdcd; border-bottom-width: 1px; border-bottom-style: solid;\">\n<div class=\"entryBody\" style=\"margin: 0px; padding: 0px;\">\n<h3 class=\"entryHeader\" style=\"margin: 0.2em 0px 10px; padding: 0px; color: #39434d; line-height: 1.3em; font-size: 14px; font-weight: bold;\"><a style=\"margin: 0px; padding: 0px; color: #39434d;\" href=\"http:\/\/blogs.warwick.ac.uk\/peggleton\/entry\/grep_on_solaris\/\" rel=\"bookmark\">grep on Solaris<\/a><\/h3>\n<p style=\"margin: 0px 0px 1em; padding: 0px;\">Today I was asked by a colleague how to match a regex in a text file and return a specific number of lines both before and after the match.<span class=\"Apple-converted-space\">\u00a0<\/span><span class=\"caps\" style=\"margin: 0px; padding: 0px;\">GNU<\/span><span class=\"Apple-converted-space\">\u00a0<\/span>grep has a very easy solution for this; the -A\/B\/C flags, as shown on my Mac<\/p>\n<pre style=\"margin: 3px 0px; padding: 10px; border: 1px solid #a1a1a1; overflow: auto; font-size: 1.2em;\"><code style=\"margin: 0px; padding: 0px;\">warwick egg$ grep --help\r\nUsage: grep [OPTION]... PATTERN [FILE] ...\r\nSearch for PATTERN in each FILE or standard input.\r\nExample: grep -i 'hello world' menu.h main.c\r\n\r\nRegexp selection and interpretation:\r\n  -E, --extended-regexp     PATTERN is an extended regular expression\r\n  -F, --fixed-strings       PATTERN is a set of newline-separated strings\r\n  -G, --basic-regexp        PATTERN is a basic regular expression\r\n  -P, --perl-regexp         PATTERN is a Perl regular expression\r\n  -e, --regexp=PATTERN      use PATTERN as a regular expression\r\n  -f, --file=FILE           obtain PATTERN from FILE\r\n  -i, --ignore-case         ignore case distinctions\r\n  -w, --word-regexp         force PATTERN to match only whole words\r\n  -x, --line-regexp         force PATTERN to match only whole lines\r\n  -z, --null-data           a data line ends in 0 byte, not newline\r\n\r\nMiscellaneous:\r\n  -s, --no-messages         suppress error messages\r\n  -v, --invert-match        select non-matching lines\r\n  -V, --version             print version information and exit\r\n      --help                display this help and exit\r\n      --mmap                use memory-mapped input if possible\r\n\r\nOutput control:\r\n  -m, --max-count=NUM       stop after NUM matches\r\n  -b, --byte-offset         print the byte offset with output lines\r\n  -n, --line-number         print line number with output lines\r\n      --line-buffered       flush output on every line\r\n  -H, --with-filename       print the filename for each match\r\n  -h, --no-filename         suppress the prefixing filename on output\r\n      --label=LABEL         print LABEL as filename for standard input\r\n  -o, --only-matching       show only the part of a line matching PATTERN\r\n  -q, --quiet, --silent     suppress all normal output\r\n      --binary-files=TYPE   assume that binary files are TYPE\r\n                            TYPE is 'binary', 'text', or 'without-match'\r\n  -a, --text                equivalent to --binary-files=text\r\n  -I                        equivalent to --binary-files=without-match\r\n  -d, --directories=ACTION  how to handle directories\r\n                            ACTION is 'read', 'recurse', or 'skip'\r\n  -D, --devices=ACTION      how to handle devices, FIFOs and sockets\r\n                            ACTION is 'read' or 'skip'\r\n  -R, -r, --recursive       equivalent to --directories=recurse\r\n      --include=PATTERN     files that match PATTERN will be examined\r\n      --exclude=PATTERN     files that match PATTERN will be skipped.\r\n      --exclude-from=FILE   files that match PATTERN in FILE will be skipped.\r\n  -L, --files-without-match only print FILE names containing no match\r\n  -l, --files-with-matches  only print FILE names containing matches\r\n  -c, --count               only print a count of matching lines per FILE\r\n  -Z, --null                print 0 byte after FILE name\r\n\r\nContext control:\r\n  -B, --before-context=NUM  print NUM lines of leading context\r\n  -A, --after-context=NUM   print NUM lines of trailing context\r\n  -C, --context=NUM         print NUM lines of output context\r\n  -NUM                      same as --context=NUM\r\n      --color[=WHEN],\r\n      --colour[=WHEN]       use markers to distinguish the matching string\r\n                            WHEN may be `always', `never' or `auto'.\r\n  -U, --binary              do not strip CR characters at EOL (MSDOS)\r\n  -u, --unix-byte-offsets   report offsets as if CRs were not there (MSDOS)\r\n\r\n`egrep' means `grep -E'.  `fgrep' means `grep -F'.\r\nWith no FILE, or when FILE is -, read standard input.  If less than\r\ntwo FILEs given, assume -h.  Exit status is 0 if match, 1 if no match,\r\nand 2 if trouble.\r\n\r\nReport bugs to &lt;bug-gnu-utils@gnu.org&gt;.<\/code><\/pre>\n<p style=\"margin: 0px 0px 1em; padding: 0px;\">Unfortunately, Solaris grep, egrep or fgrep are not quite as advanced:<\/p>\n<pre style=\"margin: 3px 0px; padding: 10px; border: 1px solid #a1a1a1; overflow: auto; font-size: 1.2em;\"><code style=\"margin: 0px; padding: 0px;\">Usage: grep -hblcnsviw pattern file . . .\r\n\r\nusage: egrep [ -bchilnsv ] [ -e exp ] [ -f file ] [ strings ] [ file ] ...\r\n\r\nusage: fgrep [ -bchilnsvx ] [ -e exp ] [ -f file ] [ strings ] [ file ] ...<\/code><\/pre>\n<p style=\"margin: 0px 0px 1em; padding: 0px;\">There is a script available written in perl called wgrep which is freely available from the internet somewhere (ask google). This wgrep does quite a good job of this with the -wB:A syntax, where B is a number of lines Before the match, and A is the number of line After the match:<\/p>\n<pre style=\"margin: 3px 0px; padding: 10px; border: 1px solid #a1a1a1; overflow: auto; font-size: 1.2em;\"><code style=\"margin: 0px; padding: 0px;\">Usage: wgrep [-n] [-w[B][:A] | -W] [-d] [-p] [-s] [-m] regexp file(s)\r\n       -n = number lines\r\n       -s = mark matched lines with asterisks\r\n       -wB:A = display B lines before and A lines after\r\n               each matched line [both default to 3]\r\n       -W = suppress window; equivalent to -w0:0\r\n       -d = suppress separation lines between sections\r\n       -m = suppress file name header lines\r\n       -p = plain mode: equivalent to -W -d\r\n       -h = print this help message and exit\r\nNote: If present, -h prevails; otherwise, the rightmost\r\n      option wins in the case of contradictions.\r\n\r\n-bash-3.00$ .\/wgrep -w4:3 -n ^fish$ \/usr\/dict\/words\r\n********** \/usr\/dict\/words **********\r\n8756 firsthand\r\n8757 fiscal\r\n8758 Fischbein\r\n8759 Fischer\r\n8760 fish\r\n8761 fisherman\r\n8762 fishermen\r\n8763 fishery<\/code><\/pre>\n<p style=\"margin: 0px 0px 1em; padding: 0px;\">However, if you know where to look, and you had the foresight to include them on install, in Solaris 10, there is quite a nice collection of freeware tools under \/usr\/sfw and if you look hard enough (not that hard actually), you can find<span class=\"Apple-converted-space\">\u00a0<\/span><span class=\"caps\" style=\"margin: 0px; padding: 0px;\">GNU<\/span><span class=\"Apple-converted-space\">\u00a0<\/span>grep:<\/p>\n<pre style=\"margin: 3px 0px; padding: 10px; border: 1px solid #a1a1a1; overflow: auto; font-size: 1.2em;\"><code style=\"margin: 0px; padding: 0px;\">-bash-3.00$ \/usr\/sfw\/bin\/ggrep --help\r\nUsage: ggrep [OPTION]... PATTERN [FILE] ...\r\nSearch for PATTERN in each FILE or standard input.\r\nExample: ggrep -i 'hello world' menu.h main.c\r\n\r\nRegexp selection and interpretation:\r\n  -E, --extended-regexp     PATTERN is an extended regular expression\r\n  -F, --fixed-strings       PATTERN is a set of newline-separated strings\r\n  -G, --basic-regexp        PATTERN is a basic regular expression\r\n  -P, --perl-regexp         PATTERN is a Perl regular expression\r\n  -e, --regexp=PATTERN      use PATTERN as a regular expression\r\n  -f, --file=FILE           obtain PATTERN from FILE\r\n  -i, --ignore-case         ignore case distinctions\r\n  -w, --word-regexp         force PATTERN to match only whole words\r\n  -x, --line-regexp         force PATTERN to match only whole lines\r\n  -z, --null-data           a data line ends in 0 byte, not newline\r\n\r\nMiscellaneous:\r\n  -s, --no-messages         suppress error messages\r\n  -v, --invert-match        select non-matching lines\r\n  -V, --version             print version information and exit\r\n      --help                display this help and exit\r\n      --mmap                use memory-mapped input if possible\r\n\r\nOutput control:\r\n  -m, --max-count=NUM       stop after NUM matches\r\n  -b, --byte-offset         print the byte offset with output lines\r\n  -n, --line-number         print line number with output lines\r\n      --line-buffered       flush output on every line\r\n  -H, --with-filename       print the filename for each match\r\n  -h, --no-filename         suppress the prefixing filename on output\r\n      --label=LABEL         print LABEL as filename for standard input\r\n  -o, --only-matching       show only the part of a line matching PATTERN\r\n  -q, --quiet, --silent     suppress all normal output\r\n      --binary-files=TYPE   assume that binary files are TYPE\r\n                            TYPE is 'binary', 'text', or 'without-match'\r\n  -a, --text                equivalent to --binary-files=text\r\n  -I                        equivalent to --binary-files=without-match\r\n  -d, --directories=ACTION  how to handle directories\r\n                            ACTION is 'read', 'recurse', or 'skip'\r\n  -D, --devices=ACTION      how to handle devices, FIFOs and sockets\r\n                            ACTION is 'read' or 'skip'\r\n  -R, -r, --recursive       equivalent to --directories=recurse\r\n      --include=PATTERN     files that match PATTERN will be examined\r\n      --exclude=PATTERN     files that match PATTERN will be skipped.\r\n      --exclude-from=FILE   files that match PATTERN in FILE will be skipped.\r\n  -L, --files-without-match only print FILE names containing no match\r\n  -l, --files-with-matches  only print FILE names containing matches\r\n  -c, --count               only print a count of matching lines per FILE\r\n  -Z, --null                print 0 byte after FILE name\r\n\r\nContext control:\r\n  -B, --before-context=NUM  print NUM lines of leading context\r\n  -A, --after-context=NUM   print NUM lines of trailing context\r\n  -C, --context=NUM         print NUM lines of output context\r\n  -NUM                      same as --context=NUM\r\n      --color[=WHEN],\r\n      --colour[=WHEN]       use markers to distinguish the matching string\r\n                            WHEN may be `always', `never' or `auto'.\r\n  -U, --binary              do not strip CR characters at EOL (MSDOS)\r\n  -u, --unix-byte-offsets   report offsets as if CRs were not there (MSDOS)\r\n\r\n`egrep' means `grep -E'.  `fgrep' means `grep -F'.\r\nWith no FILE, or when FILE is -, read standard input.  If less than\r\ntwo FILEs given, assume -h.  Exit status is 0 if match, 1 if no match,\r\nand 2 if trouble.\r\n\r\nReport bugs to &lt;bug-gnu-utils@gnu.org&gt;.\r\n\r\n-bash-3.00$ \/usr\/sfw\/bin\/ggrep -B4 -A4 ^fish$ \/usr\/dict\/words\r\nfirsthand\r\nfiscal\r\nFischbein\r\nFischer\r\nfish\r\nfisherman\r\nfishermen\r\nfishery\r\nfishmonger<\/code><\/pre>\n<p style=\"margin: 0px 0px 1em; padding: 0px;\">Next time I promise to write about something less dull, but this nugget of useful information may really save you some time.<\/p>\n<p style=\"margin: 0px 0px 1em; padding: 0px;\">Paul.<\/p>\n<p><br style=\"margin: 0px; padding: 0px;\" \/><\/p>\n<p class=\"smallcopy entryfooter\" style=\"margin: 0px 0px 2px; padding: 0px; text-align: right; color: #215f94; clear: both; font-size: 10px;\"><span class=\"author\" style=\"margin: 0px; padding: 0px;\"><img decoding=\"async\" style=\"margin: 0px; padding: 0px; max-width: 100%;\" title=\"External: null\" src=\"http:\/\/blogs.warwick.ac.uk\/blogbuilder\/static\/images\/tiny_author.gif\" alt=\"\" \/><span class=\"Apple-converted-space\">\u00a0<\/span><\/span><span class=\"entryFooterSpacer\" style=\"margin: 0px; padding: 0px;\">:<span class=\"Apple-converted-space\">\u00a0<\/span><\/span><span class=\"datetime\" style=\"margin: 0px; padding: 0px;\"><a style=\"margin: 0px; padding: 0px; color: #215f94; font-weight: bold;\" title=\"Read all entries written on this date\" href=\"http:\/\/blogs.warwick.ac.uk\/peggleton\/daily\/121010\/\">12 Oct 2010<\/a><span class=\"Apple-converted-space\">\u00a0<\/span>10:44<span class=\"Apple-converted-space\">\u00a0<\/span><\/span><span id=\"entryrating_094d735829a72d04012b9fd37abd2202\" class=\"entryrating\" style=\"margin: 0px; padding: 0px;\"><\/span><span class=\"taglist\" style=\"margin: 0px; padding: 0px;\">|\u00a0<img decoding=\"async\" style=\"margin: 0px; padding: 0px; max-width: 100%;\" src=\"http:\/\/blogs.warwick.ac.uk\/blogbuilder\/static\/images\/admin\/tag-icon.gif\" alt=\"\" \/>\u00a0Tags:\u00a0<a style=\"margin: 0px; padding: 0px; color: #215f94; font-weight: bold;\" title=\"\" href=\"http:\/\/blogs.warwick.ac.uk\/peggleton\/tag\/egrep\/\" rel=\"tag\">Egrep<\/a>\u00a0<a style=\"margin: 0px; padding: 0px; color: #215f94; font-weight: bold;\" title=\"\" href=\"http:\/\/blogs.warwick.ac.uk\/peggleton\/tag\/fgrep\/\" rel=\"tag\">Fgrep<\/a>\u00a0<a style=\"margin: 0px; padding: 0px; color: #215f94; font-weight: bold;\" title=\"\" href=\"http:\/\/blogs.warwick.ac.uk\/peggleton\/tag\/ggrep\/\" rel=\"tag\">Ggrep<\/a>\u00a0<a style=\"margin: 0px; padding: 0px; color: #215f94; font-weight: bold;\" title=\"\" href=\"http:\/\/blogs.warwick.ac.uk\/peggleton\/tag\/grep\/\" rel=\"tag\">Grep<\/a>\u00a0<a style=\"margin: 0px; padding: 0px; color: #215f94; font-weight: bold;\" title=\"\" href=\"http:\/\/blogs.warwick.ac.uk\/peggleton\/tag\/solaris\/\" rel=\"tag\">Solaris<\/a>\u00a0<a style=\"margin: 0px; padding: 0px; color: #215f94; font-weight: bold;\" title=\"\" href=\"http:\/\/blogs.warwick.ac.uk\/peggleton\/tag\/wgrep\/\" rel=\"tag\">Wgrep<\/a><span class=\"Apple-converted-space\">\u00a0<\/span><\/span><span id=\"commentpopup_094d735829a72d04012b9fd37abd2202\" class=\"commentpopup\" style=\"margin: 0px; padding: 0px;\">|\u00a0<img decoding=\"async\" style=\"margin: 0px; padding: 0px; max-width: 100%;\" src=\"http:\/\/blogs.warwick.ac.uk\/blogbuilder\/static\/images\/tiny_comment.gif\" alt=\"\" \/><span class=\"Apple-converted-space\">\u00a0<\/span><a style=\"margin: 0px; padding: 0px; color: #215f94; font-weight: bold;\" title=\"Read or add comments\" href=\"http:\/\/blogs.warwick.ac.uk\/peggleton\/entry\/grep_on_solaris\/\">Comments\u00a0(0)<\/a><span class=\"Apple-converted-space\">\u00a0<\/span><\/span><span class=\"reportlink\" style=\"margin: 0px; padding: 0px;\">|\u00a0<img decoding=\"async\" style=\"margin: 0px; padding: 0px; max-width: 100%;\" src=\"http:\/\/blogs.warwick.ac.uk\/blogbuilder\/static\/images\/tiny_pling.gif\" alt=\"\" \/>\u00a0<a style=\"margin: 0px; padding: 0px; color: #215f94; font-weight: bold;\" title=\"Tell the University if you think there may be a problem with this entry\" href=\"http:\/\/blogs.warwick.ac.uk\/blogbuilder\/admin\/reportAbuse.spr?blog=094d735829a72d04012afd424cdb3741&amp;entryId=094d735829a72d04012b9fd37abd2202\">Report\u00a0a\u00a0problem<\/a><\/span><\/p>\n<\/div>\n<div class=\"ajaxEntryTail\" style=\"margin: 0px; padding: 0px;\"><\/div>\n<\/div>\n<\/div>\n<div class=\"day\" style=\"font: 12px\/16.79px Verdana, Tahoma, Arial, sans-serif; margin: 0px; padding: 0px; color: #4c5863; text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; white-space: normal; background-color: #ffffff; -webkit-text-stroke-width: 0px;\">\n<h2 class=\"dateheader\" style=\"margin: 0px 0px 7px; padding: 0px; color: #215f94; line-height: 1.3em; font-size: 18px;\">September 20, 2010<\/h2>\n<p><a style=\"margin: 0px; padding: 0px;\" name=\"entry2\"><\/a><\/p>\n<div class=\"entry\" style=\"margin: 0px; padding: 0px; border-bottom-color: #cdcdcd; border-bottom-width: 1px; border-bottom-style: solid;\">\n<div class=\"entryBody\" style=\"margin: 0px; padding: 0px;\">\n<h3 class=\"entryHeader\" style=\"margin: 0.2em 0px 10px; padding: 0px; color: #39434d; line-height: 1.3em; font-size: 14px; font-weight: bold;\"><a style=\"margin: 0px; padding: 0px; color: #39434d;\" href=\"http:\/\/blogs.warwick.ac.uk\/peggleton\/entry\/ssl_certifcates_csr\/\" rel=\"bookmark\"><span class=\"caps\" style=\"margin: 0px; padding: 0px;\">SSL<\/span><span class=\"Apple-converted-space\">\u00a0<\/span>certifcates,<span class=\"Apple-converted-space\">\u00a0<\/span><span class=\"caps\" style=\"margin: 0px; padding: 0px;\">CSR<\/span><span class=\"Apple-converted-space\">\u00a0<\/span>generation and the openssl batch command<\/a><\/h3>\n<p style=\"margin: 0px 0px 1em; padding: 0px;\">This entry covers a recent discovery I made that has helped part automate our process of<span class=\"Apple-converted-space\">\u00a0<\/span><span class=\"caps\" style=\"margin: 0px; padding: 0px;\">SSL CSR<\/span><span class=\"Apple-converted-space\">\u00a0<\/span>generation. I\u2019m sure many of you, if you support ssl based websites are familiar with the openssl process of generating a<span class=\"Apple-converted-space\">\u00a0<\/span><span class=\"caps\" style=\"margin: 0px; padding: 0px;\">CSR<\/span><span class=\"Apple-converted-space\">\u00a0<\/span>in order to submit to Verisign, Comodo or other CA and receive a shiny new certificate for installation under apache or similar.<\/p>\n<p style=\"margin: 0px 0px 1em; padding: 0px;\">This has been for me up until recently, a manual process, looking something like the following under openssl<\/p>\n<p style=\"margin: 0px 0px 1em; padding: 0px;\">1. Generate a key;<\/p>\n<pre style=\"margin: 3px 0px; padding: 10px; border: 1px solid #a1a1a1; overflow: auto; font-size: 1.2em;\"><code style=\"margin: 0px; padding: 0px;\"># \/usr\/sfw\/bin\/openssl\r\nOpenSSL&gt; genrsa -out my.website.com.key 2048\r\nGenerating RSA private key, 2048 bit long modulus\r\n...................................+++\r\n..........+++\r\ne is 65537 (0x10001)<\/code><\/pre>\n<p style=\"margin: 0px 0px 1em; padding: 0px;\">2. Generate the<span class=\"Apple-converted-space\">\u00a0<\/span><span class=\"caps\" style=\"margin: 0px; padding: 0px;\">CSR<\/span>:<\/p>\n<pre style=\"margin: 3px 0px; padding: 10px; border: 1px solid #a1a1a1; overflow: auto; font-size: 1.2em;\"><code style=\"margin: 0px; padding: 0px;\">OpenSSL&gt; req -new -key my.website.com.key -out my.website.com.csr\r\n  You are about to be asked to enter information that will be incorporated\r\n  into your certificate request.\r\n  What you are about to enter is what is called a Distinguished Name or a DN.\r\n  There are quite a few fields but you can leave some blank\r\n  For some fields there will be a default value,\r\n  If you enter '.', the field will be left blank.\r\n  -----\r\n  Country Name (2 letter code) [US]:GB\r\n  State or Province Name (full name) [Some-State]: Gloucestershire\r\n  Locality Name (eg, city) []:Chipping Sodbury\r\n  Organization Name (eg, company) [Unconfigured OpenSSL Installation]:The Donkey Sanctuary\r\n  Organizational Unit Name (eg, section) []:WebSupport\r\n  Common Name (eg, YOUR name) []:my.website.com\r\n  Email Address []:\r\n\u00a0  \r\n  Please enter the following 'extra' attributes\r\n  to be sent with your certificate request\r\n  A challenge password []:\r\n  An optional company name []:\r\n  OpenSSL&gt; quit<\/code><\/pre>\n<p style=\"margin: 0px 0px 1em; padding: 0px;\">3. Send the file my.website.com.csr to your<span class=\"Apple-converted-space\">\u00a0<\/span><span class=\"caps\" style=\"margin: 0px; padding: 0px;\">SSL<\/span><span class=\"Apple-converted-space\">\u00a0<\/span>Certificate Authority and wait for your new certificate.<\/p>\n<p style=\"margin: 0px 0px 1em; padding: 0px;\">Given that most of us will support many sites, and the data to be input for each<span class=\"Apple-converted-space\">\u00a0<\/span><span class=\"caps\" style=\"margin: 0px; padding: 0px;\">CSR<\/span><span class=\"Apple-converted-space\">\u00a0<\/span>will change only very slightly (often, just the website name) I knew there had to be a better way, and there is. There is a -batch parameter that when combined with the -config<span class=\"Apple-converted-space\">\u00a0<\/span>option allows you to provide a config file as input for the command and avoid having to type the parameters each time. The command will look something like:<\/p>\n<pre style=\"margin: 3px 0px; padding: 10px; border: 1px solid #a1a1a1; overflow: auto; font-size: 1.2em;\"><code style=\"margin: 0px; padding: 0px;\">\/usr\/sfw\/bin\/openssl req -batch -new -key my.website.com.key -out my.website.com.csr -config config-file.txt\r\n\u00a0<\/code><\/pre>\n<p style=\"margin: 0px 0px 1em; padding: 0px;\">The config file format isn\u2019t too hard to get right either, here is an example:<\/p>\n<pre style=\"margin: 3px 0px; padding: 10px; border: 1px solid #a1a1a1; overflow: auto; font-size: 1.2em;\"><code style=\"margin: 0px; padding: 0px;\"> RANDFILE               = $ENV::HOME\/.rnd\r\n\r\n [ req ]\r\n default_bits           = 1024\r\n default_keyfile        = keyfile.pem\r\n distinguished_name     = req_distinguished_name\r\n attributes             = req_attributes\r\n prompt                 = no\r\n output_password        = mypass\r\n\r\n [ req_distinguished_name ]\r\n C                      = GB\r\n ST                     = Test State or Province\r\n L                      = Test Locality\r\n O                      = Organization Name\r\n OU                     = Organizational Unit Name\r\n CN                     = Common Name\r\n emailAddress           = test@email.address\r\n\r\n [ req_attributes ]\r\n challengePassword              = A challenge password<\/code><\/pre>\n<p style=\"margin: 0px 0px 1em; padding: 0px;\">I hope you find this useful.<\/p>\n<p style=\"margin: 0px 0px 1em; padding: 0px;\">Paul.<\/p>\n<p><br style=\"margin: 0px; padding: 0px;\" \/><\/p>\n<p class=\"smallcopy entryfooter\" style=\"margin: 0px 0px 2px; padding: 0px; text-align: right; color: #215f94; clear: both; font-size: 10px;\"><span class=\"author\" style=\"margin: 0px; padding: 0px;\"><img decoding=\"async\" style=\"margin: 0px; padding: 0px; max-width: 100%;\" title=\"External: null\" src=\"http:\/\/blogs.warwick.ac.uk\/blogbuilder\/static\/images\/tiny_author.gif\" alt=\"\" \/><span class=\"Apple-converted-space\">\u00a0<\/span><\/span><span class=\"entryFooterSpacer\" style=\"margin: 0px; padding: 0px;\">:<span class=\"Apple-converted-space\">\u00a0<\/span><\/span><span class=\"datetime\" style=\"margin: 0px; padding: 0px;\"><a style=\"margin: 0px; padding: 0px; color: #215f94; font-weight: bold;\" title=\"Read all entries written on this date\" href=\"http:\/\/blogs.warwick.ac.uk\/peggleton\/daily\/200910\/\">20 Sep 2010<\/a><span class=\"Apple-converted-space\">\u00a0<\/span>20:35<span class=\"Apple-converted-space\">\u00a0<\/span><\/span><span id=\"entryrating_094d735829a72d04012b30a49a2444eb\" class=\"entryrating\" style=\"margin: 0px; padding: 0px;\"><\/span><span class=\"taglist\" style=\"margin: 0px; padding: 0px;\">|\u00a0<img decoding=\"async\" style=\"margin: 0px; padding: 0px; max-width: 100%;\" src=\"http:\/\/blogs.warwick.ac.uk\/blogbuilder\/static\/images\/admin\/tag-icon.gif\" alt=\"\" \/>\u00a0Tags:\u00a0<a style=\"margin: 0px; padding: 0px; color: #215f94; font-weight: bold;\" title=\"\" href=\"http:\/\/blogs.warwick.ac.uk\/peggleton\/tag\/csr\/\" rel=\"tag\">Csr<\/a>\u00a0<a style=\"margin: 0px; padding: 0px; color: #215f94; font-weight: bold;\" title=\"\" href=\"http:\/\/blogs.warwick.ac.uk\/peggleton\/tag\/openssl\/\" rel=\"tag\">Openssl<\/a>\u00a0<a style=\"margin: 0px; padding: 0px; color: #215f94; font-weight: bold;\" title=\"\" href=\"http:\/\/blogs.warwick.ac.uk\/peggleton\/tag\/ssl\/\" rel=\"tag\">Ssl<\/a><span class=\"Apple-converted-space\">\u00a0<\/span><\/span><span id=\"commentpopup_094d735829a72d04012b30a49a2444eb\" class=\"commentpopup\" style=\"margin: 0px; padding: 0px;\">|\u00a0<img decoding=\"async\" style=\"margin: 0px; padding: 0px; max-width: 100%;\" src=\"http:\/\/blogs.warwick.ac.uk\/blogbuilder\/static\/images\/tiny_comment.gif\" alt=\"\" \/><span class=\"Apple-converted-space\">\u00a0<\/span><a style=\"margin: 0px; padding: 0px; color: #215f94; font-weight: bold;\" title=\"Read or add comments\" href=\"http:\/\/blogs.warwick.ac.uk\/peggleton\/entry\/ssl_certifcates_csr\/\">Comments\u00a0(0)<\/a><span class=\"Apple-converted-space\">\u00a0<\/span><\/span><span class=\"reportlink\" style=\"margin: 0px; padding: 0px;\">|\u00a0<img decoding=\"async\" style=\"margin: 0px; padding: 0px; max-width: 100%;\" src=\"http:\/\/blogs.warwick.ac.uk\/blogbuilder\/static\/images\/tiny_pling.gif\" alt=\"\" \/>\u00a0<a style=\"margin: 0px; padding: 0px; color: #215f94; font-weight: bold;\" title=\"Tell the University if you think there may be a problem with this entry\" href=\"http:\/\/blogs.warwick.ac.uk\/blogbuilder\/admin\/reportAbuse.spr?blog=094d735829a72d04012afd424cdb3741&amp;entryId=094d735829a72d04012b30a49a2444eb\">Report\u00a0a\u00a0problem<\/a><\/span><\/p>\n<\/div>\n<div class=\"ajaxEntryTail\" style=\"margin: 0px; padding: 0px;\"><\/div>\n<\/div>\n<\/div>\n<div class=\"day\" style=\"font: 12px\/16.79px Verdana, Tahoma, Arial, sans-serif; margin: 0px; padding: 0px; color: #4c5863; text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; white-space: normal; background-color: #ffffff; -webkit-text-stroke-width: 0px;\">\n<h2 class=\"dateheader\" style=\"margin: 0px 0px 7px; padding: 0px; color: #215f94; line-height: 1.3em; font-size: 18px;\">September 17, 2010<\/h2>\n<p><a style=\"margin: 0px; padding: 0px;\" name=\"entry3\"><\/a><\/p>\n<div class=\"entry\" style=\"margin: 0px; padding: 0px; border-bottom-color: #cdcdcd; border-bottom-width: 1px; border-bottom-style: solid;\">\n<div class=\"entryBody\" style=\"margin: 0px; padding: 0px;\">\n<h3 class=\"entryHeader\" style=\"margin: 0.2em 0px 10px; padding: 0px; color: #39434d; line-height: 1.3em; font-size: 14px; font-weight: bold;\"><a style=\"margin: 0px; padding: 0px; color: #39434d;\" href=\"http:\/\/blogs.warwick.ac.uk\/peggleton\/entry\/automated_zfs_snapshot\/\" rel=\"bookmark\">automated zfs snapshot of zone test<\/a><\/h3>\n<p class=\"answer\" style=\"margin: 0px 0px 1em; padding: 3px; color: black; overflow: hidden; font-weight: bold; -ms-word-wrap: break-word; background-color: #e5e5e5;\">Writing about web page<span class=\"Apple-converted-space\">\u00a0<\/span><a style=\"margin: 0px; padding: 0px; color: black; font-size: 10px;\" title=\"Related external link: http:\/\/wikis.sun.com\/display\/OpenSolarisInfo\/How+to+Manage+the+Automatic+ZFS+Snapshot+Service\" href=\"http:\/\/wikis.sun.com\/display\/OpenSolarisInfo\/How+to+Manage+the+Automatic+ZFS+Snapshot+Service\">http:\/\/wikis.sun.com\/display\/OpenSolarisInfo\/How+to+Manage+the+Automatic+ZFS+Snapshot+Service<\/a><\/p>\n<p style=\"margin: 0px 0px 1em; padding: 0px;\">While I was working on a perl script for automating<span class=\"Apple-converted-space\">\u00a0<\/span><span class=\"caps\" style=\"margin: 0px; padding: 0px;\">ZFS<\/span><span class=\"Apple-converted-space\">\u00a0<\/span>snapshots I happened to discover the automatic<span class=\"Apple-converted-space\">\u00a0<\/span><span class=\"caps\" style=\"margin: 0px; padding: 0px;\">ZFS<\/span><span class=\"Apple-converted-space\">\u00a0<\/span>snapshot service for opensolaris by Tim Foster.<\/p>\n<p style=\"margin: 0px 0px 1em; padding: 0px;\"><a style=\"margin: 0px; padding: 0px; color: #000000;\" href=\"http:\/\/wikis.sun.com\/display\/OpenSolarisInfo\/How\">http:\/\/wikis.sun.com\/display\/OpenSolarisInfo\/How<\/a>+to+Manage+the+Automatic+ZFS+Snapshot+Service<\/p>\n<p style=\"margin: 0px 0px 1em; padding: 0px;\">Which is, of course, exactly what I need \u2013 the problem is that I need it to run on Solaris 10, for which it is not currently available. However, this thread on Tim\u2019s blog (especially the comments) suggest that it is possible to get the service working, without the time slider element on Solaris 10:<\/p>\n<p style=\"margin: 0px 0px 1em; padding: 0px;\"><a style=\"margin: 0px; padding: 0px; color: #000000;\" href=\"http:\/\/blogs.sun.com\/timf\/entry\/zfs_automatic_snapshots_0_12\">http:\/\/blogs.sun.com\/timf\/entry\/zfs_automatic_snapshots_0_12<\/a><\/p>\n<p style=\"margin: 0px 0px 1em; padding: 0px;\">So, I attempted yesterday to get this installed, compiled into an<span class=\"Apple-converted-space\">\u00a0<\/span><span class=\"caps\" style=\"margin: 0px; padding: 0px;\">SVR4<\/span><span class=\"Apple-converted-space\">\u00a0<\/span>package with pkgmk and pktrans and install it on Solaris 10. It was remarkably straightforward and early testing shows it to work very well.<\/p>\n<p style=\"margin: 0px 0px 1em; padding: 0px;\">First, get the \u2018bits\u2019 and make the pkg as described on Tim\u2019s blog, using hg to clone and make to create the pkg tree.<\/p>\n<pre style=\"margin: 3px 0px; padding: 10px; border: 1px solid #a1a1a1; overflow: auto; font-size: 1.2em;\"><code style=\"margin: 0px; padding: 0px;\">$ hg clone ssh:\/\/anon@hg.opensolaris.org\/hg\/jds\/zfs-snapshot<\/code><\/pre>\n<p style=\"margin: 0px 0px 1em; padding: 0px;\">Before actually creating the package, there are 3 changes as detailed by Eli Kleinamm, again on the blog comment :<span class=\"Apple-converted-space\">\u00a0<\/span><a style=\"margin: 0px; padding: 0px; color: #000000;\" href=\"http:\/\/blogs.sun.com\/timf\/entry\/zfs_automatic_snapshots_0_12\">http:\/\/blogs.sun.com\/timf\/entry\/zfs_automatic_snapshots_0_12<\/a><\/p>\n<p style=\"margin: 0px 0px 1em; padding: 0px;\">These changes are made in<span class=\"Apple-converted-space\">\u00a0<\/span><br style=\"margin: 0px; padding: 0px;\" \/>~\/auto-snapshot\/zfs-snapshot\/src\/lib\/svc\/method<\/p>\n<pre style=\"margin: 3px 0px; padding: 10px; border: 1px solid #a1a1a1; overflow: auto; font-size: 1.2em;\"><code style=\"margin: 0px; padding: 0px;\"># vi zfs-auto-snapshot<\/code><\/pre>\n<p style=\"margin: 0px 0px 1em; padding: 0px;\">Change:<\/p>\n<p style=\"margin: 0px 0px 1em; padding: 0px;\">1) The shell to run in \/usr\/dt\/bin\/dtksh?<br style=\"margin: 0px; padding: 0px;\" \/>2) Remove on line 511 and 517 the -o com.sun:auto-snapshot-desc=\u201d$EVENT\u201d,<\/p>\n<p style=\"margin: 0px 0px 1em; padding: 0px;\">and<\/p>\n<p style=\"margin: 0px 0px 1em; padding: 0px;\">3)Remove the space\/tab on line 970 between $SWAPVOLS and<span class=\"Apple-converted-space\">\u00a0<\/span><br style=\"margin: 0px; padding: 0px;\" \/>$(echo?<span class=\"Apple-converted-space\">\u00a0<\/span><span class=\"caps\" style=\"margin: 0px; padding: 0px;\">SWAPVOLS<\/span>=\u201d$SWAPVOLS$(echo $swap | sed -e \u2019s#\/dev\/zvol\/dsk\/##\u2019)\u201d<\/p>\n<p style=\"margin: 0px 0px 1em; padding: 0px;\">Once done, run make \u2013 it should create a pkg format file tree for you in the current working directory \u2013 read the Makefile, its not long.<\/p>\n<p style=\"margin: 0px 0px 1em; padding: 0px;\">Next, create the pkg datastream for portability<\/p>\n<pre style=\"margin: 3px 0px; padding: 10px; border: 1px solid #a1a1a1; overflow: auto; font-size: 1.2em;\"><code style=\"margin: 0px; padding: 0px;\">$ pkgtrans -s . \/var\/spool\/pkg\/SUNWzfs-auto-snapshot.pkg SUNWzfs-auto-snapshot\r\nTransferring &lt;SUNWzfs-auto-snapshot&gt; package instance<\/code><\/pre>\n<p style=\"margin: 0px 0px 1em; padding: 0px;\">This will now simply pkgadd to a Solaris 10 system. I can\u2019t help but think this is particularly awesome, but as a colleague pointed out \u2013 this now really has to go through some very extensive testing before any rollout. I still think its a lot better than my dangerous perl scripting attempts.<\/p>\n<p style=\"margin: 0px 0px 1em; padding: 0px;\">This will now (if I can get agreement internally) be added as a package to the standard build for all Solaris 10 hosts using<span class=\"Apple-converted-space\">\u00a0<\/span><span class=\"caps\" style=\"margin: 0px; padding: 0px;\">ZFS<\/span><span class=\"Apple-converted-space\">\u00a0<\/span>within our control.<\/p>\n<p style=\"margin: 0px 0px 1em; padding: 0px;\">The service provides 5<span class=\"Apple-converted-space\">\u00a0<\/span><span class=\"caps\" style=\"margin: 0px; padding: 0px;\">SMF<\/span><span class=\"Apple-converted-space\">\u00a0<\/span>services for managing automatic snapshots. These are:<\/p>\n<p style=\"margin: 0px 0px 1em; padding: 0px;\">svc:\/system\/filesystem\/zfs\/auto-snapshot:monthly<br style=\"margin: 0px; padding: 0px;\" \/>svc:\/system\/filesystem\/zfs\/auto-snapshot:weekly<br style=\"margin: 0px; padding: 0px;\" \/>svc:\/system\/filesystem\/zfs\/auto-snapshot:daily<br style=\"margin: 0px; padding: 0px;\" \/>svc:\/system\/filesystem\/zfs\/auto-snapshot:hourly<br style=\"margin: 0px; padding: 0px;\" \/>svc:\/system\/filesystem\/zfs\/auto-snapshot:frequent<\/p>\n<p style=\"margin: 0px 0px 1em; padding: 0px;\">Enable these to have snapshots taken at a regularity as suggested by the name. Each has properties to tune, the most notable being how many snapshots to retain;<\/p>\n<pre style=\"margin: 3px 0px; padding: 10px; border: 1px solid #a1a1a1; overflow: auto; font-size: 1.2em;\"><code style=\"margin: 0px; padding: 0px;\">-bash-3.00$ svccfg -s auto-snapshot:daily listprop zfs\/keep\r\nzfs\/keep  astring  31\r\n\r\n-bash-3.00$ svccfg -s auto-snapshot:frequent listprop zfs\/keep\r\nzfs\/keep  astring  4\r\n\r\n-bash-3.00$ svccfg -s auto-snapshot:frequent listprop zfs\/period\r\nzfs\/period  astring  15<\/code><\/pre>\n<p style=\"margin: 0px 0px 1em; padding: 0px;\">The defaults for daily and frequent being 1 months worth of dailies and 4 frequents. Frequent is defined initially as once every 15 mins as shown by the zfs\/period property.<\/p>\n<p style=\"margin: 0px 0px 1em; padding: 0px;\">Whether a<span class=\"Apple-converted-space\">\u00a0<\/span><span class=\"caps\" style=\"margin: 0px; padding: 0px;\">ZFS<\/span><span class=\"Apple-converted-space\">\u00a0<\/span>dataset is snapshot\u2019ed or not is controlled by a user level<span class=\"Apple-converted-space\">\u00a0<\/span><span class=\"caps\" style=\"margin: 0px; padding: 0px;\">ZFS<\/span><span class=\"Apple-converted-space\">\u00a0<\/span>property com.sun:auto-snapshot which can be true or false for a dataset and com.sun:auto-snapshot:frequent, com.sun:auto-snapshot:daily, etc, etc properties for each periodicity as required. These are inherited, so it is probably a good idea to set com.sun:auto-snapshot to false at the root of a pool and then change the required sub-datasets to true as needed. Perhaps an example would help;<\/p>\n<pre style=\"margin: 3px 0px; padding: 10px; border: 1px solid #a1a1a1; overflow: auto; font-size: 1.2em;\"><code style=\"margin: 0px; padding: 0px;\">-bash-3.00$ pfexec zfs set com.sun:auto-snapshot=true datapool\/zfstestz1_ds\r\n-bash-3.00$\r\n-bash-3.00$ pfexec zfs set com.sun:auto-snapshot=false rpool              \r\n-bash-3.00$ pfexec zfs set com.sun:auto-snapshot=true rpool\/export\r\n-bash-3.00$ pfexec zfs set com.sun:auto-snapshot:frequent=true rpool\/export\r\n-bash-3.00$ pfexec zfs set com.sun:auto-snapshot:frequent=true datapool\/zfstestz1_ds\r\n-bash-3.00$\r\n\r\n&lt;getting bored with pfexec for each cmd&gt;\r\n-bash-3.00$ pfexec bash\r\nbash-3.00# zfs set com.sun:auto-snapshot=false rpool\/dump\r\nbash-3.00# zfs set com.sun:auto-snapshot=false rpool\/swap\r\n\r\nbash-3.00# cat \/etc\/release\r\n                       Solaris 10 10\/09 s10x_u8wos_08a X86\r\n           Copyright 2009 Sun Microsystems, Inc.  All Rights Reserved.\r\n                        Use is subject to license terms.\r\n                           Assembled 16 September 2009\r\nbash-3.00#\r\nbash-3.00# svcs -a |grep snapshot\r\ndisabled       17:59:54 svc:\/system\/filesystem\/zfs\/auto-snapshot:monthly\r\ndisabled       17:59:54 svc:\/system\/filesystem\/zfs\/auto-snapshot:weekly\r\ndisabled       17:59:54 svc:\/system\/filesystem\/zfs\/auto-snapshot:daily\r\ndisabled       17:59:54 svc:\/system\/filesystem\/zfs\/auto-snapshot:hourly\r\nonline         18:00:44 svc:\/system\/filesystem\/zfs\/auto-snapshot:event\r\nonline         18:09:18 svc:\/system\/filesystem\/zfs\/auto-snapshot:frequent\r\nbash-3.00#\r\n\r\nbash-3.00#\r\nbash-3.00# zfs list -t snapshot | grep frequent\r\ndatapool@zfs-auto-snap_frequent-2010-09-23-1809                   0      -  28.0K  -\r\ndatapool\/zfstestz1_ds@zfs-auto-snap_frequent-2010-09-23-1809      0      -  28.0K  -\r\nrpool\/export@zfs-auto-snap_frequent-2010-09-23-1809               0      -    23K  -\r\nrpool\/export\/home@zfs-auto-snap_frequent-2010-09-23-1809          0      -   954K  -\r\n\r\nbash-3.00#\r\nbash-3.00# pkginfo SUNWzfs-auto-snapshot\r\napplication SUNWzfs-auto-snapshot ZFS Automatic Snapshot Service\r\nbash-3.00#\r\n\r\nbash-3.00# date\r\nThursday, 23 September 2010 18:15:48 BST\r\n\r\nbash-3.00# zfs list -t snapshot | grep frequent\r\ndatapool@zfs-auto-snap_frequent-2010-09-23-1809                   0      -  28.0K  -\r\ndatapool@zfs-auto-snap_frequent-2010-09-23-1815                   0      -  28.0K  -\r\ndatapool\/zfstestz1_ds@zfs-auto-snap_frequent-2010-09-23-1809      0      -  28.0K  -\r\ndatapool\/zfstestz1_ds@zfs-auto-snap_frequent-2010-09-23-1815      0      -  28.0K  -\r\nrpool\/export@zfs-auto-snap_frequent-2010-09-23-1809               0      -    23K  -\r\nrpool\/export@zfs-auto-snap_frequent-2010-09-23-1815               0      -    23K  -\r\nrpool\/export\/home@zfs-auto-snap_frequent-2010-09-23-1809          0      -   954K  -\r\nrpool\/export\/home@zfs-auto-snap_frequent-2010-09-23-1815          0      -   954K  -<\/code><\/pre>\n<p style=\"margin: 0px 0px 1em; padding: 0px;\">I think this should prove to be very useful for us, I would be very interested, as usual in hearing your comments.<\/p>\n<p style=\"margin: 0px 0px 1em; padding: 0px;\">Paul.<\/p>\n<p><br style=\"margin: 0px; padding: 0px;\" \/><\/p>\n<p class=\"smallcopy entryfooter\" style=\"margin: 0px 0px 2px; padding: 0px; text-align: right; color: #215f94; clear: both; font-size: 10px;\"><span class=\"author\" style=\"margin: 0px; padding: 0px;\"><img decoding=\"async\" style=\"margin: 0px; padding: 0px; max-width: 100%;\" title=\"External: null\" src=\"http:\/\/blogs.warwick.ac.uk\/blogbuilder\/static\/images\/tiny_author.gif\" alt=\"\" \/><span class=\"Apple-converted-space\">\u00a0<\/span><\/span><span class=\"entryFooterSpacer\" style=\"margin: 0px; padding: 0px;\">:<span class=\"Apple-converted-space\">\u00a0<\/span><\/span><span class=\"datetime\" style=\"margin: 0px; padding: 0px;\"><a style=\"margin: 0px; padding: 0px; color: #215f94; font-weight: bold;\" title=\"Read all entries written on this date\" href=\"http:\/\/blogs.warwick.ac.uk\/peggleton\/daily\/170910\/\">17 Sep 2010<\/a><span class=\"Apple-converted-space\">\u00a0<\/span>15:36<span class=\"Apple-converted-space\">\u00a0<\/span><\/span><span id=\"entryrating_094d735829a72d04012b201fec853eb4\" class=\"entryrating\" style=\"margin: 0px; padding: 0px;\"><\/span><span class=\"taglist\" style=\"margin: 0px; padding: 0px;\">|\u00a0<img decoding=\"async\" style=\"margin: 0px; padding: 0px; max-width: 100%;\" src=\"http:\/\/blogs.warwick.ac.uk\/blogbuilder\/static\/images\/admin\/tag-icon.gif\" alt=\"\" \/>\u00a0Tags:\u00a0<a style=\"margin: 0px; padding: 0px; color: #215f94; font-weight: bold;\" title=\"\" href=\"http:\/\/blogs.warwick.ac.uk\/peggleton\/tag\/auto-snapshot\/\" rel=\"tag\">Auto-Snapshot<\/a>\u00a0<a style=\"margin: 0px; padding: 0px; color: #215f94; font-weight: bold;\" title=\"\" href=\"http:\/\/blogs.warwick.ac.uk\/peggleton\/tag\/snapshot\/\" rel=\"tag\">Snapshot<\/a>\u00a0<a style=\"margin: 0px; padding: 0px; color: #215f94; font-weight: bold;\" title=\"\" href=\"http:\/\/blogs.warwick.ac.uk\/peggleton\/tag\/zfs\/\" rel=\"tag\">Zfs<\/a>\u00a0<a style=\"margin: 0px; padding: 0px; color: #215f94; font-weight: bold;\" title=\"\" href=\"http:\/\/blogs.warwick.ac.uk\/peggleton\/tag\/zone\/\" rel=\"tag\">Zone<\/a><span class=\"Apple-converted-space\">\u00a0<\/span><\/span><span id=\"commentpopup_094d735829a72d04012b201fec853eb4\" class=\"commentpopup\" style=\"margin: 0px; padding: 0px;\">|\u00a0<img decoding=\"async\" style=\"margin: 0px; padding: 0px; max-width: 100%;\" src=\"http:\/\/blogs.warwick.ac.uk\/blogbuilder\/static\/images\/tiny_comment.gif\" alt=\"\" \/><span class=\"Apple-converted-space\">\u00a0<\/span><a style=\"margin: 0px; padding: 0px; color: #215f94; font-weight: bold;\" title=\"Read or add comments\" href=\"http:\/\/blogs.warwick.ac.uk\/peggleton\/entry\/automated_zfs_snapshot\/\">Comments\u00a0(0)<\/a><span class=\"Apple-converted-space\">\u00a0<\/span><\/span><span class=\"reportlink\" style=\"margin: 0px; padding: 0px;\">|\u00a0<img decoding=\"async\" style=\"margin: 0px; padding: 0px; max-width: 100%;\" src=\"http:\/\/blogs.warwick.ac.uk\/blogbuilder\/static\/images\/tiny_pling.gif\" alt=\"\" \/>\u00a0<a style=\"margin: 0px; padding: 0px; color: #215f94; font-weight: bold;\" title=\"Tell the University if you think there may be a problem with this entry\" href=\"http:\/\/blogs.warwick.ac.uk\/blogbuilder\/admin\/reportAbuse.spr?blog=094d735829a72d04012afd424cdb3741&amp;entryId=094d735829a72d04012b201fec853eb4\">Report\u00a0a\u00a0problem<\/a><\/span><\/p>\n<\/div>\n<div class=\"ajaxEntryTail\" style=\"margin: 0px; padding: 0px;\"><\/div>\n<\/div>\n<\/div>\n<div class=\"day\" style=\"font: 12px\/16.79px Verdana, Tahoma, Arial, sans-serif; margin: 0px; padding: 0px; color: #4c5863; text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; white-space: normal; background-color: #ffffff; -webkit-text-stroke-width: 0px;\">\n<h2 class=\"dateheader\" style=\"margin: 0px 0px 7px; padding: 0px; color: #215f94; line-height: 1.3em; font-size: 18px;\">September 15, 2010<\/h2>\n<p><a style=\"margin: 0px; padding: 0px;\" name=\"entry4\"><\/a><\/p>\n<div class=\"entry\" style=\"margin: 0px; padding: 0px; border-bottom-color: #cdcdcd; border-bottom-width: 1px; border-bottom-style: solid;\">\n<div class=\"entryBody\" style=\"margin: 0px; padding: 0px;\">\n<h3 class=\"entryHeader\" style=\"margin: 0.2em 0px 10px; padding: 0px; color: #39434d; line-height: 1.3em; font-size: 14px; font-weight: bold;\"><a style=\"margin: 0px; padding: 0px; color: #39434d;\" href=\"http:\/\/blogs.warwick.ac.uk\/peggleton\/entry\/untitled_entry\/\" rel=\"bookmark\">Analysis of zone capacity on an x4170<\/a><\/h3>\n<p style=\"margin: 0px 0px 1em; padding: 0px;\">This blog entry, wasn\u2019t intended to be published. It was simple a place for me to collect my thoughts on the state of one of our servers and its remaining capacity for extra zones.<\/p>\n<p style=\"margin: 0px 0px 1em; padding: 0px;\">The server is an<span class=\"Apple-converted-space\">\u00a0<\/span><span class=\"caps\" style=\"margin: 0px; padding: 0px;\">X4170<\/span><span class=\"Apple-converted-space\">\u00a0<\/span>with 2 Quad-Core<span class=\"Apple-converted-space\">\u00a0<\/span><span class=\"caps\" style=\"margin: 0px; padding: 0px;\">AMD<\/span><span class=\"Apple-converted-space\">\u00a0<\/span>Opterons and 64gb of ram. It is currently running 11 zones, each running an instance of apache and an instance of tomcat. The load currently looks reasonably light, certainly from a<span class=\"Apple-converted-space\">\u00a0<\/span><span class=\"caps\" style=\"margin: 0px; padding: 0px;\">CPU<\/span><span class=\"Apple-converted-space\">\u00a0<\/span>viewpoint:<\/p>\n<pre style=\"margin: 3px 0px; padding: 10px; border: 1px solid #a1a1a1; overflow: auto; font-size: 1.2em;\"><code style=\"margin: 0px; padding: 0px;\">ZONEID    NPROC  SWAP   RSS MEMORY      TIME  CPU ZONE\r\n     0       61 1314M 1308M   2.0% 804:24:29 2.9% global\r\n    13       58 1381M  936M   1.4%  35:16:01 0.5% zoneA\r\n    16       45 1238M  496M   0.8%  11:20:16 0.2% zoneB\r\n    29       55 1378M  576M   0.9%   4:30:13 0.1% zoneC\r\n     9       47 1286M  496M   0.8%  21:08:49 0.1% zoneD\r\n     2       60 1290M  464M   0.7%   7:35:19 0.0% zoneE\r\n     7       51 1298M  460M   0.7%   6:50:11 0.0% zoneF\r\n    24       57  835M  896M   1.4%  17:14:18 0.0% zoneG\r\n    27       45  138M  191M   0.3%   7:52:47 0.0% zoneH\r\n     4       47  345M  408M   0.6%  11:26:22 0.0% zoneI\r\nTotal: 573 processes, 2649 lwps, load averages: 0.38, 0.29, 0.27<\/code><\/pre>\n<p style=\"margin: 0px 0px 1em; padding: 0px;\">Note that each zone is consuming several hundred meg of ram (see<span class=\"Apple-converted-space\">\u00a0<\/span><span class=\"caps\" style=\"margin: 0px; padding: 0px;\">RSS<\/span><span class=\"Apple-converted-space\">\u00a0<\/span>column), this consumption will almost certainly be due to the java heap settings \/ sizings of the various tomcat instances.<\/p>\n<p style=\"margin: 0px 0px 1em; padding: 0px;\">Lets take a look at one of the zones<\/p>\n<pre style=\"margin: 3px 0px; padding: 10px; border: 1px solid #a1a1a1; overflow: auto; font-size: 1.2em;\"><code style=\"margin: 0px; padding: 0px;\">&gt;  zlogin zoneA ps -futomcat\r\n     UID   PID  PPID   C    STIME TTY         TIME CMD\r\n  tomcat 29407 29406   0   Jun 07 ?        1294:57 \/usr\/java\/bin\/java -Djava.util.logging.config.file=\/usr\/local\/tomcat\/conf\/loggi\r\n  tomcat 29406 20781   0   Jun 07 ?           0:47 \/usr\/local\/sbin\/cronolog \/usr\/local\/tomcat\/logs\/catalina.out.%Y-%m-%d<\/code><\/pre>\n<p style=\"margin: 0px 0px 1em; padding: 0px;\">How to interrogate this process to find the resident set size? Well, there are a few options; hunt down the config entries that lauch this tomcat server (usually set as a var<span class=\"Apple-converted-space\">\u00a0<\/span><span class=\"caps\" style=\"margin: 0px; padding: 0px;\">CATALINA<\/span>_OPTS), take the easy route and use prstat or the \u2018process tools\u2019 such as pmap. Ever used pmap? pmap -x will show more detail about the address space mapping of a process than you ever wanted to know; shown below, we can see that the tomcat process in zoneA is using &gt;700mb of ram.<\/p>\n<pre style=\"margin: 3px 0px; padding: 10px; border: 1px solid #a1a1a1; overflow: auto; font-size: 1.2em;\"><code style=\"margin: 0px; padding: 0px;\">bash-3.00# pmap -x 29407\r\n29407:  \/usr\/java\/bin\/java -Djava.util.logging.config.file=\/usr\/local\/tomcat\/c\r\n Address  Kbytes     RSS    Anon  Locked Mode   Mapped File\r\n08008000      12       -       -       - -----    [ anon ]\r\n0803D000      44      44      44       - rwx--    [ stack ]\r\n&lt;... truncated ...&gt;\r\nFEFF0000       4       4       4       - rwx--    [ anon ]\r\nFEFFB000       8       8       8       - rwx--  ld.so.1\r\nFEFFD000       4       4       4       - rwx--  ld.so.1\r\n-------- ------- ------- ------- -------\r\ntotal Kb 1349932  780360  744800       -<\/code><\/pre>\n<p style=\"margin: 0px 0px 1em; padding: 0px;\">Thought 1, there is only 6gb of free memory (as defined as actually on the freelist). Where is it all? I would expect that the<span class=\"Apple-converted-space\">\u00a0<\/span><span class=\"caps\" style=\"margin: 0px; padding: 0px;\">ZFS<\/span><span class=\"Apple-converted-space\">\u00a0<\/span>arc cache will be consuming the lions share, and this blog entry will show you how to check. As applications use more ram,<span class=\"Apple-converted-space\">\u00a0<\/span><span class=\"caps\" style=\"margin: 0px; padding: 0px;\">ZFS<\/span>should behave and reluinquish the previously \u201cunused\u201d ram; but remember that reducing<span class=\"Apple-converted-space\">\u00a0<\/span><span class=\"caps\" style=\"margin: 0px; padding: 0px;\">ZFS<\/span>\u2019s available allocation (by default 7\/8ths of<span class=\"Apple-converted-space\">\u00a0<\/span><span class=\"caps\" style=\"margin: 0px; padding: 0px;\">RAM<\/span>) will in theory impact read performance as we will likely see more cache misses.<span class=\"Apple-converted-space\">\u00a0<\/span><span class=\"caps\" style=\"margin: 0px; padding: 0px;\">ZFS<\/span><span class=\"Apple-converted-space\">\u00a0<\/span>should be pretty good at reducing the arc size as the system requests more and more ram. Let\u2019s check the numbers, both of ram used for arc and the cache efficiency statistics.<\/p>\n<p style=\"margin: 0px 0px 1em; padding: 0px;\">Here is the mdb memstat that shows the memory usage detail:<\/p>\n<pre style=\"margin: 3px 0px; padding: 10px; border: 1px solid #a1a1a1; overflow: auto; font-size: 1.2em;\"><code style=\"margin: 0px; padding: 0px;\">bash-3.00# echo \"::memstat\" | mdb -k\r\nPage Summary                Pages                MB  %Tot\r\n------------     ----------------  ----------------  ----\r\nKernel                   13015620             50842   78%\r\nAnon                      1416662              5533    8%\r\nExec and libs               42400               165    0%\r\nPage cache                 695383              2716    4%\r\nFree (cachelist)            27757               108    0%\r\nFree (freelist)           1577146              6160    9%\r\n\r\nTotal                    16774968             65527\r\nPhysical                 16327309             63778\r\nbash-3.00#<\/code><\/pre>\n<p style=\"margin: 0px 0px 1em; padding: 0px;\">Rather a lot used by the kernel (indicative of<span class=\"Apple-converted-space\">\u00a0<\/span><span class=\"caps\" style=\"margin: 0px; padding: 0px;\">ZFS<\/span><span class=\"Apple-converted-space\">\u00a0<\/span>arc usage), rather than anon, exec and libs, note also a currently a rather small freelist as a percentage of total physical ram, but as mentioned I suspect<span class=\"Apple-converted-space\">\u00a0<\/span><span class=\"caps\" style=\"margin: 0px; padding: 0px;\">ZFS<\/span><span class=\"Apple-converted-space\">\u00a0<\/span>will be consuming a lot (perhaps 40g plus?) of the othewise unused ram.<\/p>\n<p style=\"margin: 0px 0px 1em; padding: 0px;\">The free memory values and zfs arc stats can conveniently be confirmed with a quick look at the kstats via arc_summary, which is an incredibly useful tool written by Ben Rockwood (thanks Ben) which saves us all an immense amount of time both remember how, where and which kstats to interrogate for memory and zfs statistics.<\/p>\n<p style=\"margin: 0px 0px 1em; padding: 0px;\">Get it here:<span class=\"Apple-converted-space\">\u00a0<\/span><a style=\"margin: 0px; padding: 0px; color: #000000;\" href=\"http:\/\/cuddletech.com\/arc_summary\/\">http:\/\/cuddletech.com\/arc_summary\/<\/a><\/p>\n<pre style=\"margin: 3px 0px; padding: 10px; border: 1px solid #a1a1a1; overflow: auto; font-size: 1.2em;\"><code style=\"margin: 0px; padding: 0px;\">System Memory:\r\n         Physical RAM:  65527 MB\r\n         Free Memory :  4369 MB\r\n         LotsFree:      996 MB<\/code><\/pre>\n<p style=\"margin: 0px 0px 1em; padding: 0px;\">The arcsize, as suspected is large; at over 45gb<\/p>\n<pre style=\"margin: 3px 0px; padding: 10px; border: 1px solid #a1a1a1; overflow: auto; font-size: 1.2em;\"><code style=\"margin: 0px; padding: 0px;\">ARC Size:\r\n         Current Size:             46054 MB (arcsize)<\/code><\/pre>\n<p style=\"margin: 0px 0px 1em; padding: 0px;\">The<span class=\"Apple-converted-space\">\u00a0<\/span><span class=\"caps\" style=\"margin: 0px; padding: 0px;\">ARC<\/span><span class=\"Apple-converted-space\">\u00a0<\/span>cache, is however doing a good job with that 45gb, a hit ratio of 96% isn\u2019t bad.<\/p>\n<pre style=\"margin: 3px 0px; padding: 10px; border: 1px solid #a1a1a1; overflow: auto; font-size: 1.2em;\"><code style=\"margin: 0px; padding: 0px;\">ARC Efficency:\r\n         Cache Access Total:             4384785832\r\n         Cache Hit Ratio:      96%       4242292557     [Defined State for buffer]\r\n         Cache Miss Ratio:      3%       142493275      [Undefined State for Buffer]\r\n         REAL Hit Ratio:       92%       4060875546     [MRU\/MFU Hits Only]<\/code><\/pre>\n<p style=\"margin: 0px 0px 1em; padding: 0px;\">Notice also that the<span class=\"Apple-converted-space\">\u00a0<\/span><span class=\"caps\" style=\"margin: 0px; padding: 0px;\">ARC<\/span><span class=\"Apple-converted-space\">\u00a0<\/span>is doing a fairly reasonable job of correctly predicting our prefetch requirements, 36% isn\u2019t too bad compared to a directly demanded cache hit rate of 72%.<\/p>\n<pre style=\"margin: 3px 0px; padding: 10px; border: 1px solid #a1a1a1; overflow: auto; font-size: 1.2em;\"><code style=\"margin: 0px; padding: 0px;\">         Data Demand   Efficiency:    72%\r\n         Data Prefetch Efficiency:    36%<\/code><\/pre>\n<p style=\"margin: 0px 0px 1em; padding: 0px;\">OK, so in theory if we keep adding zones we have to be very careful about the available ram allocations given that these zones are running some reasonably memory-hungry (tomcat) java instances. As more and more memory is allocated to apache\/tomcat and java within new zones, less and less ram will be available for the zfs arc. This will need some careful monitoring.<\/p>\n<p style=\"margin: 0px 0px 1em; padding: 0px;\">Currently the cpu usage on this server is also fairly light, but I have no view of the future levels of usage or traffic intended to run through these services. I\u2019ll park this one for now.<\/p>\n<p style=\"margin: 0px 0px 1em; padding: 0px;\">Thought 2, disk space. Currently the zones have a zfs dataset allocated in the root pool for each zone root:<\/p>\n<pre style=\"margin: 3px 0px; padding: 10px; border: 1px solid #a1a1a1; overflow: auto; font-size: 1.2em;\"><code style=\"margin: 0px; padding: 0px;\">rpool\/ROOT\/s10x10-08\/zones\/zoneB                      6.23G  5.77G  6.23G  \/zones\/zoneB<\/code><\/pre>\n<p style=\"margin: 0px 0px 1em; padding: 0px;\">Each of which has a 12gb quota, the output above (from zfs list) is typical of the usage for the zones, around 50% of the 12g quota. There are 11 zones, each with this 12gb quota, giving a potential total usage of 132gb. The entire root pool is only 136gb and already has just 32.5 gb available as shown by zfs list:<\/p>\n<pre style=\"margin: 3px 0px; padding: 10px; border: 1px solid #a1a1a1; overflow: auto; font-size: 1.2em;\"><code style=\"margin: 0px; padding: 0px;\">root &gt; zpool list\r\nNAME       SIZE   USED  AVAIL    CAP  HEALTH  ALTROOT\r\ndatapool   816G  31.2G   785G     3%  ONLINE  -\r\nrpool      136G   104G  32.5G    76%  ONLINE  -<\/code><\/pre>\n<p style=\"margin: 0px 0px 1em; padding: 0px;\">It seems, then, rather than concerning myself about memory or cpu usage on this server, unless we find elsewhere for the zone root filesystems, we are likely to run out of local storage space way before we stretch the capabilities of this server.<\/p>\n<p style=\"margin: 0px 0px 1em; padding: 0px;\">Soon a blog entry on increasing the size of your root pool with some mirror juggling, I\u2019ve done this successfully on a VM, I just need a test server to perfect the process.<\/p>\n<p style=\"margin: 0px 0px 1em; padding: 0px;\">Comments welcome.<\/p>\n<p style=\"margin: 0px 0px 1em; padding: 0px;\">Paul<\/p>\n<p><br style=\"margin: 0px; padding: 0px;\" \/><\/p>\n<p class=\"smallcopy entryfooter\" style=\"margin: 0px 0px 2px; padding: 0px; text-align: right; color: #215f94; clear: both; font-size: 10px;\"><span class=\"author\" style=\"margin: 0px; padding: 0px;\"><img decoding=\"async\" style=\"margin: 0px; padding: 0px; max-width: 100%;\" title=\"External: null\" src=\"http:\/\/blogs.warwick.ac.uk\/blogbuilder\/static\/images\/tiny_author.gif\" alt=\"\" \/><span class=\"Apple-converted-space\">\u00a0<\/span><\/span><span class=\"entryFooterSpacer\" style=\"margin: 0px; padding: 0px;\">:<span class=\"Apple-converted-space\">\u00a0<\/span><\/span><span class=\"datetime\" style=\"margin: 0px; padding: 0px;\"><a style=\"margin: 0px; padding: 0px; color: #215f94; font-weight: bold;\" title=\"Read all entries written on this date\" href=\"http:\/\/blogs.warwick.ac.uk\/peggleton\/daily\/150910\/\">15 Sep 2010<\/a><span class=\"Apple-converted-space\">\u00a0<\/span>14:55<span class=\"Apple-converted-space\">\u00a0<\/span><\/span><span id=\"entryrating_094d735829a72d04012b15a0d3043b6a\" class=\"entryrating\" style=\"margin: 0px; padding: 0px;\"><\/span><span class=\"taglist\" style=\"margin: 0px; padding: 0px;\">|\u00a0<img decoding=\"async\" style=\"margin: 0px; padding: 0px; max-width: 100%;\" src=\"http:\/\/blogs.warwick.ac.uk\/blogbuilder\/static\/images\/admin\/tag-icon.gif\" alt=\"\" \/>\u00a0Tags:\u00a0<a style=\"margin: 0px; padding: 0px; color: #215f94; font-weight: bold;\" title=\"\" href=\"http:\/\/blogs.warwick.ac.uk\/peggleton\/tag\/arc\/\" rel=\"tag\">Arc<\/a>\u00a0<a style=\"margin: 0px; padding: 0px; color: #215f94; font-weight: bold;\" title=\"\" href=\"http:\/\/blogs.warwick.ac.uk\/peggleton\/tag\/atlantic\/\" rel=\"tag\">Atlantic<\/a>\u00a0<a style=\"margin: 0px; padding: 0px; color: #215f94; font-weight: bold;\" title=\"\" href=\"http:\/\/blogs.warwick.ac.uk\/peggleton\/tag\/pmap\/\" rel=\"tag\">Pmap<\/a>\u00a0<a style=\"margin: 0px; padding: 0px; color: #215f94; font-weight: bold;\" title=\"\" href=\"http:\/\/blogs.warwick.ac.uk\/peggleton\/tag\/zfs\/\" rel=\"tag\">Zfs<\/a>\u00a0<a style=\"margin: 0px; padding: 0px; color: #215f94; font-weight: bold;\" title=\"\" href=\"http:\/\/blogs.warwick.ac.uk\/peggleton\/tag\/zones\/\" rel=\"tag\">Zones<\/a><span class=\"Apple-converted-space\">\u00a0<\/span><\/span><span id=\"commentpopup_094d735829a72d04012b15a0d3043b6a\" class=\"commentpopup\" style=\"margin: 0px; padding: 0px;\">|\u00a0<img decoding=\"async\" style=\"margin: 0px; padding: 0px; max-width: 100%;\" src=\"http:\/\/blogs.warwick.ac.uk\/blogbuilder\/static\/images\/tiny_comment.gif\" alt=\"\" \/><span class=\"Apple-converted-space\">\u00a0<\/span><a style=\"margin: 0px; padding: 0px; color: #215f94; font-weight: bold;\" title=\"Read or add comments\" href=\"http:\/\/blogs.warwick.ac.uk\/peggleton\/entry\/untitled_entry\/\">Comments\u00a0(0)<\/a><span class=\"Apple-converted-space\">\u00a0<\/span><\/span><span class=\"reportlink\" style=\"margin: 0px; padding: 0px;\">|\u00a0<img decoding=\"async\" style=\"margin: 0px; padding: 0px; max-width: 100%;\" src=\"http:\/\/blogs.warwick.ac.uk\/blogbuilder\/static\/images\/tiny_pling.gif\" alt=\"\" \/>\u00a0<a style=\"margin: 0px; padding: 0px; color: #215f94; font-weight: bold;\" title=\"Tell the University if you think there may be a problem with this entry\" href=\"http:\/\/blogs.warwick.ac.uk\/blogbuilder\/admin\/reportAbuse.spr?blog=094d735829a72d04012afd424cdb3741&amp;entryId=094d735829a72d04012b15a0d3043b6a\">Report\u00a0a\u00a0problem<\/a><\/span><\/p>\n<\/div>\n<div class=\"ajaxEntryTail\" style=\"margin: 0px; padding: 0px;\"><\/div>\n<\/div>\n<\/div>\n<div class=\"day\" style=\"font: 12px\/16.79px Verdana, Tahoma, Arial, sans-serif; margin: 0px; padding: 0px; color: #4c5863; text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; white-space: normal; background-color: #ffffff; -webkit-text-stroke-width: 0px;\">\n<h2 class=\"dateheader\" style=\"margin: 0px 0px 7px; padding: 0px; color: #215f94; line-height: 1.3em; font-size: 18px;\">September 13, 2010<\/h2>\n<p><a style=\"margin: 0px; padding: 0px;\" name=\"entry5\"><\/a><\/p>\n<div class=\"entry\" style=\"margin: 0px; padding: 0px; border-bottom-color: #cdcdcd; border-bottom-width: 1px; border-bottom-style: solid;\">\n<div class=\"entryBody\" style=\"margin: 0px; padding: 0px;\">\n<h3 class=\"entryHeader\" style=\"margin: 0.2em 0px 10px; padding: 0px; color: #39434d; line-height: 1.3em; font-size: 14px; font-weight: bold;\"><a style=\"margin: 0px; padding: 0px; color: #39434d;\" href=\"http:\/\/blogs.warwick.ac.uk\/peggleton\/entry\/installation_of_rsync\/\" rel=\"bookmark\">Installation of rsync on Solaris 10<\/a><\/h3>\n<p style=\"margin: 0px 0px 1em; padding: 0px;\">I recently needed to synchronise a web server I look after to a remote backup. Here are my notes on the installation of rsync, the prerequisite packages and a brief note on the usage I implemented for the rsync command.<\/p>\n<p style=\"margin: 0px 0px 1em; padding: 0px;\">You can obtain rsync from<span class=\"Apple-converted-space\">\u00a0<\/span><a style=\"margin: 0px; padding: 0px; color: #000000;\" href=\"http:\/\/www.sunfreeware.com\/\">www.sunfreeware.com<\/a>, along with the pre-requisites to run it. It is also available from<span class=\"Apple-converted-space\">\u00a0<\/span><a style=\"margin: 0px; padding: 0px; color: #000000;\" href=\"http:\/\/www.blastwave.org\/\">www.blastwave.org<\/a><span class=\"Apple-converted-space\">\u00a0<\/span>if you prefer.<\/p>\n<p style=\"margin: 0px 0px 1em; padding: 0px;\">The packages required before you install rsync are:<\/p>\n<p style=\"margin: 0px 0px 1em; padding: 0px;\">&#8211; libgcc-3.4.6-sol10-sparc-local.gz<br style=\"margin: 0px; padding: 0px;\" \/>&#8211; popt-1.14-sol10-sparc-local.gz<br style=\"margin: 0px; padding: 0px;\" \/>&#8211; libiconv-1.13.1-sol10-sparc-local.gz<br style=\"margin: 0px; padding: 0px;\" \/>&#8211; libintl-3.4.0-sol10-sparc-local.gz<\/p>\n<p style=\"margin: 0px 0px 1em; padding: 0px;\">Download each from<span class=\"Apple-converted-space\">\u00a0<\/span><a style=\"margin: 0px; padding: 0px; color: #000000;\" href=\"http:\/\/www.sunfreeware.com\/\">www.sunfreeware.com<\/a>, unzip and pkgadd. Below is an example for the gcc libraries, output omitted. It is worth noting that you will have these libraries if you have gcc installed, which this particular server didn\u2019t.<\/p>\n<pre style=\"margin: 3px 0px; padding: 10px; border: 1px solid #a1a1a1; overflow: auto; font-size: 1.2em;\"><code style=\"margin: 0px; padding: 0px;\"># \/usr\/sfw\/bin\/wget ftp:\/\/ftp.sunfreeware.com\/pub\/freeware\/sparc\/10\/libgcc-3.4.6-sol10-sparc-local.gz\r\n\r\n# gunzip libgcc-3.4.6-sol10-sparc-local.gz \r\n\r\n# pkgadd -G -d libgcc-3.4.6-sol10-sparc-local <\/code><\/pre>\n<p style=\"margin: 0px 0px 1em; padding: 0px;\">The rsync syntax I used to actually perform the synchronisation was<\/p>\n<pre style=\"margin: 3px 0px; padding: 10px; border: 1px solid #a1a1a1; overflow: auto; font-size: 1.2em;\"><code style=\"margin: 0px; padding: 0px;\"> \/usr\/local\/bin\/rsync -avz --delete -e ssh &lt;username&gt;@&lt;host&gt;:\/source-dir\/source-subdir\/  \/local-destination-dir\/local-dest-subdir<\/code><\/pre>\n<p style=\"margin: 0px 0px 1em; padding: 0px;\">This is explained thus:<\/p>\n<p style=\"margin: 0px 0px 1em; padding: 0px;\">-a : archive mode : this ensures that all symbolic links, devices, attributes, permissions and ownerships are preserved in the transfer.<br style=\"margin: 0px; padding: 0px;\" \/>-v : verbose mode : this lists the file sync list as well as statistics about the transfer time and data volume<br style=\"margin: 0px; padding: 0px;\" \/>-z : compression : this trades transfer data volume for cpu cycles by compressing the data before sending over the wire<\/p>\n<p style=\"margin: 0px 0px 1em; padding: 0px;\">\u2014delete : this option will remove files in the destination directory if they no longer exist in the source tree<br style=\"margin: 0px; padding: 0px;\" \/>-s ssh : this is the transport option, advantages of using ssh are obviously encryption and secure no-password logins with<span class=\"Apple-converted-space\">\u00a0<\/span><span class=\"caps\" style=\"margin: 0px; padding: 0px;\">RSA<\/span><span class=\"Apple-converted-space\">\u00a0<\/span>keys<\/p>\n<p style=\"margin: 0px 0px 1em; padding: 0px;\">Another point of worthy note is the trailing slash on the source directory path. This is significant because it tells rsync to copy the contents of the directory, rather than the directory itself, omit this and you will likely end up with the source directory being (re)-created inside the destination\/target directory. Just be aware, so you can choose the behaviour you need.<\/p>\n<p style=\"margin: 0px 0px 1em; padding: 0px;\">The output will look something like below (which is just a test run on an apache logs directory to show the operation).<\/p>\n<pre style=\"margin: 3px 0px; padding: 10px; border: 1px solid #a1a1a1; overflow: auto; font-size: 1.2em;\"><code style=\"margin: 0px; padding: 0px;\">syncing \/opt\/coolstack\/apache2\/logs\/ \/backups\/webserv\/opt\/coolstack\/apache2\/logs\r\nreceiving incremental file list\r\naccess_log\r\nerror_log\r\nssl_request_log\r\n\r\nsent 244123 bytes  received 72351 bytes  3313.86 bytes\/sec\r\ntotal size is 589183260  speedup is 1861.71<\/code><\/pre>\n<p style=\"margin: 0px 0px 1em; padding: 0px;\">As usual, this is mostly for my benefit, but I hope it helps you too.<\/p>\n<p><br style=\"margin: 0px; padding: 0px;\" \/><\/p>\n<p class=\"smallcopy entryfooter\" style=\"margin: 0px 0px 2px; padding: 0px; text-align: right; color: #215f94; clear: both; font-size: 10px;\"><span class=\"author\" style=\"margin: 0px; padding: 0px;\"><img decoding=\"async\" style=\"margin: 0px; padding: 0px; max-width: 100%;\" title=\"External: null\" src=\"http:\/\/blogs.warwick.ac.uk\/blogbuilder\/static\/images\/tiny_author.gif\" alt=\"\" \/><span class=\"Apple-converted-space\">\u00a0<\/span><\/span><span class=\"entryFooterSpacer\" style=\"margin: 0px; padding: 0px;\">:<span class=\"Apple-converted-space\">\u00a0<\/span><\/span><span class=\"datetime\" style=\"margin: 0px; padding: 0px;\"><a style=\"margin: 0px; padding: 0px; color: #215f94; font-weight: bold;\" title=\"Read all entries written on this date\" href=\"http:\/\/blogs.warwick.ac.uk\/peggleton\/daily\/130910\/\">13 Sep 2010<\/a><span class=\"Apple-converted-space\">\u00a0<\/span>20:21<span class=\"Apple-converted-space\">\u00a0<\/span><\/span><span id=\"entryrating_094d735829a72d04012b0c8bc30639a3\" class=\"entryrating\" style=\"margin: 0px; padding: 0px;\"><\/span><span class=\"taglist\" style=\"margin: 0px; padding: 0px;\">|\u00a0<img decoding=\"async\" style=\"margin: 0px; padding: 0px; max-width: 100%;\" src=\"http:\/\/blogs.warwick.ac.uk\/blogbuilder\/static\/images\/admin\/tag-icon.gif\" alt=\"\" \/>\u00a0Tags:\u00a0<a style=\"margin: 0px; padding: 0px; color: #215f94; font-weight: bold;\" title=\"\" href=\"http:\/\/blogs.warwick.ac.uk\/peggleton\/tag\/install\/\" rel=\"tag\">Install<\/a>\u00a0<a style=\"margin: 0px; padding: 0px; color: #215f94; font-weight: bold;\" title=\"\" href=\"http:\/\/blogs.warwick.ac.uk\/peggleton\/tag\/rsync\/\" rel=\"tag\">Rsync<\/a>\u00a0<a style=\"margin: 0px; padding: 0px; color: #215f94; font-weight: bold;\" title=\"\" href=\"http:\/\/blogs.warwick.ac.uk\/peggleton\/tag\/solaris\/\" rel=\"tag\">Solaris<\/a><span class=\"Apple-converted-space\">\u00a0<\/span><\/span><span id=\"commentpopup_094d735829a72d04012b0c8bc30639a3\" class=\"commentpopup\" style=\"margin: 0px; padding: 0px;\">|\u00a0<img decoding=\"async\" style=\"margin: 0px; padding: 0px; max-width: 100%;\" src=\"http:\/\/blogs.warwick.ac.uk\/blogbuilder\/static\/images\/tiny_comment.gif\" alt=\"\" \/><span class=\"Apple-converted-space\">\u00a0<\/span><a style=\"margin: 0px; padding: 0px; color: #215f94; font-weight: bold;\" title=\"Read or add comments\" href=\"http:\/\/blogs.warwick.ac.uk\/peggleton\/entry\/installation_of_rsync\/\">Comments\u00a0(0)<\/a><span class=\"Apple-converted-space\">\u00a0<\/span><\/span><span class=\"reportlink\" style=\"margin: 0px; padding: 0px;\">|\u00a0<img decoding=\"async\" style=\"margin: 0px; padding: 0px; max-width: 100%;\" src=\"http:\/\/blogs.warwick.ac.uk\/blogbuilder\/static\/images\/tiny_pling.gif\" alt=\"\" \/>\u00a0<a style=\"margin: 0px; padding: 0px; color: #215f94; font-weight: bold;\" title=\"Tell the University if you think there may be a problem with this entry\" href=\"http:\/\/blogs.warwick.ac.uk\/blogbuilder\/admin\/reportAbuse.spr?blog=094d735829a72d04012afd424cdb3741&amp;entryId=094d735829a72d04012b0c8bc30639a3\">Report\u00a0a\u00a0problem<\/a><\/span><\/p>\n<\/div>\n<div class=\"ajaxEntryTail\" style=\"margin: 0px; padding: 0px;\"><\/div>\n<\/div>\n<p><a style=\"margin: 0px; padding: 0px;\" name=\"entry6\"><\/a><\/p>\n<div class=\"entry\" style=\"margin: 0px; padding: 0px; border-bottom-color: #cdcdcd; border-bottom-width: 1px; border-bottom-style: solid;\">\n<div class=\"entryBody\" style=\"margin: 0px; padding: 0px;\">\n<h3 class=\"entryHeader\" style=\"margin: 0.2em 0px 10px; padding: 0px; color: #39434d; line-height: 1.3em; font-size: 14px; font-weight: bold;\"><a style=\"margin: 0px; padding: 0px; color: #39434d;\" href=\"http:\/\/blogs.warwick.ac.uk\/peggleton\/entry\/installation_of_jvmstat\/\" rel=\"bookmark\">Installation of jvmstat on Solaris<\/a><\/h3>\n<p class=\"answer\" style=\"margin: 0px 0px 1em; padding: 3px; color: black; overflow: hidden; font-weight: bold; -ms-word-wrap: break-word; background-color: #e5e5e5;\">Writing about web page<span class=\"Apple-converted-space\">\u00a0<\/span><a style=\"margin: 0px; padding: 0px; color: black; font-size: 10px;\" title=\"Related external link: http:\/\/java.sun.com\/performance\/jvmstat\/\" href=\"http:\/\/java.sun.com\/performance\/jvmstat\/\">http:\/\/java.sun.com\/performance\/jvmstat\/<\/a><\/p>\n<p style=\"margin: 0px 0px 1em; padding: 0px;\">The installation of jvmstat on Solaris really is very straightforward. These notes are more a quick reminder for myself rather than anything else, but perhaps it will be of benefit to others to find the information in one place.<\/p>\n<p style=\"margin: 0px 0px 1em; padding: 0px;\">First step; I downloaded jvmstat from<span class=\"Apple-converted-space\">\u00a0<\/span><a style=\"margin: 0px; padding: 0px; color: #000000;\" href=\"http:\/\/java.sun.com\/performance\/jvmstat\/\">http:\/\/java.sun.com\/performance\/jvmstat\/<\/a><\/p>\n<p style=\"margin: 0px 0px 1em; padding: 0px;\">The installation is very simple, just unzip the file into \/usr\/local :<\/p>\n<pre style=\"margin: 3px 0px; padding: 10px; border: 1px solid #a1a1a1; overflow: auto; font-size: 1.2em;\"><code style=\"margin: 0px; padding: 0px;\"># cd -\r\n\/usr\/local\r\n# cp \/var\/spool\/pkg\/jvmstat-2.0_b11.zip .\r\n# unzip jvmstat-2.0_b11.zip\r\nArchive:  jvmstat-2.0_b11.zip\r\n   creating: jvmstat\/\r\n   creating: jvmstat\/policies\/\r\n&lt; ... truncated ... &gt;\r\n  inflating: jvmstat\/docs\/install\/windows.html\r\n  inflating: jvmstat\/docs\/install\/solaris.html<\/code><\/pre>\n<p style=\"margin: 0px 0px 1em; padding: 0px;\">I chose to install jvmstat 2.0, although 3.0 is available because 3.0 requires Java 1.5.0. At the time of install, I didn\u2019t realise that 1.5.0 was available in \/usr\/local\/jdk1.5.0_16\/. I may upgrade later.<\/p>\n<p style=\"margin: 0px 0px 1em; padding: 0px;\">The environment variable of worthy note that you would need to set are:<\/p>\n<pre style=\"margin: 3px 0px; padding: 10px; border: 1px solid #a1a1a1; overflow: auto; font-size: 1.2em;\"><code style=\"margin: 0px; padding: 0px;\"># echo $PATH\r\n\/usr\/sbin:\/usr\/bin:\/usr\/local\/jvmstat\/bin:\/usr\/java\/bin\r\n# echo $JAVA_HOME\r\n\/usr\/java<\/code><\/pre>\n<p style=\"margin: 0px 0px 1em; padding: 0px;\">Once this is all done, the Java VMs running on the system can be found with jvmps (jps in version 3.0) and a quick command line test can be run with jvmstat (jstat in version 3.0):<\/p>\n<pre style=\"margin: 3px 0px; padding: 10px; border: 1px solid #a1a1a1; overflow: auto; font-size: 1.2em;\"><code style=\"margin: 0px; padding: 0px;\"># jvmps\r\n6803 jvmps.jar\r\n1928 org.apache.catalina.startup.Bootstrap\r\n\r\n# jvmstat -gcutil 1928 1000 3\r\n  S0     S1     E      O      P     YGC     YGCT    FGC    FGCT     GCT\r\n  0.00  47.48  83.34   6.96  99.40     85    0.881     4    2.204    3.085\r\n  0.00  47.48  83.34   6.96  99.40     85    0.881     4    2.204    3.085\r\n  0.00  47.48  83.34   6.96  99.40     85    0.881     4    2.204    3.085<\/code><\/pre>\n<p style=\"margin: 0px 0px 1em; padding: 0px;\">The<span class=\"Apple-converted-space\">\u00a0<\/span><span class=\"caps\" style=\"margin: 0px; padding: 0px;\">GUI<\/span><span class=\"Apple-converted-space\">\u00a0<\/span>can be run with \u2018visualgc<span class=\"Apple-converted-space\">\u00a0<\/span>\u2019 which I tested and works fine, you will need to have an Xserver to display the output on though.<\/p>\n<p><br style=\"margin: 0px; padding: 0px;\" \/><\/p>\n<p class=\"smallcopy entryfooter\" style=\"margin: 0px 0px 2px; padding: 0px; text-align: right; color: #215f94; clear: both; font-size: 10px;\"><span class=\"author\" style=\"margin: 0px; padding: 0px;\"><img decoding=\"async\" style=\"margin: 0px; padding: 0px; max-width: 100%;\" title=\"External: null\" src=\"http:\/\/blogs.warwick.ac.uk\/blogbuilder\/static\/images\/tiny_author.gif\" alt=\"\" \/><span class=\"Apple-converted-space\">\u00a0<\/span><\/span><span class=\"entryFooterSpacer\" style=\"margin: 0px; padding: 0px;\">:<span class=\"Apple-converted-space\">\u00a0<\/span><\/span><span class=\"datetime\" style=\"margin: 0px; padding: 0px;\"><a style=\"margin: 0px; padding: 0px; color: #215f94; font-weight: bold;\" title=\"Read all entries written on this date\" href=\"http:\/\/blogs.warwick.ac.uk\/peggleton\/daily\/130910\/\">13 Sep 2010<\/a><span class=\"Apple-converted-space\">\u00a0<\/span>20:01<span class=\"Apple-converted-space\">\u00a0<\/span><\/span><span id=\"entryrating_094d735829a72d04012b0c79966e397e\" class=\"entryrating\" style=\"margin: 0px; padding: 0px;\"><\/span><span class=\"taglist\" style=\"margin: 0px; padding: 0px;\">|\u00a0<img decoding=\"async\" style=\"margin: 0px; padding: 0px; max-width: 100%;\" src=\"http:\/\/blogs.warwick.ac.uk\/blogbuilder\/static\/images\/admin\/tag-icon.gif\" alt=\"\" \/>\u00a0Tags:\u00a0<a style=\"margin: 0px; padding: 0px; color: #215f94; font-weight: bold;\" title=\"\" href=\"http:\/\/blogs.warwick.ac.uk\/peggleton\/tag\/gc\/\" rel=\"tag\">GC<\/a>\u00a0<a style=\"margin: 0px; padding: 0px; color: #215f94; font-weight: bold;\" title=\"\" href=\"http:\/\/blogs.warwick.ac.uk\/peggleton\/tag\/java\/\" rel=\"tag\">Java<\/a>\u00a0<a style=\"margin: 0px; padding: 0px; color: #215f94; font-weight: bold;\" title=\"\" href=\"http:\/\/blogs.warwick.ac.uk\/peggleton\/tag\/jvmstat\/\" rel=\"tag\">Jvmstat<\/a>\u00a0<a style=\"margin: 0px; padding: 0px; color: #215f94; font-weight: bold;\" title=\"\" href=\"http:\/\/blogs.warwick.ac.uk\/peggleton\/tag\/performance\/\" rel=\"tag\">Performance<\/a>\u00a0<a style=\"margin: 0px; padding: 0px; color: #215f94; font-weight: bold;\" title=\"\" href=\"http:\/\/blogs.warwick.ac.uk\/peggleton\/tag\/visualgc\/\" rel=\"tag\">Visualgc<\/a><span class=\"Apple-converted-space\">\u00a0<\/span><\/span><span id=\"commentpopup_094d735829a72d04012b0c79966e397e\" class=\"commentpopup\" style=\"margin: 0px; padding: 0px;\">|\u00a0<img decoding=\"async\" style=\"margin: 0px; padding: 0px; max-width: 100%;\" src=\"http:\/\/blogs.warwick.ac.uk\/blogbuilder\/static\/images\/tiny_comment.gif\" alt=\"\" \/><span class=\"Apple-converted-space\">\u00a0<\/span><a style=\"margin: 0px; padding: 0px; color: #215f94; font-weight: bold;\" title=\"Read or add comments\" href=\"http:\/\/blogs.warwick.ac.uk\/peggleton\/entry\/installation_of_jvmstat\/\">Comments\u00a0(0)<\/a><span class=\"Apple-converted-space\">\u00a0<\/span><\/span><span class=\"reportlink\" style=\"margin: 0px; padding: 0px;\">|\u00a0<img decoding=\"async\" style=\"margin: 0px; padding: 0px; max-width: 100%;\" src=\"http:\/\/blogs.warwick.ac.uk\/blogbuilder\/static\/images\/tiny_pling.gif\" alt=\"\" \/>\u00a0<a style=\"margin: 0px; padding: 0px; color: #215f94; font-weight: bold;\" title=\"Tell the University if you think there may be a problem with this entry\" href=\"http:\/\/blogs.warwick.ac.uk\/blogbuilder\/admin\/reportAbuse.spr?blog=094d735829a72d04012afd424cdb3741&amp;entryId=094d735829a72d04012b0c79966e397e\">Report\u00a0a\u00a0problem<\/a><\/span><\/p>\n<\/div>\n<div class=\"ajaxEntryTail\" style=\"margin: 0px; padding: 0px;\"><\/div>\n<\/div>\n<\/div>\n<div class=\"day\" style=\"font: 12px\/16.79px Verdana, Tahoma, Arial, sans-serif; margin: 0px; padding: 0px; color: #4c5863; text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; white-space: normal; background-color: #ffffff; -webkit-text-stroke-width: 0px;\">\n<h2 class=\"dateheader\" style=\"margin: 0px 0px 7px; padding: 0px; color: #215f94; line-height: 1.3em; font-size: 18px;\">September 10, 2010<\/h2>\n<p><a style=\"margin: 0px; padding: 0px;\" name=\"entry7\"><\/a><\/p>\n<div class=\"entry\" style=\"margin: 0px; padding: 0px; border-bottom-color: #cdcdcd; border-bottom-width: 1px; border-bottom-style: solid;\">\n<div class=\"entryBody\" style=\"margin: 0px; padding: 0px;\">\n<h3 class=\"entryHeader\" style=\"margin: 0.2em 0px 10px; padding: 0px; color: #39434d; line-height: 1.3em; font-size: 14px; font-weight: bold;\"><a style=\"margin: 0px; padding: 0px; color: #39434d;\" href=\"http:\/\/blogs.warwick.ac.uk\/peggleton\/entry\/fun_with_tomcat\/\" rel=\"bookmark\">Fun with tomcat and jvmstat on Mac OS<\/a><\/h3>\n<p class=\"p1\" style=\"margin: 0px 0px 1em; padding: 0px;\">\n<p class=\"p1\" style=\"margin: 0px 0px 1em; padding: 0px;\">Today I needed to install visualgc for tomcat on Solaris.\u00a0 Now, GC analysis and configuration of the tools required to do so is something I&#8217;ve not done in a number of years. So, as a small exercise designed to re-familiarise myself with the foibles of tomcat, garbage collection, java command line configuration options and so on I ventured on a brief excursion into the world of tomcat, java and jvmstat on Mac OS X.\u00a0 It is Unix, afterall, so what could be so hard &#8211; right?<\/p>\n<p class=\"p2\" style=\"margin: 0px 0px 1em; padding: 0px;\">First task, download and install tomcat.<span class=\"Apple-converted-space\" style=\"margin: 0px; padding: 0px;\"><span class=\"Apple-converted-space\">\u00a0<\/span><\/span>This really couldn&#8217;t be simpler, a zipped tar file to install pretty much wherever you choose.<span class=\"Apple-converted-space\" style=\"margin: 0px; padding: 0px;\"><span class=\"Apple-converted-space\">\u00a0<\/span><\/span>A typical, popular location is \/usr\/local.<span class=\"Apple-converted-space\" style=\"margin: 0px; padding: 0px;\"><span class=\"Apple-converted-space\">\u00a0<\/span><\/span>I have chosen \/usr\/local\/tomcat.<\/p>\n<p class=\"p2\" style=\"margin: 0px 0px 1em; padding: 0px;\">I downloaded apache-tomcat-5.5.30.tar.gz (there are later versions available depending on your requirements, but this is the version I will be monitoring at work) from http:\/\/tomcat.apache.org\/<\/p>\n<p class=\"p2\" style=\"margin: 0px 0px 1em; padding: 0px;\">Copy the file into \/usr\/local and extract<\/p>\n<pre class=\"p2\" style=\"margin: 3px 0px; padding: 10px; border: 1px solid #a1a1a1; overflow: auto; font-size: 1.2em;\">$ gnutar -xzvf apache-tomcat-5.5.30.tar.gz<\/pre>\n<p class=\"p1\" style=\"margin: 0px 0px 1em; padding: 0px;\">\n<p class=\"p2\" style=\"margin: 0px 0px 1em; padding: 0px;\">Change the ownership to your local user and group:<\/p>\n<pre class=\"p2\" style=\"margin: 3px 0px; padding: 10px; border: 1px solid #a1a1a1; overflow: auto; font-size: 1.2em;\">$ chown -R egg:staff apache-tomcat-5.5.30<\/pre>\n<p class=\"p2\" style=\"margin: 0px 0px 1em; padding: 0px;\">\n<p class=\"p2\" style=\"margin: 0px 0px 1em; padding: 0px;\">In order to start and stop tomcat with the correct details for CATALINA_HOME etc, you&#8217;ll need tomcat stop and start scripts.\u00a0 I used the following, fairly standard looking scripts that I placed into $HOME\/bin, please note that the variables will of course vary depending on your configuration.\u00a0 Worthy of note here is that I *did not* eventually use JAVA_HOME set to \/usr &#8211; more on that later.<\/p>\n<p class=\"p4\" style=\"margin: 0px 0px 1em; padding: 0px;\">start_tomcat<\/p>\n<pre class=\"p6\" style=\"margin: 3px 0px; padding: 10px; border: 1px solid #a1a1a1; overflow: auto; font-size: 1.2em;\">#!\/bin\/sh<br style=\"margin: 0px; padding: 0px;\" \/>export CATALINA_HOME=\/usr\/local\/apache-tomcat-5.5.30<br style=\"margin: 0px; padding: 0px;\" \/>export JAVA_HOME=\/usr<br style=\"margin: 0px; padding: 0px;\" \/>$CATALINA_HOME\/bin\/startup.sh<\/pre>\n<p class=\"p7\" style=\"margin: 0px 0px 1em; padding: 0px;\"><span class=\"Apple-converted-space\" style=\"margin: 0px; padding: 0px;\">\u00a0<\/span><\/p>\n<p class=\"p8\" style=\"margin: 0px 0px 1em; padding: 0px;\">stop_tomcat<\/p>\n<pre class=\"p6\" style=\"margin: 3px 0px; padding: 10px; border: 1px solid #a1a1a1; overflow: auto; font-size: 1.2em;\">#!\/bin\/sh<br style=\"margin: 0px; padding: 0px;\" \/>export CATALINA_HOME=\/usr\/local\/apache-tomcat-5.5.30<br style=\"margin: 0px; padding: 0px;\" \/>export JAVA_HOME=\/usr<br style=\"margin: 0px; padding: 0px;\" \/>$CATALINA_HOME\/bin\/shutdown.sh<\/pre>\n<p class=\"p2\" style=\"margin: 0px 0px 1em; padding: 0px;\">\n<p class=\"p2\" style=\"margin: 0px 0px 1em; padding: 0px;\">As mentioned, a good place for these are in your local home directory, but this may vary depending on your environment.<span class=\"Apple-converted-space\" style=\"margin: 0px; padding: 0px;\"><span class=\"Apple-converted-space\">\u00a0<\/span><\/span>I put them in ~\/bin\/start_tomcat and ~\/bin\/stop_tomcat.<span class=\"Apple-converted-space\" style=\"margin: 0px; padding: 0px;\"><span class=\"Apple-converted-space\">\u00a0<\/span><\/span>Don&#8217;t forget to make them executable.<\/p>\n<p class=\"p2\" style=\"margin: 0px 0px 1em; padding: 0px;\">For my purposes, I created a tomcat-env.sh script that can be used to\u00a0 some CATALINA_OPTS, I was only really interested in changing the java min and max heap sizes for now:<\/p>\n<pre class=\"p2\" style=\"margin: 3px 0px; padding: 10px; border: 1px solid #a1a1a1; overflow: auto; font-size: 1.2em;\">$ cat tomcat-env.sh<br style=\"margin: 0px; padding: 0px;\" \/>CATALINA_OPTS=$CATALINA_OPTS\" -Xms512m -Xmx512m\"<br style=\"margin: 0px; padding: 0px;\" \/>export CATALINA_OPTS<\/pre>\n<p class=\"p1\" style=\"margin: 0px 0px 1em; padding: 0px;\">\n<p class=\"p2\" style=\"margin: 0px 0px 1em; padding: 0px;\">You should now be able to run ~\/bin\/start_tomcat and connect to http:\/\/localhost:8080 to be greeted with your tomcat installation home page.\u00a0<span class=\"Apple-converted-space\">\u00a0<\/span><\/p>\n<p class=\"p2\" style=\"margin: 0px 0px 1em; padding: 0px;\">Next, download jvmstart from http:\/\/java.sun.com\/performance\/jvmstat\/<\/p>\n<p class=\"p2\" style=\"margin: 0px 0px 1em; padding: 0px;\">I chose to put this in \/usr\/local\/jvmstat, again, this is local site install dependent.<\/p>\n<pre class=\"p2\" style=\"margin: 3px 0px; padding: 10px; border: 1px solid #a1a1a1; overflow: auto; font-size: 1.2em;\">$ cp \/Users\/egg\/Downloads\/jvmstat-3_0.zip \/usr\/local<br style=\"margin: 0px; padding: 0px;\" \/>$ unzip jvmstat-3_0.zip<\/pre>\n<p class=\"p1\" style=\"margin: 0px 0px 1em; padding: 0px;\">\n<p class=\"p2\" style=\"margin: 0px 0px 1em; padding: 0px;\">I created a ~\/jvmstat-env.sh to set required variables for jvmstat:<\/p>\n<pre class=\"p2\" style=\"margin: 3px 0px; padding: 10px; border: 1px solid #a1a1a1; overflow: auto; font-size: 1.2em;\">export JAVA_HOME=\/System\/Library\/Frameworks\/JavaVM.framework\/Versions\/1.6.0\/Home<br style=\"margin: 0px; padding: 0px;\" \/>PATH=JVMSTAT_HOME\/bin:JAVA_HOME\/bin:$PATH<br style=\"margin: 0px; padding: 0px;\" \/>export PATH<br style=\"margin: 0px; padding: 0px;\" \/>export JVMSTAT_JAVA_HOME=$JAVA_HOME<\/pre>\n<p class=\"p1\" style=\"margin: 0px 0px 1em; padding: 0px;\">\n<p class=\"p2\" style=\"margin: 0px 0px 1em; padding: 0px;\">This is where I should say something about the madness of JDKs on MacOS.<span class=\"Apple-converted-space\" style=\"margin: 0px; padding: 0px;\"><span class=\"Apple-converted-space\">\u00a0<\/span><\/span>Under most OSes, the Java JDK has a ~\/lib\/tools.jar that the jvmstat tools rely on.<span class=\"Apple-converted-space\" style=\"margin: 0px; padding: 0px;\"><span class=\"Apple-converted-space\">\u00a0<\/span>In fact, jvmstat (more specificailly visualgc) looks for this file to determine whether you have pointed your java home at a jre or a jdk.\u00a0 If visualgc thinks you don&#8217;t have a complete jdk you get the following rather helpful error:<\/span><\/p>\n<pre class=\"p2\" style=\"margin: 3px 0px; padding: 10px; border: 1px solid #a1a1a1; overflow: auto; font-size: 1.2em;\">$ \/usr\/local\/jvmstat\/bin\/visualgc 8650<br style=\"margin: 0px; padding: 0px;\" \/>The java.exe found at:<br style=\"margin: 0px; padding: 0px;\" \/>\/System\/Library\/Frameworks\/JavaVM.framework\/Versions\/1.5.0\/Home<br style=\"margin: 0px; padding: 0px;\" \/>is not in a JDK directory. Please set and export your<br style=\"margin: 0px; padding: 0px;\" \/>JVMSTAT_JAVA_HOME environment variable to refer to a<br style=\"margin: 0px; padding: 0px;\" \/>directory containing the Sun J2SE 1.5.0 JDK (not a JRE)<\/pre>\n<p class=\"p2\" style=\"margin: 0px 0px 1em; padding: 0px;\">\n<p class=\"p2\" style=\"margin: 0px 0px 1em; padding: 0px;\">Yes, this is Mac OS, and yes it does bizarrely refer to &#8216;java.exe&#8217;.\u00a0 A little investigation shows that visualgc is indeed looking for the tools.jar on start:<\/p>\n<pre style=\"margin: 3px 0px; padding: 10px; border: 1px solid #a1a1a1; overflow: auto; font-size: 1.2em;\"># check that we are dealing with a JDK, not a JRE or installed JDK<br style=\"margin: 0px; padding: 0px;\" \/>if [ ! -f \"${JVMSTAT_JAVA_HOME}\/lib\/tools.jar\" ] ; then<br style=\"margin: 0px; padding: 0px;\" \/>  jreerror<br style=\"margin: 0px; padding: 0px;\" \/>fi<\/pre>\n<p class=\"p2\" style=\"margin: 0px 0px 1em; padding: 0px;\">\n<p class=\"p2\" style=\"margin: 0px 0px 1em; padding: 0px;\">Under MacOS, however, the equivalent to tools.jar is classes.jar.<span class=\"Apple-converted-space\" style=\"margin: 0px; padding: 0px;\"><span class=\"Apple-converted-space\">\u00a0<\/span>I am yet to establish why this should be different.<span class=\"Apple-converted-space\">\u00a0<\/span><\/span>The Java home isn&#8217;t to be found in \/usr either, that directory just contain a \/usr\/bin\/java symlink to the latest runtimes for Java applications on your Mac, instead I found I had to set a java home to:<\/p>\n<p class=\"p2\" style=\"margin: 0px 0px 1em; padding: 0px;\">export JAVA_HOME=\/System\/Library\/Frameworks\/JavaVM.framework\/Versions\/1.6.0\/Home<\/p>\n<p class=\"p2\" style=\"margin: 0px 0px 1em; padding: 0px;\">Or, if you are lucky, the following may work :<\/p>\n<p class=\"p2\" style=\"margin: 0px 0px 1em; padding: 0px;\">export JAVA_HOME=\/System\/Library\/Frameworks\/JavaVM.framework\/Home<\/p>\n<p class=\"p2\" style=\"margin: 0px 0px 1em; padding: 0px;\">However, classes.jar only seemed to exist in \/System\/Library\/Frameworks\/JavaVM.framework\/Versions\/1.6.0\/Classes\/classes.jar<\/p>\n<p class=\"p2\" style=\"margin: 0px 0px 1em; padding: 0px;\">So, with JAVA_HOME set to \/System\/Library\/Frameworks\/JavaVM.framework\/Versions\/1.6.0\/Home<\/p>\n<p class=\"p2\" style=\"margin: 0px 0px 1em; padding: 0px;\">I created a symbolic link from \/System\/Library\/Frameworks\/JavaVM.framework\/Versions\/1.6.0\/Home\/lib\/tools.jar to<span class=\"Apple-converted-space\" style=\"margin: 0px; padding: 0px;\"><span class=\"Apple-converted-space\">\u00a0<\/span><\/span>\/System\/Library\/Frameworks\/JavaVM.framework\/Versions\/1.6.0\/Classes\/classes.jar, now visualgc would finally start without the error.<\/p>\n<p class=\"p2\" style=\"margin: 0px 0px 1em; padding: 0px;\">Once you have tomcat installed, the jvmstat installed, the jvmstat-env.sh set correctly and the java home set with a valid tools.jar \/ classes.jar you should be able to start tomcat, test jvmstat using gcutil at the command line and finally launch visualgc with some success:<\/p>\n<pre class=\"p2\" style=\"margin: 3px 0px; padding: 10px; border: 1px solid #a1a1a1; overflow: auto; font-size: 1.2em;\">$ . tomcat-env.sh<br style=\"margin: 0px; padding: 0px;\" \/>$ . jvmstat-env.sh<br style=\"margin: 0px; padding: 0px;\" \/>$ bin\/start_tomcat<br style=\"margin: 0px; padding: 0px;\" \/>Using CATALINA_BASE: \/usr\/local\/apache-tomcat-5.5.30<br style=\"margin: 0px; padding: 0px;\" \/>Using CATALINA_HOME: \/usr\/local\/apache-tomcat-5.5.30<br style=\"margin: 0px; padding: 0px;\" \/>Using CATALINA_TMPDIR: \/usr\/local\/apache-tomcat-5.5.30\/temp<br style=\"margin: 0px; padding: 0px;\" \/>Using JRE_HOME:<span class=\"Apple-converted-space\" style=\"margin: 0px; padding: 0px;\"> \u00a0 \u00a0 \u00a0 <\/span>\/System\/Library\/Frameworks\/JavaVM.framework\/Versions\/1.6.0\/Home<br style=\"margin: 0px; padding: 0px;\" \/>Using CLASSPATH: <span class=\"Apple-converted-space\" style=\"margin: 0px; padding: 0px;\"> \u00a0 \u00a0 <\/span>\/usr\/local\/apache-tomcat-5.5.30\/bin\/bootstrap.jar<\/pre>\n<p class=\"p1\" style=\"margin: 0px 0px 1em; padding: 0px;\">\n<p class=\"p2\" style=\"margin: 0px 0px 1em; padding: 0px;\">Lets check tomcat is running:<\/p>\n<pre class=\"p2\" style=\"margin: 3px 0px; padding: 10px; border: 1px solid #a1a1a1; overflow: auto; font-size: 1.2em;\">$ ps -ef |grep java<span class=\"Apple-converted-space\" style=\"margin: 0px; padding: 0px;\"><br style=\"margin: 0px; padding: 0px;\" \/><\/span>501 86749 <span class=\"Apple-converted-space\" style=\"margin: 0px; padding: 0px;\"> \u00a0 <\/span>1 0 0:00.24 ttys002<span class=\"Apple-converted-space\" style=\"margin: 0px; padding: 0px;\"> \u00a0 <\/span>0:03.39 \/System\/Library\/Frameworks\/JavaVM.framework\/Versions\/1.6.0\/Home\/bin\/java<br style=\"margin: 0px; padding: 0px;\" \/>-Djava.util.logging.config.file=\/usr\/local\/apache-tomcat-5.5.30\/conf\/logging.properties<br style=\"margin: 0px; padding: 0px;\" \/> -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager <br style=\"margin: 0px; padding: 0px;\" \/>-Xms512m -Xmx512m -Xms512m -Xmx512m -Xms512m -Xmx512m <br style=\"margin: 0px; padding: 0px;\" \/>-Djava.endorsed.dirs=\/usr\/local\/apache-tomcat-5.5.30\/common\/endorsed <br style=\"margin: 0px; padding: 0px;\" \/>-classpath \/usr\/local\/apache-tomcat-5.5.30\/bin\/bootstrap.jar <br style=\"margin: 0px; padding: 0px;\" \/>-Dcatalina.base=\/usr\/local\/apache-tomcat-5.5.30 <br style=\"margin: 0px; padding: 0px;\" \/>-Dcatalina.home=\/usr\/local\/apache-tomcat-5.5.30 <br style=\"margin: 0px; padding: 0px;\" \/>-Djava.io.tmpdir=\/usr\/local\/apache-tomcat-5.5.30\/temp <br style=\"margin: 0px; padding: 0px;\" \/>org.apache.catalina.startup.Bootstrap start<\/pre>\n<p class=\"p2\" style=\"margin: 0px 0px 1em; padding: 0px;\">Marvellous.<\/p>\n<p class=\"p2\" style=\"margin: 0px 0px 1em; padding: 0px;\">Now find the process id of interest, the easy way:<\/p>\n<pre class=\"p2\" style=\"margin: 3px 0px; padding: 10px; border: 1px solid #a1a1a1; overflow: auto; font-size: 1.2em;\">$ jps<br style=\"margin: 0px; padding: 0px;\" \/>86749 Bootstrap<br style=\"margin: 0px; padding: 0px;\" \/>86754 Jps<\/pre>\n<p class=\"p1\" style=\"margin: 0px 0px 1em; padding: 0px;\">\n<p style=\"margin: 0px 0px 1em; padding: 0px;\">We are interested in &#8216;Bootstrap&#8217; (org.apache.catalina.startup.Bootstrap)<\/p>\n<p class=\"p2\" style=\"margin: 0px 0px 1em; padding: 0px;\">Let&#8217;s test the jvmstat with gcutil on the command line, using the process number (86749) gleaned from jps:<\/p>\n<pre class=\"p2\" style=\"margin: 3px 0px; padding: 10px; border: 1px solid #a1a1a1; overflow: auto; font-size: 1.2em;\">$ jstat -gcutil 86749 1000 3<span class=\"Apple-converted-space\" style=\"margin: 0px; padding: 0px;\"><br style=\"margin: 0px; padding: 0px;\" \/><\/span>S0 <span class=\"Apple-converted-space\" style=\"margin: 0px; padding: 0px;\"> \u00a0 <\/span>S1 <span class=\"Apple-converted-space\" style=\"margin: 0px; padding: 0px;\"> \u00a0 <\/span>E<span class=\"Apple-converted-space\" style=\"margin: 0px; padding: 0px;\"> \u00a0 \u00a0 <\/span>O<span class=\"Apple-converted-space\" style=\"margin: 0px; padding: 0px;\"> \u00a0 \u00a0 <\/span>P <span class=\"Apple-converted-space\" style=\"margin: 0px; padding: 0px;\"> \u00a0 <\/span>YGC <span class=\"Apple-converted-space\" style=\"margin: 0px; padding: 0px;\"> \u00a0 <\/span>YGCT<span class=\"Apple-converted-space\" style=\"margin: 0px; padding: 0px;\"> \u00a0 <\/span>FGC<span class=\"Apple-converted-space\" style=\"margin: 0px; padding: 0px;\"> \u00a0 <\/span>FGCT <span class=\"Apple-converted-space\" style=\"margin: 0px; padding: 0px;\"> \u00a0 <\/span>GCT<span class=\"Apple-converted-space\" style=\"margin: 0px; padding: 0px;\"> \u00a0<br style=\"margin: 0px; padding: 0px;\" \/><\/span>0.0097.0566.06 0.0067.34<span class=\"Apple-converted-space\" style=\"margin: 0px; padding: 0px;\"> \u00a0 \u00a0 <\/span>1<span class=\"Apple-converted-space\" style=\"margin: 0px; padding: 0px;\"> \u00a0 <\/span>0.020 <span class=\"Apple-converted-space\" style=\"margin: 0px; padding: 0px;\"> \u00a0 <\/span>0<span class=\"Apple-converted-space\" style=\"margin: 0px; padding: 0px;\"> \u00a0 <\/span>0.000<span class=\"Apple-converted-space\" style=\"margin: 0px; padding: 0px;\"> \u00a0 <\/span>0.020<span class=\"Apple-converted-space\" style=\"margin: 0px; padding: 0px;\"><br style=\"margin: 0px; padding: 0px;\" \/><\/span>0.0097.0566.06 0.0067.34<span class=\"Apple-converted-space\" style=\"margin: 0px; padding: 0px;\"> \u00a0 \u00a0 <\/span>1<span class=\"Apple-converted-space\" style=\"margin: 0px; padding: 0px;\"> \u00a0 <\/span>0.020 <span class=\"Apple-converted-space\" style=\"margin: 0px; padding: 0px;\"> \u00a0 <\/span>0<span class=\"Apple-converted-space\" style=\"margin: 0px; padding: 0px;\"> \u00a0 <\/span>0.000<span class=\"Apple-converted-space\" style=\"margin: 0px; padding: 0px;\"> \u00a0 <\/span>0.020<br style=\"margin: 0px; padding: 0px;\" \/>0.0097.0566.06 0.0067.34<span class=\"Apple-converted-space\" style=\"margin: 0px; padding: 0px;\"> \u00a0 \u00a0 <\/span>1<span class=\"Apple-converted-space\" style=\"margin: 0px; padding: 0px;\"> \u00a0 <\/span>0.020 <span class=\"Apple-converted-space\" style=\"margin: 0px; padding: 0px;\"> \u00a0 <\/span>0<span class=\"Apple-converted-space\" style=\"margin: 0px; padding: 0px;\"> \u00a0 <\/span>0.000<span class=\"Apple-converted-space\" style=\"margin: 0px; padding: 0px;\"> \u00a0 <\/span>0.020<\/pre>\n<p class=\"p1\" style=\"margin: 0px 0px 1em; padding: 0px;\">\n<p class=\"p2\" style=\"margin: 0px 0px 1em; padding: 0px;\">Looks good, and as long as we have the java home, and the link from tools.jar to classes.jar as described above, we should be able to lauch visualgc:<\/p>\n<pre class=\"p2\" style=\"margin: 3px 0px; padding: 10px; border: 1px solid #a1a1a1; overflow: auto; font-size: 1.2em;\">$ \/usr\/local\/jvmstat\/bin\/visualgc 86749<\/pre>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p> grep on Solaris <\/p>\n<p style=\"margin: 0px 0px 1em; padding: 0px;\">Today I was asked by a colleague how to match a regex in a text file and return a specific number of lines both before and after the match. GNU grep has a very easy solution for this; the -A\/B\/C flags, as shown on my [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[39],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/3288"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3288"}],"version-history":[{"count":2,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/3288\/revisions"}],"predecessor-version":[{"id":3290,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/3288\/revisions\/3290"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3288"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3288"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3288"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}