<!--{{{-->
<link rel='alternate' type='application/rss+xml' title='RSS' href='index.xml' />
<!--}}}-->
Background: #fff
Foreground: #000
PrimaryPale: #8cf
PrimaryLight: #18f
PrimaryMid: #04b
PrimaryDark: #014
SecondaryPale: #ffc
SecondaryLight: #fe8
SecondaryMid: #db4
SecondaryDark: #841
TertiaryPale: #eee
TertiaryLight: #ccc
TertiaryMid: #999
TertiaryDark: #666
Error: #f88
/*{{{*/
body {background:[[ColorPalette::Background]]; color:[[ColorPalette::Foreground]];}

a {color:[[ColorPalette::PrimaryMid]];}
a:hover {background-color:[[ColorPalette::PrimaryMid]]; color:[[ColorPalette::Background]];}
a img {border:0;}

h1,h2,h3,h4,h5,h6 {color:[[ColorPalette::SecondaryDark]]; background:transparent;}
h1 {border-bottom:2px solid [[ColorPalette::TertiaryLight]];}
h2,h3 {border-bottom:1px solid [[ColorPalette::TertiaryLight]];}

.button {color:[[ColorPalette::PrimaryDark]]; border:1px solid [[ColorPalette::Background]];}
.button:hover {color:[[ColorPalette::PrimaryDark]]; background:[[ColorPalette::SecondaryLight]]; border-color:[[ColorPalette::SecondaryMid]];}
.button:active {color:[[ColorPalette::Background]]; background:[[ColorPalette::SecondaryMid]]; border:1px solid [[ColorPalette::SecondaryDark]];}

.header {background:[[ColorPalette::PrimaryMid]];}
.headerShadow {color:[[ColorPalette::Foreground]];}
.headerShadow a {font-weight:normal; color:[[ColorPalette::Foreground]];}
.headerForeground {color:[[ColorPalette::Background]];}
.headerForeground a {font-weight:normal; color:[[ColorPalette::PrimaryPale]];}

.tabSelected{color:[[ColorPalette::PrimaryDark]];
	background:[[ColorPalette::TertiaryPale]];
	border-left:1px solid [[ColorPalette::TertiaryLight]];
	border-top:1px solid [[ColorPalette::TertiaryLight]];
	border-right:1px solid [[ColorPalette::TertiaryLight]];
}
.tabUnselected {color:[[ColorPalette::Background]]; background:[[ColorPalette::TertiaryMid]];}
.tabContents {color:[[ColorPalette::PrimaryDark]]; background:[[ColorPalette::TertiaryPale]]; border:1px solid [[ColorPalette::TertiaryLight]];}
.tabContents .button {border:0;}

#sidebar {}
#sidebarOptions input {border:1px solid [[ColorPalette::PrimaryMid]];}
#sidebarOptions .sliderPanel {background:[[ColorPalette::PrimaryPale]];}
#sidebarOptions .sliderPanel a {border:none;color:[[ColorPalette::PrimaryMid]];}
#sidebarOptions .sliderPanel a:hover {color:[[ColorPalette::Background]]; background:[[ColorPalette::PrimaryMid]];}
#sidebarOptions .sliderPanel a:active {color:[[ColorPalette::PrimaryMid]]; background:[[ColorPalette::Background]];}

.wizard {background:[[ColorPalette::PrimaryPale]]; border:1px solid [[ColorPalette::PrimaryMid]];}
.wizard h1 {color:[[ColorPalette::PrimaryDark]]; border:none;}
.wizard h2 {color:[[ColorPalette::Foreground]]; border:none;}
.wizardStep {background:[[ColorPalette::Background]]; color:[[ColorPalette::Foreground]];
	border:1px solid [[ColorPalette::PrimaryMid]];}
.wizardStep.wizardStepDone {background:[[ColorPalette::TertiaryLight]];}
.wizardFooter {background:[[ColorPalette::PrimaryPale]];}
.wizardFooter .status {background:[[ColorPalette::PrimaryDark]]; color:[[ColorPalette::Background]];}
.wizard .button {color:[[ColorPalette::Foreground]]; background:[[ColorPalette::SecondaryLight]]; border: 1px solid;
	border-color:[[ColorPalette::SecondaryPale]] [[ColorPalette::SecondaryDark]] [[ColorPalette::SecondaryDark]] [[ColorPalette::SecondaryPale]];}
.wizard .button:hover {color:[[ColorPalette::Foreground]]; background:[[ColorPalette::Background]];}
.wizard .button:active {color:[[ColorPalette::Background]]; background:[[ColorPalette::Foreground]]; border: 1px solid;
	border-color:[[ColorPalette::PrimaryDark]] [[ColorPalette::PrimaryPale]] [[ColorPalette::PrimaryPale]] [[ColorPalette::PrimaryDark]];}
	
.wizard .notChanged {background:transparent;}
.wizard .changedLocally {background:#80ff80;}
.wizard .changedServer {background:#8080ff;}
.wizard .changedBoth {background:#ff8080;}
.wizard .notFound {background:#ffff80;}
.wizard .putToServer {background:#ff80ff;}
.wizard .gotFromServer {background:#80ffff;}

#messageArea {border:1px solid [[ColorPalette::SecondaryMid]]; background:[[ColorPalette::SecondaryLight]]; color:[[ColorPalette::Foreground]];}
#messageArea .button {color:[[ColorPalette::PrimaryMid]]; background:[[ColorPalette::SecondaryPale]]; border:none;}

.popupTiddler {background:[[ColorPalette::TertiaryPale]]; border:2px solid [[ColorPalette::TertiaryMid]];}

.popup {background:[[ColorPalette::TertiaryPale]]; color:[[ColorPalette::TertiaryDark]]; border-left:1px solid [[ColorPalette::TertiaryMid]]; border-top:1px solid [[ColorPalette::TertiaryMid]]; border-right:2px solid [[ColorPalette::TertiaryDark]]; border-bottom:2px solid [[ColorPalette::TertiaryDark]];}
.popup hr {color:[[ColorPalette::PrimaryDark]]; background:[[ColorPalette::PrimaryDark]]; border-bottom:1px;}
.popup li.disabled {color:[[ColorPalette::TertiaryMid]];}
.popup li a, .popup li a:visited {color:[[ColorPalette::Foreground]]; border: none;}
.popup li a:hover {background:[[ColorPalette::SecondaryLight]]; color:[[ColorPalette::Foreground]]; border: none;}
.popup li a:active {background:[[ColorPalette::SecondaryPale]]; color:[[ColorPalette::Foreground]]; border: none;}
.popupHighlight {background:[[ColorPalette::Background]]; color:[[ColorPalette::Foreground]];}
.listBreak div {border-bottom:1px solid [[ColorPalette::TertiaryDark]];}

.tiddler .defaultCommand {font-weight:bold;}

.shadow .title {color:[[ColorPalette::TertiaryDark]];}

.title {color:[[ColorPalette::SecondaryDark]];}
.subtitle {color:[[ColorPalette::TertiaryDark]];}

.toolbar {color:[[ColorPalette::PrimaryMid]];}
.toolbar a {color:[[ColorPalette::TertiaryLight]];}
.selected .toolbar a {color:[[ColorPalette::TertiaryMid]];}
.selected .toolbar a:hover {color:[[ColorPalette::Foreground]];}

.tagging, .tagged {border:1px solid [[ColorPalette::TertiaryPale]]; background-color:[[ColorPalette::TertiaryPale]];}
.selected .tagging, .selected .tagged {background-color:[[ColorPalette::TertiaryLight]]; border:1px solid [[ColorPalette::TertiaryMid]];}
.tagging .listTitle, .tagged .listTitle {color:[[ColorPalette::PrimaryDark]];}
.tagging .button, .tagged .button {border:none;}

.footer {color:[[ColorPalette::TertiaryLight]];}
.selected .footer {color:[[ColorPalette::TertiaryMid]];}

.sparkline {background:[[ColorPalette::PrimaryPale]]; border:0;}
.sparktick {background:[[ColorPalette::PrimaryDark]];}

.error, .errorButton {color:[[ColorPalette::Foreground]]; background:[[ColorPalette::Error]];}
.warning {color:[[ColorPalette::Foreground]]; background:[[ColorPalette::SecondaryPale]];}
.lowlight {background:[[ColorPalette::TertiaryLight]];}

.zoomer {background:none; color:[[ColorPalette::TertiaryMid]]; border:3px solid [[ColorPalette::TertiaryMid]];}

.imageLink, #displayArea .imageLink {background:transparent;}

.annotation {background:[[ColorPalette::SecondaryLight]]; color:[[ColorPalette::Foreground]]; border:2px solid [[ColorPalette::SecondaryMid]];}

.viewer .listTitle {list-style-type:none; margin-left:-2em;}
.viewer .button {border:1px solid [[ColorPalette::SecondaryMid]];}
.viewer blockquote {border-left:3px solid [[ColorPalette::TertiaryDark]];}

.viewer table, table.twtable {border:2px solid [[ColorPalette::TertiaryDark]];}
.viewer th, .viewer thead td, .twtable th, .twtable thead td {background:[[ColorPalette::SecondaryMid]]; border:1px solid [[ColorPalette::TertiaryDark]]; color:[[ColorPalette::Background]];}
.viewer td, .viewer tr, .twtable td, .twtable tr {border:1px solid [[ColorPalette::TertiaryDark]];}

.viewer pre {border:1px solid [[ColorPalette::SecondaryLight]]; background:[[ColorPalette::SecondaryPale]];}
.viewer code {color:[[ColorPalette::SecondaryDark]];}
.viewer hr {border:0; border-top:dashed 1px [[ColorPalette::TertiaryDark]]; color:[[ColorPalette::TertiaryDark]];}

.highlight, .marked {background:[[ColorPalette::SecondaryLight]];}

.editor input {border:1px solid [[ColorPalette::PrimaryMid]];}
.editor textarea {border:1px solid [[ColorPalette::PrimaryMid]]; width:100%;}
.editorFooter {color:[[ColorPalette::TertiaryMid]];}

#backstageArea {background:[[ColorPalette::Foreground]]; color:[[ColorPalette::TertiaryMid]];}
#backstageArea a {background:[[ColorPalette::Foreground]]; color:[[ColorPalette::Background]]; border:none;}
#backstageArea a:hover {background:[[ColorPalette::SecondaryLight]]; color:[[ColorPalette::Foreground]]; }
#backstageArea a.backstageSelTab {background:[[ColorPalette::Background]]; color:[[ColorPalette::Foreground]];}
#backstageButton a {background:none; color:[[ColorPalette::Background]]; border:none;}
#backstageButton a:hover {background:[[ColorPalette::Foreground]]; color:[[ColorPalette::Background]]; border:none;}
#backstagePanel {background:[[ColorPalette::Background]]; border-color: [[ColorPalette::Background]] [[ColorPalette::TertiaryDark]] [[ColorPalette::TertiaryDark]] [[ColorPalette::TertiaryDark]];}
.backstagePanelFooter .button {border:none; color:[[ColorPalette::Background]];}
.backstagePanelFooter .button:hover {color:[[ColorPalette::Foreground]];}
#backstageCloak {background:[[ColorPalette::Foreground]]; opacity:0.6; filter:'alpha(opacity:60)';}
/*}}}*/
/*{{{*/
* html .tiddler {height:1%;}

body {font-size:.75em; font-family:arial,helvetica; margin:0; padding:0;}

h1,h2,h3,h4,h5,h6 {font-weight:bold; text-decoration:none;}
h1,h2,h3 {padding-bottom:1px; margin-top:1.2em;margin-bottom:0.3em;}
h4,h5,h6 {margin-top:1em;}
h1 {font-size:1.35em;}
h2 {font-size:1.25em;}
h3 {font-size:1.1em;}
h4 {font-size:1em;}
h5 {font-size:.9em;}

hr {height:1px;}

a {text-decoration:none;}

dt {font-weight:bold;}

ol {list-style-type:decimal;}
ol ol {list-style-type:lower-alpha;}
ol ol ol {list-style-type:lower-roman;}
ol ol ol ol {list-style-type:decimal;}
ol ol ol ol ol {list-style-type:lower-alpha;}
ol ol ol ol ol ol {list-style-type:lower-roman;}
ol ol ol ol ol ol ol {list-style-type:decimal;}

.txtOptionInput {width:11em;}

#contentWrapper .chkOptionInput {border:0;}

.externalLink {text-decoration:underline;}

.indent {margin-left:3em;}
.outdent {margin-left:3em; text-indent:-3em;}
code.escaped {white-space:nowrap;}

.tiddlyLinkExisting {font-weight:bold;}
.tiddlyLinkNonExisting {font-style:italic;}

/* the 'a' is required for IE, otherwise it renders the whole tiddler in bold */
a.tiddlyLinkNonExisting.shadow {font-weight:bold;}

#mainMenu .tiddlyLinkExisting,
	#mainMenu .tiddlyLinkNonExisting,
	#sidebarTabs .tiddlyLinkNonExisting {font-weight:normal; font-style:normal;}
#sidebarTabs .tiddlyLinkExisting {font-weight:bold; font-style:normal;}

.header {position:relative;}
.header a:hover {background:transparent;}
.headerShadow {position:relative; padding:4.5em 0em 1em 1em; left:-1px; top:-1px;}
.headerForeground {position:absolute; padding:4.5em 0em 1em 1em; left:0px; top:0px;}

.siteTitle {font-size:3em;}
.siteSubtitle {font-size:1.2em;}

#mainMenu {position:absolute; left:0; width:10em; text-align:right; line-height:1.6em; padding:1.5em 0.5em 0.5em 0.5em; font-size:1.1em;}

#sidebar {position:absolute; right:3px; width:16em; font-size:.9em;}
#sidebarOptions {padding-top:0.3em;}
#sidebarOptions a {margin:0em 0.2em; padding:0.2em 0.3em; display:block;}
#sidebarOptions input {margin:0.4em 0.5em;}
#sidebarOptions .sliderPanel {margin-left:1em; padding:0.5em; font-size:.85em;}
#sidebarOptions .sliderPanel a {font-weight:bold; display:inline; padding:0;}
#sidebarOptions .sliderPanel input {margin:0 0 .3em 0;}
#sidebarTabs .tabContents {width:15em; overflow:hidden;}

.wizard {padding:0.1em 1em 0em 2em;}
.wizard h1 {font-size:2em; font-weight:bold; background:none; padding:0em 0em 0em 0em; margin:0.4em 0em 0.2em 0em;}
.wizard h2 {font-size:1.2em; font-weight:bold; background:none; padding:0em 0em 0em 0em; margin:0.4em 0em 0.2em 0em;}
.wizardStep {padding:1em 1em 1em 1em;}
.wizard .button {margin:0.5em 0em 0em 0em; font-size:1.2em;}
.wizardFooter {padding:0.8em 0.4em 0.8em 0em;}
.wizardFooter .status {padding:0em 0.4em 0em 0.4em; margin-left:1em;}
.wizard .button {padding:0.1em 0.2em 0.1em 0.2em;}

#messageArea {position:fixed; top:2em; right:0em; margin:0.5em; padding:0.5em; z-index:2000; _position:absolute;}
.messageToolbar {display:block; text-align:right; padding:0.2em 0.2em 0.2em 0.2em;}
#messageArea a {text-decoration:underline;}

.tiddlerPopupButton {padding:0.2em 0.2em 0.2em 0.2em;}
.popupTiddler {position: absolute; z-index:300; padding:1em 1em 1em 1em; margin:0;}

.popup {position:absolute; z-index:300; font-size:.9em; padding:0; list-style:none; margin:0;}
.popup .popupMessage {padding:0.4em;}
.popup hr {display:block; height:1px; width:auto; padding:0; margin:0.2em 0em;}
.popup li.disabled {padding:0.4em;}
.popup li a {display:block; padding:0.4em; font-weight:normal; cursor:pointer;}
.listBreak {font-size:1px; line-height:1px;}
.listBreak div {margin:2px 0;}

.tabset {padding:1em 0em 0em 0.5em;}
.tab {margin:0em 0em 0em 0.25em; padding:2px;}
.tabContents {padding:0.5em;}
.tabContents ul, .tabContents ol {margin:0; padding:0;}
.txtMainTab .tabContents li {list-style:none;}
.tabContents li.listLink { margin-left:.75em;}

#contentWrapper {display:block;}
#splashScreen {display:none;}

#displayArea {margin:1em 17em 0em 14em;}

.toolbar {text-align:right; font-size:.9em;}

.tiddler {padding:1em 1em 0em 1em;}

.missing .viewer,.missing .title {font-style:italic;}

.title {font-size:1.6em; font-weight:bold;}

.missing .subtitle {display:none;}
.subtitle {font-size:1.1em;}

.tiddler .button {padding:0.2em 0.4em;}

.tagging {margin:0.5em 0.5em 0.5em 0; float:left; display:none;}
.isTag .tagging {display:block;}
.tagged {margin:0.5em; float:right;}
.tagging, .tagged {font-size:0.9em; padding:0.25em;}
.tagging ul, .tagged ul {list-style:none; margin:0.25em; padding:0;}
.tagClear {clear:both;}

.footer {font-size:.9em;}
.footer li {display:inline;}

.annotation {padding:0.5em; margin:0.5em;}

* html .viewer pre {width:99%; padding:0 0 1em 0;}
.viewer {line-height:1.4em; padding-top:0.5em;}
.viewer .button {margin:0em 0.25em; padding:0em 0.25em;}
.viewer blockquote {line-height:1.5em; padding-left:0.8em;margin-left:2.5em;}
.viewer ul, .viewer ol {margin-left:0.5em; padding-left:1.5em;}

.viewer table, table.twtable {border-collapse:collapse; margin:0.8em 1.0em;}
.viewer th, .viewer td, .viewer tr,.viewer caption,.twtable th, .twtable td, .twtable tr,.twtable caption {padding:3px;}
table.listView {font-size:0.85em; margin:0.8em 1.0em;}
table.listView th, table.listView td, table.listView tr {padding:0px 3px 0px 3px;}

.viewer pre {padding:0.5em; margin-left:0.5em; font-size:1.2em; line-height:1.4em; overflow:auto;}
.viewer code {font-size:1.2em; line-height:1.4em;}

.editor {font-size:1.1em;}
.editor input, .editor textarea {display:block; width:100%; font:inherit;}
.editorFooter {padding:0.25em 0em; font-size:.9em;}
.editorFooter .button {padding-top:0px; padding-bottom:0px;}

.fieldsetFix {border:0; padding:0; margin:1px 0px 1px 0px;}

.sparkline {line-height:1em;}
.sparktick {outline:0;}

.zoomer {font-size:1.1em; position:absolute; overflow:hidden;}
.zoomer div {padding:1em;}

* html #backstage {width:99%;}
* html #backstageArea {width:99%;}
#backstageArea {display:none; position:relative; overflow: hidden; z-index:150; padding:0.3em 0.5em 0.3em 0.5em;}
#backstageToolbar {position:relative;}
#backstageArea a {font-weight:bold; margin-left:0.5em; padding:0.3em 0.5em 0.3em 0.5em;}
#backstageButton {display:none; position:absolute; z-index:175; top:0em; right:0em;}
#backstageButton a {padding:0.1em 0.4em 0.1em 0.4em; margin:0.1em 0.1em 0.1em 0.1em;}
#backstage {position:relative; width:100%; z-index:50;}
#backstagePanel {display:none; z-index:100; position:absolute; width:90%; margin:0em 3em 0em 3em; padding:1em 1em 1em 1em;}
.backstagePanelFooter {padding-top:0.2em; float:right;}
.backstagePanelFooter a {padding:0.2em 0.4em 0.2em 0.4em;}
#backstageCloak {display:none; z-index:20; position:absolute; width:100%; height:100px;}

.whenBackstage {display:none;}
.backstageVisible .whenBackstage {display:block;}
/*}}}*/
/***
StyleSheet for use when a translation requires any css style changes.
This StyleSheet can be used directly by languages such as Chinese, Japanese and Korean which need larger font sizes.
***/
/*{{{*/
body {font-size:0.8em;}
#sidebarOptions {font-size:1.05em;}
#sidebarOptions a {font-style:normal;}
#sidebarOptions .sliderPanel {font-size:0.95em;}
.subtitle {font-size:0.8em;}
.viewer table.listView {font-size:0.95em;}
/*}}}*/
/*{{{*/
@media print {
#mainMenu, #sidebar, #messageArea, .toolbar, #backstageButton, #backstageArea {display: none ! important;}
#displayArea {margin: 1em 1em 0em 1em;}
/* Fixes a feature in Firefox 1.5.0.2 where print preview displays the noscript content */
noscript {display:none;}
}
/*}}}*/
<!--{{{-->
<div class='header' macro='gradient vert [[ColorPalette::PrimaryLight]] [[ColorPalette::PrimaryMid]]'>
<div class='headerShadow'>
<span class='siteTitle' refresh='content' tiddler='SiteTitle'></span>&nbsp;
<span class='siteSubtitle' refresh='content' tiddler='SiteSubtitle'></span>
</div>
<div class='headerForeground'>
<span class='siteTitle' refresh='content' tiddler='SiteTitle'></span>&nbsp;
<span class='siteSubtitle' refresh='content' tiddler='SiteSubtitle'></span>
</div>
</div>
<div id='mainMenu' refresh='content' tiddler='MainMenu'></div>
<div id='sidebar'>
<div id='sidebarOptions' refresh='content' tiddler='SideBarOptions'></div>
<div id='sidebarTabs' refresh='content' force='true' tiddler='SideBarTabs'></div>
</div>
<div id='displayArea'>
<div id='messageArea'></div>
<div id='tiddlerDisplay'></div>
</div>
<!--}}}-->
<!--{{{-->
<div class='toolbar' macro='toolbar [[ToolbarCommands::ViewToolbar]]'></div>
<div class='title' macro='view title'></div>
<div class='subtitle'><span macro='view modifier link'></span>, <span macro='view modified date'></span> (<span macro='message views.wikified.createdPrompt'></span> <span macro='view created date'></span>)</div>
<div class='tagging' macro='tagging'></div>
<div class='tagged' macro='tags'></div>
<div class='viewer' macro='view text wikified'></div>
<div class='tagClear'></div>
<!--}}}-->
<!--{{{-->
<div class='toolbar' macro='toolbar [[ToolbarCommands::EditToolbar]]'></div>
<div class='title' macro='view title'></div>
<div class='editor' macro='edit title'></div>
<div macro='annotations'></div>
<div class='editor' macro='edit text'></div>
<div class='editor' macro='edit tags'></div><div class='editorFooter'><span macro='message views.editor.tagPrompt'></span><span macro='tagChooser'></span></div>
<!--}}}-->
To get started with this blank TiddlyWiki, you'll need to modify the following tiddlers:
* SiteTitle & SiteSubtitle: The title and subtitle of the site, as shown above (after saving, they will also appear in the browser title bar)
* MainMenu: The menu (usually on the left)
* DefaultTiddlers: Contains the names of the tiddlers that you want to appear when the TiddlyWiki is opened
You'll also need to enter your username for signing your edits: <<option txtUserName>>
These InterfaceOptions for customising TiddlyWiki are saved in your browser

Your username for signing your edits. Write it as a WikiWord (eg JoeBloggs)

<<option txtUserName>>
<<option chkSaveBackups>> SaveBackups
<<option chkAutoSave>> AutoSave
<<option chkRegExpSearch>> RegExpSearch
<<option chkCaseSensitiveSearch>> CaseSensitiveSearch
<<option chkAnimate>> EnableAnimations

----
Also see AdvancedOptions
<<importTiddlers>>
Source: http://www.ficml.org/jemimap/style/color/wheel.html 
<html><iframe name="content" src="http://www.ficml.org/jemimap/style/color/wheel.html" width=100% height=600></iframe></html>
| Agenda 2009 |c
|>|>|>|>|>|>| !January |!|>|>|>|>|>|>| !February |
| Sun | Mon | Tue | Wed | Thu | Fri | Sat |!| Sun | Mon | Tue | Wed | Thu | Fri | Sat |
|>|>|>|!| 1 | 2 |bgcolor(#DEDEAD): 3 |!|bgcolor(#DEDEAD): 1 | 2 | 3 | 4 | 5 | 6 |bgcolor(#DEDEAD): 7 |
|bgcolor(#DEDEAD): 4 | 5 | 6 | 7 | 8 | 9 |bgcolor(#DEDEAD): 10 |!|bgcolor(#DEDEAD): 8 | 9 | 10 | 11 | 12 | 13 |bgcolor(#DEDEAD): 14 |
|bgcolor(#DEDEAD): 11 | 12 | 13 | 14 | 15 | 16 |bgcolor(#DEDEAD): 17 |!|bgcolor(#DEDEAD): 15 | 16 | 17 | 18 | 19 | 20 |bgcolor(#DEDEAD): 21 |
|bgcolor(#DEDEAD): 18 | 19 | 20 | 21 | 22 | 23 |bgcolor(#DEDEAD): 24 |!|bgcolor(#DEDEAD): 22 | 23 | 24 | 25 | 26 | 27 |bgcolor(#DEDEAD): 28 |
|bgcolor(#DEDEAD): 25 | 26 | 27 | 28 | 29 | 30 |bgcolor(#DEDEAD): 31 |!|>|>|>|>|>|>|>|!|
|>|>|>|>|>|>| !March |!|>|>|>|>|>|>| !April |
| Sun | Mon | Tue | Wed | Thu | Fri | Sat |!| Sun | Mon | Tue | Wed | Thu | Fri | Sat |
|bgcolor(#DEDEAD): 1 | 2 | 3 | 4 | 5 | 6 |bgcolor(#DEDEAD): 7 |!|>|>|!| 1 | 2 | 3 |bgcolor(#DEDEAD): 4 |
|bgcolor(#DEDEAD): 8 | 9 | 10 | 11 | 12 | 13 |bgcolor(#DEDEAD): 14 |!|bgcolor(#DEDEAD): 5 | 6 | 7 | 8 | 9 | 10 |bgcolor(#DEDEAD): 11 |
|bgcolor(#DEDEAD): 15 | 16 | 17 | 18 | 19 | 20 |bgcolor(#DEDEAD): 21 |!|bgcolor(#DEDEAD): 12 | 13 | 14 | 15 | 16 | 17 |bgcolor(#DEDEAD): 18 |
|bgcolor(#DEDEAD): 22 | 23 | 24 | 25 | 26 | 27 |bgcolor(#DEDEAD): 28 |!|bgcolor(#DEDEAD): 19 | 20 | 21 | 22 | 23 | 24 |bgcolor(#DEDEAD): 25 |
|bgcolor(#DEDEAD): 29 | 30 | 31 |>|>|>|!|!|bgcolor(#DEDEAD): 26 | 27 | 28 | 29 | 30 |>|!|
|>|>|>|>|>|>| !May |!|>|>|>|>|>|>| !June |
| Sun | Mon | Tue | Wed | Thu | Fri | Sat |!| Sun | Mon | Tue | Wed | Thu | Fri | Sat |
|>|>|>|>|!| 1 |bgcolor(#DEDEAD): 2 |!|!| 1 | 2 | 3 | 4 | 5 |bgcolor(#DEDEAD): 6 |
|bgcolor(#DEDEAD): 3 | 4 | 5 | 6 | 7 | 8 |bgcolor(#DEDEAD): 9 |!|bgcolor(#DEDEAD): 7 | 8 | 9 | 10 | 11 | 12 |bgcolor(#DEDEAD): 13 |
|bgcolor(#DEDEAD): 10 | 11 | 12 | 13 | 14 | 15 |bgcolor(#DEDEAD): 16 |!|bgcolor(#DEDEAD): 14 | 15 | 16 | 17 | 18 | 19 |bgcolor(#DEDEAD): 20 |
|bgcolor(#DEDEAD): 17 | 18 | 19 | 20 | 21 | 22 |bgcolor(#DEDEAD): 23 |!|bgcolor(#DEDEAD): 21 | 22 | 23 | 24 | 25 | 26 |bgcolor(#DEDEAD): 27 |
|bgcolor(#DEDEAD): 24 | 25 | 26 | 27 | 28 | 29 |bgcolor(#DEDEAD): 30 |!|bgcolor(#DEDEAD): 28 | 29 | 30 |>|>|>|!|
|bgcolor(#DEDEAD): 31 |>|>|>|>|>|!|!|>|>|>|>|>|>|>|!|
|>|>|>|>|>|>| !July |!|>|>|>|>|>|>| !August |
| Sun | Mon | Tue | Wed | Thu | Fri | Sat |!| Sun | Mon | Tue | Wed | Thu | Fri | Sat |
|>|>|!| 1 | 2 | 3 |bgcolor(#DEDEAD): 4 |!|>|>|>|>|>|!|bgcolor(#DEDEAD): 1 |
|bgcolor(#DEDEAD): 5 | 6 | 7 | 8 | 9 | 10 |bgcolor(#DEDEAD): 11 |!|bgcolor(#DEDEAD): 2 | 3 | 4 | 5 | 6 | 7 |bgcolor(#DEDEAD): 8 |
|bgcolor(#DEDEAD): 12 | 13 | 14 | 15 | 16 | 17 |bgcolor(#DEDEAD): 18 |!|bgcolor(#DEDEAD): 9 | 10 | 11 | 12 | 13 | 14 |bgcolor(#DEDEAD): 15 |
|bgcolor(#DEDEAD): 19 | 20 | 21 | 22 | 23 | 24 |bgcolor(#DEDEAD): 25 |!|bgcolor(#DEDEAD): 16 | 17 | 18 | 19 | 20 | 21 |bgcolor(#DEDEAD): 22 |
|bgcolor(#DEDEAD): 26 | 27 | 28 | 29 | 30 | 31 |!|!|bgcolor(#DEDEAD): 23 | 24 | 25 | 26 | 27 | 28 |bgcolor(#DEDEAD): 29 |
|>|>|>|>|>|>|>|!|!|bgcolor(#DEDEAD): 30 | 31 |>|>|>|>|!|
|>|>|>|>|>|>| !September |!|>|>|>|>|>|>| !October |
| Sun | Mon | Tue | Wed | Thu | Fri | Sat |!| Sun | Mon | Tue | Wed | Thu | Fri | Sat |
|>|!| 1 | 2 | 3 | 4 |bgcolor(#DEDEAD): 5 |!|>|>|>|!| 1 | 2 |bgcolor(#DEDEAD): 3 |
|bgcolor(#DEDEAD): 6 | 7 | 8 | 9 | 10 | 11 |bgcolor(#DEDEAD): 12 |!|bgcolor(#DEDEAD): 4 | 5 | 6 | 7 | 8 | 9 |bgcolor(#DEDEAD): 10 |
|bgcolor(#DEDEAD): 13 | 14 | 15 | 16 | 17 | 18 |bgcolor(#DEDEAD): 19 |!|bgcolor(#DEDEAD): 11 | 12 | 13 | 14 | 15 | 16 |bgcolor(#DEDEAD): 17 |
|bgcolor(#DEDEAD): 20 | 21 | 22 | 23 | 24 | 25 |bgcolor(#DEDEAD): 26 |!|bgcolor(#DEDEAD): 18 | 19 | 20 | 21 | 22 | 23 |bgcolor(#DEDEAD): 24 |
|bgcolor(#DEDEAD): 27 | 28 | 29 | 30 |>|>|!|!|bgcolor(#DEDEAD): 25 | 26 | 27 | 28 | 29 | 30 |bgcolor(#DEDEAD): 31 |
|>|>|>|>|>|>| !November |!|>|>|>|>|>|>| !December |
| Sun | Mon | Tue | Wed | Thu | Fri | Sat |!| Sun | Mon | Tue | Wed | Thu | Fri | Sat |
|bgcolor(#DEDEAD): 1 | 2 | 3 | 4 | 5 | 6 |bgcolor(#DEDEAD): 7 |!|>|!| 1 | 2 | 3 | 4 |bgcolor(#DEDEAD): 5 |
|bgcolor(#DEDEAD): 8 | 9 | 10 | 11 | 12 | 13 |bgcolor(#DEDEAD): 14 |!|bgcolor(#DEDEAD): 6 | 7 | 8 | 9 | 10 | 11 |bgcolor(#DEDEAD): 12 |
|bgcolor(#DEDEAD): 15 | 16 | 17 | 18 | 19 | 20 |bgcolor(#DEDEAD): 21 |!|bgcolor(#DEDEAD): 13 | 14 | 15 | 16 | 17 | 18 |bgcolor(#DEDEAD): 19 |
|bgcolor(#DEDEAD): 22 | 23 | 24 | 25 | 26 | 27 |bgcolor(#DEDEAD): 28 |!|bgcolor(#DEDEAD): 20 | 21 | 22 | 23 | 24 | 25 |bgcolor(#DEDEAD): 26 |
|bgcolor(#DEDEAD): 29 | 30 |>|>|>|>|!|!|bgcolor(#DEDEAD): 27 | 28 | 29 | 30 | 31 |>|!|
| Agenda 2010 |c
|>|>|>|>|>|>| !January |!|>|>|>|>|>|>| !February |
| Sun | Mon | Tue | Wed | Thu | Fri | Sat |!| Sun | Mon | Tue | Wed | Thu | Fri | Sat |
|>|>|>|>|!| 1 |bgcolor(#DEDEAD): 2 |!|!| 1 | 2 | 3 | 4 | 5 |bgcolor(#DEDEAD): 6 |
|bgcolor(#DEDEAD): 3 | 4 | 5 | 6 | 7 | 8 |bgcolor(#DEDEAD): 9 |!|bgcolor(#DEDEAD): 7 | 8 | 9 | 10 | 11 | 12 |bgcolor(#DEDEAD): 13 |
|bgcolor(#DEDEAD): 10 | 11 | 12 | 13 | 14 | 15 |bgcolor(#DEDEAD): 16 |!|bgcolor(#DEDEAD): 14 | 15 | 16 | 17 | 18 | 19 |bgcolor(#DEDEAD): 20 |
|bgcolor(#DEDEAD): 17 | 18 | 19 | 20 | 21 | 22 |bgcolor(#DEDEAD): 23 |!|bgcolor(#DEDEAD): 21 | 22 | 23 | 24 | 25 | 26 |bgcolor(#DEDEAD): 27 |
|bgcolor(#DEDEAD): 24 | 25 | 26 | 27 | 28 | 29 |bgcolor(#DEDEAD): 30 |!|bgcolor(#DEDEAD): 28 |>|>|>|>|>|!|
|bgcolor(#DEDEAD): 31 |>|>|>|>|>|!|!|>|>|>|>|>|>|>|!|
|>|>|>|>|>|>| !March |!|>|>|>|>|>|>| !April |
| Sun | Mon | Tue | Wed | Thu | Fri | Sat |!| Sun | Mon | Tue | Wed | Thu | Fri | Sat |
|!| 1 | 2 | 3 | 4 | 5 |bgcolor(#DEDEAD): 6 |!|>|>|>|!| 1 | 2 |bgcolor(#DEDEAD): 3 |
|bgcolor(#DEDEAD): 7 | 8 | 9 | 10 | 11 | 12 |bgcolor(#DEDEAD): 13 |!|bgcolor(#DEDEAD): 4 | 5 | 6 | 7 | 8 | 9 |bgcolor(#DEDEAD): 10 |
|bgcolor(#DEDEAD): 14 | 15 | 16 | 17 | 18 | 19 |bgcolor(#DEDEAD): 20 |!|bgcolor(#DEDEAD): 11 | 12 | 13 | 14 | 15 | 16 |bgcolor(#DEDEAD): 17 |
|bgcolor(#DEDEAD): 21 | 22 | 23 | 24 | 25 | 26 |bgcolor(#DEDEAD): 27 |!|bgcolor(#DEDEAD): 18 | 19 | 20 | 21 | 22 | 23 |bgcolor(#DEDEAD): 24 |
|bgcolor(#DEDEAD): 28 | 29 | 30 | 31 |>|>|!|!|bgcolor(#DEDEAD): 25 | 26 | 27 | 28 | 29 | 30 |!|
|>|>|>|>|>|>| !May |!|>|>|>|>|>|>| !June |
| Sun | Mon | Tue | Wed | Thu | Fri | Sat |!| Sun | Mon | Tue | Wed | Thu | Fri | Sat |
|>|>|>|>|>|!|bgcolor(#DEDEAD): 1 |!|>|!| 1 | 2 | 3 | 4 |bgcolor(#DEDEAD): 5 |
|bgcolor(#DEDEAD): 2 | 3 | 4 | 5 | 6 | 7 |bgcolor(#DEDEAD): 8 |!|bgcolor(#DEDEAD): 6 | 7 | 8 | 9 | 10 | 11 |bgcolor(#DEDEAD): 12 |
|bgcolor(#DEDEAD): 9 | 10 | 11 | 12 | 13 | 14 |bgcolor(#DEDEAD): 15 |!|bgcolor(#DEDEAD): 13 | 14 | 15 | 16 | 17 | 18 |bgcolor(#DEDEAD): 19 |
|bgcolor(#DEDEAD): 16 | 17 | 18 | 19 | 20 | 21 |bgcolor(#DEDEAD): 22 |!|bgcolor(#DEDEAD): 20 | 21 | 22 | 23 | 24 | 25 |bgcolor(#DEDEAD): 26 |
|bgcolor(#DEDEAD): 23 | 24 | 25 | 26 | 27 | 28 |bgcolor(#DEDEAD): 29 |!|bgcolor(#DEDEAD): 27 | 28 | 29 | 30 |>|>|!|
|bgcolor(#DEDEAD): 30 | 31 |>|>|>|>|!|!|>|>|>|>|>|>|>|!|
|>|>|>|>|>|>| !July |!|>|>|>|>|>|>| !August |
| Sun | Mon | Tue | Wed | Thu | Fri | Sat |!| Sun | Mon | Tue | Wed | Thu | Fri | Sat |
|>|>|>|!| 1 | 2 |bgcolor(#DEDEAD): 3 |!|bgcolor(#DEDEAD): 1 | 2 | 3 | 4 | 5 | 6 |bgcolor(#DEDEAD): 7 |
|bgcolor(#DEDEAD): 4 | 5 | 6 | 7 | 8 | 9 |bgcolor(#DEDEAD): 10 |!|bgcolor(#DEDEAD): 8 | 9 | 10 | 11 | 12 | 13 |bgcolor(#DEDEAD): 14 |
|bgcolor(#DEDEAD): 11 | 12 | 13 | 14 | 15 | 16 |bgcolor(#DEDEAD): 17 |!|bgcolor(#DEDEAD): 15 | 16 | 17 | 18 | 19 | 20 |bgcolor(#DEDEAD): 21 |
|bgcolor(#DEDEAD): 18 | 19 | 20 | 21 | 22 | 23 |bgcolor(#DEDEAD): 24 |!|bgcolor(#DEDEAD): 22 | 23 | 24 | 25 | 26 | 27 |bgcolor(#DEDEAD): 28 |
|bgcolor(#DEDEAD): 25 | 26 | 27 | 28 | 29 | 30 |bgcolor(#DEDEAD): 31 |!|bgcolor(#DEDEAD): 29 | 30 | 31 |>|>|>|!|
|>|>|>|>|>|>| !September |!|>|>|>|>|>|>| !October |
| Sun | Mon | Tue | Wed | Thu | Fri | Sat |!| Sun | Mon | Tue | Wed | Thu | Fri | Sat |
|>|>|!| 1 | 2 | 3 |bgcolor(#DEDEAD): 4 |!|>|>|>|>|!| 1 |bgcolor(#DEDEAD): 2 |
|bgcolor(#DEDEAD): 5 | 6 | 7 | 8 | 9 | 10 |bgcolor(#DEDEAD): 11 |!|bgcolor(#DEDEAD): 3 | 4 | 5 | 6 | 7 | 8 |bgcolor(#DEDEAD): 9 |
|bgcolor(#DEDEAD): 12 | 13 | 14 | 15 | 16 | 17 |bgcolor(#DEDEAD): 18 |!|bgcolor(#DEDEAD): 10 | 11 | 12 | 13 | 14 | 15 |bgcolor(#DEDEAD): 16 |
|bgcolor(#DEDEAD): 19 | 20 | 21 | 22 | 23 | 24 |bgcolor(#DEDEAD): 25 |!|bgcolor(#DEDEAD): 17 | 18 | 19 | 20 | 21 | 22 |bgcolor(#DEDEAD): 23 |
|bgcolor(#DEDEAD): 26 | 27 | 28 | 29 | 30 |>|!|!|bgcolor(#DEDEAD): 24 | 25 | 26 | 27 | 28 | 29 |bgcolor(#DEDEAD): 30 |
|>|>|>|>|>|>|>|!|!|bgcolor(#DEDEAD): 31 |>|>|>|>|>|!|
|>|>|>|>|>|>| !November |!|>|>|>|>|>|>| !December |
| Sun | Mon | Tue | Wed | Thu | Fri | Sat |!| Sun | Mon | Tue | Wed | Thu | Fri | Sat |
|!| 1 | 2 | 3 | 4 | 5 |bgcolor(#DEDEAD): 6 |!|>|>|!| 1 | 2 | 3 |bgcolor(#DEDEAD): 4 |
|bgcolor(#DEDEAD): 7 | 8 | 9 | 10 | 11 | 12 |bgcolor(#DEDEAD): 13 |!|bgcolor(#DEDEAD): 5 | 6 | 7 | 8 | 9 | 10 |bgcolor(#DEDEAD): 11 |
|bgcolor(#DEDEAD): 14 | 15 | 16 | 17 | 18 | 19 |bgcolor(#DEDEAD): 20 |!|bgcolor(#DEDEAD): 12 | 13 | 14 | 15 | 16 | 17 |bgcolor(#DEDEAD): 18 |
|bgcolor(#DEDEAD): 21 | 22 | 23 | 24 | 25 | 26 |bgcolor(#DEDEAD): 27 |!|bgcolor(#DEDEAD): 19 | 20 | 21 | 22 | 23 | 24 |bgcolor(#DEDEAD): 25 |
|bgcolor(#DEDEAD): 28 | 29 | 30 |>|>|>|!|!|bgcolor(#DEDEAD): 26 | 27 | 28 | 29 | 30 | 31 |!|
| Agenda 2011 |c
|>|>|>|>|>|>| !January |!|>|>|>|>|>|>| !February |
| Sun | Mon | Tue | Wed | Thu | Fri | Sat |!| Sun | Mon | Tue | Wed | Thu | Fri | Sat |
|>|>|>|>|>|!|bgcolor(#DEDEAD): 1 |!|>|!| 1 | 2 | 3 | 4 |bgcolor(#DEDEAD): 5 |
|bgcolor(#DEDEAD): 2 | 3 | 4 | 5 | 6 | 7 |bgcolor(#DEDEAD): 8 |!|bgcolor(#DEDEAD): 6 | 7 | 8 | 9 | 10 | 11 |bgcolor(#DEDEAD): 12 |
|bgcolor(#DEDEAD): 9 | 10 | 11 | 12 | 13 | 14 |bgcolor(#DEDEAD): 15 |!|bgcolor(#DEDEAD): 13 | 14 | 15 | 16 | 17 | 18 |bgcolor(#DEDEAD): 19 |
|bgcolor(#DEDEAD): 16 | 17 | 18 | 19 | 20 | 21 |bgcolor(#DEDEAD): 22 |!|bgcolor(#DEDEAD): 20 | 21 | 22 | 23 | 24 | 25 |bgcolor(#DEDEAD): 26 |
|bgcolor(#DEDEAD): 23 | 24 | 25 | 26 | 27 | 28 |bgcolor(#DEDEAD): 29 |!|bgcolor(#DEDEAD): 27 | 28 |>|>|>|>|!|
|bgcolor(#DEDEAD): 30 | 31 |>|>|>|>|!|!|>|>|>|>|>|>|>|!|
|>|>|>|>|>|>| !March |!|>|>|>|>|>|>| !April |
| Sun | Mon | Tue | Wed | Thu | Fri | Sat |!| Sun | Mon | Tue | Wed | Thu | Fri | Sat |
|>|!| 1 | 2 | 3 | 4 |bgcolor(#DEDEAD): 5 |!|>|>|>|>|!| 1 |bgcolor(#DEDEAD): 2 |
|bgcolor(#DEDEAD): 6 | 7 | 8 | 9 | 10 | 11 |bgcolor(#DEDEAD): 12 |!|bgcolor(#DEDEAD): 3 | 4 | 5 | 6 | 7 | 8 |bgcolor(#DEDEAD): 9 |
|bgcolor(#DEDEAD): 13 | 14 | 15 | 16 | 17 | 18 |bgcolor(#DEDEAD): 19 |!|bgcolor(#DEDEAD): 10 | 11 | 12 | 13 | 14 | 15 |bgcolor(#DEDEAD): 16 |
|bgcolor(#DEDEAD): 20 | 21 | 22 | 23 | 24 | 25 |bgcolor(#DEDEAD): 26 |!|bgcolor(#DEDEAD): 17 | 18 | 19 | 20 | 21 | 22 |bgcolor(#DEDEAD): 23 |
|bgcolor(#DEDEAD): 27 | 28 | 29 | 30 | 31 |>|!|!|bgcolor(#DEDEAD): 24 | 25 | 26 | 27 | 28 | 29 |bgcolor(#DEDEAD): 30 |
|>|>|>|>|>|>| !May |!|>|>|>|>|>|>| !June |
| Sun | Mon | Tue | Wed | Thu | Fri | Sat |!| Sun | Mon | Tue | Wed | Thu | Fri | Sat |
|bgcolor(#DEDEAD): 1 | 2 | 3 | 4 | 5 | 6 |bgcolor(#DEDEAD): 7 |!|>|>|!| 1 | 2 | 3 |bgcolor(#DEDEAD): 4 |
|bgcolor(#DEDEAD): 8 | 9 | 10 | 11 | 12 | 13 |bgcolor(#DEDEAD): 14 |!|bgcolor(#DEDEAD): 5 | 6 | 7 | 8 | 9 | 10 |bgcolor(#DEDEAD): 11 |
|bgcolor(#DEDEAD): 15 | 16 | 17 | 18 | 19 | 20 |bgcolor(#DEDEAD): 21 |!|bgcolor(#DEDEAD): 12 | 13 | 14 | 15 | 16 | 17 |bgcolor(#DEDEAD): 18 |
|bgcolor(#DEDEAD): 22 | 23 | 24 | 25 | 26 | 27 |bgcolor(#DEDEAD): 28 |!|bgcolor(#DEDEAD): 19 | 20 | 21 | 22 | 23 | 24 |bgcolor(#DEDEAD): 25 |
|bgcolor(#DEDEAD): 29 | 30 | 31 |>|>|>|!|!|bgcolor(#DEDEAD): 26 | 27 | 28 | 29 | 30 |>|!|
|>|>|>|>|>|>| !July |!|>|>|>|>|>|>| !August |
| Sun | Mon | Tue | Wed | Thu | Fri | Sat |!| Sun | Mon | Tue | Wed | Thu | Fri | Sat |
|>|>|>|>|!| 1 |bgcolor(#DEDEAD): 2 |!|!| 1 | 2 | 3 | 4 | 5 |bgcolor(#DEDEAD): 6 |
|bgcolor(#DEDEAD): 3 | 4 | 5 | 6 | 7 | 8 |bgcolor(#DEDEAD): 9 |!|bgcolor(#DEDEAD): 7 | 8 | 9 | 10 | 11 | 12 |bgcolor(#DEDEAD): 13 |
|bgcolor(#DEDEAD): 10 | 11 | 12 | 13 | 14 | 15 |bgcolor(#DEDEAD): 16 |!|bgcolor(#DEDEAD): 14 | 15 | 16 | 17 | 18 | 19 |bgcolor(#DEDEAD): 20 |
|bgcolor(#DEDEAD): 17 | 18 | 19 | 20 | 21 | 22 |bgcolor(#DEDEAD): 23 |!|bgcolor(#DEDEAD): 21 | 22 | 23 | 24 | 25 | 26 |bgcolor(#DEDEAD): 27 |
|bgcolor(#DEDEAD): 24 | 25 | 26 | 27 | 28 | 29 |bgcolor(#DEDEAD): 30 |!|bgcolor(#DEDEAD): 28 | 29 | 30 | 31 |>|>|!|
|bgcolor(#DEDEAD): 31 |>|>|>|>|>|!|!|>|>|>|>|>|>|>|!|
|>|>|>|>|>|>| !September |!|>|>|>|>|>|>| !October |
| Sun | Mon | Tue | Wed | Thu | Fri | Sat |!| Sun | Mon | Tue | Wed | Thu | Fri | Sat |
|>|>|>|!| 1 | 2 |bgcolor(#DEDEAD): 3 |!|>|>|>|>|>|!|bgcolor(#DEDEAD): 1 |
|bgcolor(#DEDEAD): 4 | 5 | 6 | 7 | 8 | 9 |bgcolor(#DEDEAD): 10 |!|bgcolor(#DEDEAD): 2 | 3 | 4 | 5 | 6 | 7 |bgcolor(#DEDEAD): 8 |
|bgcolor(#DEDEAD): 11 | 12 | 13 | 14 | 15 | 16 |bgcolor(#DEDEAD): 17 |!|bgcolor(#DEDEAD): 9 | 10 | 11 | 12 | 13 | 14 |bgcolor(#DEDEAD): 15 |
|bgcolor(#DEDEAD): 18 | 19 | 20 | 21 | 22 | 23 |bgcolor(#DEDEAD): 24 |!|bgcolor(#DEDEAD): 16 | 17 | 18 | 19 | 20 | 21 |bgcolor(#DEDEAD): 22 |
|bgcolor(#DEDEAD): 25 | 26 | 27 | 28 | 29 | 30 |!|!|bgcolor(#DEDEAD): 23 | 24 | 25 | 26 | 27 | 28 |bgcolor(#DEDEAD): 29 |
|>|>|>|>|>|>|>|!|!|bgcolor(#DEDEAD): 30 | 31 |>|>|>|>|!|
|>|>|>|>|>|>| !November |!|>|>|>|>|>|>| !December |
| Sun | Mon | Tue | Wed | Thu | Fri | Sat |!| Sun | Mon | Tue | Wed | Thu | Fri | Sat |
|>|!| 1 | 2 | 3 | 4 |bgcolor(#DEDEAD): 5 |!|>|>|>|!| 1 | 2 |bgcolor(#DEDEAD): 3 |
|bgcolor(#DEDEAD): 6 | 7 | 8 | 9 | 10 | 11 |bgcolor(#DEDEAD): 12 |!|bgcolor(#DEDEAD): 4 | 5 | 6 | 7 | 8 | 9 |bgcolor(#DEDEAD): 10 |
|bgcolor(#DEDEAD): 13 | 14 | 15 | 16 | 17 | 18 |bgcolor(#DEDEAD): 19 |!|bgcolor(#DEDEAD): 11 | 12 | 13 | 14 | 15 | 16 |bgcolor(#DEDEAD): 17 |
|bgcolor(#DEDEAD): 20 | 21 | 22 | 23 | 24 | 25 |bgcolor(#DEDEAD): 26 |!|bgcolor(#DEDEAD): 18 | 19 | 20 | 21 | 22 | 23 |bgcolor(#DEDEAD): 24 |
|bgcolor(#DEDEAD): 27 | 28 | 29 | 30 |>|>|!|!|bgcolor(#DEDEAD): 25 | 26 | 27 | 28 | 29 | 30 |bgcolor(#DEDEAD): 31 |
[[Start Android in Safe Mode]]
[[awk - print even lines]]
[[awk - awk Examples]]
config.formatters.push(
{
keywords : {
	"var":"blue",
	"try":"blue",
	"catch":"blue",
	"if":"blue",
	"fi":"blue",
	"else":"blue",
	"elsif":"blue",
	"then":"blue",
	"for":"blue",
	"case":"blue",
	"esac":"blue",
	"in":"blue",
	"while":"blue",
	"do":"blue",
	"done":"blue",
	"function":"blue",
	"Function":"blue",
	"String":"blue",
	"Object":"blue",
	"RegExp":"blue",
	"Array":"blue",
	"Math":"blue",
	"Date":"blue",
	";":"blue",
	"+":"red",
	"-":"red",
	"*":"red",
	"/":"red",
	"%":"red",
	"^":"red",
	"&":"red",
	"|":"red",
	"!":"red",
	"~":"red",
	"=":"red",
	"<":"red",
	">":"red",
	"false":"DarkBlue",
	"true":"DarkBlue",
	"window":"DarkBlue",
	"document":"DarkBlue",
	"alert":"IndianRed",
	"eval":"IndianRed",
	"setInterval":"IndianRed",
	"setTimeout":"IndianRed",
	"toString":"IndianRed",
	"write":"IndianRed"
},
	match: "<[Cc][Oo][Dd][Ee]>\\n",
	lookahead: "<[Cc][Oo][Dd][Ee]>\\n((?:.|\\n)*?)\\n</[Cc][Oo][Dd][Ee]>",
	handler: function(w)
	{
		var lookaheadRegExp = new RegExp(this.lookahead,"mg");
		lookaheadRegExp.lastIndex = w.matchStart;
		var lookaheadMatch = lookaheadRegExp.exec(w.source)
		if(lookaheadMatch && lookaheadMatch.index == w.matchStart)
			{
			var e = createTiddlyElement(w.output,"pre");
			var str = lookaheadMatch[1];
var Reg = /(\/\/.*?$)|(\/\*(.|\n)*?\*\/)|[&#39;]{2}|(&#39;.*?[^\\]&#39;)|["]{2}|(".*?[^\\]")|\w+|[\s\n]+|./mg;
var parts = str.match(Reg);
for(var i = 0; i < parts.length; i++){
if(parts[i].match(/^[\s\n]/))parts[i] = parts[i].replace(/\t/g,"&nbsp;&nbsp;&nbsp;&nbsp;").replace(/\n/g,"<br/>").replace(/\r/g,"");
else if(parts[i].match(/^(?:\/\/)|(?:\/\*)/))parts[i] = "<span style=\"color:green;\">"+parts[i].htmlEncode().replace(/\\n/g,"&lt;br/&gt;")+"</span>";
else if(parts[i].charAt(0)=="\""||parts[i].charAt(0)=="&#39;")parts[i] = "<span style=\"color:teal;\">"+parts[i].htmlEncode()+"</span>";
else if(this.keywords[parts[i]])parts[i] = "<span style=\"color:"+this.keywords[parts[i]]+";\">"+parts[i].htmlEncode()+"</span>";
}
e.innerHTML = parts.join("");
			w.nextMatch = lookaheadMatch.index + lookaheadMatch[0].length;
			}
	}
}
);
[[HtmlEntities]]
[[MathHtmlEntities]]
[[NATO phonetic alphabet]]
Source: http://www.coloria.net/bonus/colornames.htm.
<html><iframe src="http://www.coloria.net/bonus/colornames.htm" width=100% height=600></iframe></html>
{{{
db2iauto -on db2inst1
}}}
!Backup
#db2 -tvf ./db2_full_backup.sql
##db2_full_backup.sql: BACKUP DATABASE SAMPLE ONLINE TO "/data/backup/sample" WITH 2 BUFFERS BUFFER 1024 PARALLELISM 1 COMPRESS INCLUDE LOGS WITHOUT PROMPTING;
!Restore
#Get backup file from TSM
##su - db2inst1
##cd /data/backup/sample
##dsmc restore /data/backup/sample/SAMPLE.0.db2inst1.NODE0000.CATN0000.20090204005010.001
#cp SAMPLE.0.db2inst1.NODE0000.CATN0000.20090204005010.001 /tmp/db2_restore_tst/
#db2 catalog db sample
#db2 drop db sample
#db2 list db directory
#db2 uncatalog db sample
#db2 restore db sample from /tmp/db2_restore_tst/ taken at 20090204005010 logtarget '/home/db2inst1/logbackup/'
#db2 -tvf ./db2_roll_forward_command.sql
##db2_roll_forward_command.sql: ROLLFORWARD DATABASE SAMPLE TO END OF LOGS AND COMPLETE OVERFLOW LOG PATH ("/home/db2inst1/logbackup");

db2 backup database db_name_here user db2inst1 to /backup/destination/on/disk;
db2 backup database sample online use tsm open 1 sessions with 2 buffers buffer 1024 parallelism 1 include logs without prompting;
db2 backup db sample use tsm
db2 backup db sample to /data/backups


db2pd
db2pd -dbptnmem
db2pd -db sample -bufferpools
db2pd -db sample -tablespaces
----
db2 reset monitor all
db2 get snapshot for all on dbnamehere (first activate parameters - check with db get cfg)
db2 update monitor switches using bufferpool on


db2adutl query
db2adutl query full
db2adutl query show inactive
db2adutl query logs
db2adutl query verbose
db2adutl verify
db2adutl verify taken at 20090101110101
db2adutl extract full taken at 20090101110101
db2ckbkp -h SAMPLE.0.db2inst1.NODE0000.CATN0000.20090101110101.001



{{{
Command Syntax

Read syntax diagramSkip visual syntax diagram>>-db2mtrk--+---+--+---+--+---+--+---+-------------------------->
            '-i-'  '-d-'  '-p-'  +-m-+
                                 '-w-'

>--+------------------------+--+---+--+---+--------------------><
   '-r--interval--+-------+-'  '-v-'  '-h-'
                  '-count-'


Command Parameters

-i
    On UNIX platforms, show instance level memory. On Windows platforms, show 1 instance and database level memory. 1 
-d
    Show database level memory.

    Not available on Windows.
-p
    Show private memory. 
-m
    Show maximum values for each pool. 
-w
    Show high watermark values for each pool. 
-r
    Repeat mode 
interval
    Number of seconds to wait between subsequent calls to the memory tracker (in repeat mode). 
count
    Number of times to repeat. 
-v
    Verbose output. 
-h
    Show help screen. If you specify -h, only the help screen appears. No other information is displayed. 
}}}

db2mtrk -d
db2mtrk -d -v
db2mtrk -p -v
db2mtrk -i -v
db2mtrk -d -m

db2mtrk -i -d -v -r 10
db2mtrk -i -d -p
db2mtrk -i -d -p -v




# unzip/untar: ''v9.5_linuxx64_rtcl.tar.gz'' into ''/tmp/db2/rtcl''
# run ''/tmp/db2/rtcl/db2_install'' as root
## install in: ''/opt/ibm/db2/V9.5''
## type ''RTCL'' to continue
# run ''/tmp/db2/rtcl/db2setup''
# Select: Install a Product - Install New
# Accept Software License Agreement
# Install type: Custom (150-420 MB)
# Save response file to: ''/root/db2rtcl.rsp''
# Select Features to install:
## IBM Data Server Runtime Client Version 9.5
### Client support - check
#### Base client support (required) - check
#### DB2 LDAP support - check
#### Java support (required)  check
## Install directory: ''/opt/ibm/db2/V9.5_01''
# No additional languaes
# DB2 Information Center: On the IBM Web site
# Create a DB2 instance - new user: ''db2rmtinst1''
# Finish
# Logon with db2instance user: ''db2rmtinst1''
# Create local node and database
## ''db2 catalog TCPIP NODE UDB2SRV remote 192.168.0.101 server 50001''
## ''db2 catalog database DBNAME as DBNAME at node UDB2SRV''
## check with
### ''db2 list db directory''
### ''db2 list node directory''
## test connection
### ''db2 connect to DBNAME user db2inst1 using db2inst1_passhere''

''db2inst1'' is the user created on the db2 server (db2 server install)
''db2rmtinst1'' is the user created on the client host (db2 client install)



db2 terminate


''Compress db2dia.log''
Script to compress the db2diag.log
{{{
#!/usr/bin/python
# -*- coding: cp1252 -*-

"""
**************************************************************************************
Author: Vinicius Rodrigues da Cunha Perallis
Script name: compress_db2diag.py
Function: Rename, compact and move the db2diag.log and nfy files
Created at:12/10/2008
Last Updates: 12/11/2008
              12/12/2008
              12/15/2008 
**************************************************************************************
"""

#Import the libraries to use the OS commands and date and time functions
import os
import time
import string

####### Variable to be configurated by user #######

#Directory where will store the db2diag and nfy zipped
dir_target='/home/db2inst1/report/db2diags'

####### db2diag path ########

diagpath=string.split(os.popen("db2 get dbm cfg| grep -i DIAGPATH| awk '{print $7}'").read())
file_nfy=diagpath[0] + '/db2inst1.nfy'
file_diag=diagpath[0] + '/db2diag.log'

#File where will received the error messages from this scriot
file_output=dir_target + '/compress_db2diag.log'

####### Assembly of commands to be executed ########
#db2diag
db2diag_db2diag='db2diag -A ' + file_diag
gzip_db2diag='gzip ' + file_diag + '_*'
#### Choose the method to move your logs: move to another directory or move to TSM ####

### move to directory ###
#move_db2diag='mv ' + file_diag + '_* '
### move to TSM ###
move_db2diag='dsmc ar "' + file_diag + '_*" -delete files '

#nfy
db2diag_nfy='db2diag -A ' + file_nfy
gzip_nfy='gzip ' + file_nfy + '_*'
#move_nfy='mv ' + file_nfy + '_* '
move_nfy='dsmc a "' + file_nfy + '_*" -delete files '

#Open the files to written
f=open(file_output,'a')

#Function to execute the rename, compress and move commands
def compress(log,gzip,move,file):
     if (os.system(log) == 0):
          file.write("1 - Command db2diag -A completed successufully\n")
          if (os.system(gzip) == 0):
               file.write("2 - Command gzip completed successfully\n")
               os.system(move)
               file.write("3 - Script compress_db2diag completed successfully !!!\n")
          else:
               file.write("2 - Command gzip failed\n")
     else:
          file.write("1 - File to be compressed doesn't exist\n")


######### Move all .gz to dir_target ###########
os.system('mv ' + diagpath[0] + '/*.gz ' + dir_target)

########## Compress nfy #########

f.write("\n------------  Compressing db2inst1.nfy ... - Date: " + time.strftime('%Y%m%d%H') + " ------------- \n\n")
compress(db2diag_nfy,gzip_nfy,move_nfy,f)

########## Compress diag #########
f.write("\n------------ Compressing db2diag.log ... - Date: " + time.strftime('%Y%m%d%H') + " ------------- \n\n")
compress(db2diag_db2diag,gzip_db2diag,move_db2diag,f)

f.close()
}}}
db2 catalog TCPIP NODE UDB2SRV remote 192.168.0.101 server 50001
db2 catalog database DBNAME as DBNAME at node USB2SRV
db2 connect to DBNAME user db2rmtinst1 using db2rmtinst1passhere
db2 -tvf ./some_sql01.sql > ./some_sql01.log
*http://www.ibm.com/developerworks/data/library/techarticle/0203zikopoulos/0203zikopoulos.html
*http://www.ibm.com/developerworks/data/library/techarticle/dm-0804zikopoulos/
*http://www.ibm.com/developerworks/data/library/techarticle/dm-0512kokkat/
*http://www.ibm.com/developerworks/data/library/techarticle/dm-0401chong/
{{{
db2 "CALL SYSPROC.ADMIN_COPY_SCHEMA('ORGSCH','SRCSCH','COPY','ORGSCH','USERSPACE1','USERSPACE1','SYSTOOLS','ERR_TAB')"
}}}
{{{
ADMIN_COPY_SCHEMA( source_schema, target_schema, copymode, object_owner,source_tablespace, target_tablespace, error_table_schema, error_table_name)
}}}
where
|source_schema|is the name of the schema you want to copy objects from|
|target_schema|is the target schema name you want to copy objects to|
|copymode|is either 'DDL', in which case the stored procedure will copy all of the objects but not the data in the objects, or COPY, in which case both the DDL and the data will be copied into the new schema. When moving the data DB2 uses the load from cursor command|
|object_owner|this is the authorization ID that you would like to use as the owner for the newly created objects. If you specify NULL then the new objects will be owned by the userid that is running the copy schema command|
|source_tablespace|this is a list of the tablespaces that hold objects in the source schema|
|target_tablespace|this is a list of tablespaces that you want to use to hold the target schemas objects. When a table is being copied, DB2 looks in the source tablespace list to see what tablespace this object is coming from. If it is the nth tablespace in the source list then DB2 will use the nth tablespace in the target_tablespace list to put this table in. So you need to match up the source tablespaces with the list of target tablespaces that you want the objects moved to|
|error_tables_schema|this is the schema for the error table|
|error_table_name|this is a table that will hold error messages that may be produced by the copy schema. This table is automatically created by the stored procedure and lives in the SYSTOOLSPACE tablespace and will contain one or more message in the event anything goes wrong when objects are being copied|
*http://publib.boulder.ibm.com/infocenter/db2luw/v9/index.jsp?topic=/com.ibm.db2.udb.admin.doc/doc/r0022035.htm
{{{
CREATE VIEW upperemp (empno, firstnme, midinit, lastname, workdept, phoneno,hiredeate, edlevel, birthdate, salary, bonus, comm)
   AS SELECT 
      UPPER(empno), 
      UPPER(firstnme), 
      UPPER(midinit), 
      UPPER(lastname),
      UPPER(workdept), 
      UPPER(phoneno), 
      hiredate, 
      edlevel, 
      birthdate,
      salary, 
      bonus, 
      comm
   FROM employee
}}}
*Create script file
**vi script.db2
{{{
CREATE PROCEDURE LBU_INV.SITEM
(IN id INT)
LANGUAGE SQL
BEGIN
select GAME_NO from INVENTORY_ITEM where INVENTORY_ITEM_ID=id;
END@
}}}
*Next run:
**db2 -td@ -svf ./script.db2
groupadd -g 999 db2iadm1
groupadd -g 998 db2fadm1
groupadd -g 997 dasadm1 
Login with root user and go to /opt/IBM/db2/V9.1/instance.

./db2icrt -u db2fenc1 db2inst1
./db2icrt -u db2fenc1 db2inst2
./db2icrt -u db2fenc1 db2inst3
./db2icrt -u db2fenc1 db2inst4
./db2icrt -u db2fenc1 db2inst5
./db2icrt -u db2fenc1 db2inst6
create schema db2schna authorization db2usr


useradd -u 1100 -g db2iadm1 -m -d /home/db2inst1 db2inst1 -p passw0rd
useradd -u 1101 -g db2fadm1 -m -d /home/db2fenc1 db2fenc1 -p passw0rd
useradd -u 1102 -g dasadm1 -m -d /home/dasadm1 dasusr1 -p passw0rd

useradd -u 1103 -g db2iadm1 -m -d /home/db2inst2 db2inst2 -p passw0rd
useradd -u 1104 -g db2iadm1 -m -d /home/db2inst3 db2inst3 -p passw0rd
useradd -u 1105 -g db2iadm1 -m -d /home/db2inst4 db2inst4 -p passw0rd
useradd -u 1106 -g db2iadm1 -m -d /home/db2inst5 db2inst5 -p passw0rd
useradd -u 1107 -g db2iadm1 -m -d /home/db2inst6 db2inst6 -p passw0rd
db2 "LOAD FROM /dev/null OF IXF REPLACE INTO schema.tablename"
----
*Problem
----
{{{
db2 connect to mydatabase
db2 quiesce database immediate force connections
db2 connect reset
db2 drop database mydatabase

This allways give:

SQL1035N  The database is currently in use.  SQLSTATE=57019

running this command shows no connections/applications

DB2 list applications

I can even deactivate the database, but still can't drop it.

db2 => deactivate database mydatabase
DB20000I  The DEACTIVATE DATABASE command completed successfully.
db2 => drop database mydatabase
SQL1035N  The database is currently in use.  SQLSTATE=57019
db2 =>
}}}
----
*Sollution (does not work, because an remote app is instantly reconnecting to the db.)
----
{{{
db2 force applications all 
db2 terminate 

db2set DB2COMM= 
db2stop 
db2start 

db2 force applications all 
db2 terminate 

... do your stuff here ...

db2set DB2COMM=TCPIP 
db2stop 
db2start 
}}}
{{{
db2 "CALL ADMIN_DROP_SCHEMA ( 'SCHEMNAME', NULL, 'SYSTOOLS', 'ERR_TAB')"
}}}
{{{
ADMIN_DROP_SCHEMA ( schema_name, drop_mode, error_table_schema, error_table_name)
}}}
where
|schema_name|is the name of the schema for which you want to drop all the object for|
|drop_mode|is reserved for future use and in DB2 9 is just set to NULL|
|error_table_schema|this is the schema for the error table|
|error_table_name|the table that will store any error messages that occur during the drop operation of each object in the schema|
*http://it.toolbox.com/blogs/db2luw/drop-schema-in-db2-9-10627
http://www.ibm.com/developerworks/data/library/techarticle/0205pilaka/0205pilaka2.html
{{{
db2 "CALL GET_DBSIZE_INFO(?, ?, ?, 0)"
}}}
{{{
SELECT MAX(mycolumn)+ 1 FROM mytable;
ALTER TABLE mytable ALTER COLUMN mycolumn RESTART WITH <above_result>;
}}}
{{{
 (http://www.itexpert.cz/uninstall-db2-server)

It’s quite easy to uninstall DB2 server. You must only follow those steps:

   1. Stopping the DB2 administration server
          * Log in as the DB2 administration server owner
          * Stop the DB2 administration server by entering the db2admin stop command.
   2. Stopping all DB2 instances
          * Log in as a user with root authority
          * To obtain a list of the names of all DB2 instances associated with your current DB2 copy, enter the following command: DB2DIR/bin/db2ilist, where DB2DIR is e.g. /opt/IBM/db2/V8.1
          * Log out
          * Log back in as the owner of the instance you want to stop
          * Stop the DB2 database manager by entering the db2stop force command
          * Confirm that the instance is stopped by entering the db2 terminate command
          * Repeat these steps for each instance
   3. Removing DB2 instances
          * Log in as a user with root authority
          * Remove the instance by entering the following command: DB2DIR/instance/db2idrop InstName
            , where DB2DIR is e.g. /opt/IBM/db2/V8.1
          * Repeat these steps for each instance
          * remove DB2DIR/instance/dasdrop (remove das admin server)
   4. Removing DB2 products using the db2_deinstall
          * Log in as a user with root authority
          * Run the db2_deinstall -a command from the DB2DIR/install, where DB2DIR is e.g. /opt/IBM/db2/V8.1
   5. Remove entry from inittab
          * reload config init: init q

      Note: The db2idrop command removes the instance entry from the list of instances and removes the INSTHOME/sqllib directory, where INSTHOME is the home directory of the instance and where InstName is the login name of the instance. If you are storing any files in /sqllib directory, these files will be removed by this action. If you still need these files, you must make a copy of them before dropping the instance.
}}}
*su - db2inst1
*db2 stop
*su - dasusr1
*db2admin stop
*./installFixPack -b /opt/ibm/db2/V9.5_01
*''check db2level !!!!''
*su - root
*/opt/ibm/db2/V9.5_01/instance/db2iupdt db2inst1
*/opt/ibm/db2/V9.5_01/instance/dasupdt




''Limit to 1 GB (4K pages) -> value 250000''
{{{
DB2 UPDATE DATABASE CONFIGURATION using DATABASE_MEMORY 250000 IMMEDIATE; 
CONNECT RESET;
}}}

{{{
------Change_mem_usage.bat---------------------------
echo Preparing to change DB2 Express memory limitation"
CONNECT TO <db_name>
UPDATE DATABASE CONFIGURATION using DATABASE_MEMORY 250000 IMMEDIATE
AUTOCONFIGURE USING MEM_PERCENT 33 APPLY DB AND DBM
CONNECT RESET
echo Completing the change of DB2 Express memory limitation;
QUIT
--------------------------------------------------------------------
}}}
seach for ''db2diag.log'' in instance home directory.
f.e.: ''/home/db2inst1/sqlib/db2dump/db2diag.log''

!Install
*Login as root.
*Create groups:
**groupadd -g 999 db2iadm1
**groupadd -g 998 db2fadm1
**groupadd -g 997 dasadm1
*Create users for each group:
**useradd -u 1004 -g db2iadm1 -m -d /home/db2inst1 db2inst1
**useradd -u 1003 -g db2fadm1 -m -d /home/db2fenc1 db2fenc1
**useradd -u 1002 -g dasadm1 -m -d /home/dasusr1 dasusr1
*Set password for each users created:
**passwd db2inst1
**passwd db2fenc1
**passwd dasusr1
*cd to installation file directory:
**Example: /tmp/db2/exp/disk1
*Run installation script:
**./db2_install.sh
!Post Install
*Login as root.
*Install license (example):
**/opt/ibm/db2/V9.1/adm/db2licm –a /tmp/db2/exp/disk1/db2/license/db2exp_uw.lic
!!Create the DB2 Administration Server (DAS)
*Login as root.
*Create DAS with dasusr1
**/opt/ibm/db2/V9.1/instance/dascrt -u dasusr1
*Login as dasuser1
**Start the DAS: db2admin start
*Optional: to enable autostarting of the DAS upon reboot
**/opt/ibm/db2/V9.1/instance/dascrt/dasauto –on
!!Create DB2 instance
**Login as root.
*Create instance with users db2fenc1 and db2inst1:
**/opt/ibm/db2/V9.1/instance/db2icrt -a server -u db2fenc1 db2inst1
*Optional: enable autostarting of the db2inst1 instance
**/opt/ibm/db2/V9.1/instance/db2iauto –on db2inst1
!!Update environment variables
*Example:
*Login as db2inst1
*edit .bash_profile
**vi /home/db2inst1/.bash_profile
**insert the following line at the end of the file – “. /home/db2inst1/sqllib/db2profile”
*Do the same for dasusr1, using its corresponding directory.
!!Database service
*Login as root:
*Add new service entry:
**vi etc/services
**insert this line “DB2_TMINST 50000/tcp” at the end of the file
!!Verification
*Login as db2inst1
*List installed DB2 products and features: db2ls
*Display the default instance: db2 get instance
**Result: The current database manager instance is: db2inst1
*Start the database instance: db2start
**Result: SQL1063N DB2START processing was successful.
*Stop the database instance: db2stop
**Result: SQL1064N DB2STOP processing was successful. 
*First connect to database
{{{
db2 connect to database_name
}}}
*Export
{{{
db2 export to table_name.ixf of ixf 'select * from schema_name.table_name'
}}}
*Import
{{{
db2 import from file_name.ixf of ixf insert into schema_name.table_name
}}}
or (if transaction logs full)
{{{
db2 import from file_name.ixf of ixf commitcount 10000 insert into schema_name.table_name
}}}
or (if updating)
{{{
db2 import from file_name.ixf of ixf commitcount 10000 insert_update into schema_name.table_name
}}}


http://www.ibm.com/developerworks/data/library/techarticle/pworld/0112mccluney.html

http://publib.boulder.ibm.com/infocenter/db2luw/v9/index.jsp?topic=/com.ibm.db2.udb.uprun.doc/doc/t0007438.htm

There are tasks that are necessary and tasks that are optional after you install a fix pack. The tasks differ for Windows® and Linux® or UNIX® operating systems.
Related tasks
Adding your user ID to the DB2ADMNS and DB2USERS user groups (Windows)
Applying DB2 licenses
Applying fix packs
DB2 Version 9 co-existence and migration with DB2 UDB Version 8 ( Windows )
Enabling communications between database partition servers ( Linux and UNIX )
Enabling Control Center administration (Linux)
Enabling the execution of remote commands (Linux and UNIX)
[[DB2 - Setting up notification and contact lists]]
Updating the node configuration file (Linux and UNIX)
Upgrading your 32-bit DB2 instances to 64-bit instances (Windows)
Using the Default DB2 Selection wizard (Windows)
Working with existing DB2 copies
Related reference
DB2 node configuration file - db2nodes.cfg
----
*Check Territory code
*Check mail send to (smtp-server)
*Check autostart instance


http://www.ibm.com/developerworks/data/library/techarticle/0303bhogal/0303bhogal.html
*If for some reason you need to reset the DB2 database parameter changes to system default, disconnect the active database connection and execute reset db cfg (either one of this CLP command):
{{{
db2 reset db cfg for database_alias
db2 reset database configuration for database_alias
}}}
where database_alias refers to the target database (usually database name and database alias is the same).

''alter table tabname alter colname restart with somenum''
restore database sample tablespaces (userspace1) online use tsm open 1 sessions taken at 20090101120101 with 2 buffers buffer 1024 parallellism 1 without rolling forward without prompting;

restore database sample tablespaces (userspace1) online use tsm open 1 sessions taken at 20090101120101 with 2 buffers buffer 1024 parallelism 1 without prompting;
rollforward database sample to end of logs and complete tablespace (userspace1) online;

restore database sample tablespaces (userspace1) online use tsm open 1 sessions taken at 20090101120101 with 2 buffers buffer 1024 parallelism 1 without prompting;
rollforward database sample to 20090101120101 using local time and complete tablespace (userspace1) online;

restore database sample tablespaces (userspace1) online use tsm open 1 sessions taken at 20090101120101 with 2 buffers buffer 1024 replace history file parallelism 1 without prompting without rolling forward without prompting;

restore db sample from /tmp/db2 taken at 200000...... redirect generate script sample.sql

restore database samplefrom '/tmp/db2' taken at 20000.... on '/data' dbpath on '/data/ictsmp' into sampprod

 
''db2 "select * from schemanm.tablenm fetch first 10 rows only"''
# ''db2_install''
# ''/opt/ibm/db2/V9.5'' (install destination)
# no
# EXP
# ''db2_setup''
# Install now
# Accept Software License Agreement
# Custom
# ''/root/db2exp.rsp'' (response file)
# Add: 
## Informix data source support
## XML Extender
## Base application development tools
# Directory: ''/opt/ibm/db2/V9.5_01'' (+- 632 MB required)
# No additional languages
# DB2 Information Center (On the IBM Web Site)
# DB2 Admin SRV
## DB2 Administration Server
### username: ''dasusr1'' (default UID)
### groupname: ''dasadm1'' (default GID)
### password: ''dasadminpasshere''
### homedirectory: ''/home/dasusr1''
# DB2 Instance Create
## DB2 Instance
### username: ''db2inst1'' (default UID)
### groupname: ''db2iadm1'' (default GID)
### password: ''db2inst1passhere''
### homedirectory: ''/home/db2inst1''
# DB2 Fence user
## DB2 fenced user
### username: ''db2fenc1'' (default UID)
### groupname: ''db2fadm1'' (default GID)
### password: ''db2fenc1passhere''
### homedirectory: ''/home/db2fenc1''
# TCP Configuration
## Service name: ''db2c_db2isnt1''
## Port number: ''50001''
## Auto start the instance at system startup
# Prepare the DB2 tools catalog (check)
## Instance: ''db2inst1''
## Database: ''TOOLSDB''
## Schema: ''SYSTOOLS''
# Set up your DB2 server to send notifications
## Notification SMTP server: smtpserver.host.com
## Administer contact list on this computer
### Local - Create a contact list on this computer (check)
# Administration contact for this instance
## Name: ''db2inst2''
## email-address: ''db2inst1@somehost''
# Informix data source support
## Check: Defer this task until after installation is complete
# Finish - Finish
# Logon as ''db2inst1''
## ''DISPLAY=someotherhost:0.0''
## ''export DISPLAY''
## ''db2fs'' (db2 first steps)

#Logon as root
#su - db2inst1
#db2 force applications all
#db2stop
#exit
#su - dasusr1
#db2admin stop
#exit
#/opt/ibm/db2/V9.5_01/instance/db2stop db2inst1
#/opt/ibm/db2/V9.5_01/instance/dasdrop dasusr1
#/opt/ibm/db2/V9.5_01/install/db2_deinstall -a
#remove entry in '/etc/inittab'
#'init q'
#kill the last remaining db2 program you see with 'ps ax'
*Upgrade from DB2-Express means uninstall DB2-Express and install DB2-ESE.
*Next install fix packs if availlable.
*http://publib.boulder.ibm.com/infocenter/db2luw/v9r5/index.jsp?topic=/com.ibm.db2.luw.qb.server.doc/doc/t0006352.html
*The processes
The following tables lists all the DB2 processes per instance, per database, and by function. Note that some of the processes in the tables below are not listed in alphabetical order, but grouped based on functionality. If you would like to look for a process in alphabetical order, refer to Table 7 below.

|!Process name|!Description|!Applicability|
|db2cart|Determines when a log file can be archived and invokes the user exit to do the actual archiving. There is one db2cart process per instance, but it is only running if there is at least one database in the instance which has USEREXIT enabled.|All|
db2 update database manager configuration using svcename
db2c_inst_name
db2set DB2COMM=tcpip
db2stop
db2start
*Set the port number of the instance
Edit the/etc/services file and add the following line:
{{{
db2c_inst_name inst_port /tcp
}}}
For your DB2(R) product to contact you or others regarding the health of your databases, you will have to set up notification and contact lists. If you did not do this during the DB2 installation, you can manually set up these lists.
Procedure

To set up notification and contact lists:

   1. Log on as the instance owner or a user with SYSADM authority.
   2. If the SMTP server was not specified during the installation process, you can configure it manually using the following command:

{{{
         db2 update admin cfg using smtp_server host1
}}}

      where host1 represents the TCP/IP host name for the SMTP server used for e-mail notification. You can also update this information using the Create Database with Automatic Maintenance wizard, or the Troubleshoot Alert Notification wizard in the Health Center.
   3. If you want the contact information to be located on a remote DB2 administration server (DAS), you can specify the contact_host parameter using the following command:

{{{
         db2 update admin cfg using contact_host host2
}}}

      where host2 represents the TCP/IP host name where the DAS is running. If the contact_host parameter is not specified, the DAS assumes the contact information is local.
   4. Turn on the scheduler using the following command:

{{{
         db2 update admin cfg using sched_enable on
}}}

   5. For these changes to take effect, you need to restart the DAS use the following commands:

{{{
         db2admin stop
         db2admin start
}}}
   6. From either the Task Center or the Health Center, click the Contacts icon Picture of the Contacts icon in the Task bar. Select System name, then click Add Contact. Type in contact information and then click OK.

http://www-01.ibm.com/support/docview.wss?rs=203&uid=swg21231084
Occasionally, if the tablespaces in db2 isn’t system managed, it can get full. Your application might fail from…

>DB2 SQL error: SQLCODE: -289, SQLSTATE: 57011, SQLERRMC: TBSPNAME

This tells you the tablespace that probably ran out free pages. You can do the following to add additional pages to this tablespace.

>DB2 CONNECT TO database_name
>DB2 LIST TABLESPACES SHOW DETAIL
>DB2 "ALTER TABLESPACE tablespace_name EXTEND (ALL 100000)"

This should resolve a lot of user managed tablespace out of page space issues.

Thanks to: http://islocated.wordpress.com/2007/06/13/db2-tablespaces-pages-full/
*http://www.ibm.com/developerworks/data/library/techarticle/dm-0910db2incrementalbackup/index.html
db2 activate db db_name_here
*[[DB2 - alter bufferpool]]
*[[DB2 - alter sequence]]
*[[DB2 - alter table]]
db2 alter bufferpool bpname immediate size 20000

{{{
ALTER SEQUENCE myseq 
RESTART WITH 2 
INCREMENT BY 3 
MAXVALUE 33 
CYCLE 
CACHE 12 
ORDER 
}}}
* Change varchar size
>db2 ALTER TABLE ELMT_T ALTER COLUMN CDTY_CD SET DATA TYPE VARCHAR(100)
*If you use DMS tablespaces , you will have to maintain the tablespace yourselve, unlike SMS tablespaces who are managed by DB2 itself. In your case you have to add containers to enlarge the tablespace, using the ALTER TABLESPACE syntax or by using CONTROL CENTER. (alter table space GUI)
{{{
ALTER TABLESPACE 'tablespace-name'
ADD FILE 'container-string'  number-of-pages
}}}
do a commit and contents of tablespace are automatically rebalanced over the containers, without restriction to access to the tablespace..... 
db2 catalog tcpip node db2node remote hostname server service_name
db2 catalog database db_name as alias_name at node db2node
db2 uncatalog database alias_name
{{{
db2 list db directory
db2 list node directory
db2 catalog db sample
db2 drop db sample
db2 uncatalog db sample
}}}
{{{
C:\>db2 list db directory
SQL1057W  The system database directory is empty.  SQLSTATE=01606

C:\>db2 create db test on c:
SQL1005N  The database alias "TEST" already exists in either the local
database directory or system database directory.

C:\>db2 catalog db test
DB20000I  The CATALOG DATABASE command completed successfully.
DB21056W  Directory changes may not be effective until the directory cache is
refreshed.

C:\>db2 drop db test
DB20000I  The DROP DATABASE command completed successfully.

C:\>db2 create db test on c:
DB20000I  The CREATE DATABASE command completed successfully.
}}}
I typically run scripts as follows: 
>DB2 -tvf filename.ddl 
>-t sets the default termination character (;), 
>-v echoes the contents of the file to the screen (so I can check what I told DB2 to do) 
>-f tells the CLP to use an input file. 
Help for all options is available with "DB2 ? options" 
*Extract structure: specify database-name, schema-name and output-file
''db2look -e -d dbname -z schemaname -o output.ddl''

*Generate the DDL statements for objects created by user walid in database DEPARTMENT. The db2look output is sent to file db2look.sql:
''db2look -d department -u walid -e -o db2look.sql''

*Generate the DDL statements for objects that have schema name ianhe, created by user walid, in database DEPARTMENT. The db2look output is sent to file db2look.sql:
''db2look -d department -u walid -z ianhe -e -o db2look.sql''

*Generate the UPDATE statements to replicate the statistics for the tables and indexes created by user walid in database DEPARTMENT. The output is sent to file db2look.sql:
''db2look -d department -u walid -m -o db2look.sql''

*Generate both the DDL statements for the objects created by user walid and the UPDATE statements to replicate the statistics on the tables and indexes created by the same user. The db2look output is sent to file db2look.sql:
''db2look -d department -u walid -e -m -o db2look.sql''

*Generate the DDL statements for objects created by all users in the database DEPARTMENT. The db2look output is sent to file db2look.sql:
''db2look -d department -a -e -o db2look.sql''

*Generate the DDL statements for all user-defined database partition groups, buffer pools and table spaces. The db2look output is sent to file db2look.sql:
''db2look -d department -l -o db2look.sql''

*Generate the UPDATE statements for optimizer-related database and database manager configuration parameters, as well as the db2set statements for optimizer-related registry variables in database DEPARTMENT. The db2look output is sent to file db2look.sql:
''db2look -d department -f -o db2look.sql''

db2mtrk -d
db2mtrk -d -v
db2mtrk -p -v
db2mtrk -i -v
db2mtrk -d -m
db2pd -osinfo
db2pd -V
db2pd -version
db2pd -inst
db2pd -everything
db2pd -db dbname -bufferpools
db2pd -db dbname -tablespaces
db2 drop function db2inst1.functname
db2 drop database sample
*Export data to a DEL file, using a single quotation mark as the string delimiter, a semicolon as the column delimiter, and a comma as the decimal point. The same convention should be used when importing data back into the database.
{{{
db2 export to myfile.del of del
      modified by chardel'' coldel; decpt,
      select * from staff
}}}
*Examples
db2 export to file001.ixf of ixf "select * from schemaname.table"
db2 import from file001.ixf of ixf commitcount 10000 insert into schemaname.table
db2 list appilcations
db2 "force application(6688)"
db2 force applications all


*Get DB2 parameters
{{{
db2 get dbm cfg
db2 get db cfg show detail
}}}
*To display both current and deferred DB2 database configuration parameters value (some parameter value changes are not effective for the current active connection until the client initiate a new database connection):
{{{
db2 get db cfg show detail
}}}
*Get db2diag.log path
{{{
db2 get dbm cfg| grep -i DIAGPATH| awk '{print $7}'
}}}
{{{
db2 GET MONITOR SWITCHES
}}}



GRANT SELECT ON EMPLOYEE TO USER HERON
GRANT SELECT ON EMPLOYEE TO GROUP HERON
GRANT SELECT,UPDATE ON TABLE STAFF TO GROUP PERSONNL 
GRANT SELECT ON TABLE MYSELECTS TO PUBLIC



*List tables
{{{
db2 list tables
db2 list tables for schema schema_name
}}}
*List databases
{{{
db2 list database directory
}}}
db2 reorg table employee index empid allow no access indexscan longlobdata
db2 reorg table homer.employee use mytemp1
db2 reorg indexes all for table homer.employee allow write access cleanup only
db2 reorg indexes all for table homer.employee allow write access cleanup only pages 
db2 reorg table homer.employee use tempspace1

REVOKE SELECT ON EMPLOYEE FROM USER HERON
REVOKE SELECT ON TABLE SYSCAT.TABAUTH FROM PUBLIC



select * from dirlist order by size_in_mb desc fetch first 10 rows only;
db2 update dbm cfg using DFT_MON_BUFPOOL on
db2 update dbm cfg using DFT_MON_LOCK on
db2 update dbm cfg using DFT_MON_SORT on
db2 update dbm cfg using DFT_MON_STMT on
db2 update dbm cfg using DFT_MON_TABLE on
db2 update dbm cfg using DFT_MON_TIMESTAMP on
db2 update dbm cfg using DFT_MON_UOW on
db2 update dbm cfg using HEALTH_MON on

db2 reset monitor all
db2 get snapshot for all on db_name_here > snapshot_result.log

get snapshot for database manager
get snapshot for database on sample
get snapshot for application agentid 765
get snapshot for dynamic sql on sample
get snapshot db2 with global
*To update DB2 database configuration for a parameter called LOGFILSIZ (Log file size)
{{{
db2 update db cfg using LOGFILSIZ 2000
}}}
----
db2 "update dbm cfg using SVCNAME myport"
db2 udpate dbm cfg using INSTANCE_MEMORY automatic
db2set DB2COMM=tcpip
db2set DB2AUTOSTART=YES



http://www.ibm.com/developerworks/data/library/techarticle/0212wieser/0212wieser.html
!How to alter parameter settings to deal with deadlocks
!!Viewing lock list settings
To view lock list settings, issue the following command:
<<<
{{{
db2 get db cfg
}}}
Below, is an example of the information returned as a result of issuing this command:
{{{
Max storage for lock list (4KB)		(LOCKLIST) = 50
Interval for checking deadlock (ms)	(DLCHKTIME) = 10000
Percent. of lock lists per application	(MAXLOCKS) = 22
Lock time out (sec)			(LOCKTIMEOUT) = -1
Max number of active applications	(MAXAPPLS) = AUTOMATIC
}}}
<<<
!!Setting LOCKLIST
<<<
For DB2 8:
*Estimate the maximum number of active applications (MAXAPPLS, if set).
*Estimate the average number of locks per application.
*Estimate the lower and upper lock list size:
{{{
        (Avg # locks per application * 36 * MAXAPPLS) / 4096
          (Avg # locks per application * 72 * MAXAPPLS) / 4096
}}}
>      where:
>      72 = # bytes of first lock on object
>      36 = # bytes of additional locks on object
*Set an initial LOCKLIST somewhere between the upper and lower bounds.
      For example:
{{{
        db2 update db cfg using LOCKLIST 200
}}}
For DB2 9, there are new formulas for estimating LOCKLIST size. There are changes for 32-bit and 64-bit platforms. Refer to the LOCKLIST documentation in the DB2 Infocenter for details.
<<<
!!Setting MAXLOCKS
<<<
*Determine the percentage of lock list any single application can consume before lock escalation occurs. This could be a flat percentage or based on common transaction volumes.
      For example, if applications are allowed twice the average number of locks:
{{{
       100 * (Avg  # locks per application * 2 * 72 bytes per lock)
        / (LOCKLIST * 4096 bytes)
}}}
      Then set MAXLOCKS as shown in the following statement:
{{{
       db2 update db cfg using MAXLOCKS 22
}}}
*Additional tuning of lock list parameters involves the use of the snapshot and event monitors. Look for the following information at the database level:
          * Total lock list memory in use
          * Number of lock escalations that have occurred
*Use the event monitor for the maximum number of locks held by transaction.

For DB2 9, refer to the MAXLOCKS documentation in the DB2 Infocenter for details at http://publib.boulder.ibm.com/infocenter/db2luw/v9/index.jsp?topic=/com.ibm.db2.udb.admin.doc/doc/r0000268.htm.
<<<
!!!Diagnosing lock problems
<<<
A few useful tools to diagnose lock problems are detailed below.
*Find db2 application IDs for SDE processes.
{{{
      SELECT  appl_id FROM  TABLE(SNAPSHOT_APPL_INFO('SDE',-1)) as SNAPSHOT_APPL_INFO where appl_name like 'gsrvr%'
      SELECT  appl_id,appl_name FROM  TABLE(SNAPSHOT_APPL_INFO('SDE',-1)) 
}}}
*Use snapshots for lock and application information; for example:
{{{
      db2 get snapshot for locks on sde > all_locks.txt
      db2 get snapshot for locks for application applid '*LOCAL.DB2.00AB42215335' > app_locks.txt
      db2 get snapshot for application applid '*LOCAL.DB2.00AB42215335' > app_info.txt
}}}
      A quick search on the snapshot output for items of interest yields the following:
{{{
       Application status = Lock-wait
       Locks held by application = 1254
       Number of SQL requests since last commit = 12
       Open local cursors = 1
       Most recent operation = Execute

       Object type	= Table
       Tablespace name	= USERSPACE1
       Table schema	= SDE
       Table name	= STATE_LINEAGES
       Mode = X
       Status	 = Converting
       Current mode = IX
       Lock escalation	= YES
}}}
*As noted above, deep lineages may be an issue for acquiring a large number of row locks. The following SQL statements can provide a quick check of lineage depths and of max lineage depth:
{{{
      select count(*) from state_lineages group by lineage_name
      select max(a.depth) from (select count(*) from state_lineages group by lineage_name) a(depth)
}}}
<<<
!Minimize disk I/O contention in DB2
Disk I/O contention within a DB2 database is minimized by properly arranging the components of the database throughout the file system. Ultimately, the database administrator must reduce the possibility of one process waiting for another to complete its I/O request. This is often referred to as waiting on I/O.

The following are recommendations to help you avoid disk I/O contention.
<<<
!!For temporary user table spaces, use SMS; for all other table spaces, use DMS.
There are two types of table space storage models in DB2: System Managed Space (SMS) and Database Managed Space (DMS). ESRI recommends that you use SMS table spaces for user temporary table spaces and DMS for other table spaces for better performance especially if your data is expected to grow on a regular basis.

NOTE: At DB2 9, you will require the use of an additional DB2 global temporary table (DECLARE GLOBAL TEMPORARY TABLE). Per DB2 documentation, declaring global temp tables requires "either SYSADM or DBADM privileges" or "USE privilege on a USER TEMPORARY table space".

For DB2 9, you should consider using Automatic Storage features for databases as well as incorporating the Automatic Sizing attributes for table spaces. In DB2 9, DMS table spaces have the ability to provision additional storage as physical requirements increase.
<<<
<<<
!Set up buffer pools.
Setting up the buffer pools is critical to performance. By default, DB2 provides a single buffer pool named IBMDEFAULTBP. In DB2 9, by default, the IBMDEFAULTBP buffer pool is configured for automatic sizing. The database manager adjusts the size of this buffer pool in response to workload requirements.

You should create a separate buffer pool for each table space. The database snapshot should be reviewed to check the buffer pool physical read values. The buffer pool should be large enough that a snapshot of a map redraw results in a small number of physical reads.

To determine the efficiency of a buffer pool, calculate its buffer pool hit ratio (BPHR). An ideal BPHR, if possible, is somewhere over 90%. The formula is as follows:
{{{
BPHR (%) = (1 - (("Buffer pool data physical reads" 
+ "Buffer pool index physical reads")
 / ("Buffer pool data logical reads" 
+ "Buffer pool index logical reads"))) * 100
}}}

Another method for reviewing buffer pool hit ratios is through the use of the SYSIBMADM.BP_HITRATIO administrative view. This view can return hit ratios, including total hit ratio, data hit ratio, XDA hit ratio, and index hit ratio for all buffer pools.
{{{
SELECT SUBSTR(DB_NAME,1,8) AS DB_NAME, 	
SUBSTR(BP_NAME,1,140) AS BP_NAME,
TOTAL_HIT_RATIO_PERCENT, 
DATA_HIT_RATIO_PERCENT, 	
INDEX_HIT_RATIO_PERCENT, 
XDA_HIT_RATIO_PERCENT, DBPARTITIONNUM
FROM SYSIBMADM.BP_HITRATIO
ORDER BY DBPARTITIONNUM
}}}
<<<
<<<
!!Establish the threshold table size.

As a rule, store small tables together in the same table space and large tables by themselves in their own table spaces. Decide how large a table must be before it requires its own table space. Generally, the threshold corresponds in part to the maximum container size. Tables capable of filling the maximum size container should be stored in their own table space. Tables approaching this limit should also be considered. Follow the same policy for indexes.

Separate the tables and indexes into those that require their own table spaces and those that will be grouped together. Never store large or frequently accessed tables and their indexes together in the same table space.

If you are using DB2 9, you should consider incorporating Automatic Storage attributes for table spaces.
<<<
<<<
!!Store small tables and indexes by access.

Base the decision of which small tables to store together in the same table space on expected access. Store tables of high access in one table space and tables of low access in another. Doing so allows you to position the containers of the high access table spaces with low access containers. This same rule applies to indexes. They, too, should be divided by access.

It is recommended that the DB2 logs have their own disks apart from indexes and data. ESRI recommends that you set the operating system's kernel parameter MAXUPROC value to a higher value than the default so all processes owned by the ArcSDE and DB2 instance users can run when invoked.
<<<
<<<
!!For AIX operating systems, turn off db2set DB2_MMAP_READ and db2set DB2_MMAP_WRITE.

ESRI recommends turning off the following variables on AIX to improve performance.

These variables are used in conjunction with each other to allow DB2 to use a multifunction, multiservice access platform (MMAP) as an alternative method of I/O. This is used to avoid operating system locks when multiple processes are writing to different sections of the same file. Default is ON.
{{{
db2set DB2_MMAP_READ=OFF
db2set DB2_MMAP_WRITE=OFF
}}}
<<<
<<<
!!When loading large amounts of data, such as raster data, set the database to use circular logging.

Circular logging uses a ring of log files to record changes to the database. When the last log in the ring is filled, the first file is reused. Since transaction information can be overwritten, when you use circular logging, roll-forward recovery is not possible; however, recovery is generally not needed during data loads. Circular logging is the default logging model.

If you need to use roll-forward recovery, use archive logging. Archive logging does not overwrite log files; rather, it creates additional logs to record all transactions since the last backup. Note that you will need more disk space to use archive logging since logs are not reused as in circular logging.
<<<
    If you are installing DB2 Express Edition or DB2 Express-C on a system that has more memory than the maximum memory limit of 4 GB, as outlined in the terms and conditions of the product, you need to explicitly set the DATABASE_MEMORY configuration parameter to 4 GB or less, so that the Self Tuning Memory Manager will work within your licensed memory limits.
    Note: If you have more than one database on that server, the sum of all database memory usage cannot exceed ''4 GB''.
    You can use the Control Center (on Linux platforms only) or the UPDATE DATABASE CONFIGURATION command to make this change. For example, to set the DATABASE_MEMORY limit to 4 GB, enter the following command:

{{{
    DB2 UPDATE DATABASE CONFIGURATION using DATABASE_MEMORY 1000000 IMMEDIATE; 
    CONNECT RESET;
}}}

    Also, when using the Configuration Advisor to assist you in configuring the performance of your database, you need to set the Target Memory on the Server page to a percentage of your total system memory that will ensure you stay under the 4 GB memory limit.
select sysibm.systables.name, sysibm.systables.tbspace from sysibm.systables;
[[DB2 - database sample already exists]]
http://www.michael-thomas.com/tech/db2/db2_survival_guide.htm
The error message results when the number of uncommitted transactions exceeds the space available for logging. There are several ways around this:
#increase the number of primary and secondary logs
#increase the size of a log file (logfilsz)
#or to issue 'COMMITS'
If you are inserting data via IMPORT you have the option to specify a COMMITCOUNT. If you are inserting the data via 'insert' commands, every x number of inserts you should issue a commit.

Increase the DB2 transaction log sizes by typing:
{{{
db2 update db cfg for ldaptest using logprimary X
db2 update db cfg for ldaptest using logsecond X
}}}
where X is greater than what is currently defined.

For large amounts of data, LOAD is a better option than import.  Import does inserts while LOAD writes data directly into the database. No logging done during Loads.  Load is faster than import.

if using a commitcount of 100 every 100 data sets will be commited.
!Tuning memory in DB2
<<<
!!Set up buffer pools.

Setting up the buffer pools is critical to performance. By default, DB2 provides a single buffer pool named IBMDEFAULTBP. The DB2 9 default characteristic for IBMDEFAULTBP is to use automatic sizing.

You should create a separate buffer pool for each table space. The database snapshot should be reviewed to check the buffer pool physical read values. The buffer pool should be large enough that a snapshot of a map redraw results in a small number of physical reads.
<<<
<<<
!!Properly set the package cache size parameter (PCKCACHESIZE).

Package cache size specifies the amount of memory allocated for caching dynamic and static SQL requests. This is allocated at database startup and freed at shutdown. If DB2 does not find a SQL statement in the package cache, the statement will need to be recompiled (dynamic SQL) or loaded from the package catalog (static SQL), which can consume considerable time.

The DB2 9 default parameter value for PCKCACHESIZE is AUTOMATIC. Depending upon system configuration, you may not have to maintain this item.

ESRI recommends you start with an initial size of 6,000 and monitor the package cache lookups and package cache insert values in a database snapshot.
<<<
DB2 offers the db2pd utility you can use to collect statistics on your DB2 instances and databases to help you troubleshoot problems, monitor your databases, and tune database performance. For information on how to use this utility, consult the DB2 online documentation.

DB2 also offers a tool—the Configuration Advisor, provided with the Control Center—that is designed to capture specific information about your database environment and recommend changes to configuration parameters based on the information you provide.
http://www.ibm.com/developerworks/data/library/techarticle/dm-0509wright/index.html
DB2 Info here
!DB2 - Online help
*Online help: ''http://publib.boulder.ibm.com/infocenter/db2luw/v9r5/index.jsp''
!DB2 - General
*[[DB2 Problems]]
*[[DB2 Deadlocks]]
*[[DB2 Disk I/O]]
*[[DB2 Tuning memory]]
----
*[[DB2 - Autostart an instance]]
*[[DB2 - Reset Database]]
*[[DB2 - Get Database size]]
*[[DB2 - Limit Database size]]
*[[DB2 - Drop Database]]
*[[DB2 - Close connection]]
*[[DB2 - Create schema]]
*[[DB2 - Compress db2diag.log]]
*[[DB2 - Delete all rows quickly]]
*[[DB2 - Select limit output]]
*[[DB2 - Logs]]
*[[DB2 - snapshots]]
*[[DB2 - How to uninstall DB2 server]]
!DB2 - Install - Server - Client - Fix Pack
*An instance called db2inst1 is created during DB2 installation, along with three users: db2inst1,db2fenc1,dasusr1
*[[DB2 - Server Install on a Linux host]]
*[[DB2 - Manual Server Installation on Linux]]
*[[DB2 - Client Install on a Linux host]]
*[[DB2 - Server upgrade on a Linux host]]
*[[DB2 - Server deinstall on a Linux host]]
*[[DB2 - Install Fix Pack]]
*[[DB2 - Post Installations Tasks]]
*[[DB2 - Setting up notification and contact lists]]
*[[DB2 - Set the port number of the instance]]
*[[DB2 - Connect from a db2 client]]
!DB2 - Backup - Restore - TSM
*[[DB2 - Performing a Database Backup, Restore, and Rollforward]]
*[[DB2 - Backup a database]]
*[[DB2 - Restore a database]]
*[[DB2 - Backup - Restore]]
*[[DB2 - Check TSM backup]]
*[[DB2 - Check backup]]
*[[DB2 - export / import data]]
*[[DB2 - Move data]]
*[[DB2 - db2look]]
*[[DB2 - Using DB2 incremental backup]]
!DB2 - Check
*[[DB2 - Check memory use]]
*[[DB2 - Check DB2]]
*[[DB2 - TCP/IP keepalive settings and related DB2 registry variables]]
*[[DB2 - Tablespaces Pages Full]]
!DB2 - Commands
*[[DB2 - activate]]
*[[DB2 - list]]
*[[DB2 - get]]
*[[DB2 - force]]
*[[DB2 - grant]]
*[[DB2 - revoke]]
*[[DB2 - alter]]
*[[DB2 - alter bufferpool]]
*[[DB2 - alter sequence]]
*[[DB2 - alter tablespace]]
*[[DB2 - update]]
*[[DB2 - drop]]
*[[DB2 - db2mtrk - check memory for database]]
*[[DB2 - db2pd]]
*[[DB2 - reorg]]
*[[DB2 - catalog - uncatalog]]
*[[DB2 - select]]
!DB2 - Create Commands
*[[DB2 - Create new DB2 instances]]
*[[DB2 - Create users for DB2]]
*[[DB2 - Create groups for DB2]]
*[[DB2 - Create schema]]
*[[DB2 - Create Tablespace]]
*[[DB2 - Create Bufferpool]]
*[[DB2 - Create Table]]
*[[DB2 - Create View]]
*[[DB2 - Create Index]]
!DB2 - other
*[[DB2 - Generating Unique Values in DB2 Universal Database]]
*[[DB2 - Putting Your DB2 Database to the Test: Measuring Performance with JMeter]]
----
*[[DB2 Transaction logs full]]
*[[DB2 Survival Guide]]
*[[DB2 Basics: Table Spaces and Buffer Pools]]
*[[Register a DB2 license]]
*[[DB2 - Set the communication protocols for the instance]]
*[[Increase the DB2 transaction log sizes]]
*[[DB2 Express Edition memory limits and the DATABASE_MEMORY configuration parameter]]
*[[DB2 memory and file cache performance tuning on Linux]]
*[[DB2 Get list of tables with corresponding tablespaces]]
*[[DB2 - Copy a schema]]
*[[DB2 - Drop a schema]]
*[[DB2 - Resetting a auto-increment column]]
*[[DB2 - How to find the next generated value for a auto-increment column?]]
*[[DB2 - Create a stored procedure]]
----
*[[DB2 - db2 -tvf file.ddl]]
----
*[[DB2 - Services]]
----
*[[DB2 - Connectivity]]
[[Welcome]]
[[Emacs - Command list]]


C = Control
M = Meta = Alt|Esc

''Basics''
{{{
C-x C-f "find" file i.e. open/create a file in buffer
C-x C-s save the file
C-x C-w write the text to an alternate name
C-x C-v find alternate file
C-x i insert file at cursor position
C-x b create/switch buffers
C-x C-b show buffer list
C-x k kill buffer
C-z suspend emacs
C-X C-c close down emacs
}}}
''Basic movement''
{{{
C-f forward char
C-b backward char
C-p previous line
C-n next line
M-f forward one word
M-b backward one word
C-a beginning of line
C-e end of line
C-v one page up
M-v scroll down one page
M-< beginning of text
M-> end of text
}}}
''Editing''
{{{
M-n repeat the following command n times
C-u repeat the following command 4 times
C-u n repeat n times
C-d delete a char
M-d delete word
M-Del delete word backwards
C-k kill line
}}}
{{{
C-Space Set beginning mark (for region marking for example)
C-W "kill" (delete) the marked region region
M-W copy the marked region
C-y "yank" (paste) the copied/killed region/line
M-y yank earlier text (cycle through kill buffer)
C-x C-x exchange cursor and mark
}}}
{{{
C-t transpose two chars
M-t transpose two words
C-x C-t transpose lines
M-u make letters uppercase in word from cursor position to end
M-c simply make first letter in word uppercase
M-l opposite to M-u
}}}
''Important''
{{{
C-g quit the running/entered command
C-x u undo previous action
M-x revert-buffer RETURN (insert like this) undo all changes since last save
M-x recover-file RETURN Recover text from an autosave-file
M-x recover-session RETURN if you edited several files
}}}
''Online-Help''
{{{
C-h c which command does this keystroke invoke
C-h k which command does this keystroke invoke and what does it do?
C-h l what were my last 100 typed keys
C-h w what key-combo does this command have?
C-h f what does this function do
C-h v what's this variable and what is it's value
C-h b show all keycommands for this buffer
C-h t start the emacs tutorial
C-h i start the info reader
C-h C-k start up info reader and go to a certain key-combo point
C-h F show the emacs FAQ
C-h p show infos about the Elisp package on this machine
}}}
''Search/Replace''
{{{
C-s Search forward
C-r search backward
C-g return to where search started (if you are still in search mode)
M-% query replace
}}}
{{{
    Space or y replace this occurence
    Del or n don't replace
    . only replace this and exit (replace)
    , replace and pause (resume with Space or y)
    ! replace all following occurences
    ^ back to previous match
    RETURN or q quit replace
}}}
''Search/Replace with regular expressions''
{{{
Characters to use in regular expressions:
^ beginning of line
$ end of line
. single char
.* group or null of chars
\< beginning of a word
\> end of a word
[] every char inside the backets (for example [a-z] means every small letter)
}}}
{{{
M C-s RETURN search for regular expression forward
M C-r RETURN search for regular expression backward
M C-s incremental search
C-s repeat incremental search
M C-r incremental search backwards
C-r repeat backwards
M-x query-replace-regexp search and replace
}}}
''Window-Commands''
{{{
C-x 2 split window vertically
C-x o change to other window
C-x 0 delete window
C-x 1 close all windows except the one the cursors in
C-x ^ enlarge window
M-x shrink-window command says it ;-)
M C-v scroll other window
C-x 4 f find file in other window
C-x 4 o change to other window
C-x 4 0 kill buffer and window
C-x 5 2 make new frame
C-x 5 f find file in other frame
C-x 5 o change to other frame
C-x 5 0 close this frame
}}}
''Bookmark commands''
{{{
C-x r m set a bookmark at current cursor pos
C-x r b jump to bookmark
M-x bookmark-rename says it
M-x bookmark-delete "
M-x bookmark-save "
C-x r l list bookmarks
}}}
{{{
    d mark bookmark for deletion
    r rename bookmark
    s save all listed bookmarks
    f show bookmark the cursor is over
    m mark bookmarks to be shown in multiple window
    v show marked bookmarks (or the one the cursor is over)
    t toggle listing of the corresponding paths
    w " path to this file
    x delete marked bookmarks
    Del ?
    q quit bookmark list
}}}
{{{
M-x bookmark-write write all bookmarks in given file
M-x bookmark-load load bookmark from given file
}}}
''Shell''
{{{
M-x shell starts shell modus
C-c C-c same as C-c under unix (stop running job)
C-d delete char forward
C-c C-d Send EOF
C-c C-z suspend job (C-z under unix)
M-p show previous commands
}}}
''DIRectory EDitor (dired)''
{{{
C-x d start up dired
C (large C) copy
d mark for erase
D delete right away
e or f open file or directory
g reread directory structure from file
G change group permissions (chgrp)
k delete line from listing on screen (don't actually delete)
m mark with *
n move to next line
o open file in other window and go there
C-o open file in other window but don't change there
P print file
q quit dired
Q do query-replace in marked files
R rename file
u remove mark
v view file content
x delete files marked with D
z compress file
M-Del remove all marks (whatever kind)
~ mark backup files (name~ files) for deletion
# mark auto-save files (#name#) for deletion
*/ mark directory with * (C-u * removes that mark again)
= compare this file with marked file
M-= compare this file with it's backup file
! apply shell command to this file
M-} change to the next file marked with * od D
M-{ " previous "
% d mark files described through regular expression for deletion
% m " (with *)
+ create directory
> changed to next dir
< change to previous dir
s toggle between sorting by name or date
}}}
{{{
Maybe into this category also fits this command:
M-x speedbar starts up a separate window with a directory view
}}}
''Telnet''
{{{
M-x telnet starts up telnet-modus
C-d either delete char or send EOF
C-c C-c stop running job (similar to C-c under unix)
C-c C-d send EOF
C-c C-o clear output of last command
C-c C-z suspend execution of command
C-c C-u kill line backwards
M-p recall previous command
}}}
''Text''
{{{
Works only in text mode
M-s center line
M-S center paragraph
M-x center-region name says
}}}
''Macro-commands''
{{{
C-x ( start macro definition
C-x ) end of macro definition
C-x e execute last definied macro
M-n C-x e execute last defined macro n times
M-x name-last-kbd-macro give name to macro (for saving)
M-x insert-keyboard-macro save named macro into file
M-x load-file load macro
M-x macroname execute macroname
}}}
''Programming''
{{{
M C-\ indent region between cursor and mark
M-m move to first (non-space) char in this line
M-^ attach this line to previous
M-; formatize and indent comment
C, C++ and Java Modes
M-a beginning of statement
M-e end of statement
M C-a beginning of function
M C-e end of function
C-c RETURN Set cursor to beginning of function and mark at the end
C-c C-q indent the whole function according to indention style
C-c C-a toggle modus in which after electric signs (like {}:';./*) emacs does the indention
C-c C-d toggle auto hungry mode in which emacs deletes groups of spaces with one del-press
C-c C-u go to beginning of this preprocessor statement
C-c C-c comment out marked area
More general (I guess)
M-x outline-minor-mode collapses function definitions in a file to a mere {...}
M-x show-subtree If you are in one of the collapsed functions, this un-collapses it
In order to achive some of the feats coming up now you have to run etags *.c *.h *.cpp (or what ever ending you source files have) in the source directory
M-. (Thats Meta dot) If you are in a function call, this will take you to it's definition
M-x tags-search ENTER Searches through all you etaged
M-, (Meta comma) jumps to the next occurence for tags-search
M-x tags-query-replace yum. This lets you replace some text in all the tagged files
}}}
''GDB (Debugger)''
{{{
M-x gdb starts up gdm in an extra window
}}}
''Version Control''
{{{
C-x v d show all registered files in this dir
C-x v = show diff between versions
C-x v u remove all changes since last checkin
C-x v ~ show certain version in different window
C-x v l print log
C-x v i mark file for version control add
C-x v h insert version control header into file
C-x v r check out named snapshot
C-x v s create named snapshot
C-x v a create changelog file in gnu-style
}}}
[[Fiber and Copper - how do they compare?]]
[[Fiber - Insertion loss]]
[[Fiber - Single mode - Multi mode]]
[[Fiber - Core sizes]]
There are three core sizes of fiber cables: ''62.5/125'', ''50/125'', and ''8.3/125''. 
For each size, the first number represents the size of the fiber core (in microns) and the second number represents the size of the cladding, the inside layer around the core.
''Understanding Insertion Loss with Fiber Optics''
Insertion loss, also known as optical loss, refers to the amount of light that is lost from one end of the fiber-optic cable to the other. This can occur due to absorption or dispersion of the light within the cable. Measured in decibels (dBs), this loss can be tested with a number of fiber test sets on the market today.
''Multimode fiber'' has a larger-diameter core and supports multiple pathways, or modes, of light. Several pathways of light are transmitted simultaneously through the fiber, bouncing off the edge of the core. Multimode fiber is best suited for shorter-distance applications.

''Singlemode fiber'' permits only one pathway to travel through the core. This allows data to travel greater distances than over multimode, up to 50 times more. Singlemode offers the best solution in situations where low signal loss and high data rates are required, such as long-haul network applications, those spread out over campuses and greater distances.
||!Copper|!Fiber|
| Security | Can be compromised | Multimode |
| Distance | 100 meters @ 1,000Mbps | 40km or more at 10,000Mbps |
| Electrical Noise | Vulnerable to cross talk and voltage interference | Impervious |
| Installation/Use | Thicker and heavier | lightweight and thin diameter |
Morris Gray has very nice lists of how to do ASCII symbols, Greek and Latin symbols, HTML entities and Math symbols at his wonderful TW Help site. To see these lists at his site, [[click here|http://twhelp.tiddlyspot.com/#Entities-Codes]].
''Line-by-line blockquotes:''
{{{>level 1}}}
{{{>level 1}}}
{{{>>level 2}}}
{{{>>level 2}}}
{{{>>>level 3}}}
{{{>>>level 3}}}
{{{>>level 2}}}
{{{>level 1}}}

produces:
>level 1
>level 1
>>level 2
>>level 2
>>>level 3
>>>level 3
>>level 2
>level 1

''Extended blockquotes:''
{{{<<<}}}
{{{Extended blockquotesExtended blockquotesExtended blockquotesExtended blockquotesExtended blockquotesExtended blockquotesExtended blockquotesExtended blockquotesExtended blockquotesExtended blockquotesExtended blockquotesExtended blockquotesExtended blockquotesExtended blockquotesExtended blockquotesExtended blockquotesExtended blockquotesExtended blockquotes}}}
{{{<<<}}} 

produces:
<<<
Extended blockquotesExtended blockquotesExtended blockquotesExtended blockquotesExtended blockquotesExtended blockquotesExtended blockquotesExtended blockquotesExtended blockquotesExtended blockquotesExtended blockquotesExtended blockquotesExtended blockquotesExtended blockquotesExtended blockquotesExtended blockquotesExtended blockquotesExtended blockquotes
<<<

|bgcolor(#dddddd):Links with wikiwords|EnchiLada (inactive link - no tiddler yet)<br>WikiWord (active link to tiddler)|{{{EnchiLada}}}<br>{{{WikiWord}}}|
|bgcolor(#dddddd):~De-Wikify a ~WikiWord|~WikiWord, ~EnchiLada|{{{~WikiWord, ~EnchiLada}}}|
|bgcolor(#dddddd):Links with brackets|[[How to add background images]]|{{{[[How to add background images]]}}}|
|bgcolor(#dddddd):Pretty links|[[display text|ColorSchemes]] - links to the tiddler of color schemes|{{{[[display text|ColorSchemes]]}}}|
|bgcolor(#dddddd):External links work the same way:|http://groups.google.com/group/TiddlyWiki <br><br>[[TiddlyWiki Google group|http://groups.google.com/group/TiddlyWiki]]|{{{http://groups.google.com/group/TiddlyWiki}}} <br><br> {{{[[TiddlyWiki Google group|http://groups.google.com/group/TiddlyWiki]]}}}|
|bgcolor(#dddddd):Links to local files|To a file on a CD in your D drive: <br><br>To a file on your USB stick on your e drive: <br><br>To a file in your hard drive:|{{{file:///D:/filename.doc/}}}<br><br>{{{file:///E:/filename.doc/}}}<br><br>{{{file:///C:/filepath/filename.doc/}}}| 

''Images:''
{{{[img[http://farm1.static.flickr.com/39/122259544_6913ca58f3_m.jpg]]}}} is the formatting for:

[img[http://farm1.static.flickr.com/39/122259544_6913ca58f3_m.jpg]]

''A tip from Jeremy Hodge:''
"...[You] may add an image as a local file with the following: {{{[img[.\filepath\filename.jpg]]}}} which adds a picture from the directory that is contained within the same directory as TW. This is very useful for me or anyone who carries their own TW on a USB drive such as myself."

''Numbered lists:''
{{{#item one }}}
{{{##Item 1a}}}
{{{###Item 1ai}}} 

produces:
#item one   
##Item 1a 
###Item 1ai 
''Bulleted lists:''
{{{*Bullet one}}}
{{{**Bullet two}}}
{{{***Bullet three}}}
 
produces:
*Bullet one    
**Bullet two    
***Bullet level three    

!This is the formatting:

{{{|!Table header|!Column Two|}}}
{{{|>| colspan |}}}
{{{| rowspan |left aligned|}}}
{{{|~| right aligned|}}}
{{{|bgcolor(#DC1A1A):colored| centered |}}}
{{{||*lists<br>*within<br>*tables<br><br>and double-spaced too|}}}
{{{|caption|c}}}

!This is the result:

|!Table header|!Column Two|
|>| colspan |
| rowspan |left aligned|
|~| right aligned|
|bgcolor(#DC1A1A):colored| centered |
||*lists<br>*within<br>*tables<br><br>and double-spaced too|
|caption|c

[[More information on tables]]
!Format text
|!Format|!It will look like this...|!...if you format it like this...|
|Bold-faced type|''text''|{{{''text''}}}|
|Italic text|//text//|{{{//text//}}}|
|Underlined text|__text__|{{{__text__}}}|
|Strike-through text|--text--|{{{--text--}}}|
|Colored text|@@color(green):green colored@@|{{{@@color(green):green colored@@}}}|
|Text with colored background|@@bgcolor(#ff0000):color(#ffffff):red colored@@|{{{@@bgcolor(#ff0000):color(#ffffff):red colored@@}}}|
|Highlighting|@@text@@|{{{@@text@@}}}|
|Superscript|2^^3^^=8|{{{2^^3^^=8}}}|
|Subscript|a~~ij~~ = -a~~ji~~|{{{a~~ij~~ = -a~~ji~~}}}|

!Make the first letter of a paragraph extra large
(from Morris Gray's TW Help)

''Sample'':

{{firstletter{
 @@color:#bbbbbb;O@@}}}kay, so you know how to use ~TiddlyWiki, but now you want more. You want to change the color or layout. You want to add features to it. As the subtitle says, this is an entry-level introduction, so I am not going to show you how to do every possible thing you can do with ~TiddlyWiki. I probably don't know half of what can be done. Advanced documentation such as that found at http://www.tiddlywiki.org/wiki and http://tiddlyspot.com/twhelp/ can hopefully expand your horizons. 

''How to do it:''

1. Add the following code to your StyleSheet:

 {{{
.firstletter{ float:left; width:0.75em; font-size:400%; font-family:times,arial; line-height:60%; }
}}}

2. Add the following code to your tiddler at the place where your enlarged letter would go (replacing "O" with the appropriate letter):
{{{
{{firstletter{
 @@color:#c06;O@@
 }}}
}}}
[img[http://lh4.ggpht.com/_odP7v2tr9u4/SmdbpAXsu0I/AAAAAAAACc8/jIA5L5rOWB0/s640/IMG_2128.JPG]]
[img[http://lh5.ggpht.com/_odP7v2tr9u4/SCy1z_xVd2I/AAAAAAAAAHE/ZDQQbe3NT8I/s640/IMG_0405.JPG]]
http://picasaweb.google.com/hvanbelle/Werfenweg2008#slideshow
[[Google - Links]]
|!What?|!URL|
|Google sites - ''hvanbelle''|http://sites.google.com/site/hvanbelle/|
|Google sites - ''hvanbelle2''|http://sites.google.com/site/hvanbelle2/|
|!What?|!URL|
|Google - ''iGoogle''|http://www.google.com/ig/|
|!What?|!URL|
|Google code|http://code.google.com/|
|Google code - ''Site Directory''|http://code.google.com/more/|
|Google code - Google ''Android''|http://code.google.com/android/|
|Google code - Google ''App Engine''|http://code.google.com/appengine/|
|Google code - Google ''Gadgets API''|http://code.google.com/apis/gadgets/|
|Google code - Google ''Apps Script''|http://code.google.com/googleapps/appsscript/|
|Google code - Google ''Book Search APIs (Labs)''|http://code.google.com/apis/books/|
|Google code - Google ''Project Hosting''|http://code.google.com/projecthosting/|
[[The fundamental differences between "GET" and "POST"]]
[[HtmlEntities]]
[[MathHtmlEntities]]
[[HTTP Error 500 Internal server error]]
''Introduction''

*The Web server (running the Web Site) encountered an unexpected condition that prevented it from fulfilling the request by the client (e.g. your Web browser or our CheckUpDown robot) for access to the requested URL.
*This is a 'catch-all' error generated by the Web server. Basically something has gone wrong, but the server can not be more specific about the error condition in its response to the client. In addition to the 500 error notified back to the client, the Web server should generate some kind of internal error log which gives more details of what went wrong. It is up to the operators of the Web server site to locate and analyse these logs.

''500 errors in the HTTP cycle''

*Any client (e.g. your Web browser or our CheckUpDown robot) goes through the following cycle when it communicates with the Web server:
**Obtain an IP address from the IP name of the site (the site URL without the leading 'http://'). This lookup (conversion of IP name to IP address) is provided by domain name servers (DNSs).
*Open an IP socket connection to that IP address.
**Write an HTTP data stream through that socket.
**Receive an HTTP data stream back from the Web server in response. This data stream contains status codes whose values are determined by the HTTP protocol. Parse this data stream for status codes and other useful information.
*This error occurs in the final step above when the client receives an HTTP status code that it recognises as '500'.

''Fixing 500 errors - general''

*This error can only be resolved by fixes to the Web server software. It is not a client-side problem. It is up to the operators of the Web server site to locate and analyse the logs which should give further information about the error.

''Fixing 500 errors - CheckUpDown''

*Please contact us (email preferred) whenever you encounter 500 errors on your CheckUpDown account. We then have to liaise with your ISP and the vendor of the Web server software so they can trace the exact reason for the error. Correcting the error may require recoding program logic for the Web server software, which could take some time.

http://www.checkupdown.com/status/E500.html
[[Fiber]]
[[Physical Addressing Extensions (PAE)]]
[[Rescan scsi bus]]
[[Recovering from multiple Defunct Dead Disks (DDDs) in a ServeRAID environment]]
http://www.giffmex.org/twfortherestofus.html
Entities in HTML documents allow characters to be entered that can't easily be typed on an ordinary keyboard. They take the form of an ampersand (&), an identifying string, and a terminating semi-colon (;). There's a complete reference [[here|http://www.htmlhelp.com/reference/html40/entities/]]; some of the more common and useful ones are shown below. Also see [[Paul's Notepad|http://thepettersons.org/PaulsNotepad.html#GreekHtmlEntities%20HtmlEntitiesList%20LatinHtmlEntities%20MathHtmlEntities]] for a more complete list.

|>|>|>|>|>|>| !HTML Entities |
| &amp;nbsp; | &nbsp; | no-break space | &nbsp;&nbsp; | &amp;apos; | &apos; | single quote, apostrophe |
| &amp;ndash; | &ndash; | en dash |~| &amp;quot; | " | quotation mark |
| &amp;mdash; | &mdash; | em dash |~| &amp;prime; | &prime; | prime; minutes; feet |
| &amp;hellip; | &hellip; |	horizontal ellipsis |~| &amp;Prime; | &Prime; | double prime; seconds; inches |
| &amp;copy; | &copy; | Copyright symbol |~| &amp;lsquo; | &lsquo; | left single quote |
| &amp;reg; | &reg; | Registered symbol |~| &amp;rsquo; | &rsquo; | right  single quote |
| &amp;trade; | &trade; | Trademark symbol |~| &amp;ldquo; | &ldquo; | left double quote |
| &amp;dagger; | &dagger; | dagger |~| &amp;rdquo; | &rdquo; | right double quote |
| &amp;Dagger; | &Dagger; | double dagger |~| &amp;laquo; | &laquo; | left angle quote |
| &amp;para; | &para; | paragraph sign |~| &amp;raquo; | &raquo; | right angle quote |
| &amp;sect; | &sect; | section sign |~| &amp;times; | &times; | multiplication symbol |
| &amp;uarr; | &uarr; | up arrow |~| &amp;darr; | &darr; | down arrow |
| &amp;larr; | &larr; | left arrow |~| &amp;rarr; | &rarr; | right arrow |
| &amp;lArr; | &lArr; | double left arrow |~| &amp;rArr; | &rArr; | double right arrow |
| &amp;harr; | &harr; | left right arrow |~| &amp;hArr; | &hArr; | double left right arrow |

The table below shows how accented characters can be built up by subsituting a base character into the various accent entities in place of the underscore ('_'):

|>|>|>|>|>|>|>|>|>|>|>|>|>|>|>|>|>| !Accented Characters |
| grave accent | &amp;_grave; | &Agrave; | &agrave; | &Egrave; | &egrave; | &Igrave; | &igrave; | &Ograve; | &ograve; | &Ugrave; | &ugrave; | &nbsp; | &nbsp; | &nbsp; | &nbsp; | &nbsp; | &nbsp; |
| acute accent | &amp;_acute; | &Aacute; | &aacute; | &Eacute; | &eacute; | &Iacute; | &iacute; | &Oacute; | &oacute; | &Uacute; | &uacute; | &nbsp; | &nbsp; | &Yacute; | &yacute; | &nbsp; | &nbsp; |
| circumflex accent | &amp;_circ; | &Acirc; | &acirc; | &Ecirc; | &ecirc; | &Icirc; | &icirc; | &Ocirc; | &ocirc; | &Ucirc; | &ucirc; | &nbsp; | &nbsp; | &nbsp; | &nbsp; | &nbsp; | &nbsp; |
| umlaut mark | &amp;_uml; | &Auml; | &auml; |  &Euml; | &euml; | &Iuml; | &iuml; | &Ouml; | &ouml; | &Uuml; | &uuml; | &nbsp; | &nbsp; | &Yuml; | &yuml; | &nbsp; | &nbsp; |
| tilde | &amp;_tilde; | &Atilde; | &atilde; | &nbsp; | &nbsp; | &nbsp; | &nbsp; | &Otilde; | &otilde; | &nbsp; | &nbsp; | &Ntilde; | &ntilde; | &nbsp; | &nbsp; | &nbsp; | &nbsp; |
| ring | &amp;_ring; | &Aring; | &aring; | &nbsp; | &nbsp; | &nbsp; | &nbsp; | &nbsp; | &nbsp; | &nbsp; | &nbsp; | &nbsp; | &nbsp; | &nbsp; | &nbsp; | &nbsp; |
| slash | &amp;_slash; | &nbsp; | &nbsp; | &nbsp; | &nbsp; | &nbsp; | &nbsp; | &Oslash; | &oslash; | &nbsp; | &nbsp; | &nbsp; | &nbsp; | &nbsp; | &nbsp; | &nbsp; |
| cedilla | &amp;_cedil; | &nbsp; | &nbsp; | &nbsp; | &nbsp; | &nbsp; | &nbsp; | &nbsp; | &nbsp; | &nbsp; | &nbsp; | &nbsp; | &nbsp; | &nbsp; | &nbsp; | &Ccedil; | &ccedil; |
db2 update db cfg for ldaptest using logprimary X
db2 update db cfg for ldaptest using logsecond X
where X is greater than what is currently defined.
*The TSM Linux client installs into ''/opt/tivoli/tsm/client/''  with some additional files placed in ''/usr/lib''  and ''/usr/bin''
*The relevant executables are:
|!Application|!Description|
|''dsmj''|The Java GUI client|
|''dsmc''|The command line client|
|''dsmtca''|The 'trusted client agent', which allows non-root users to connect to the HFS|
|''dsmcad''|The client-acceptor daemon, which manages scheduled backups|
*A file /etc/TIVGUID is created the first time a client is run. This file holds the Global Unique Identifier that associates a TSM client with a TSM server and should not be edited or removed.
*The password for the HFS account will be stored in an encrypted form, readable only by root, in ''/etc/adsm/TSM.PWD''
*''/opt/tivoli/tsm/client/ba/bin/tsm-install.log'': describes what the post installation scripts have attempted to do, and highlights any problems
*TSM needs two configuration files: (these files are installed in the installation directory ''/opt/tivoli/tsm/client/ba/bin/'')
**dsm.sys
**dsm.opt
*Log file location
|!Log file|!Location|!Description|
|''dsmerror.log''|$HOME|Logs any errors when running manual backups|
|''dsmsched.log''|/var/log|Logs all transactions when running scheduled backups|
|''dsmwebcl.log''|/var/log|Logs the time of next scheduled backup|
|''dsmerror.log''|/var/log|Logs any errors when running scheduled backups|
*Using the Command Line Interface (CLI) to change the password
{{{
dsmc
tsm>  set password [oldpassword] [newpassword]
}}}
[[Putting Your DB2 Database to the Test: Measuring Performance with JMeter]]
[[Java - Understanding Java's "Perm Gen" (MaxPermSize, heap space, ...)]]
*JVM arg -Xmx defines the maximum heap size.  
*Arg -Xms defines the initial heap size.  
Here is an example showing how you use these JVM arguments:
>-Xmx1638m -Xms512m
In Tomcat, these settings would go in your startup.sh or init script, depending on how you start and run Tomcat.  
With regards to the MaxPermSize, this argument adjusts the size of the "permanent generation."  
As I understand it, the perm gen holds information about the "stuff" in the heap.  
So, the heap stores the objects and the perm gen keeps information about the "stuff" inside of it.  
Consequently, the larger the heap, the larger the perm gen needs to be.  
Here is an example showing how you use MaxPermSize:
>-XX:MaxPermSize=128m

*Here are some additional notes on interesting/important JVM parameters:
>Use the JVM options ''-XX:+TraceClassloading'' and ''-XX:+TraceClassUnloading'' to see what classes are loaded/un-loaded in real-time.  
>If you have doubts about excessive class loading in your app; this might help you find out exactly what classes are loaded and where.

>Use ''-XX:+UseParallelGC'' to tell the JVM to use multi-threaded, one thread per CPU, garbage collection.  This might improve GC performance since the default garbage collector is single-threaded.  
>Define the number of GC threads to use with the ''-XX:ParallelGCThreads={no of threads}'' option.

>Never call ''System.gc()''.  
>The application doesn't know the best time to garbage-collect, only the JVM really does.

>The JVM option ''-XX:+AggressiveHeap'' inspects the machine resources (size of memory and number of processors) and attempts to set various heap and memory parameters to be optimal for long-running, memory allocation-intensive jobs.
[[Javascript examples]]
{{{
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html>
<head>

<script type="text/javascript">
function MsgBox(textstring) {
	alert(textstring);
}
</script>

</head>

<body>

<form action="text/javascript" id="aform">
<div>
<input name="text1" type="text"  value="Type Some Text"/>
<input name="submit" type="button" value="Show Me" onclick="MsgBox(document.getElementById('aform').text1.value)"/>
</div>
</form>

</body>
</html>
}}}
[[Javascript - push_a_button.html]]
{{invisibletable{
|width:25em; When I became acquainted with ~TiddlyWiki in September 2006 I //instantly// realized how useful it would be for me. But at the time there was not much documentation, and what little existed was written by and for computer geniuses. Their documentation assumed that the reader already knew quite a bit about various computer codes and the inner workings of ~TiddlyWiki.<br><br>So I had to learn ~TiddlyWiki the hard, slow way. The people at the ~TiddlyWiki Google group were very helpful in guiding me along. But I knew not every newcomer like me would want to go through such a tedious learning process. So I decided to create this simple tutorial. If you've heard about ~TiddlyWiki but don't know "Tiddly squat" about it, then this tutorial is for you. Enjoy!|''Basic instructions:''<br>[[What in the world is a TiddlyWiki?]]<br>[[For beginners: reading TiddlyWikis on the Internet]]<br>[[Save a TiddlyWiki file to your computer]]<br>[[Browser-specific issues]]<br>[[Printing from a TiddlyWiki file]]<br>[[For medium users: adding your own material to a TiddlyWiki file]]<br>[[For advanced users: Customize your TW experience]]<br>[[Host your TiddlyWiki online]]<br><br>''Also helpful:''<br>[[A visual guide to the TiddlyWiki layout]]<br>[[Version 2.2]]<br>[[Special formatting]]<br>[[Where to go for more information]]<br><br>If you found this tutorial helpful, would you consider helping me buy books via an Amazon gift certificate?<br><br><html><a href="https://www.amazon.com/gp/registry/wishlist/1OTJM9IE7SPVS/ref=wl_web/"><img src="https://images-na.ssl-images-amazon.com/images/G/01/gifts/registries/wishlist/v2/web/wl-btn-74-b._V46774601_.gif" width="74" alt="My Amazon.com Wish List" height="42" border="0" /></a></html>|
}}}


{{invisibletable{
|width:25em; Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy <br><br>Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy Enjoy |''Basic instructions:''<br>[[What in the world is a TiddlyWiki?]]<br>''Also helpful:''<br>[[A visual guide to the TiddlyWiki layout]]<br>[[Version 2.2]]<br>[[Special formatting]]<br>[[Where to go for more information]]<br><br>If you found this tutorial helpful, would you consider helping me buy books via an Amazon gift certificate?<br><br>|
}}}


!Inline Formatting
|!Option|!Syntax|!Output|
|bold font|{{{''bold''}}}|''bold''|
|italic type|{{{//italic//}}}|//italic//|
|underlined text|{{{__underlined__}}}|__underlined__|
|strikethrough text|{{{--strikethrough--}}}|--strikethrough--|
|superscript text|{{{^^super^^script}}}|^^super^^script|
|subscript text|{{{~~sub~~script}}}|~~sub~~script|
|highlighted text|{{{@@highlighted@@}}}|@@highlighted@@|
|preformatted text|<html><code>{{{preformatted}}}</code></html>|{{{preformatted}}}|
!Block Elements
!!Headings
{{{
!Heading 1
!!Heading 2
!!!Heading 3
!!!!Heading 4
!!!!!Heading 5
}}}
<<<
!Heading 1
!!Heading 2
!!!Heading 3
!!!!Heading 4
!!!!!Heading 5
<<<
!!Lists
{{{
* unordered list, level 1
** unordered list, level 2
*** unordered list, level 3

# ordered list, level 1
## ordered list, level 2
### unordered list, level 3

; definition list, term
: definition list, description
}}}
<<<
* unordered list, level 1
** unordered list, level 2
*** unordered list, level 3

# ordered list, level 1
## ordered list, level 2
### unordered list, level 3

; definition list, term
: definition list, description
<<<
!!Blockquotes
{{{
> blockquote, level 1
>> blockquote, level 2
>>> blockquote, level 3

<<<
blockquote
<<<
}}}
<<<
> blockquote, level 1
>> blockquote, level 2
>>> blockquote, level 3

> blockquote
<<<
!!Preformatted Text
<html><pre>
{{{
preformatted (e.g. code)
}}}
</pre></html>
<<<
{{{
preformatted (e.g. code)
}}}
<<<
!!Tables
{{{
|CssClass|k
|!heading column 1|!heading column 2|
|row 1, column 1|row 1, column 2|
|row 2, column 1|row 2, column 2|
|>|COLSPAN|
|ROWSPAN| … |
|~| … |
|CssProperty:value;…| … |
|caption|c
}}}
''Annotation:''
* The {{{>}}} marker creates a "colspan", causing the current cell to merge with the one to the right.
* The {{{~}}} marker creates a "rowspan", causing the current cell to merge with the one above.
<<<
|CssClass|k
|!heading column 1|!heading column 2|
|row 1, column 1|row 1, column 2|
|row 2, column 1|row 2, column 2|
|>|COLSPAN|
|ROWSPAN| … |
|~| … |
|CssProperty:value;…| … |
|caption|c
<<<
!!Images /% TODO %/
cf. [[TiddlyWiki.com|http://www.tiddlywiki.com/#EmbeddedImages]]
!Hyperlinks
* [[WikiWords|WikiWord]] are automatically transformed to hyperlinks to the respective tiddler
** the automatic transformation can be suppressed by preceding the respective WikiWord with a tilde ({{{~}}}): {{{~WikiWord}}}
* [[PrettyLinks]] are enclosed in square brackets and contain the desired tiddler name: {{{[[tiddler name]]}}}
** optionally, a custom title or description can be added, separated by a pipe character ({{{|}}}): {{{[[title|target]]}}}<br>''N.B.:'' In this case, the target can also be any website (i.e. URL).
!Custom Styling
* {{{@@CssProperty:value;CssProperty:value;…@@}}}<br>''N.B.:'' CSS color definitions should use lowercase letters to prevent the inadvertent creation of WikiWords.
* <html><code>{{customCssClass{…}}}</code></html>
* raw HTML can be inserted by enclosing the respective code in HTML tags: {{{<html> … </html>}}}
!Special Markers
* {{{<br>}}} forces a manual line break
* {{{----}}} creates a horizontal ruler
* [[HTML entities|http://www.tiddlywiki.com/#HtmlEntities]]
* {{{<<macroName>>}}} calls the respective [[macro|Macros]]
* To hide text within a tiddler so that it is not displayed, it can be wrapped in {{{/%}}} and {{{%/}}}.<br/>This can be a useful trick for hiding drafts or annotating complex markup.
* To prevent wiki markup from taking effect for a particular section, that section can be enclosed in three double quotes: e.g. {{{"""WikiWord"""}}}.
[[Linux - Commands]]
----
[[Linux - Advanced Bash-Scripting Guide]]
[[Linux - rc-boot-scripts in Linux]]
[[Linux - Bringing up an Ethernet interface with ifconfig]]
[[Linux - Setting the Default Route]]
[[Linux - Removing a static network route and adding a static host route]]
[[Linux - Increasing the file descriptor limit]]
[[Linux - Multipathing]]
[[Linux - takescreenshot.sh]]
[[Linux - writing udev rules]]
[[Linux - How to setup / use multipathing on SLES]]
[[Linux - Howto use a SSL tunnel]]
[[Linux - A tunnel for a VNC server]]
[[Linux - Quickly find the largest files in a directory]]
[[Linux - Create File of a Given Size]]
[[Linux - How to mount your drives over the internet using SSHFS]]
VNCservers use as default port 5900 + DISPLAY_Number. So to access a VNCserver not directly visible at private IP address 192.168.222.222 you can connect to this via a ssh tunnel as follows.

On 192.168.222.222 with name wwwsecrete you start the VNCserver. (Since you most likely can not directly login to wwwsecrete you also have to that via charly)

>''vncserver -geometry 1280x1024 ''

The response of the program is:

New 'wwwsecrete:1 (user)' desktop is wwwsecrete:1

On your local maschine you establish the tunnel through charly:

>''ssh charly.physik.uni-muenchen.de -L 15901:192.168.222.222:5901''

Now you can start the VNCviewer on your local machine with:

>''vncviewer localhost:15901''
http://tldp.org/LDP/abs/html/
''ifconfig eth0 192.168.99.14 netmask 255.255.255.0 up
''
[[Linux-Commands - Check multiple cpu's]]
[[Linux-Commands - Check exported nfs filesystems]]
[[Linux-Commands - Displays top CPU users on a Linux system]]
[[Linux-Commands - iostat command]]
[[Linux-Commands - find large files]]
[[Linux-Commands - Bash -  Get a file's basename, dirname, extension, etc?]]
[[Linux-Commands - Bash -  Substring function?]]
[[Linux-Commands - Bash -  Loop over some command's output]]
[[Linux-Commands - useradd]]
[[Linux-Commands - Decompress and extract a tgz or tar.gz archive in a single step]]
[[Linux-Commands - howto convert iso-8859-1 charset html files into utf-8 charset files]]
[[Linux-Commands - set up ssh keys]]
[[Linux-Commands - convert image]]
[[Linux-Commands - grep]]
[[Linux-Commands - curl]]
[[Linux-Commands - logger]]
[[Linux-Commands - tcpdump]]
[[Linux-Commands - rsync]]
[[Linux-Commands - du]]
[[Linux-Commands - tail]]
[[Linux-Commands - top]]
[[Linux-Commands - find]]
[[Linux-Commands - uuidgen]]
[[Linux-Commands - dd]]
[[Linux-Commands - kill]]
[[Linux-Commands - 2>&1]]
*''dd if=/dev/zero of=output.dat  bs=1024  count=10240''
>(The above dd command creates a zero-filled file named output.dat consisting of a count of 10240 blocks, each of block size 1024)
*''dd if=/dev/zero of=output.dat  bs=1M  count=10''
>(creates a 10M file)
*''dd if=/dev/zero of=output.dat bs=1M count=14''
>(You can also use K / M / G as extension for bs)
*Install ''sshfs''
>''sshfs user@host:directory mountpoint''
*Append the following to /etc/fstab
>''sshfs#user@host:directory mountpoint fuse user 0 0''
>(The “user” argument allows the mount to be manipulated by users other than root. Some distrobutions may complain about a badly-formatted fstab on statup, but this is normal and will not harm your system)
<html>
<head>


<title>How to setup / use multipathing on SLES</title>


</head><body>


<!-- End Rater --><h3>Information</h3>
<p><b>Preamble:</b> The procedure described within this article is only
supported on SLES9 SP2 level and higher. Earlier releases may not work
as expected.</p>
<h3>1. Introduction</h3>
<p>The Multipath IO (MPIO) support in SLES9 (SP2) is based on the
Device Mapper (DM) multipath module of the Linux kernel, and the
multipath-tools user-space package. These have been enhanced and
integrated into SLES9 SP2 by SUSE Development.</p>

<p>DM MPIO is the preferred form of MPIO on SLES9 and the only option completely supported by Novell/SUSE.</p>

<p>DM MPIO features automatic configuration of the MPIO subsystem for a
large variety of setups. Active/passive or active/active (with
round-robin load balancing) configurations of up to 8 paths to each
device are supported.</p>

<p>The framework is extensible both via specific hardware handlers (see
below) or via more sophisticated load balancing algorithms than
round-robin.</p>

<p>The user-space component takes care of automatic path discovery and
grouping, as well as automated path retesting, so that a previously
failed path is automatically reinstated when it becomes healthy again.
This minimizes, if not obviates, the need for administrator attention
in a production environment.</p>
<h3>2. Supported configurations</h3>
<ul>
<li><p><b>Supported hardware: Architectures</b></p> <p>MPIO is
supported on all seven architectures: IA32, AMD64/EM64T, IPF/IA64,
p-Series (32-bit/64-bit), z-Series (31-bit and 64-bit).</p>
</li>
<li><p><b>Supported hardware: Storage subsystems</b></p> <p>The multipath-tools package is currently aware of the following storage subsystems:</p>
<ul>
<li><p>3Pardata VV</p>
</li>
<li><p>Compaq HSV110 / MSA1000</p>
</li>
<li><p>DDN SAN MultiDirector</p>
</li>
<li><p>DEC HSG80</p>
</li>
<li><p>EMC CLARiiON CX</p>
</li>
<li><p>FSC CentricStor</p>
</li>
<li><p>HP HSV110 / A6189A / Open-</p>
</li>
<li><p>Hitachi DF400 / DF500 / DF600</p>
</li>
<li><p>IBM 3542 / ProFibre 4000R</p>
</li>
<li><p>NETAPP</p>
</li>
<li><p>SGI TP9100 / TP9300 / TP9400 / TP9500</p>
</li>
<li><p>STK OPENstorage DS280</p>
</li>
<li><p>SUN StorEdge 3510 / T4</p>
</li>
</ul>
<p>In general, most other storage subsystems should work; however, the
ones above will be detected automatically. Others might require an
appropriate entry in the <code style="font-size: 11px;">/etc/multipath.conf</code> devices section.</p> <p>Storage
arrays which require special commands on fail-over from one path to the
other, or require special non-standard error handling, might require
more extensive support; however, the DM framework has hooks for
hardware handlers, and one such handler for the EMC CLARiiON CX family
of arrays is already provided.</p>
</li>
<li><p><b>Hardware support: Host bus adapters</b></p>
<ul>
<li><p>Qlogic</p>
</li>
<li><p>Emulex</p>
</li>
<li><p>LSI</p>
</li>
</ul>
<p>In general, all Fibre Channel / SCSI cards should work, as our MPIO implementation is above the device layer.</p>
</li>
<li><p><b>Supported software configurations summary</b></p> <p>Currently,
DM MPIO is not available for either the root or the boot partition, as
the boot loader does not know how to handle MPIO.</p> <p>All auxiliary data partitions such as <code style="font-size: 11px;">/home</code> or application data can be placed on an MPIO device.</p> <p>LVM2 is supported on top of DM MPIO. See the setup notes.</p> <p>Partitions are supported in combination with DM MPIO, but have limitations. See the setup notes.</p> <p>Software
RAID on top of DM MPIO is also supported; however, note that
auto-discovery is not available and that you will need to setup <code style="font-size: 11px;">/etc/raidtab</code> (if using raidtools) or <code style="font-size: 11px;">/etc/mdadm.conf</code> (if using mdadm) correctly.</p>
</li>
</ul>

<h3>3. Installation notes</h3>
<ul><li><p><b>Software installation</b></p> <p>Upgrade a system to SLES9 SP2 level (or more recent) and install the multipath-tools package.</p>
</li>
<li><p><b>Changing system configuration</b></p>

<p>Using an editor of your choice, within /etc/sysconfig/hotplug set this value:</p>
<p><code style="font-size: 11px;">HOTPLUG_USE_SUBFS=no</code></p>
<p>In addition to the above change, please configure the system to
automatically load the device drivers for the controllers the MPIO
devices are connected to within the INITRD. The boot scripts will only
detect MPIO devices if the modules for the respective controllers are
loaded at boot time. To achieve this, simply add the needed driver
module to the variable INITRD_MODULES within the file
/etc/sysconfig/kernel.</p>
<p>Example:</p>
<p>Your system contains a RAID controller that is accessed by the cciss
driver and you are using ReiserFS as a filesystem. The MPIO devices
will be connected to a Qlogic controller accessed by the driver
qla2xxx, which is not yet configured to be used on this system. The
mentioned entry within /etc/sysconfig/kernel will then probably look
like this:</p>
<p><code style="font-size: 11px;">INITRD_MODULES="cciss reiserfs"</code></p>
<p>Using an editor, you would now change this entry:</p>
<p><code style="font-size: 11px;">INITRD_MODULES="cciss reiserfs qla2xxx"</code></p>
<p>When you have applied this change, you will need to recreate the INITRD on your system to reflect it. Simply run this command:</p>
<p><code style="font-size: 11px;">mkinitrd</code></p>
<p>When you are using GRUB as a bootmanager, you do not use to make any
further changes. Upon the next reboot the needed driver will be loaded
within the INITRD. If you are using LILO as bootmanager, please
remember to run it once to update the boot record.</p>
</li>
<li><p><b>Configuring multipath-tools</b></p>
<p>If your system is one of those listed above, no further configuration should be required.</p>
<p>You might otherwise have to create <code style="font-size: 11px;">/etc/multipath.conf</code> (see the examples under <code style="font-size: 11px;">/usr/share/doc/packages/multipath-tools/</code>) and add an appropriate devices entry for your storage subsystem.</p>
<p>One particularly interesting option in the <code style="font-size: 11px;">/etc/multipath-tools.conf </code>file is the "polling_interval" which defines the frequency of the path checking that can be configured.</p>
<p>Alternatively, you might choose to blacklist certain devices which you do not want multipath-tools to scan.</p>
<p>You can then run:</p>
<p><code style="font-size: 11px;">multipath -v2 -d</code></p>
<p>to perform a 'dry-run' with this configuration. This will only scan the devices and print what the setup would look like.</p>

<p>The output will look similar to:</p>
<pre class="code">3600601607cf30e00184589a37a31d911
[size=127 GB][features="0"][hwhandler="1 emc"]
\_ round-robin 0 [first]
  \_ 1:0:1:2 sdav 66:240  [ready ]
  \_ 0:0:1:2 sdr  65:16   [ready ]
\_ round-robin 0
  \_ 1:0:0:2 sdag 66:0    [ready ]
  \_ 0:0:0:2 sdc  8:32    [ready ]
</pre>
<p>showing you the name of the MPIO device, its size, the features and
hardware handlers involved, as well as the (in this case, two) priority
groups (PG). For each PG, it shows whether it is the first (highest
priority) one, the scheduling policy used to balance IO within the
group, and the paths contained within the PG. For each path, its
physical address (host:bus:target:lun), device nodename and major:minor
number is shown, and of course whether the path is currently active or
not.</p>

<p>Paths are grouped into priority groups; there's always just one
priority group in active use. To model an active/active configuration,
all paths end up in the same group; to model active/passive, the paths
which should not be active in parallel will be placed in several
distinct priority groups. This normally happens completely
automatically on device discovery.</p>
</li>

<li><p><b>Enabling the MPIO components</b></p>

<p>Now run</p>
<pre class="code">/etc/init.d/boot.multipath start
/etc/init.d/multipathd start
</pre>
<p>as user root. The multipath devices should now show up automatically under <code style="font-size: 11px;">/dev/disk/by-name/</code>; the default naming will be the WWN of the Logical Unit, which you can override via <code style="font-size: 11px;">/etc/multipath.conf</code> to suit your tastes.</p>

<p>Run</p>
<pre class="code">insserv boot.multipath multipathd
</pre>
<p>to integrate the multipath setup into the boot sequence.</p>

<p>From now on all access to the devices should go through the MPIO layer.</p>
</li>

<li><p><b>Querying MPIO status</b></p>

<p>To query the current MPIO status, run</p>
<pre class="code">multipath -l
</pre>
<p>This will output the current status of the multipath maps in a format similar to the command already explained above:</p>
<pre class="code">3600601607cf30e00184589a37a31d911
[size=127 GB][features="0"][hwhandler="1 emc"]
\_ round-robin 0 [active][first]
  \_ 1:0:1:2 sdav 66:240  [ready ][active]
  \_ 0:0:1:2 sdr  65:16   [ready ][active]
\_ round-robin 0 [enabled]
  \_ 1:0:0:2 sdag 66:0    [ready ][active]
  \_ 0:0:0:2 sdc  8:32    [ready ][active]
</pre>
<p>However, it includes additional information about which priority
group is active, disabled or enabled, as well as for each path whether
it is currently active or not.</p>
</li>

<li><p><b>Tuning the fail-over with specific HBAs</b></p>

<p>HBA timeouts are typically setup for non-MPIO environments, where
longer timeouts make sense - as the only alternative would be to error
out the IO and propagate the error to the application. However, with
MPIO, some faults (like cable failures) <i>should</i> be propagated
upwards as fast as possible so that the MPIO layer can quickly take
action and redirect the IO to another, healthy path.</p>

<p>For the QLogic 2xxx family of HBAs, the following setting in <code style="font-size: 11px;">/etc/modprobe.conf.local</code> is thus recommended:</p>
<pre class="code">options qla2xxx qlport_down_retry=1 ql2xfailover=0 ql2xretrycount=5
</pre>
</li>
<li><p><b>Managing IO in error situations</b></p>
<p>In certain scenarios, where the driver, the HBA or the fabric
experiences spurious errors,it is advisable that DM MPIO is configured
to queue all IO in case of errors leading loss of all paths, and never
propagate errors upwards.</p>
<p>This can be achieved by setting</p>
<pre class="code">defaults {
		default_features "1 queue_if_no_path"
}
				</pre>
<p>in /etc/multipath.conf.</p>
<p>As this will lead to IO being queued forever, unless a path is
reinstated, make sure that multipathd is running and works for your
scenario. Otherwise, IO might be stalled forever on the affected MPIO
device, until reboot or until you manually issue a</p>
<pre class="code">dmsetup message 3600601607cf30e00184589a37a31d911 0 fail_if_no_path
				</pre>
<p>(substituting the correct map name), which will immediately cause
all queued IO to fail. You can reactivate the queue if no path feature
by issueing</p>
<pre class="code">dmsetup message 3600601607cf30e00184589a37a31d911 0 queue_if_no_path
</pre>
<p>You can also use these two commands to switch between both modes for
testing, before committing the command to your /etc/multipath.conf.</p>
</li>
</ul>
<h3>4. Using the MPIO devices</h3>

<ul>
<li><p><b>Using the whole MPIO devices directly</b></p> <p>If you want
to use the whole LUs directly (if for example you're using the SAN
features to partition your storage), you can simply use the <code style="font-size: 11px;">/dev/disk/by-name/xxx</code> names directly for mkfs, <code style="font-size: 11px;">/etc/fstab</code>, your application, etc.</p>
</li>
<li><p><b>Using LVM2 on top of the MPIO devices</b></p> <p>To make LVM2 recognize the MPIO devices as possible Physical Volumes (PVs), you will have to modify <code style="font-size: 11px;">/etc/lvm/lvm.conf</code>.
You will also want to modify it so that it does not scan and use the
physical paths, but only accesses your MPIO storage via the MPIO layer.</p> <p>Thus, change the "filter" entry in <code style="font-size: 11px;">lvm.conf</code> as follows and add the types extension to make LVM2 recognize them:</p>
<pre class="code">filter = [ "a|/dev/disk/by-name/.*|", "r|.*|" ]
types = [ "device-mapper", 1 ] </pre> <p>This
will allow LVM2 to only scan the by-name paths and reject everything
else. (If you are also using LVM2 on non-MPIO devices, you will of
course need to make the necessary adjustments to suit your setup.)</p>
<p>You can then use pvcreate and the other LVM2 commands as usual on the <code style="font-size: 11px;">/dev/disk/by-name/</code> path.</p>
</li>
<li><p><b>Partitions on top of MPIO devices</b></p> <p>It is not
currently possible to partition the MPIO devices themselves. However,
if the underlying physical device is partitioned, the MPIO device will
reflect those partitions and the MPIO layer will provide <code style="font-size: 11px;">/dev/disk/by-name/&gt;name&lt;p1 ... pN</code> devices so you can access the partitions through the MPIO layer.</p> <p>So
you will have to partition the devices prior to enabling MPIO; if you
change the partitioning in the running system, MPIO will not
automatically detect this and reflect the changes; you will have to
reinit MPIO, which in a running system, with active access to the
devices, will likely imply a reboot.</p> <p>Thus, using the LUNs directly or via LVM2 is recommended.</p>
</li>
</ul>

<h3>5. More information</h3>
<p>Should you have trouble using MPIO on SLES9 SP2, please contact Novell support.</p>

<p>More information can be found at <a href="javascript:openExternal('http://christophe.varoqui.free.fr/')">http://christophe.varoqui.free.fr/</a> for the multipath-tools package as well as <a href="javascript:openExternal('http://sources.redhat.com/dm/')">http://sources.redhat.com/dm/</a> for the kernel Device Mapper components.</p>

</html>
To access a service available on a machine with a private IP address in Garching from outside (e.g. via DSL) one can establish a SSL tunnel for the network port used by the service through a machine with a public address which can see the private address. In our example we use charly.physik.uni-muenchen.de.

Assume the Webserver lives on host wwwsecrete visible from charly with IP address 192.168.111.111 and uses port 80 as webservers normally do.

The following command connects this service to port 10080 on the local maschine:

>''ssh charly.physik.uni-muenchen.de -L 10080:192.168.111.111:80''
Access with:
>''http://localhost:10080/atlas/slowcontrol/slowcontrol.html''

or
>''ssh charly.physik.uni-muenchen.de -L charly.physick.uni-muenchen.de:10080:192.168.111.111:80''
Access with:
>''http://charly.physik.uni-muenchen.de:10080/atlas/slowcontrol/slowcontrol.html''
{{{
The file descriptor limit can be increased using the following procedure:

   1. Edit /etc/security/limits.conf and add the lines:

      *       soft    nofile  1024
      *       hard    nofile  65535

   2. Edit /etc/pam.d/login, adding the line:

      session required /lib/security/pam_limits.so

   3. The system file descriptor limit is set in /proc/sys/fs/file-max. 
       The following command will increase the limit to 65535:

      echo 65535 > /proc/sys/fs/file-max

   4. You should then be able to increase the file descriptor limits using:

      ulimit -n unlimited

      The above command will set the limits to the hard limit specified in /etc/security/limits.conf
}}}

{{{
The following is an example of the output of ulimit -aH. 
You can see that the current shell (and its children) is restricted to 1024 open file descriptors.

core file size (blocks)     unlimited
data seg size (kbytes)      unlimited
file size (blocks)          unlimited
max locked memory (kbytes)  unlimited
max memory size (kbytes)    unlimited
open files                  1024
pipe size (512 bytes)       8
stack size (kbytes)         unlimited
cpu time (seconds)          unlimited
max user processes          4094
virtual memory (kbytes)     unlimited

}}}
http://support.novell.com/techcenter/sdb/en/2005/04/sles_multipathing.html
ls -lShr
''route del -net 192.168.98.0 netmask 255.255.255.0 gw 192.168.99.1''
''route add -net 192.168.98.42 netmask 255.255.255.255 gw 192.168.99.1''
''route add -host 192.168.98.42 gw 192.168.99.1''

''route add default gw 192.168.99.254''
''route -n''
*Example - ''tsmacceptor'' script
*''chkconfig -a tsmacceptor'' -> will be activated in 3 and 5
|!Commands to use|
|rc.status|
|rc.reset|
|rc_status -v|
|startproc|
|killproc|
|checkproc|

{{{
#!/bin/sh
#
# tsmacceptor
#
### BEGIN INIT INFO
# Provides: tsmacceptor
# Default-Start: 3 5
# Default-Stop: 0 1 2 6
# Description: Start local config
### END INIT INFO  
                             
# Source function library
. /etc/rc.status               # For SuSE, enables setting from /etc/rc.config
rc_reset

case "$1" in
    start)
        echo -n "Starting TSM Client Acceptor Service"
        startproc /opt/tivoli/tsm/client/ba/bin/dsmcad >/opt/tivoli/tsm/client/ba/bin/tsmaccepterr.out 2>&1 &
        rc_status -v
        ;;

    stop)
        echo -n "Shutting down TSM Client Acceptor Service"
        killproc /opt/tivoli/tsm/client/ba/bin/dsmcad 
        rc_status -v
        ;;

    status)
        echo -n "Checking for service tsmacceptor (dsmcad)"
        checkproc /opt/tivoli/tsm/client/ba/bin/dsmcad 
        rc_status -v
        ;;

    *)
        echo "Usage: tsm {start|stop|status}"
        exit 1
esac
rc_exit
}}}
{{{
#!/bin/bash
#
# http://tips.webdesign10.com
#
# Use this script at your own risk
# 
# Takes a screenshot with ImageMagick.
# Link to this file from the GNOME panel
# Do NOT check the box "run in terminal"
# Remember to chmod +x this file
# Screenshot will save to ~/Desktop/

# The name of your file
screenshot='screenshot';

# Creates an unusual filename based on nanoseconds so that
# you don't accidentally overwrite another screenshot.
# The `backticks` tell the script to run another command (date).
# Type 'man date' in the terminal for more info
nano=`date '+%d%b%y-%N'`;

# Adds the file extension
extension='.png';

# Generate a filename for this screenshot
file="$HOME/Desktop/$screenshot-$nano$extension";

# Use ImageMagick to take the screenshot
# Saves to ~/Desktop
import $file;
}}}
<html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xml:lang="en" xmlns="http://www.w3.org/1999/xhtml" lang="en"><head>


<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style type="text/css">
<!--
	.green { color: #003300; }
	.blue  { color: #0000CC; }
	.maroon { color: maroon; }
//-->
</style>
<title>Writing udev rules</title>
</head><body>

<h1>Writing udev rules</h1>
by Daniel Drake (dsd)<br>
Version 0.74<br><br>

The most recent version of this document can always be found at: <br>

<a href="http://www.reactivated.net/writing_udev_rules.html">http://www.reactivated.net/writing_udev_rules.html</a>

<h2>Contents</h2>
<ul>
<li>Introduction
	<ul>
	<li><a href="#about">About this document</a></li>
	<li><a href="#history">History</a></li>
	</ul>
</li>
<li>The concepts
	<ul>
	<li><a href="#terminology">Terminology: devfs, sysfs, nodes, etc.</a></li>
	<li><a href="#why">Why?</a></li>
	<li><a href="#builtin">Built-in persistent naming schemes</a></li>
	</ul>
</li>
<li>Rule writing
	<ul>
	<li><a href="#syntax">Rule files and semantics</a></li>
	<li><a href="#syntax">Rule syntax</a></li>
	<li><a href="#basic">Basic rules</a></li>
	<li><a href="#sysfsmatch">Matching sysfs attributes</a></li>
	<li><a href="#hierarchy">Device hierarchy</a></li>
	<li><a href="#strsubst">String substitutions</a></li>
	<li><a href="#strmatch">String matching</a></li>
	</ul>
</li>
<li>Finding suitable information from sysfs
	<ul>
	<li><a href="#sysfstree">The sysfs tree</a></li>
	<li><a href="#udevinfo">udevinfo</a></li>
	<li><a href="#sysfsalt">Alternative methods</a></li>
	</ul>
</li>
<li>Advanced topics
	<ul>
	<li><a href="#ownership">Controlling permissions and ownership</a></li>
	<li><a href="#external-naming">Using external programs to name devices</a></li>
	<li><a href="#external-run">Running external programs on certain events</a></li>
	<li><a href="#env">Environment interaction</a></li>
	<li><a href="http://www.reactivated.net/options">Additional options</a></li>
	</ul>
</li>
<li>Examples
	<ul>
	<li><a href="#example-printer">USB Printer</a></li>
	<li><a href="#example-camera">USB Camera</a></li>
	<li><a href="#example-usbhdd">USB Hard Disk</a></li>
	<li><a href="#example-usbcardreader">USB Card Reader</a></li>
	<li><a href="#example-pilot">USB Palm Pilot</a></li>
	<li><a href="#example-cdrom">CD/DVD drives</a></li>
	<li><a href="#example-netif">Network interfaces</a></li>
	</ul>
</li>
<li>Testing and debugging
	<ul>
	<li><a href="#testing">Putting your rules into action</a></li>
	<li><a href="#udevtest">udevtest</a></li>
	</ul>
</li>
<li><a href="#author">Author and contact</a></li>
</ul>

<h2>Introduction</h2>

<a name="about"></a>
<h3>About this document</h3>

<p>
udev is targeted at Linux kernels 2.6 and beyond to provide a userspace
solution for a dynamic /dev directory, with persistent device naming.
The previous /dev implementation, <i>devfs</i>, is now deprecated, and udev is seen as the successor. udev vs devfs is a sensitive area of conversation - you should read <a href="http://kernel.org/pub/linux/utils/kernel/hotplug/udev_vs_devfs">this document</a> before making comparisons.
</p>

<p>
Over the years, the things that you might use udev rules for has
changed, as well as the flexibility of rules themselves. On a modern
system, udev provides persistent naming for some device types
out-of-the-box, eliminating the need for custom rules for those
devices. However, some users will still require the extra level of
customisation.
</p>

<p>This document assumes that you have udev installed and running OK
with default configurations. This is usually handled by your Linux
distribution.
</p>

<p>This document does not cover every single detail of rule writing,
but does aim to introduce all of the main concepts. The finer details
can be found in the udev man page.
</p>

<p>This document uses various examples (many of which are entirely
fictional) to illustrate ideas and concepts. Not all syntax is
explicitly described in the accompanying text, be sure to look at the
example rules to get a complete understanding.
</p>

<a name="history"></a>
<h3>History</h3>

<ul>
<li>April 5th 2008 v0.74: Typo fixes.</li>
<li>December 3rd 2007 v0.73: Update for new udev versions, and some miscellaneous improvements.</li>
<li>October 2nd 2006 v0.72: Fixed a typo in one of the example rules.</li>
<li>June 10th 2006 v0.71: Misc changes based on recent feedback - thanks!</li>
<li>June 3rd 2006 v0.7: Complete rework, to be more suited for the modern-day udev.</li>
<li>May 9th 2005 v0.6: Misc updates, including information about udevinfo, groups and permissions, logging, and udevtest.</li>
<li>June 20th 2004 v0.55: Added info on multiple symlinks, and some minor changes/updates.</li>
<li>April 26th 2004 v0.54: Added some Debian info. Minor corrections.
Re-reverted information about what to call your rule file. Added info
about naming network interfaces.</li>
<li>April 15th 2004 v0.53: Minor corrections. Added info about NAME{all_partitions}. Added info about other udevinfo tricks.</li>
<li>April 14th 2004 v0.52: Reverted to suggesting using "udev.rules" until the udev defaults allow for other files. Minor work.</li>
<li>April 6th 2004 v0.51: I now write suggest users to use their own "local.rules" file rather than prepending "udev.rules".</li>
<li>April 3rd 2004 v0.5: Minor cleanups and preparations for possible inclusion in the udev distribution.</li>
<li>March 20th 2004 v0.4: General improvements, clarifications, and
cleanups. Added more information about writing rules for usb-storage.</li>
<li>February 23rd 2004 v0.3: Rewrote some parts to emphasise how sysfs
naming works, and how it can be matched. Updated rule-writing parts to
represent udev 018s new SYSFS{filename} naming scheme. Improved
sectioning, and clarified many points. Added info about KDE.</li>
<li>February 18th 2004 v0.2: Fixed a small omission in an example.
Updated section on identifying mass-storage devices. Updated section on
nvidia.</li>
<li>February 15th 2004 v0.1: Initial publication.</li>
</ul>

<h2>The concepts</h2>

<a name="terminology"></a>
<h3>Terminology: devfs, sysfs, nodes, etc.</h3>

<p>
A basic introduction only, might not be totally accurate.
</p>

<p>
On typical Linux-based systems, the <i>/dev</i> directory is used to store file-like device <b>nodes</b>
which refer to certain devices in the system. Each node points to a
part of the system (a device), which might or might not exist.
Userspace applications can use these device nodes to interface with the
systems hardware, for example, the X server will "listen to"
/dev/input/mice so that it can relate the user's mouse movements to
moving the visual mouse pointer.
</p>

<p>
The original <i>/dev</i> directories were just populated with every
device that might possibly appear in the system. /dev directories were
typically very large because of this. <b>devfs</b> came along to
provide a more manageable approach (noticeably, it only populated /dev
with hardware that is plugged into the system), as well as some other
functionality, but the system proved to have problems which could not
be easily fixed.
</p>

<p>
<b>udev</b> is the "new" way of managing <i>/dev</i> directories, designed to clear up some issues with previous <i>/dev</i> implementations, and provide a robust path forward. In order to create and name <i>/dev</i> device nodes corresponding to devices that are present in the system, udev relies on matching information provided by <i>sysfs</i> with <i>rules</i>
provided by the user. This documentation aims to detail the process of
rule-writing, one of the only udev-related tasks that must (optionally)
be performed by the user.
</p>

<p>
<b>sysfs</b> is a new filesystem to the 2.6 kernels. It is managed by
the kernel, and exports basic information about the devices currently
plugged into your system. udev can use this information to create
device nodes corresponding to your hardware. sysfs is mounted at <i>/sys</i>
and is browseable. You may wish to investigate some of the files stored
there before getting to grips with udev. Throughout this document, I
will use the terms <i>/sys</i> and <i>sysfs</i> interchangeably.
</p>

<a name="why"></a>
<h3>Why?</h3>

<p>
udev rules are flexible and very powerful. Here are some of the things you can use rules to achieve:
</p>

<ul>
<li>Rename a device node from the default name to something else</li>
<li>Provide an alternative/persistent name for a device node by creating a symbolic link to the default device node</li>
<li>Name a device node based on the output of a program</li>
<li>Change permissions and ownership of a device node</li>
<li>Launch a script when a device node is created or deleted (typically when a device is attached or unplugged)</li>
<li>Rename network interfaces</li>
</ul>

<p>
Writing rules is <u>not</u> a workaround for the problem where no
device nodes for your particular device exist. Even if there are no
matching rules, udev will create the device node with the default name
supplied by the kernel.
</p>

<p>Having persistently named device nodes has several advantages.
Assume you own two USB storage devices: a digital camera and a USB
flash disk. These devices are typically assigned device nodes <em>/dev/sda</em> and <em>/dev/sdb</em>
but the exact assignment depends on the order which they were
originally connected. This may cause problems to some users, who would
benefit greatly if each device could be named persistently every time,
e.g. <em>/dev/camera</em> and <em>/dev/flashdisk</em>.
</p>

<a name="builtin"></a>
<h3>Built-in persistent naming schemes</h3>

<p>
udev provides persistent naming for some device types out of the box.
This is a very useful feature, and in many circumstances means that
your journey ends here: you do not have to write any rules.
</p>

<p>
udev provides out-of-the-box persistent naming for storage devices in the <em>/dev/disk</em> directory. To view the persistent names which have been created for your storage hardware, you can use the following command:
</p>

<blockquote><pre># ls -lR /dev/disk</pre></blockquote>

<p>
This works for all storage types. As an example, udev has created <em>/dev/disk/by-id/scsi-SATA_ST3120827AS_4MS1NDXZ-part3</em> which is a persistent-named symbolic link to my root partition. udev creates <em>/dev/disk/by-id/usb-Prolific_Technology_Inc._USB_Mass_Storage_Device-part1</em> when I plug my USB flash disk in, which is also a persistent name.
</p>

<!-- FIXME: document CDROM persistent naming when things settle down -->

<h2>Rule writing</h2>

<a name="files"></a>
<h3>Rule files and semantics</h3>

<p>When deciding how to name a device and which additional actions to
perform, udev reads a series of rules files. These files are kept in
the <em>/etc/udev/rules.d</em> directory, and they all must have the <em>.rules</em> suffix.
</p>

<p>
Default udev rules are stored in <em>/etc/udev/rules.d/50-udev.rules</em>.
You may find it interesting to look over this file - it includes a few
examples, and then some default rules proving a devfs-style /dev
layout. However, you should not write rules into this file directly.
</p>

<p>
Files in /etc/udev/rules.d/ are parsed in <b>lexical</b> order, and
in some circumstances, the order in which rules are parsed is
important. In general, you want your own rules to be parsed before the
defaults, so I suggest you create a file at <em>/etc/udev/rules.d/10-local.rules</em> and write all your rules into this file.
</p>

<p>
In a rules file, lines starting with "#" are treated as comments. Every
other non-blank line is a rule. Rules cannot span multiple lines.
</p>

<p>One device can be matched by more than one rule. This has it's
practical advantages, for example, we can write two rules which match
the same device, where each one provides its own alternate name for the
device. Both alternate names will be created, even if the rules are in
separate files. It is important to understand that udev will <em>not</em> stop processing when it finds a matching rule, it will continue searching and attempt to apply every rule that it knows about.
</p>

<a name="syntax"></a>
<h3>Rule syntax</h3>

<p>
Each rule is constructed from a series of key-value pairs, which are separated by commas. <b>match</b> keys are conditions used to identify the device which the rule is acting upon. When <u>all</u> match keys in a rule correspond to the device being handled, then the rule is applied and the actions of the <b>assignment</b> keys are invoked. Every rule should consist of at least one match key and at least one assignment key.
</p>

<p>
Here is an example rule to illustrate the above:
</p>

<blockquote><pre>KERNEL=="hdb", NAME="my_spare_disk"</pre></blockquote>

<p>
The above rule includes one match key (<em>KERNEL</em>) and one assignment key (<em>NAME</em>).
The semantics of these keys and their properties will be detailed
later. It is important to note that the match key is related to its
value through the equality operator (==), whereas the assignment key is
related to its value through the assignment operator (=).
</p>

<p>Be aware that udev does not support any form of line continuation.
Do not insert any line breaks in your rules, as this will cause udev to
see your one rule as multiple rules and will not work as expected.
</p>

<a name="basic"></a>
<h3>Basic Rules</h3>

<p>udev provides several different match keys which can be used to
write rules which match devices very precisely. Some of the most common
keys are introduced below, others will be introduced later in this
document. For a complete list, see the udev man page.
</p>

<ul>
<li><b>KERNEL</b> - match against the kernel name for the device</li>
<li><b>SUBSYSTEM</b> - match against the subsystem of the device</li>
<li><b>DRIVER</b> - match against the name of the driver backing the device</li>
</ul>

<p>After you have used a series of match keys to precisely match a
device, udev gives you fine control over what happens next, through a
range of assignment keys. For a complete list of possible assignment
keys, see the udev man page. The most basic assignment keys are
introduced below. Others will be introduced later in this document.
</p>

<ul>
<li><b>NAME</b> - the name that shall be used for the device node</li>
<li><b>SYMLINK</b> - a <b>list</b> of symbolic links which act as alternative names for the device node</li>
</ul>

<p>As hinted above, udev only creates one true device node for one
device. If you wish to provide alternate names for this device node,
you use the symbolic link functionality. With the <em>SYMLINK</em> assignment, you are actually maintaining a <em>list</em>
of symbolic links, all of which will be pointed at the real device
node. To manipulate these links, we introduce a new operator for
appending to lists: <b>+=</b>. You can append multiple symlinks to the list from any one rule by separating each one with a space.
</p>

<blockquote><pre>KERNEL=="hdb", NAME="my_spare_disk"</pre></blockquote>

<p>
The above rule says: <em>match a device which was named by the kernel as hdb, and instead of calling it hdb, name the device node as my_spare_disk</em>. The device node appears at <em>/dev/my_spare_disk</em>.
</p>

<blockquote><pre>KERNEL=="hdb", DRIVER=="ide-disk", SYMLINK+="sparedisk"</pre></blockquote>

<p>
The above rule says: <em>match a device which was named by the
kernel as hdb AND where the driver is ide-disk. Name the device node
with the default name and create a symbolic link to it named sparedisk</em>. Note that we did not specify a device node name, so udev uses the default. In order to preserve the standard <em>/dev</em> layout, your own rules will typically leave the NAME alone but create some SYMLINKs and/or perform other assignments.
</p>

<blockquote><pre>KERNEL=="hdc", SYMLINK+="cdrom cdrom0"</pre></blockquote>

<p>
The above rule is probably more typical of the types of rules you might be writing. It creates two symbolic links at <em>/dev/cdrom</em> and <em>/dev/cdrom0</em>, both of which point at <em>/dev/hdc</em>. Again, no NAME assignment was specified, so the default kernel name (hdc) is used.
</p>

<a name="sysfsmatch"></a>
<h3>Matching sysfs attributes</h3>

<p>
The match keys introduced so far only provide limited matching
capabilities. Realistically we require much finer control: we want to
identify devices based on advanced properties such as vendor codes,
exact product numbers, serial numbers, storage capacities, number of
partitions, etc.
</p>

<p>Many drivers export information like this into sysfs, and udev
allows us to incorporate sysfs-matching into our rules, using the <em>ATTR</em> key with a slightly different syntax.
</p>

<p>
Here is an example rule which matches a single attribute from sysfs.
Further detail will be provided later in this document which will aid
you in writing rules based on sysfs attributes.
</p>

<blockquote><pre>SUBSYSTEM=="block", ATTR{size}=="234441648", SYMLINK+="my_disk"
</pre></blockquote>

<a name="hierarchy"></a>
<h3>Device hierarchy</h3>

<p>The Linux kernel actually represents devices in a tree-like
structure, and this information is exposed through sysfs and useful
when writing rules. For example, the device representation of my hard
disk device is a child of the SCSI disk device, which is in turn a
child of the Serial ATA controller device, which is in turn a child of
the PCI bus device. It is likely that you will find yourself needing to
refer to information from a parent of the device in question, for
example the serial number of my hard disk device is not exposed at the
device level, it is exposed by its direct parent at the SCSI disk
level.
</p>

<p>The four main match keys introduced so far
(KERNEL/SUBSYSTEM/DRIVER/ATTR) only match against values corresponding
to the device in question, and do not match values from parent devices.
udev provides variants of the match keys that will search upwards
through the tree:
</p>

<ul>
<li><b>KERNELS</b> - match against the kernel name for the device, or the kernel name for any of the parent devices</li>
<li><b>SUBSYSTEMS</b> - match against the subsystem of the device, or the subsystem of any of the parent devices</li>
<li><b>DRIVERS</b> - match against the name of the driver backing the device, or the name of the driver backing any of the parent devices</li>
<li><b>ATTRS</b> - match a sysfs attribute of the device, or a sysfs attribute of any of the parent devices</li>
</ul>

<p>With hierarchy considerations in mind, you may feel that rule
writing is becoming a little complicated. Rest assured that there are
tools that help out here, which will be introduced later.
</p>

<a name="strsubst"></a>
<h3>String substitutions</h3>

<p>
When writing rules which will potentially handle multiple similar devices, udev's <em>printf-like string substitution operators</em>
are very useful. You can simply include these operators in any
assignments your rule makes, and udev will evaluate them when they are
executed.
</p>

<p>
The most common operators are <b>%k</b> and <b>%n</b>. %k evaluates to the kernel name for the device, e.g. "sda3" for a device that would (by default) appear at <em>/dev/sda3</em>. <b>%n</b> evaluates to the kernel number for the device (the partition number for storage devices), e.g. "3" for <em>/dev/sda3</em>.
</p>

<p>udev also provides several other substitution operators for more
advanced functionality. Consult the udev man page after reading the
rest of this document. There is also an alternative syntax for these
operators - <b>$kernel</b> and <b>$number</b> for the examples above. For this reason, if you wish to match a literal % in a rule then you must write <b>%%</b>, and if you wish to match a literal $ then you must write <b>$$</b>.
</p>

<p>
To illustrate the concept of string substitution, some example rules are shown below.
</p>

<blockquote><pre>KERNEL=="mice", NAME="input/%k"
KERNEL=="loop0", NAME="loop/%n", SYMLINK+="%k"
</pre></blockquote>

<p>
The first rule ensures that the mice device node appears exclusively in the <em>/dev/input</em> directory (by default it would be at <em>/dev/mice</em>). The second rule ensures that the device node named loop0 is created at <em>/dev/loop/0</em> but also creates a symbolic link at <em>/dev/loop0</em> as usual.
</p>

<p>
The use of the above rules is questionable, as they all could be
rewritten without using any substitution operators. The true power of
these substitutions will become apparent in the next section.
</p>

<a name="strmatch"></a>
<h3>String matching</h3>

<p>
As well as matching strings exactly, udev allows you to use shell-style pattern matching. There are 3 patterns supported:
</p>

<ul>
<li><b>*</b> - match any character, zero or more times</li>
<li><b>?</b> - match any character exactly once</li>
<li><b>[]</b> - match any single character specified in the brackets, ranges are also permitted</li>
</ul>

<p>
Here are some examples which incorporate the above patterns. Note the use of the string substitution operators.
</p>

<blockquote><pre>KERNEL=="fd[0-9]*", NAME="floppy/%n", SYMLINK+="%k"
KERNEL=="hiddev*", NAME="usb/%k"
</pre></blockquote>

<p>
The first rule matches all floppy disk drives, and ensures that the device nodes are placed in the <em>/dev/floppy</em>
directory, as well as creating a symbolic link from the default name.
The second rule ensures that hiddev devices are only present in the <em>/dev/usb</em> directory.
</p>

<h2>Finding information from sysfs</h2>

<a name="sysfstree"></a>
<h3>The sysfs tree</h3>

<p>
The concept of using interesting information from sysfs was briefly
touched upon above. In order to write rules based on this information,
you first need to know the names of the attributes and their current
values.
</p>

<p>
sysfs is actually a very simple structure. It is logically divided into directories. Each directory contains a number of files (<em>attributes</em>)
which typically contain just one value. Some symbolic links are
present, which link devices to their parents. The hierarchical
structure was touched upon above.
</p>

<p>
Some directories are referred to as <em>top-level device paths</em>.
These directories represent actual devices that have corresponding
device nodes. Top-level device paths can be classified as sysfs
directories which contain a <em>dev</em> file, the following command will list these for you:
</p>

<blockquote><pre># find /sys -name dev</pre></blockquote>

<p>
For example, on my system, the <em>/sys/block/sda</em> directory is the device path for my hard disk. It is linked to it's parent, the SCSI disk device, through the <em>/sys/block/sda/device</em> symbolic link.
</p>

<p>
When you write rules based on sysfs information, you are simply
matching attribute contents of some files in one part of the chain. For
example, I can read the size of my hard disk as follows:
</p>

<blockquote><pre># cat /sys/block/sda/size
234441648
</pre></blockquote>

<p>In a udev rule, I could use ATTR{size}=="234441648" to identify this
disk. As udev iterates through the entire device chain, I could
alternatively opt to match attributes in another part of the chain
(e.g. attributes in <em>/sys/class/block/sda/device/</em>) using <em>ATTRS</em>, however there are some caveats when dealing with different parts of the chain which are described later.
</p>

<p>
Although this serves as a useful introduction as to the structure of
sysfs and exactly how udev matches values, manually trawling through
sysfs is both time consuming and unnecessary.
</p>

<a name="udevinfo"></a>
<h3>udevinfo</h3>

<p>
Enter <em>udevinfo</em>, which is probably the most straightforward
tool you can use to construct rules. All you need to know is the sysfs
device path of the device in question. A trimmed example is shown
below:
</p>

<blockquote><pre># udevinfo -a -p /sys/block/sda

<span class="green">  looking at device '/block/sda':
    KERNEL=="sda"
    SUBSYSTEM=="block"
    ATTR{stat}=="  128535     2246  2788977   766188    73998   317300  3132216  5735004        0   516516  6503316"
    ATTR{size}=="234441648"
    ATTR{removable}=="0"
    ATTR{range}=="16"
    ATTR{dev}=="8:0"</span>

<span class="blue">  looking at parent device '/devices/pci0000:00/0000:00:07.0/host0/target0:0:0/0:0:0:0':
    KERNELS=="0:0:0:0"
    SUBSYSTEMS=="scsi"
    DRIVERS=="sd"
    ATTRS{ioerr_cnt}=="0x0"
    ATTRS{iodone_cnt}=="0x31737"
    ATTRS{iorequest_cnt}=="0x31737"
    ATTRS{iocounterbits}=="32"
    ATTRS{timeout}=="30"
    ATTRS{state}=="running"
    ATTRS{rev}=="3.42"
    ATTRS{model}=="ST3120827AS     "
    ATTRS{vendor}=="ATA     "
    ATTRS{scsi_level}=="6"
    ATTRS{type}=="0"
    ATTRS{queue_type}=="none"
    ATTRS{queue_depth}=="1"
    ATTRS{device_blocked}=="0"</span>

<span class="maroon">  looking at parent device '/devices/pci0000:00/0000:00:07.0':
    KERNELS=="0000:00:07.0"
    SUBSYSTEMS=="pci"
    DRIVERS=="sata_nv"
    ATTRS{vendor}=="0x10de"
    ATTRS{device}=="0x037f"</span>
</pre></blockquote>

<p>As you can see, udevinfo simply produces a list of attributes you
can use as-is as match keys in your udev rules. From the above example,
I could produce (e.g.) either of the following two rules for this
device:
</p>

<blockquote><pre><span class="green">SUBSYSTEM=="block"</span>, <span class="green">ATTR{size}=="234441648",</span> NAME="my_hard_disk"
<span class="green">SUBSYSTEM=="block"</span>, <span class="blue">SUBSYSTEMS=="scsi"</span>, <span class="blue">ATTRS{model}=="ST3120827AS",</span> NAME="my_hard_disk"</pre></blockquote>

<p>You may have noted the use of colour in the above examples. This is
to demonstrate that while it is legal to combine the attributes from
the device in question and a <em>single</em>
parent device, you cannot mix-and-match attributes from multiple parent
devices - your rule will not work. For example, the following rule is <em>invalid</em> as it attempts to match attributes from two parent devices:
</p>

<blockquote><pre><span class="green">SUBSYSTEM=="block"</span>, <span class="blue">ATTRS{model}=="ST3120827AS"</span>, <span class="maroon">DRIVERS=="sata_nv"</span>, NAME="my_hard_disk"</pre></blockquote>

<p>
You are usually provided with a large number of attributes, and you
must pick a number of them to construct your rule. In general, you want
to choose attributes which identify your device in a persistent and
human-recognisable way. In the examples above, I chose the size of my
disk and its model number. I did not use meaningless numbers such as
ATTRS{iodone_cnt}=="0x31737".
</p>

<p>
Observe the effects of hierarchy in the udevinfo output. The <span class="green">green</span> section corresponding to the device in question uses the standard match keys such as KERNEL and ATTR. The <span class="blue">blue</span> and <span class="maroon">maroon</span>
sections corresponding to parent devices use the parent-traversing
variants such as SUBSYSTEMS and ATTRS. This is why the complexity
introduced by the hierarchical structure is actually quite easy to deal
with, just be sure to use the exact values that udevinfo suggests.
</p>

<p>Another point to note is that it is common for text attributes to
appear in the udevinfo output to be padded with spaces (e.g. see
ST3120827AS above). In your rules, you can either specify the extra
spaces, or you can cut them off as I have done.
</p>

<p>The only complication with using udevinfo is that you are required
to know the top-level device path (/sys/block/sda in the example
above). This is not always obvious. However, as you are generally
writing rules for device nodes which already exist, you can use
udevinfo to look up the device path for you:
</p>

<blockquote><pre># udevinfo -a -p $(udevinfo -q path -n /dev/sda)</pre></blockquote>

<a name="sysfsalt"></a>
<h3>Alternative methods</h3>

<p>Although udevinfo is almost certainly the most straightforward way
of listing the exact attributes you can build rules from, some users
are happier with other tools. Utilities such as <a href="http://www.kroah.com/linux/usb/">usbview</a> display a similar set of information, most of which can be used in rules.
</p>

<h2>Advanced topics</h2>

<a name="ownership"></a>
<h3>Controlling permissions and ownership</h3>

<p>
udev allows you to use additional assignments in rules to control ownership and permission attributes on each device.
</p>

<p>
The <em>GROUP</em> assignment allows you to define which Unix group should own the device node. Here is an example rule which defines that the <em>video</em> group will own the framebuffer devices:
</p>

<blockquote><pre>KERNEL=="fb[0-9]*", NAME="fb/%n", SYMLINK+="%k", GROUP="video"</pre></blockquote>

<p>
The <em>OWNER</em> key, perhaps less useful, allows you to define
which Unix user should have ownership permissions on the device node.
Assuming the slightly odd situation where you would want <em>john</em> to own your floppy devices, you could use:
</p>

<blockquote><pre>KERNEL=="fd[0-9]*", OWNER="john"</pre></blockquote>

<p>
udev defaults to creating nodes with Unix permissions of 0660
(read/write to owner and group). If you need to, you can override these
defaults on certain devices using rules including the <em>MODE</em> assignment. As an example, the following rule defines that the inotify node shall be readable and writable to everyone:
</p>

<blockquote><pre>KERNEL=="inotify", NAME="misc/%k", SYMLINK+="%k", MODE="0666"</pre></blockquote>

<a name="external-naming"></a>
<h3>Using external programs to name devices</h3>

<p>
Under some circumstances, you may require more flexibility than
standard udev rules can provide. In this case, you can ask udev to run
a program and use the standard output from that program to provide
device naming.
</p>

<p>
To use this functionality, you simply specify the absolute path of the program to run (and any parameters) in the <em>PROGRAM</em> assignment, and you then use some variant of the <em>%c</em> substitution in the NAME/SYMLINK assignments.
</p>

<p>
The following examples refer to a fictional program found at <em>/bin/device_namer</em>.
device_namer takes one command line argument which is the kernel name
for the device. Based upon this kernel name, device_namer does its
magic and produces some output to the usual <em>stdout</em> pipe, split into several parts. Each part is just a single word, and parts are separated by a single space.
</p>

<p>
In our first example, we assume that device_namer outputs a number of
parts, each one to form a symbolic link (alternative name) for the
device in question.
</p>

<blockquote><pre>KERNEL=="hda", PROGRAM="/bin/device_namer %k", SYMLINK+="%c"</pre></blockquote>

<p>The next example assumes that device_namer outputs two parts, the
first being the device name, and the second being the name for an
additional symbolic link. We now introduce the <em>%c{N}</em> substitution, which refers to part N of the output:
</p>

<blockquote><pre>KERNEL=="hda", PROGRAM="/bin/device_namer %k", NAME="%c{1}", SYMLINK+="%c{2}"</pre></blockquote>

<p>
The next example assumes that device_namer outputs one part for the
device name, followed by any number of parts which will form additional
symbolic links. We now introduce the <em>%c{N+}</em> substitution, which evaluates to part N, N+1, N+2, ... until the end of the output.
</p>

<blockquote><pre>KERNEL=="hda", PROGRAM="/bin/device_namer %k", NAME="%c{1}", SYMLINK+="%c{2+}"</pre></blockquote>

<p>
Output parts can be used in any assignment key, not only NAME and
SYMLINK. The example below uses a fictional program to determine the
Unix group which should own the device:
</p>

<blockquote><pre>KERNEL=="hda", PROGRAM="/bin/who_owns_device %k", GROUP="%c"</pre></blockquote>

<a name="external-run"></a>
<h3>Running external programs upon certain events</h3>

<p>Yet another reason for writing udev rules is to run a particular
program when a device is connected or disconnected. For example, you
might want to execute a script to automatically download all of your
photos from your digital camera when it is connected.
</p>

<p>
Do not confuse this with the <em>PROGRAM</em> functionality described above. <em>PROGRAM</em>
is used for running programs which produce device names (and they
shouldn't do anything other than that). When those programs are being
executed, the device node has not yet been created, so acting upon the
device in any way is not possible.
</p>

<p>The functionality introduced here allows you to run a program after
the device node is put in place. This program can act on the device,
however it must not run for any extended period of time, because udev
is effectively paused while these programs are running. One workaround
for this limitation is to make sure your program immediately detaches
itself.
</p>

<p>
Here is an example rule which demonstrates the use of the <em>RUN</em> list assignment:
</p>

<blockquote><pre>KERNEL=="sdb", RUN+="/usr/bin/my_program"</pre></blockquote>

<p>
When <em>/usr/bin/my_program</em> is executed, various parts of the udev environment are available as environment variables, including key values such as <em>SUBSYSTEM</em>. You can also use the <em>ACTION</em>
environment variable to detect whether the device is being connected or
disconnected - ACTION will be either "add" or "remove" respectively.
</p>

<p>udev does not run these programs on any active terminal, and it does
not execute them under the context of a shell. Be sure to ensure your
program is marked executable, if it is a shell script ensure it starts
with an appropriate <a href="http://en.wikipedia.org/wiki/Shebang_%28Unix%29">shebang</a> (e.g. <code>#!/bin/sh</code>), and do not expect any standard output to appear on your terminal.
</p>

<a name="env"></a>
<h3>Environment interaction</h3>

<p>
udev provides an <em>ENV</em> key for environment variables which can be used for both matching and assignment.
</p>

<p>
In the assignment case, you can set environment variables which you can
then match against later. You can also set environment variables which
can be used by any external programs invoked using the techniques
mentioned above. A fictional example rule which sets an environment
variable is shown below.
</p>

<blockquote><pre>KERNEL=="fd0", SYMLINK+="floppy", ENV{some_var}="value"</pre></blockquote>

<p>In the matching case, you can ensure that rules only run depending
on the value of an environment variable. Note that the environment that
udev sees will not be the same user environment as you get on the
console. A fictional rule involving an environment match is shown
below.
</p>

<blockquote><pre>KERNEL=="fd0", ENV{an_env_var}=="yes", SYMLINK+="floppy"</pre></blockquote>

<p>
The above rule only creates the <em>/dev/floppy</em> link if $an_env_var is set to "yes" in udev's environment.
</p>

<a name="options"></a>
<h3>Additional options</h3>

<p>
Another assignment which can prove useful is the <em>OPTIONS</em> list. A few options are available:
</p>

<ul>
<li><b>all_partitions</b> - create all possible partitions for a block device, rather than only those that were initially detected</li>
<li><b>ignore_device</b> - ignore the event completely</li>
<li><b>last_rule</b> - ensure that no later rules have any effect</li>
</ul>

<p>
For example, the rule below sets the group ownership on my hard disk node, and ensures that no later rule can have any effect:
</p>

<blockquote><pre>KERNEL=="sda", GROUP="disk", OPTIONS+="last_rule"</pre></blockquote>


<h2>Examples</h2>

<a name="example-printer"></a>
<h3>USB Printer</h3>

<p>
I power on my printer, and it is assigned device node <em>/dev/lp0</em>.
Not satisfied with such a bland name, I decide to use udevinfo to aid
me in writing a rule which will provide an alternative name:
</p>

<blockquote><pre># udevinfo -a -p $(udevinfo -q path -n /dev/lp0)
  looking at device '/class/usb/lp0':
    KERNEL=="lp0"
    SUBSYSTEM=="usb"
    DRIVER==""
    ATTR{dev}=="180:0"

  looking at parent device '/devices/pci0000:00/0000:00:1d.0/usb1/1-1':
    SUBSYSTEMS=="usb"
    ATTRS{manufacturer}=="EPSON"
    ATTRS{product}=="USB Printer"
    ATTRS{serial}=="L72010011070626380"
</pre></blockquote>

<p>
My rule becomes:
</p>

<blockquote><pre>SUBSYSTEM=="usb", ATTRS{serial}=="L72010011070626380", SYMLINK+="epson_680"</pre></blockquote>

<a name="example-camera"></a>
<h3>USB Camera</h3>

<p>Like most, my camera identifies itself as an external hard disk
connected over the USB bus, using the SCSI transport. To access my
photos, I mount the drive and copy the image files onto my hard disk.
</p>

<p>
Not all cameras work in this way: some of them use a non-storage protocol such as cameras supported by <a href="http://www.gphoto.org/">gphoto2</a>.
In the gphoto case, you do not want to be writing rules for your
device, as is it controlled purely through userspace (rather than a
specific kernel driver).
</p>

<p>A common complication with USB camera devices is that they usually
identify themselves as a disk with a single partition, in this case <em>/dev/sdb</em> with <em>/dev/sdb1</em>.
The sdb node is useless to me, but sdb1 is interesting - this is the
one I want to mount. There is a problem here that because sysfs is
chained, the useful attributes which udevinfo produces for /dev/sdb1
are identical to the ones for /dev/sdb. This results in your rule
potentially matching <u>both</u> the raw disk and the partition, which is not what you want, your rule should be <b>specific</b>.
</p>

<p>
To get around this, you simply need to think about what differs between
sdb and sdb1. It is surprisingly simple: the name itself differs, so we
can use a simple pattern match on the NAME field.
</p>

<blockquote><pre># udevinfo -a -p $(udevinfo -q path -n /dev/sdb1)
  looking at device '/block/sdb/sdb1':
    KERNEL=="sdb1"
    SUBSYSTEM=="block"

  looking at parent device '/devices/pci0000:00/0000:00:02.1/usb1/1-1/1-1:1.0/host6/target6:0:0/6:0:0:0':
    KERNELS=="6:0:0:0"
    SUBSYSTEMS=="scsi"
    DRIVERS=="sd"
    ATTRS{rev}=="1.00"
    ATTRS{model}=="X250,D560Z,C350Z"
    ATTRS{vendor}=="OLYMPUS "
    ATTRS{scsi_level}=="3"
    ATTRS{type}=="0"
</pre></blockquote>

<p>
My rule:
</p>

<blockquote><pre>KERNEL=="sd?1", SUBSYSTEMS=="scsi", ATTRS{model}=="X250,D560Z,C350Z", SYMLINK+="camera"</pre></blockquote>

<a name="example-usbhdd"></a>
<h3>USB Hard Disk</h3>

<p>A USB hard disk is comparable to the USB camera I described above,
however typical usage patterns are different. In the camera example, I
explained that I am not interested in the sdb node - it's only real use
is for partitioning (e.g. with fdisk), but why would I want to
partition my camera!?
</p>

<p>Of course, if you have a 100GB USB hard disk, it is perfectly
understandable that you might want to partition it, in which case we
can take advantage of udev's string substitutions:
</p>

<blockquote><pre>KERNEL=="sd*", SUBSYSTEMS=="scsi", ATTRS{model}=="USB 2.0 Storage Device", SYMLINK+="usbhd%n"</pre></blockquote>

<p>
This rule creates symlinks such as:
</p>

<ul>
<li><em>/dev/usbhd</em> - The fdiskable node</li>
<li><em>/dev/usbhd1</em> - The first partition (mountable)</li>
<li><em>/dev/usbhd2</em> - The second partition (mountable)</li>
</ul>

<a name="example-usbcardreader"></a>
<h3>USB Card Reader</h3>

<p>USB card readers (CompactFlash, SmartMedia, etc) are yet another
range of USB storage devices which have different usage requirements.
</p>

<p>These devices typically do not inform the host computer upon media
change. So, if you plug in the device with no media, and then insert a
card, the computer does not realise, and you do not have your mountable
sdb1 partition node for the media.
</p>

<p>
One possible solution is to take advantage of the <em>all_partitions</em> option, which will create 16 partition nodes for every block device that the rule matches:
</p>

<blockquote><pre>KERNEL="sd*", SUBSYSTEMS=="scsi", ATTRS{model}=="USB 2.0 CompactFlash Reader", SYMLINK+="cfrdr%n", OPTIONS+="all_partitions"</pre></blockquote>

You will now have nodes named: cfrdr, cfrdr1, cfrdr2, cfrdr3, ..., cfrdr15.

<a name="example-pilot"></a>
<h3>USB Palm Pilot</h3>

<p>
These devices work as USB-serial devices, so by default, you only get the <em>ttyUSB1</em> device node. The palm utilities rely on <em>/dev/pilot</em>, so many users will want to use a rule to provide this.
</p>

<p>
<a href="http://www.clasohm.com/blog/one-entry?entry%5fid=12096">Carsten Clasohm's blog post</a> appears to be the definitive source for this. Carsten's rule is shown below:
</p>

<blockquote><pre>SUBSYSTEMS=="usb", ATTRS{product}=="Palm Handheld", KERNEL=="ttyUSB*", SYMLINK+="pilot"</pre></blockquote>

<p>Note that the product string seems to vary from product to product,
so make sure that you check (using udevinfo) which one applies to you.
</p>

<a name="example-cdrom"></a>
<h3>CD/DVD drives</h3>

<p>I have two optical drives in this computer: a DVD reader (hdc), and
a DVD rewriter (hdd). I do not expect these device nodes to change,
unless I physically rewire my system. However, many users like to have
device nodes such as <em>/dev/dvd</em> for convenience.
</p>

<p>
As we know the KERNEL names for these devices, rule writing is simple. Here are some examples for my system:
</p>

<blockquote><pre>SUBSYSTEM=="block", KERNEL=="hdc", SYMLINK+="dvd", GROUP="cdrom"
SUBSYSTEM=="block", KERNEL=="hdd", SYMLINK+="dvdrw", GROUP="cdrom"
</pre></blockquote>

<a name="example-netif"></a>
<h3>Network interfaces</h3>

<p>
Even though they are referenced by names, network interfaces typically
do not have device nodes associated with them. Despite that, the rule
writing process is almost identical.
</p>

<p>It makes sense to simply match the MAC address of your interface in
the rule, as this is unique. However, make sure that you use the <em>exact</em> MAC address as shown as udevinfo, because if you do not match the case exactly, your rule will not work.
</p>

<blockquote><pre># udevinfo -a -p /sys/class/net/eth0
  looking at class device '/sys/class/net/eth0':
    KERNEL=="eth0"
    ATTR{address}=="00:52:8b:d5:04:48"
</pre></blockquote>

<p>
Here is my rule:
</p>

<blockquote><pre>KERNEL=="eth*", ATTR{address}=="00:52:8b:d5:04:48", NAME="lan"</pre></blockquote>

<p>
You will need to reload the net driver for this rule to take effect.
You can either unload and reload the module, or simply reboot the
system. You will also need to reconfigure your system to use "lan"
rather than "eth0". I had some troubles getting this going (the
interface wasn't being renamed) until I had completely dropped all
references to eth0.
After that, you should be able to use "lan" instead of "eth0" in any
calls to ifconfig or similar utilities.
</p>

<h2>Testing and debugging</h2>

<a name="testing"></a>
<h3>Putting your rules into action</h3>

<p>
Assuming you are on a recent kernel with <em>inotify</em> support,
udev will automatically monitor your rules directory and automatically
pick up any modifications you make to the rule files.
</p>

<p>Despite this, udev will not automatically reprocess all devices and
attempt to apply the new rule(s). For example, if you write a rule to
add an extra symbolic link for your camera while your camera is plugged
in, you cannot expect the extra symbolic link to show up right away.
</p>

<p>To make the symbolic link show up, you can either disconnect and
reconnect your camera, or alternatively in the case of non-removable
devices, you can run <b>udevtrigger</b>.
</p>

<p>
If your kernel does not have inotify support, new rules will not be detected automatically. In this situation, you must run <b>udevcontrol reload_rules</b> after making any rule file modifications for those modifications to take effect.
</p>

<a name="udevtest"></a>
<h3>udevtest</h3>

<p>
If you know the top-level device path in sysfs, you can use <b>udevtest</b>
to show the actions which udev would take. This may help you debug your
rules. For example, assuming you want to debug a rule which acts on <em>/sys/class/sound/dsp</em>:
</p>

<blockquote><pre># udevtest /class/sound/dsp
main: looking at device '/class/sound/dsp' from subsystem 'sound'
udev_rules_get_name: add symlink 'dsp'
udev_rules_get_name: rule applied, 'dsp' becomes 'sound/dsp'
udev_device_event: device '/class/sound/dsp' already known, remove possible symlinks
udev_node_add: creating device node '/dev/sound/dsp', major = '14', minor = '3', mode = '0660', uid = '0', gid = '18'
udev_node_add: creating symlink '/dev/dsp' to 'sound/dsp'
</pre></blockquote>

<p>
Note the <em>/sys</em> prefix was removed from the udevtest command
line argument, this is because udevtest operates on device paths. Also
note that udevtest is purely a testing/debugging tool, it does not
create any device nodes, despite what the output suggests!
</p>

<a name="author"></a>
<h2>Author and contact</h2>

<p>
This document is written by Daniel Drake &lt;<a href="mailto:dan@reactivated.net">dan@reactivated.net</a>&gt;. Feedback is appreciated.
</p>

<p>
For support, you should mail the linux-hotplug mailing list: <a href="mailto:linux-hotplug-devel@lists.sourceforge.net">linux-hotplug-devel@lists.sourceforge.net</a>.
</p>

<p>
Copyright (C) 2003-2006 Daniel Drake.<br>
This document is licensed under the <a href="http://www.gnu.org/licenses/old-licenses/gpl-2.0.html">GNU General Public License, Version 2</a>.
</p>

</body>
</html>
{{{
I have to admire you for running all these tests to try to learn. 
The three pieces I think you're missing in your analysis are 
"How many commands am I running?", 
"What order am I redirecting things in?" and 
"What does | do anyway?"

The first missing piece:
---

For example
Code:
./command.sh >file.txt 2>&1
is only running ONE command, namely "command.sh"

However
Code:
./command.sh 2>&1 | tee file.txt
is running TWO commands, namely "command.sh" and "tee"

When you are running more than one command, you have to remember that EACH command has it's own stdout and stderr. 
So depending on where you put that little "2>&1" thingy, for example, will determine whether you're redirecting stderr from "command.sh" or from "tee". 
The same goes for when you're running subshells. 
The subshell itself is a command so think about whether you're redirecting output from "command.sh" which is running within the subshell, or redirecting output from the subshell itself.

To the second missing piece:
---

Remember "1" = stdout and "2" = stderr. "1" is assumed if you don't provide a number.

Example: ls -l >file.txt is the same as ls -l 1>file.txt

An ampersand can be thought of as meaning: "to the same place as"

Example: ls -l >file.txt 2>&1 means "Send stdout to file.txt and send stderr to the same place as stdout

When we're talking ampersands, "to the same place as" has to also take into account "at this time"

Example
Code:
ls -l >file.txt 2>&1
will send both stdout and stderr to file.txt. Why? Because FIRST stdout was redirected to file.txt and THEN stderr was told to go to the same place as stdout.

On the other hand
Code:
ls -l 2>&1 >file.txt
will send stderr to your screen and stdout to file.txt. 
Why? 
Because stderr was redirected to the same place as stdout, but at this time stdout was still pointing to the console. stdout was not redirected to file.txt until AFTER stderr had been redirected. 
When we are talking AFTER in this example we are talking about placement on the command line. 
Things specified further to the right are thought of as coming after. 
So this example does nothing for stderr. stderr is indeed redirected to the same place as stdout, which is the console at the time of the redirection, but stderr was ALREADY pointing there in the first place - resulting in no perceivable change.

To the third missing piece:
---

The pipe symbol "|" can be thought of like a fancy redirection of stdout. 
It redirects stdout from the first command to the stdin of the second command. 
So ls -l | tee file.txt says "Take the stdout of ls and send it to the stdin of tee. "tee" is simply a program that takes its stdin and sends it to two places, stdout and also to a file.

The eagle-eyed observer will notice an apparent discrepancy for "|" ...

ls -l 2>&1 | tee file.txt will log BOTH stdout and stderr from ls to file.txt. 
But at this time, when stderr was redirected to the same place as stdout, stdout had not yet been redirected to tee via the "|". Hmmm ... gotcha! Just one of those things. 
Never fails - when you try to rationalize your way through something logically ... you run into an exception! 
This is one of those things were experience tells me "I know it works this way", but when you press me with the "why?" question, 
I have to hem and haw and say "Because that's the way it is!"

---

Now that you head is spining with this cryptic "explanation", maybe it will start making more sense why you're seeing what you're seeing in your tests.
}}}
{{{
# set the 'file' variable first

# get extension; everything after last '.'
ext=${file##*.}

# basename
basename=`basename "$file"`
# everything after last '/'
basename=${file##*/}

# dirname
dirname=`dirname "$file"`
# everything before last '/'
basename=${file%/*}
}}}
{{{
for word in `cat somefile`
do
    echo Do something with $word here.
done


find . -iname "*.jpg" | while read file
do
    echo Do something with $file here.
done


for tool in jhead basename find mkdir mogrify cp; do
	if ! type $tool >/dev/null 2>&1; then
		echo "ERROR: \"$tool\" not found."
		echo "       This is needed by $scriptname to work. Check your"
		echo "       \$PATH variable or install the tool \"$tool\"."
		exit 2
	fi
done
}}}
{{{
myvar=abcdef
slice_of_myvar=${myvar:3:2}
}}}
*''showmount -e somehost''
>NFS list exported filesystems on a host
>Export list for this_host
>/home <anon clnt>
*Check that sar is installed before issueing the command: ''mpstat -P ALL''
gzip -dc target.tar.gz | tar xf -
''ps -eo pcpu,pid,user,args | sort -k 1 -r | head -10''
''ps -eo pcpu,pid,user,args | sort -r -k1 | less''
{{{
convert a1.png -resize 50% half_a1.png
convert a1.png -resize 75% a1_75.png
}}}
''curl -u username:password http://localhost:8080/manager/stop?path=/webapp1''
''curl -u username:password http://localhost:8080/manager/start?path=/webapp1''
[[Linux - Create File of a Given Size]]
{{{
du -c -h --max-depth=1
}}}
*Each file has three time stamps, which record the last time that certain operations were performed on the file:
>[a] ''access'' (read the file's contents) - ''atime''
>[b] ''change'' the status (modify the file or its attributes) - ''ctime''
>[c] ''modify'' (change the file's contents) - ''mtime''
You can search for files whose time stamps are within a certain age range, or compare them to other time stamps.
You can use -mtime option. It returns list of file if the file was last accessed N*24 hours ago. For example to find file in last 2 months (60 days) you need to use -mtime +60 option.
> -mtime +60 means you are looking for a file modified 60 days ago.
> -mtime -60 means less than 60 days.
> -mtime 60 If you skip + or - it means exactly 60 days.
*So to find text files that were last modified 60 days ago, use
{{{
find /home/you -iname "*.txt" -mtime -60 -print
}}}
*Display content of file on screen that were last modified 60 days ago, use
{{{
find /home/you -iname "*.txt" -mtime -60 -exec cat {} \;
}}}
*Count total number of files using wc command
{{{
find /home/you -iname "*.txt" -mtime -60 | wc -l
}}}
*You can also use access time to find out pdf files. Following command will print the list of all pdf file that were accessed in last 60 days:
{{{
find /home/you -iname "*.pdf" -atime -60 -type -f
}}}
*List all mp3s that were accessed exactly 10 days ago:
{{{
find /home/you -iname "*.mp3" -atime 10 -type -f
}}}
*There is also an option called -daystart. It measure times from the beginning of today rather than from 24 hours ago. So, to list the all mp3s in your home directory that were accessed yesterday, type the command
{{{
find /home/you -iname "*.mp3" -daystart -type f -mtime 1
}}}
Where,
> -type f - Only search for files and not directories
*find all directories except tmp directory
{{{
find /path/to/dest -type d \( ! -name tmp \) -print
}}}
*Find all directories except tmp and cache
{{{
find /path/to/dest -type d \( ! -name tmp \) -o \( ! -name cache \) -print
}}}
*The -prune option make sure that you do not descend into directory:
{{{
find /path/to/dest -type d \( ! -name tmp \) -o \( ! -name cache -prune \) -print
}}}
*You can find all *.pl find except in tmp and root directory, enter:
{{{
find /  \( ! -name tmp \) -o \( ! -name root -prune \)  -name "*.pl" -print
}}}
Finds all files over 20,000KB (roughly 20MB) in size and presents their names and size in a human readable format:

''find / -type f -size +20000k -exec ls -lh {} \; | awk '{ print $9 ": " $5 }'''

and sort it...

''find / -type f -size +20000k -exec ls -lh {} \; 2> /dev/null | awk '{ print $NF ": " $5 }'  | sort -nrk 2,2''
*remove empty lines
{{{
cat file.txt | grep -v "^$"
}}}
{{{
iconv --from-code=ISO-8859-1 --to-code=UTF-8 ./oldfile.htm > ./newfile.html
}}}
*Central Processing Unit (CPU) statistics and input/output statistics for devices and partitions
|!Command|!Description|
|''iostat''|gives information since the last reboot|
|''iostat -xtc 5 3''|gives you three outputs every 5 seconds|
|!Signal name|!Signal number|
|SIGTERM| 15 |
|SIGKILL| 9 |
*The default signal sent is ''SIGTERM''.
*All signals except for ''SIGKILL'' and ''SIGSTOP'' can be "intercepted" by the process, meaning that a special function can be called when the program receives those signals. The two exceptions ''SIGKILL'' and ''SIGSTOP'' are only seen by the host system's kernel, providing reliable ways of controlling the execution of processes. ''SIGKILL'' kills the process, and ''SIGSTOP'' pauses it until a ''SIGCONT'' is received.
*A process can be sent a ''SIGTERM'' signal in four ways (the process ID is '1234' in this case):
>kill 1234
>kill -s TERM 1234
>kill -TERM 1234
>kill -15 1234
*The process can be sent a ''SIGKILL'' signal in three ways:
>kill -s KILL 1234
>kill -KILL 1234
>kill -9 1234

|!Constant|!Meaning|!Systems|
|SIGHUP|Hangup|POSIX|
|SIGINT|Interrupt|ANSI|
|SIGQUIT|Quit|POSIX|
|SIGILL|Illegal instruction|ANSI|
|SIGABRT|Abort|ANSI|
|SIGTRAP|	Trace trap|POSIX|
|SIGIOT|IOT trap|4.2 BSD|
|SIGEMT|EMT trap|4.2 BSD|
|SIGFPE|Floating-point exception|ANSI|
|SIGKILL|Kill, unblock-able|POSIX|
|SIGBUS|Bus error|4.2 BSD|
|SIGSEGV|Segmentation violation|ANSI|
|SIGSYS|Bad argument to system call|4.2 BSD|
|SIGPIPE|Broken pipe|POSIX|
|SIGALRM|Alarm clock|POSIX|
|SIGTERM|Termination|ANSI|
|SIGUSR1|User-defined signal 1|POSIX|
|SIGUSR2|	User-defined signal 2|POSIX|
|SIGCHLD|	Child status has changed|POSIX|
|SIGCLD|Same as SIGCHLD|System V|
|SIGPWR|Power failure restart|System V|
|SIGXCPU|Exceeded CPU time|POSIX|
|SIGSTOP|Pause execution|POSIX|
|SIGCONT|Resume execution|POSIX|
* Text ''"test message"'' will be written to /var/log/messages
----
* Command: 
{{{
logger -p local0.notice -t $0[$$] test message
}}}
*Result
{{{
Oct 15 13:44:26 mylinuxhost bash[22841]: test message
}}}
----
http://linux.about.com/library/cmd/blcmdl1_rsync.htm
http://sial.org/howto/rsync/


{{{
rsync -ave ssh --numeric-ids --delete machine1:/home /machine1
rsync -ave ssh --numeric-ids --delete machine1:/src /machine1

rsync -ave ssh --numeric-ids --delete machine2:/home /machine2
rsync -ave ssh --numeric-ids --delete machine2:/mail /machine2

rsync -ave ssh --numeric-ids --delete machine3:/home /machine3
rsync -ave ssh --numeric-ids --delete machine3:/var/www /machine3
rsync -ave ssh --numeric-ids --delete machine3:/etc/httpd /machine3

# Crontab entries
# Scripts to rsync machines
59 20 * * * /root/scripts/sync-machine1.sh >/root/logs/sync-machine1.log 2>&1
59 21 * * * /root/scripts/sync-machine2.sh >/root/logs/sync-machine2.log 2>&1
59 22 * * * /root/scripts/sync-machine3.sh >/root/logs/sync-machine3.log 2>&1
#
# Nightly Backup script
59 23  * * * /root/scripts/backup.sh > /root/logs/backup.log 2>&1
}}}
{{{
#!/bin/sh
rsync -e 'ssh -ax' --delete -avz remoothost:/root/thing2sync* /root/localdir
}}}
{{{
rsync --verbose  --progress --stats --compress --rsh=/usr/local/bin/ssh \
      --recursive --times --perms --links --delete \
      --exclude "*bak" --exclude "*~" \
      /www/* webserver:simple_path_name
}}}
*ssh-keygen -t dsa
*ssh-keygen -t rsa
{{{
ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa
cat~/.ssh/id_dsa_pub >> ~/.ssh/authorized_keys
}}}
*tail with color
{{{
tail -f file | perl -pe 's/keyword/\e[1;31;43m$&\e[0m/g'

This only works on ANSI terminals, but all others have become virtually
extinct. \e[...m ist the ANSI escape sequence SGR "select graphic
rendition". The "..." can be replaced by some semicolon-separated
integers, with the meaning:

0 : all attributes off
1 : bold
31 : foreground red
43 : background yellow

"keyword", of course, can be any perl regular expression:

(foo|bar) highlight the strings foo and bar
\b((foo|bar)\b highlight the words foo and bar
.*\b((foo|bar)\b.* highlight the whole line that contains the words foo or bar
}}}
tcpdump 
>-i eth0 
>-s 0 
>-nn
>-w tcpdump_result.pcap
>'(((not src 192.168.1.1) and (not dst host 192.168.1.1 ) and (src host  192.168.1.2 or dst host 192.168.1.2)))' 

*tcpdump -i eth0 -s 0 -nn -w tcpdump_result.pcap '(((not src 192.168.1.1) and (not dst host 192.168.1.1 ) and (src host  192.168.1.2 or dst host 192.168.1.2)))' 
top -F -R -o cpu
useradd -d /home/nagios -G nagios -m -k /etc/skel nagios
*Create Universally Unique Identifier: ''uuidgen''
/***
|''Name:''|LoadRemoteFileThroughProxy (previous LoadRemoteFileHijack)|
|''Description:''|When the TiddlyWiki file is located on the web (view over http) the content of [[SiteProxy]] tiddler is added in front of the file url. If [[SiteProxy]] does not exist "/proxy/" is added. |
|''Version:''|1.1.0|
|''Date:''|mar 17, 2007|
|''Source:''|http://tiddlywiki.bidix.info/#LoadRemoteFileHijack|
|''Author:''|BidiX (BidiX (at) bidix (dot) info)|
|''License:''|[[BSD open source license|http://tiddlywiki.bidix.info/#%5B%5BBSD%20open%20source%20license%5D%5D ]]|
|''~CoreVersion:''|2.2.0|
***/
//{{{
version.extensions.LoadRemoteFileThroughProxy = {
 major: 1, minor: 1, revision: 0, 
 date: new Date("mar 17, 2007"), 
 source: "http://tiddlywiki.bidix.info/#LoadRemoteFileThroughProxy"};

if (!window.bidix) window.bidix = {}; // bidix namespace
if (!bidix.core) bidix.core = {};

bidix.core.loadRemoteFile = loadRemoteFile;
loadRemoteFile = function(url,callback,params)
{
 if ((document.location.toString().substr(0,4) == "http") && (url.substr(0,4) == "http")){ 
 url = store.getTiddlerText("SiteProxy", "/proxy/") + url;
 }
 return bidix.core.loadRemoteFile(url,callback,params);
}
//}}}
[[MSWindows - Restart or Shutdown Windows (XP, 2000 and Vista) from Command Line]]
[[MSWindows - Syslog and Windows]]
|!Command|!Info|
|shutdown -s -t 01|shutdown in 1 sec|
|shutdown -r -t 01|restart in 1 sec|
{{{
shutdown /?” command at command prompt.

The options available for shutdown are:

No arguments : Display this message (same as -?)
-i : Display GUI interface, must be the first option
-l : Log off (cannot be used with -m option)
-s : Shutdown the computer
-r : Shutdown and restart the computer
-a : Abort a system shutdown
-m \\computername : Remote computer to shutdown/restart/abort
-t xx : Set timeout for shutdown to xx seconds
-c “comment” : Shutdown comment (maximum of 127 characters)
-f : Forces running applications
to close without warning
-d [u][p]:xx:yy : The reason code for the shutdown
}}}
http://troy.jdmz.net/syslogwin/
http://sourceforge.net/projects/ntsyslog/


|>|>| !Math |
| !Symbol | !Character | !Description |
| {{{&deg;}}} | &deg; |degree sign |
| {{{&plusmn;}}} | &plusmn; |plus or minus sign |
| {{{&times;}}} | &times; |multiplication sign |
| {{{&divide;}}} | &divide; |division sign |
| {{{&lt;}}} | &lt; |less-than sign |
| {{{&gt;}}} | &gt; |greater-than sign |
| {{{&lang;}}} | &lang; |left angle bracket |
| {{{&rang;}}} | &rang; |right angle bracket |
| {{{&not;}}} | &not; |not sign |
| {{{&sup1;}}} | &sup1; |superscript one |
| {{{&sup2;}}} | &sup2; |superscript two |
| {{{&sup3;}}} | &sup3; |superscript three |
| {{{&middot;}}} | &middot; |middle dot |
| {{{&afrac14;}}} | &frac14; |one quarter |
| {{{&frac12;}}} | &frac12; |one half |
| {{{&frac34;}}} | &frac34; |three quarters |
| {{{&permil;}}} | &permil; |per mille sign |
| {{{&fnof;}}} | &fnof; |latin small f with hook (function) |
| {{{&prime;}}} | &prime; |prime / minutes / feet |
| {{{&Prime;}}} | &Prime; |double prime / seconds / inches |
| {{{&frasl;}}} | &frasl; |fraction slash |
| {{{&weierp;}}} | &weierp; |script capital P |
| {{{&image;}}} | &image; |bold I / imaginary part |
| {{{&real;}}} | &real; |bold R / real part |
| {{{&alefsym;}}} | &alefsym; |first transfinite cardinal |
| {{{&micro;}}} | &micro; |micro sign |
| {{{&forall;}}} | &forall; |for all |
| {{{&part;}}} | &part; |partial differential |
| {{{&exist;}}} | &exist; |there exists |
| {{{&empty;}}} | &empty; |empty set / diameter |
| {{{&nabla;}}} | &nabla; |backward difference |
| {{{&isin;}}} | &isin; |element of |
| {{{&notin;}}} | &notin; |not an element of |
| {{{&ni;}}} | &ni; |contains as member |
| {{{&prod;}}} | &prod; |product sign |
| {{{&sum;}}} | &sum; |n-ary sumation |
| {{{&minus;}}} | &minus; |minus sign |
| {{{&lowast;}}} | &lowast; |asterisk operator |
| {{{&radic;}}} | &radic; |square root / radical |
| {{{&prop;}}} | &prop; |proportional to |
| {{{&infin;}}} | &infin; |infinity |
| {{{&ang;}}} | &ang; |angle |
| {{{&and;}}} | &and; |logical and |
| {{{&or;}}} | &or; |logical or |
| {{{&cap;}}} | &cap; |intersection |
| {{{&cup;}}} | &cup; |union |
| {{{&int;}}} | &int; |integral |
| {{{&there4;}}} | &there4; |therefore |
| {{{&sim;}}} | &sim; |similar to |
| {{{&cong;}}} | &cong; |approximately equal to |
| {{{&asymp;}}} | &asymp; |almost equal to |
| {{{&ne;}}} | &ne; |not equal to |
| {{{&equiv;}}} | &equiv; |identical to |
| {{{&le;}}} | &le; |less-than or equal to |
| {{{&ge;}}} | &ge; |greater-than or equal to |
| {{{&sub;}}} | &sub; |subset of |
| {{{&sup;}}} | &sup; |superset of |
| {{{&nsub;}}} | &nsub; |not a subset of |
| {{{&sube;}}} | &sube; |subset of or equal to |
| {{{&supe;}}} | &supe; |superset of or equal to |
| {{{&oplus;}}} | &oplus; |direct sum |
| {{{&otimes;}}} | &otimes; |vector product |
| {{{&perp;}}} | &perp; |orthogonal to / perpendicular |
| {{{&sdot;}}} | &sdot; |dot operator |
''Simple indenting:''

{{{ {{indent{text }}} produces:

{{indent{text


''Headlines'':

{{{!Text}}} produces:
!Text
{{{!!Text}}} produces:
!!Text
{{{!!!Text}}} produces:
!!!Text
and so on.


''Dotted horizontal lines:'' 

{{{----}}} produces the following line:
----

[[SAR]]
[[SNMP]]
[[Nagios]]
[[WebScarab]]
[[JMeter]]
[[Syslog]]
|!Letter|!Code word|
|A|Alfa » AL FAH|
|B|Bravo » BRAH VOH|
|C|Charlie » CHAR LEE or SHAR LEE|
|D|Delta » DELL TAH|
|E|Echo » ECK OH|
|F|Foxtrot » FOKS TROT|
|G|Golf » GOLF|
|H|Hotel » HOH TELL|
|I|India » IN DEE AH|
|J|Juliett » JEW LEE ETT|
|K|Kilo » KEY LOH|
|L|Lima » LEE MAH|
|M|Mike » MIKE|
|N|November » NO VEM BER|
|O|Oscar » OSS CAH|
|P|Papa » PAH PAH|
|Q|Quebec » KEH BECK|
|R|Romeo » ROW ME OH|
|S|Sierra » SEE AIR RAH|
|T|Tango » TANG GO|
|U|Uniform » YOU NEE FORM or OO NEE FORM|
|V|Victor » VIK TAH|
|W|Whiskey » WISS KEY|
|X|X-ray » ECKS RAY|
|Y|Yankee » YANG KEY|
|Z|Zulu » ZOO LOO|
[[Nagios - DB2 Monitoring]]
[[Nagios - Host and Service Monitoring Tool]]
[[Nagios - check_files_exists]]
[[Nagios - DB2 Monitoring - scripts]]
[[Nagios - DB2 Monitoring - scripts - check_dbs_conn.py]]
[[Nagios - DB2 Monitoring - scripts - check_log_usage.py]]
[[Nagios - DB2 Monitoring - scripts - check_backups.py]]
[[Nagios - DB2 Monitoring - scripts - check_instances.py]]
[[Nagios - DB2 Monitoring - scripts - check_lock_waiting.py]]
[[Nagios - DB2 Monitoring - scripts - check_inserts_seconds.py]]
''Script Python to check backups in DB2 Databases V9''
Script to check if backups were executed in DB2 Database or not,this script is can be used transparently as a nagios plugin.
{{{
#!/usr/bin/python
# -*- coding: cp1252 -*-
"""
Author: Vinícius Rodrigues da Cunha Perallis
http://www.dbatodba.com
Function:Check if backups were executed or not in DB2 DATABASE 

Created in: 01/14/2009
Updated in: 01/15/2009   

########################################################################################
Descripton: This program return 3 types of value:
0 = normal
1 = warning
3 = unknown error

If the there is backup image, then the exit of program is 0.
If the there is not backup image, then the exit of program is 1.
If is not possible connect to database or if is not possible to perform any command, then the exit of program is 3.
########################################################################################
"""
import string
import os
import time
import sys

database=sys.argv[1]
threshold_warning=sys.argv[2]
resultado=0
if (os.system("db2 connect to " + database +" > /dev/null") == 0):
    backup=string.split(os.popen("db2 connect to " + database + " ; db2 'select 1 from sysibmadm.SNAPDB where LAST_BACKUP > current timestamp - "+  threshold_warning + " days'  | grep -i selected |awk '{print $1}' ").read())
    try:     
        if backup[18] == 1:
            print "OK: Backup on DB "+database+" was completed successfully in the last " + threshold_warning + "days"
            resultado=0
        elif backup[18] == 0:
            print "WARNING: NO BACKUP in the last " + threshold_warning + "days" 
            resultado=1
    except:
        print "UNKNOWN: It is no possible execute select command on "+ database        
        resultado=3     
else:
     print "UNKNOWN: It is no possible to connect on "+ database     
     resultado=3

if resultado==0:
   sys.exit(0)
elif resultado==1:
   sys.exit(1)
elif resultado==3:
   sys.exit(3)
}}}
http://www.dbatodba.com/db2/scripts-db2
{{{
python  check_dbs_conn.py db1 db2 db3
}}}
{{{
#!/usr/bin/python
# -*- coding: cp1252 -*-
"""
Author: Vinícius Rodrigues da Cunha Perallis
Script Name: check_dbs_conn.py
Function:Check databases connectivity 
Date: 28/01/2009

########################################################################################
Descripton: This program return 2 types of value:
0 = NORMAL
2 = CRITICAL

If all databases are connectable,then the exit of program is 0.
If at least one database is not connectable, then the exit of program is 2.
########################################################################################
"""
import string
import os
import time
import sys

#Variables
count=0
count2=0
dbs=[]
errors=[]
d_errors=''
flag=0

#Get all command line parameters and check if is possibe to connect to all databases
for database in sys.argv:
   #"If clause" to ignore the fist parameters (script name)
   if count==1:  
       if os.system("/home/db2inst1/sqllib/bin/db2 connect to " + database+" > /dev/null")==0:
            pass
       #get the dabatase name that was not possible to connect, and the error name
       else:
         errors_total=string.split(os.popen("/home/db2inst1/sqllib/bin/db2 connect to " + database).read()) 
         errors.append(errors_total[0])
         dbs.append(database)
         flag=1 
   count=1

#Build the phrase with database names and its errors
for i in dbs:
  d_errors=d_errors + " " + i + ":"+errors[count2] + " | "
  count2+=1

#Show the message
if flag==1:
   print "CRITICAL: It was not possible to connect to DB:" + d_errors
   sys.exit(2)
else:
   print "OK : Banco(s) connectable"
   sys.exit(0)
}}}


''Python Script to check inserts per second in DB2 Databases V9''
Script to check the rate per second of inserts in db2 databases

Check the related content to use PyDB2 to connect to DB2 using python

To execute the script, inform the database name and number of execution:
{{{
python <database_name> <num_execution>
}}}
example
{{{
python sample 50
}}}
{{{
#!/usr/bin/python
# -*- coding: 1252 -*-

"""
Author: Vinícius Rodrigues da Cunha Perallis
http://www.dbatodba.com
Script Name:check_inserts_seconds.py
Function: Check rowsinserted per seconds in DB2 Databases

Created in: 01/23/2009
"""
import sys
import DB2
import time


#Get the database name and the number of execution from command line
try:
   database=sys.argv[1]
except:
   print "Please inform the database name"
   sys.exit(1)
try:
   num_executions=int(sys.argv[2])
except:
   print"Please inform the number of execution"
   sys.exit(1)

#Create a database connection

try:
    conn = DB2.connect(dsn=database,uid='db2inst1',pwd='db2inst1')
    curs=conn.cursor()
except:
    print "Connection was uncessufully"
    sys.exit(1)

for i in range(num_executions):
     curs.execute('select ROWS_INSERTED from sysibmadm.snapdb')
     rows1 = curs.fetchone()
     time.sleep(2)
     curs.execute('select ROWS_INSERTED from sysibmadm.snapdb')
     rows2 = curs.fetchone()
     print (rows2[0] - rows1[0])/2

#Close the database connection
curs.close()
conn.close() 
}}}
''Script Python to check if DB2 instance is running''
Script to check if DB2 instance is running, this script is can be used transparently as a nagios plugin.
(check_instances.py 4 -> when checking 4 instances)
{{{
#!/usr/bin/python
# -*- coding: cp1252 -*-
"""
Author: Vinícius Rodrigues da Cunha Perallis
http://www.dbatodba.com
Function:Check if instance is running fine 

Created in: 01/14/2009
Updated in: 01/15/2009   

########################################################################################
Descripton: This program return 2 types of value:
0 = normal
2 = error

If all instances running properly,then the exit of program is 0.
If any instance is down, then the exit of program is 2.
########################################################################################
"""
import string
import os
import time
import sys

try:
  number_of_instances=int(sys.argv[1])
except:
  #default value of number of instances
  number_of_instances=1

resultado=0
db2sysc=string.split(os.popen("ps -ef | awk 'BEGIN {QTDE=0} {if ($8 ~ /db2sysc/) {QTDE=QTDE+1}}END {print QTDE}'").read())
db2sysc_real=int(db2sysc[0])

if db2sysc_real==number_of_instances:
     if number_of_instances==1:  
         print "OK: Instance is running properly."
     elif number_of_instances>1:
         print "OK:",number_of_instances,"instances are running properly."
     sys.exit(0)
else:
     if number_of_instances==1:  
         print "CRITICAL:",number_of_instances-db2sysc_real,"instances is DOWN"     
     elif number_of_instances>1:
         print "CRITICAL:",number_of_instances-db2sysc_real,"instances are DOWN"    
     sys.exit(2)
}}}
''Script Python to check locks waiting on DB2 - install PyDB2 for this to work''
Script to check locks waiting in DB2 Database,this script is can be used transparently as a nagios plugin. Ex: python check_lock_waiting.py sample user password 10 80 90
{{{
#!/usr/bin/python
# -*- coding: cp1252 -*-

"""
Author: Vinícius Rodrigues da Cunha Perallis
Function:Check the ipercentage of locks waitl 
Script Name: locks_wait.py
Date: 01/23/2009

########################################################################################

Descripton: This program return 3 types of value:
0 = normal
1 = warning
2 = error
3 = unknown error

If the percentage of locks waiting per applications is < threshold_warning, then the exit of program is 0.
If the percentage of locks waiting per applications is >= threshold_warning, then the exit of program is 1.
If the percentage of locks waiting per applications is >= is threshold_error, then the exit of program is 2.
If is not possible connect to database, then the exit of program is 3.
#######################################################################################

"""
import string
import os
import time
import sys
import DB2

#Get the variables from command line

try:
    database=sys.argv[1]
    user=sys.argv[2]
    passwd=sys.argv[3]
    appl_minimal=sys.argv[4]
    threshold_warning=sys.argv[5]
    threshold_severe=sys.argv
except:
    print "Please provide the database name, user, password,minimal applications, threshold warning, threshold critical"
    sys.exit(3)

# Connect to database
try:
  conn=DB2.connect(dsn=database,uid=user,pwd=passwd)
  curs=conn.cursor()
except:
  print "UNKNOWN: Database not connectable"
  sys.exit(3)

# Select the number of applications and the number of applications in lock-wait 
curs.execute('select locks_waiting, (int(appls_cur_cons) -1) from sysibmadm.snapdb')
rows=curs.fetchone()
appl=int(rows[1])
locks=int(rows[0])
if locks==0:
   print "NORMAL: NO LOCKS WAITING"
   sys.exit(0) 
else:
   percentage=(float(locks)/float(appl))*100

if int(appl)>=int(appl_minimal) :
   if percentage>=float(threshold_warning) and percentage<float(threshold_severe):
      print "WARNING: The percentage of locks waiting per applications is",percentage
      sys.exit(1)
   elif percentage>float(threshold_severe):
      print "CRITICAL The percentage of locks waiting per applications is",percentage 
      sys.exit(2)
   else:
      print "NORMAL: The percentage of locks waitning per application is",percentage
      sys.exit(0)
else:
    print "The minimal number of applications connected was not reach to validade this script"
    sys.exit(0)

}}}
''Script Python to check log usage in DB2 Database V9''
Script to check log usage in DB2 Database,this script is can be used transparently as a nagios plugin. Ex: python check_log_usage.py sample 80 90
{{{
#!/usr/bin/python
# -*- coding: cp1252 -*-

"""

Author: Vinícius Rodrigues da Cunha Perallis
http://www.dbatodba.com
Script Name: check_log_usage.py
Function:Check the log usage in DB2 DATABASE.
Can be used as a nagios plugin
Date: 13/01/2009



########################################################################################

Descripton: This program return 4 types of value:

0 = normal
1 = warning
2 = error
3 = unknown error



If the percentage of log usage is < threshold_warning, then the exit of program is 0.
If the percentage of log usage is >= threshold_warning, then the exit of program is 1.
If the percentage of log usage is threshold_error, then the exit of program is 2.
If is not possible connect to database, then the exit of program is 3.

########################################################################################

"""

import string
import os
import time
import sys


database=sys.argv[1]
try:
   threshold_warning=sys.argv[2]
except:
   threshold_warning=str(80)
try:
   threshold_severe=sys.argv[3]
except:
   threshold_severe=str(90)

if (os.system("db2 connect to " + database +" > /dev/null") == 0):
    logs=string.split(os.popen("db2 connect to " + database + "; db2 'select int((float(total_log_used)/float(total_log_used+total_log_available))*100) from sysibmadm.snapdb'").read())
    if logs[20]<threshold_warning:
        print "OK: Utilization of logs is: " + logs[20] +"% | log-db2 "+database+":" +logs[20] +"%;"+threshold_warning+";"+threshold_severe
        sys.exit(0)
    elif logs[20]>=threshold_warning and logs[20]<threshold_severe:
        print "WARNING: Utilization of logs more than "+threshold_warning + "% | log-db2 "+database+":" +logs[20] +"%;"+threshold_warning+";"+threshold_severe
        sys.exit(1)
    elif logs[20]>=threshold_severe<101:
        print "CRITICAL:  Utilization of logs more than "+threshold_severe + "% | log-db2 "+database+":" +logs[20] +"%;"+threshold_warning+";"+threshold_severe 
        sys.exit(2)
    else:
        print "UNKNOWN: It is no possible execute select command on "+ database        
        sys.exit(3)
else:
   print "UNKNOWN: It is no possible to connect on "+ database
   sys.exit(3)

}}}
http://www.novell.com/coolsolutions/feature/16723.html
{{{
#!/bin/bash
#
# Check if a local file exist
#
while getopts F: VAR
do
   case "$VAR" in
       F ) LOGFILE=$OPTARG ;;
       * ) echo "wrong syntax: use $o -F <file to check>"
       exit 3 ;;
   esac
done

if test "$LOGFILE" = ""
   then
       echo "wrong syntax: use $0 -F <file to check>"
       # Nagios exit code 3 = status UNKNOWN = orange
       exit 3
   fi

if test -e "$LOGFILE"
   then
       if test -x "$LOGFILE"
           then
               echo "Critical $LOGFILE is executable !"
               # Nagios exit code 2 = status CRITICAL = red
           exit 2
       else
           echo "Warning $LOGFILE exists !"
           # Nagios exit code 1 = status WARNING = yellow
           exit 1
       fi
   else
       echo "OK: $LOGFILE does not exist !"
       # Nagios exit code 0 = status OK = green
       exit 0
fi
}}}
[[RIPE Database Search]]
----
[[tcpserver.pl]]
[[tcpserver.py]]
----
<code>
...
</code>
[[OSX - TiddlySaver]]
[[OSX - Boot keys for Mac OS X system start]]
[[OSX - Flush DNS Cache]]
[[OSX - Eject a stuck DVD from your MacBook]]
[[OSX - Disable Dock Bouncing]]
[[OSX - Lock the Dock in Mac OS X]]
[[OSX - Track an applications usage in Mac OS X with opensnoop]]
[[OSX - Change the Mac Login Screen Background]]
[[OSX - Spotlight]]
[[OSX - Schedule sleep and wake from the Terminal]]
[[OSX - Open Finder from the Terminal]]
[[OSX - Access the clipboard from the command line]]
[[OSX - List all mounted drives and their partitions from the Terminal]]
[[OSX - Secrets of the Command-Tab Mac Application Switcher]]
[[OSX - Quickly Reboot, Log out, and Sleep your Mac]]
[[OSX - Quickly turn off your Mac’s displays with Shift-Control-Eject]]
[[OSX - Force Safari to open target links in new tab rather than window]]
[[OSX - Get extensive information about your Mac from it’s serial number]]
[[OSX - Enable hidden Quick Look feature for folder content previews]]
[[OSX - Quickly Sleep your Mac]]
[[OSX - Convert a Nero Image File to ISO format]]
[[OSX - Access and Mount an SMB Share via Command Line]]
[[OSX - Enabling Terminal’s directory and file color highlighting in Mac OS X]]
[[OSX - Convert a DMG to ISO and Convert ISO to DMG on Mac]]
[[OSX - Install Snow Leopard from External Firewire or USB Hard Drive, or How to Upgrade to 10.6 Without a DVD Drive]]
[[OSX - Eject a stuck disk from your Mac DVD super drive]]
[[OSX - Hide any File or Folder by making it Invisible to the Mac OS X Finder]]
[[OSX - Rearrange the status items in the Mac menu bar]]
[[OSX - Virtually Scale Window Size to Increase or Decrease Desktop Screen Workspace]]
[[OSX - How to create an IP Alias in Mac OS X using ifconfig]]
[[OSX - Change your User ID]]
[[OSX - How to flush your DNS cache in Mac OS X]]
[[OSX - Use Quick Look from the command line]]


{{{
smbclient -U user -I 192.168.0.105 -L //smbshare/ 
mount -t smbfs -o username=winusername //smbserver/myshare /mnt/smbshare
mount -t cifs -o username=winusername,password=winpassword //192.168.0.105/myshare /mnt/share
}}}
*''pbcopy'' – pbpaste is how you dump contents to the clipboard
*''pbpaste'' – pbpaste is how you dump the contents of the clipboard
{{{
ls -lha |pbcopy
pbpaste > clipboard.txt
pbpaste | ssh username@host 'cat > ~/myclipboard.txt'
}}}
Here’s a list of system startup hot keys to press while Mac OS X is booting, and their various effects:

C – Boot from a CD/DVD
T – Boot in Target Disk mode (FireWire only)
N – Boot from an attached network server (NetBoot mode)
X – Attempt to force Mac OS X to boot
Shift – Boot up in ‘Safe Mode’ which has limited functionality
Command+V – Boot into Verbose mode
Command+S – Boot in Single user mode
/System/Library/CoreServices/DefaultDesktop.jpg
*Change ID from 501 to 1000
>''dscl . -change /Users/will UniqueID 501 1000''
>''chown -R 1000 /Users/will''
*Convert a DMG file to ISO
>''hdiutil convert /path/imagefile.dmg -format UDTO -o /path/convertedimage.iso''
*Convert an ISO file to DMG format
>''hdiutil convert /path/imagefile.iso -format UDRW -o /path/convertedimage.dmg''
''dd bs=1k if=image.nrg of=image.iso skip=300''
*Disable Dock Bouncing (Dock will relaunch after kill):
{{{
defaults write com.apple.dock no-bouncing -bool TRUE
killall Dock
}}}
*Re-enable Dock bouncing by entering these commands (Dock will relaunch after kill):
{{{
defaults write com.apple.dock no-bouncing -bool FALSE
killall Dock
}}}
drutil eject
''drutil eject''
{{{
defaults write com.apple.finder QLEnableXRayFolders 1
defaults write com.apple.finder QLEnableXRayFolders 0
}}}
{{{
Enabling directory and file color highlighting requires that you open (or create) ~/.bash_profile in your favourite text editor, add these contents:

export CLICOLOR=1
export LSCOLORS=ExFxCxDxBxegedabagacad

… save the file and open a new Terminal window (shell session). Any variant of the “ls” command:

ls
ls -l
ls -la
ls -lah

… will then display its output in color.

More details on the LSCOLORS variable can be found by looking at the man page for “ls“:

man ls

LSCOLORS needs 11 sets of letters indicating foreground and background colors:

   1. directory
   2. symbolic link
   3. socket
   4. pipe
   5. executable
   6. block special
   7. character special
   8. executable with setuid bit set
   9. executable with setgid bit set
  10. directory writable to others, with sticky bit
  11. directory writable to others, without sticky bit

The possible letters to use are:

a  black
b  red
c  green
d  brown
e  blue
f  magenta
c  cyan
h  light grey
A  block black, usually shows up as dark grey
B  bold red
C  bold green
D  bold brown, usually shows up as yellow
E  bold blue
F  bold magenta
G  bold cyan
H  bold light grey; looks like bright white
x  default foreground or background

By referencing these values, the LSCOLORS variable setting mentioned above translates to:

Bold blue with default background for directories, bold magenta with default background for symbolic links, bold green with default background for sockets, etc.
}}}
sudo dscacheutil -flushcache
{{{
defaults write com.apple.Safari TargetedClicksCreateTabs -bool true
defaults write com.apple.Safari TargetedClicksCreateTabs -bool false
}}}
http://www.appleserialnumberinfo.com/Desktop/index.php
*Make a file or folder invisible in Mac OS X Finder
>''setfile -a V testfile.txt''
*Make a file or folder visible again in Mac OS X Finder
>''setfile -a v testfile.txt''
*Type the following at the command line prompt to alias the new IP of 192.168.0.101 to your existing subnet mask
>''sudo ifconfig en0 alias 192.168.0.101 255.255.255.0''
*If you want to get rid of the alias, just type:
>''sudo ifconfig en0 -alias 192.168.0.101 ''
''dscacheutil -flushcache''
If you have a Mac without a functioning DVD drive (or a MacBook Air), you’ll need to find another way to upgrade to Snow Leopard, thankfully this is very easy, all you’ll need is an external firewire or USB hard drive. OK so the title might be slightly misleading, you’ll need access to a DVD drive *somewhere* so that you can make a disk image of the Snow Leopard install disk with the Disk Utility tool, but once you have the disc image you won’t need the DVD drive again. What you WILL need the entire time though is an external Firewire or USB drive that you don’t mind formatting, so that you can make the device bootable and upgrade to Snow Leopard from it.
----
*''Snow Leopard Install DVD image''

>As some readers pointed out, this step isn’t required. If you do need to, you can create a DMG file of the Snow Leopard disk, this is very easy.
>* Launch Disk Utility
>* Select the Snow Leopard DVD within Disk Utility
>* Click the “New Image” button at the top
>* Name the image and put it somewhere you can find it easily (Desktop)
>* Click OK and wait for the image to be created

>Easy enough right? Ok so here’s how you create a bootable Snow Leopard installation drive out of your external firewire or USB hard disk.

----
*''Install Snow Leopard from an external Firewire or USB drive''

>* Launch Disk Utility
>* Select the External Firewire/USB device that you want to use as the boot drive for the upgrade
>* Click “Partition” from the menu options
>* Select 1 Partition, then click “Options” below the partition scheme
>* Select the top option for “GUID Partition Table” – it MUST be GUID to be bootable!
>* Click OK to create the GUID partition (this will reformat the drive, ie: all data is lost)
>* Next, click the “Restore” tab within Disk Utility
>* Select your newly made Snow Leopard 10.6 Install DVD image and restore this image to the GUID partition you just created OR…
>* Alternatively, you can select the Snow Leopard Install DVD and restore directly from the DVD to the GUID partition
>* After the restoration is complete, your GUID partition will now be bootable by Mac OS X!
>* Reboot the Mac holding down the “Option” key to pull up the boot loader, select the Snow Leopard install drive you just created rather than your default Mac OS hard drive
>* Install Snow Leopard as usual!
diskutil list
*Lock the Dock to Prevent Changes to Contents (Dock will relaunch after kill)
{{{
defaults write com.apple.Dock contents-immutable -bool yes
killall Dock
}}}
*Lock the Dock to Prevent Changes in Size (Dock will relaunch after kill)
{{{
defaults write com.apple.Dock size-immutable -bool yes
killall Dock
}}}
*Lock the Dock’s Position on the Screen (Dock will relaunch after kill)
{{{
defaults write com.apple.Dock position-immutable -bool yes
killall Dock
}}}
open .
open /Applications/Utilities/
*Immediately Reboot Mac OS X
>''Control + Command + Eject''
*Immediately Shutdown Mac OS X
>''Command + Option + Control + Eject''
*Immediately Log User Out of Mac OS X
>''Control + Option + Shift + Q''
*Immediately Put Your Mac to Sleep
>''Command + Option + Eject (hold the buttons down for 2 seconds)''
*Immediately Shut Off Your Mac Display
>''Shift + Control + Eject''
''Command + Option + Eject''
''Shift+Ctrl+Eject''
hold Command and drag the icons
pmset schedule sleep "12/24/2009 00:00:00"
pmset schedule wake "12/26/2009 00:00:00"
pmset repeat wakeorpoweron MTWRF 07:45:00
pmset repeat cancel
*''Command+Tab'' launches the application switcher, continue holding down Command and then try:
{{{
* tab – move selection to the right in the app list
* ` – move selection to the left
* h – hide the selected application
* q – quit the selected application
* mouse scrollwheel – move the selection back and forth
* left arrow – move selection to the left
* right arrow – move selection to the right
* up arrow – enter expose within the selected application
* down arrow – enter expose within the selected application
}}}
*Example:
{{{
type:text "search for this text in a file"
kind:pdf search_for_this
}}}
*Spotlight Search Operators
{{{
Note that all of these search operators are used in Spotlight in the following syntax format:
kind:audio Rolling
kind:application
kind:pdf
kind:jpeg
kind:word
kind:folder
kind:image
kind:audio
date:today
date:yesterday
}}}
*Advanced Spotlight Search Operators
{{{
date:>10/1/09 will find any file modified after November 1, 2009, note that the dates you enter must correspond to the short date format you have set in your International preferences
date:<12/31/09 will find any file modified before December 31, 2009
date:1/1/06-12/31/09 will find files modified between the two specified dates. Example syntax is:
date:1/1/06-12/31/09 contract
}}}
The ~TiddlySaver Java applet allows ~TiddlyWiki to save changes in a local version (from a file:// URL) of Safari, Opera and other browsers. It is a small file named [["TiddlySaver.jar"|TiddlySaver.jar]] that must be placed in the same directory as your ~TiddlyWiki file. As of August 2008, when an empty ~TiddlyWiki file is downloaded using either Safari or Opera, it is bundled with a copy of the ~TiddlySaver.jar file in a zip file - both files must be in the same directory ''whenever the ~TiddlyWiki file is opened'' in order to work.



[["TiddlySaver.jar"|TiddlySaver.jar]]  is signed by [[UnaMesa Association|UnaMesa]]. The [[UnaMesa Association|UnaMesa]] certificate is signed by the ''Thawte Code Signing CA'' intermediate certificate which is chained to the ''Thawte Premium Server CA'' root certificate. You need to trust this certificate Chain to be able to use the applet.



Note that there is currently [[a bug|http://trac.tiddlywiki.org/ticket/172]] that prevents ~TiddlySaver from working if you have specified a backup directory in AdvancedOptions and the directory doesn't exist.



Thanks to Andrew Gregory for the original TiddlySaver code, and ~BidiX for arranging all the certificate magic.
sudo opensnoop -n Safari
sudo opensnoop -f /etc/hosts
sudo opensnoop -p PID
(opensnoop is based on DTrace)
''qlmanage -p filename.jpg''
*The following will render all displayed elements at 80% of their original size
>''defaults write -g AppleDisplayScaleFactor 0.8''
>''killall Finder''
*To set back to the default simply change the Scale Factor to 1.0 like so:
>''defaults write -g AppleDisplayScaleFactor 1.0''
>''killall Finder''
http://pleac.sourceforge.net/pleac_python/index.html
/***
|''Name:''|PasswordOptionPlugin|
|''Description:''|Extends TiddlyWiki options with non encrypted password option.|
|''Version:''|1.0.2|
|''Date:''|Apr 19, 2007|
|''Source:''|http://tiddlywiki.bidix.info/#PasswordOptionPlugin|
|''Author:''|BidiX (BidiX (at) bidix (dot) info)|
|''License:''|[[BSD open source license|http://tiddlywiki.bidix.info/#%5B%5BBSD%20open%20source%20license%5D%5D ]]|
|''~CoreVersion:''|2.2.0 (Beta 5)|
***/
//{{{
version.extensions.PasswordOptionPlugin = {
	major: 1, minor: 0, revision: 2, 
	date: new Date("Apr 19, 2007"),
	source: 'http://tiddlywiki.bidix.info/#PasswordOptionPlugin',
	author: 'BidiX (BidiX (at) bidix (dot) info',
	license: '[[BSD open source license|http://tiddlywiki.bidix.info/#%5B%5BBSD%20open%20source%20license%5D%5D]]',
	coreVersion: '2.2.0 (Beta 5)'
};

config.macros.option.passwordCheckboxLabel = "Save this password on this computer";
config.macros.option.passwordInputType = "password"; // password | text
setStylesheet(".pasOptionInput {width: 11em;}\n","passwordInputTypeStyle");

merge(config.macros.option.types, {
	'pas': {
		elementType: "input",
		valueField: "value",
		eventName: "onkeyup",
		className: "pasOptionInput",
		typeValue: config.macros.option.passwordInputType,
		create: function(place,type,opt,className,desc) {
			// password field
			config.macros.option.genericCreate(place,'pas',opt,className,desc);
			// checkbox linked with this password "save this password on this computer"
			config.macros.option.genericCreate(place,'chk','chk'+opt,className,desc);			
			// text savePasswordCheckboxLabel
			place.appendChild(document.createTextNode(config.macros.option.passwordCheckboxLabel));
		},
		onChange: config.macros.option.genericOnChange
	}
});

merge(config.optionHandlers['chk'], {
	get: function(name) {
		// is there an option linked with this chk ?
		var opt = name.substr(3);
		if (config.options[opt]) 
			saveOptionCookie(opt);
		return config.options[name] ? "true" : "false";
	}
});

merge(config.optionHandlers, {
	'pas': {
 		get: function(name) {
			if (config.options["chk"+name]) {
				return encodeCookie(config.options[name].toString());
			} else {
				return "";
			}
		},
		set: function(name,value) {config.options[name] = decodeCookie(value);}
	}
});

// need to reload options to load passwordOptions
loadOptionsCookie();

/*
if (!config.options['pasPassword'])
	config.options['pasPassword'] = '';

merge(config.optionsDesc,{
		pasPassword: "Test password"
	});
*/
//}}}
[[Perl Scripts]]
[[Perl - How to read a directory in Perl?]]
[[Perl - The split function in Perl]]
[[Perl - The grep function in Perl]]
[[Perl - Removing file from path to get directory only in Perl]]
[[Perl - Get commandline options in Perl]]
[[Perl - Process directory recursively in Perl]]
{{{
#!/usr/bin/perl
use warnings;
use strict;
use Getopt::Std;
 
getopt 'hl', \my %opt;
 
exists $opt{ h } && die <<HELP;
usage: $0 [-h] [-l] [directory]
      -h    this message
      -l    long listing
HELP
 
my $dir    = shift || '.';
my $format = "%-25s %10s %-8s %-8s\n";
 
opendir my $dh, $dir or die "Cannot open '$dir' $!";
 
if ( exists $opt{ l } ) {
     printf $format, 'File Name', 'Size', 'Owner', 'Group'
     }
else {
     print "File Name\n"
     }
 
while ( my $file = readdir $dh ) {
     my ( $uid, $gid, $size ) = ( lstat "$dir/$file" )[ 4, 5, 7 ] or die "Cannot stat '$dir' $!";
     next unless -f _;
     if ( exists $opt{ l } ) {
         printf $format, $file, $size, scalar getpwuid $uid, scalar getgrgid $gid
         }
     else {
         print "$file\n"
         }
     }
}}}
It's very simple to print a list of all files in a directory using the built-in Perl glob function. 
Let's look over a short script that globs and prints a list of all files, in the directory containing the script itself:
{{{
    #!/usr/bin/perl -w

    @files = <*>;
    foreach $file (@files) {
      print $file . "\n";
    } 
}}}
When you run the program, you'll see it output the filenames of all files in the directory, one per line. The glob is happening on the first line, as the <*> characters pulls the filenames into the @files array.
{{{
    @files = <*>; 
}}}
Then we simply use a foreach loop to print out the files in the array.

You can include any path in your filesystem between the <> marks. For example, say your web site is in the /var/www/htdocs/ directory and you want a list of all the files:
{{{
    @files = </var/www/htdocs/*>; 
}}}
Or if you just want a list of the files with the extension .html:
{{{
    @files = </var/www/htdocs/*.html>; 
}}}
{{{
#!/usr/bin/perl -w

use strict;

sub recurse($) {
  my($path) = @_;

  ## append a trailing / if it's not there
  $path .= '/' if($path !~ /\/$/);

  ## print the directory being searched
  print $path,"\n";

  ## loop through the files contained in the directory
  for my $eachFile (glob($path.'*')) {

    ## if the file is a directory
    if( -d $eachFile) {
      ## pass the directory to the routine ( recursion )
      recurse($eachFile);
    } else {

      ## print the file ... tabbed for readability
      print "\t",$eachFile,"\n";
    }
  }
}

## initial call ... $ARGV[0] is the first command line argument
recurse($ARGV[0]);
}}}
{{{
#!/usr/bin/perl

use strict;
use warnings;

use File::Basename;

my $fpath = "/home/user/hello/hey.pl";

print "Original  : " . $fpath . "\n";

my($filename, $directories) = fileparse($fpath);

print "Filename  : " . $filename    . "\n";
print "Directory : " . $directories . "\n";
}}}
{{{
@myNames = ('Jacob', 'Michael', 'Joshua', 'Matthew', 'Alexander', 'Andrew');
    @grepNames = grep(/^A/, @myNames);
    foreach $name (@grepNames) {
	    print "Name: $name\n";
    }
}}}
{{{
$info = "Caine:Michael:Actor:14, Leafy Drive";
@personal = split(/:/, $info);
foreach $person (@personal) {
            print "$person\n";
}
}}}
[[image_processing.pl]]
[[rename_files.pl]]
[[file_conversion.pl]]
[[create_directories.pl]]
[[padding_unpadding_files.pl]]

[[finding_free_machines.pl]]
[[finding_processes.pl]]
[[finding_files.pl]]
[[finding_users.pl]]

[[generating_html.pl]]
[[modify_text_files.pl]]
[[convert_timecode_data.pl]]

[[read_directory.pl]]
[[read_directory2.pl]]
[[read_directory3.pl]]

[[cp_directory_recursive.pl]]

[[change_recursive_dir.pl]]
[[list_directory_file_permissions.pl]]

[[read_from_logfile.pl]]

[[tcpserver.pl]]
Enable x86/32 machines to address up to 64 GB of physical memory.
Do you have sar enabled on your systems? If so, i bet you thought about plotting its reports! The most simple way to do that is to use gnuplot - free and opensource plotting program. It is very easy to build and install gnuplot on solaris 10 (./configure && make && make install) so i skipped this step here. Lets begin:

{{{
# sar -f /var/adm/sa/sa09 > cpu_util.dat
# gnuplot
gnuplot> set terminal png
gnuplot> set out "cpu_util.png"
gnuplot> set title "CPU Utilization"
gnuplot> set xdata time
gnuplot> set timefmt "%H:%M:%S"
gnuplot> set format x "%H:%M"
gnuplot> plot "cpu_util.dat" using 1:2 title "%user" with lines, \
    "cpu_util.dat" using 1:3 title "%sys" with lines
# rm cpu_util.dat
}}}

http://blog.curthread.org/posts/solaris/tips/plot_sar_reports.html
[[Polymorphism - Java]]
[[Polymorphism - Python]]
[[Polymorphism - Perl]]
[[Polymorphism - Ruby]]
{{{
interface Animal 
{
    String getName();
    String talk();
}
 
abstract class AnimalBase implements Animal
{
    private final String name;
 
    protected AnimalBase(String name) {
        this.name = name;
    }
 
    public String getName() {
        return name;
    }
}
 
class Cat extends AnimalBase 
{
    public Cat(String name) {
        super(name);
    }
 
    public String talk() {
        return "Meowww!";
    }
}
 
class Dog extends AnimalBase 
{
    public Dog(String name) {
        super(name);
    }
 
    public String talk() {
        return "Arf! Arf!";
    }
}
 
public class TestAnimals
{
    // prints the following:
    //
    // Missy: Meowww!
    // Mr. Bojangles: Meowww!
    // Lassie: Arf! Arf!
    //
    public static void main(String[] args) {
        Animal[] animals = {
            new Cat("Missy"),
            new Cat("Mr. Bojangles"),
            new Dog("Lassie")
        };
 
        for (Animal a : animals) {
            System.out.println(a.getName() + ": " + a.talk());
        }
    }
}
}}}
{{{
{
    package Animal;
    sub new {
        my ( $class, $name ) = @_;
        bless { name => $name }, $class;
    }
}
 
{
    package Cat;
    use base qw(Animal);
    sub talk  { 'Meow' }
}
 
{
    package Dog;
    use base qw(Animal);
    sub talk  { 'Woof! Woof!' }
}
 
my $a = Cat->new('Missy');
my $b = Cat->new('Mr. Bojangles');
my $c = Dog->new('Lassie');
 
for my $animal ( $a, $b, $c ) {
    say $animal->{name} . ': ' . $animal->talk;
}
 
# prints the following:
#
# Missy: Meow
# Mr. Bojangles: Meow
# Lassie: Woof! Woof!
}}}
{{{
class Animal:
    def __init__(self, name):    # Constructor of the class
        self.name = name
    def talk(self):              # Abstract method, defined by convention only
        raise NotImplementedError("Subclass must implement abstract method")
 
class Cat(Animal):
    def talk(self):
        return 'Meow!'
 
class Dog(Animal):
    def talk(self):
        return 'Woof! Woof!'
 
animals = [Cat('Missy'), 
           Cat('Mr. Bojangles'), 
           Dog('Lassie')]
 
for animal in animals:
    print animal.name + ': ' + animal.talk()
 
# prints the following:
#
# Missy: Meow!
# Mr. Bojangles: Meow!
# Lassie: Woof! Woof!
}}}
{{{
class Thing
  def who_am_I
    puts "I'm a thing!"
  end
end
 
class AnotherThing
  def who_am_I
    puts "I'm another thing!"
  end
end
 
#adds 'who_am_I' method to class String:
class String
  def who_am_I
    puts "I'm a plain Ruby String!"
  end
end
 
things = [Thing.new, AnotherThing.new, 'boring string']
things.each{|current_thing| current_thing.who_am_I}
 
#prints:
#
#I'm a thing!
#I'm another thing!
#I'm a plain Ruby String!
}}}
[[The Python Tutorial]]
[[PLEAC-Python]]
----
[[Python - if statements]]
[[Python - for statements]]
[[Python - The range() Function]]
[[Python - break and continue Statements, and else Clauses on Loops]]
[[Python - pass Statements]]
[[Python - Looping Techniques]]
[[Python - Defining Functions]]
[[Python - Functions - Default Argument Values]]
[[Python - Functions - Keyword Arguments]]
----
[[Python - Directory listing]]
[[Python - Reading and Writing Files]]
[[Python - Methods of File Objects]]
[[Python - File Wildcards]]
[[Python - shutil — High-level file operations]]
----
[[Python - Internet Access]]
[[Python - Dates and Times]]
----
[[Python - String Pattern Matching]]
[[Python - Split text]]
[[Python - Reverse a string]]
[[Python - Checking whether a string contains a set of chars]]
----
[[Python - getopt — Parser for command line options]]
[[Python - Operating System Interface]]
[[Python - get os environment vars]]
----
[[Python - Logging]]
[[Python - syslog]]
[[Python - win32security]]
----
[[Python - socket testing]]
----
[[Python Scripts]]
----
{{{
def containsAny(str, set):
    """Check whether 'str' contains ANY of the chars in 'set'"""
    return 1 in [c in str for c in set]

def containsAll(str, set):
    """Check whether 'str' contains ALL of the chars in 'set'"""
    return 0 not in [c in str for c in set]

if __name__ == "__main__":
    # unit tests, must print "OK!" when run
    assert containsAny('*.py', '*?[]')
    assert not containsAny('file.txt', '*?[]')
    assert containsAll('43221', '123')
    assert not containsAll('134', '123')
    print "OK!"
}}}
The datetime module supplies classes for manipulating dates and times in both simple and complex ways. While date and time arithmetic is supported, the focus of the implementation is on efficient member extraction for output formatting and manipulation. The module also supports objects that are timezone aware.
{{{
# dates are easily constructed and formatted
>>> from datetime import date
>>> now = date.today()
>>> now
datetime.date(2003, 12, 2)
>>> now.strftime("%m-%d-%y. %d %b %Y is a %A on the %d day of %B.")
'12-02-03. 02 Dec 2003 is a Tuesday on the 02 day of December.'

# dates support calendar arithmetic
>>> birthday = date(1964, 7, 31)
>>> age = now - birthday
>>> age.days
14368
}}}
We can create a function that writes the Fibonacci series to an arbitrary boundary:
{{{
>>> def fib(n):    # write Fibonacci series up to n
...     """Print a Fibonacci series up to n."""
...     a, b = 0, 1
...     while b < n:
...         print b,
...         a, b = b, a+b
...
>>> # Now call the function we just defined:
... fib(2000)
1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597
}}}
The keyword def introduces a function definition. It must be followed by the function name and the parenthesized list of formal parameters. The statements that form the body of the function start at the next line, and must be indented.

The first statement of the function body can optionally be a string literal; this string literal is the function’s documentation string, or docstring. (More about docstrings can be found in the section Documentation Strings.) There are tools which use docstrings to automatically produce online or printed documentation, or to let the user interactively browse through code; it’s good practice to include docstrings in code that you write, so make a habit of it.

The execution of a function introduces a new symbol table used for the local variables of the function. More precisely, all variable assignments in a function store the value in the local symbol table; whereas variable references first look in the local symbol table, then in the local symbol tables of enclosing functions, then in the global symbol table, and finally in the table of built-in names. Thus, global variables cannot be directly assigned a value within a function (unless named in a global statement), although they may be referenced.

The actual parameters (arguments) to a function call are introduced in the local symbol table of the called function when it is called; thus, arguments are passed using call by value (where the value is always an object reference, not the value of the object). [1] When a function calls another function, a new local symbol table is created for that call.

A function definition introduces the function name in the current symbol table. The value of the function name has a type that is recognized by the interpreter as a user-defined function. This value can be assigned to another name which can then also be used as a function. This serves as a general renaming mechanism:
{{{
>>> fib
<function fib at 10042ed0>
>>> f = fib
>>> f(100)
1 1 2 3 5 8 13 21 34 55 89
}}}
Coming from other languages, you might object that fib is not a function but a procedure since it doesn’t return a value. In fact, even functions without a return statement do return a value, albeit a rather boring one. This value is called None (it’s a built-in name). Writing the value None is normally suppressed by the interpreter if it would be the only value written. You can see it if you really want to using print:
{{{
>>> fib(0)
>>> print fib(0)
None
}}}
It is simple to write a function that returns a list of the numbers of the Fibonacci series, instead of printing it:
{{{
>>> def fib2(n): # return Fibonacci series up to n
...     """Return a list containing the Fibonacci series up to n."""
...     result = []
...     a, b = 0, 1
...     while b < n:
...         result.append(b)    # see below
...         a, b = b, a+b
...     return result
...
>>> f100 = fib2(100)    # call it
>>> f100                # write the result
[1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
}}}
This example, as usual, demonstrates some new Python features:

    * The return statement returns with a value from a function. return without an expression argument returns None. Falling off the end of a function also returns None.
    * The statement result.append(b) calls a method of the list object result. A method is a function that ‘belongs’ to an object and is named obj.methodname, where obj is some object (this may be an expression), and methodname is the name of a method that is defined by the object’s type. Different types define different methods. Methods of different types may have the same name without causing ambiguity. (It is possible to define your own object types and methods, using classes, as discussed later in this tutorial.) The method append() shown in the example is defined for list objects; it adds a new element at the end of the list. In this example it is equivalent to result = result + [b], but more efficient.
{{{
import os

for dirname, dirnames, filenames in os.walk('.'):
    for subdirname in dirnames:
        print os.path.join(dirname, subdirname)
    for filename in filenames:
        print os.path.join(dirname, filename)
}}}
The glob module provides a function for making file lists from directory wildcard searches:
{{{
>>> import glob
>>> glob.glob('*.py')
['primes.py', 'random.py', 'quote.py']
}}}
The most useful form is to specify a default value for one or more arguments. This creates a function that can be called with fewer arguments than it is defined to allow. For example:
{{{
def ask_ok(prompt, retries=4, complaint='Yes or no, please!'):
    while True:
        ok = raw_input(prompt)
        if ok in ('y', 'ye', 'yes'): return True
        if ok in ('n', 'no', 'nop', 'nope'): return False
        retries = retries - 1
        if retries < 0: raise IOError, 'refusenik user'
        print complaint
}}}
This function can be called either like this: ask_ok('Do you really want to quit?') or like this: ask_ok('OK to overwrite the file?', 2).

This example also introduces the in keyword. This tests whether or not a sequence contains a certain value.

The default values are evaluated at the point of function definition in the defining scope, so that
{{{
i = 5

def f(arg=i):
    print arg

i = 6
f()
}}}
will print 5.

''Important warning:'' The default value is evaluated only once. This makes a difference when the default is a mutable object such as a list, dictionary, or instances of most classes. For example, the following function accumulates the arguments passed to it on subsequent calls:
{{{
def f(a, L=[]):
    L.append(a)
    return L

print f(1)
print f(2)
print f(3)
}}}
This will print
{{{
[1]
[1, 2]
[1, 2, 3]
}}}
If you don’t want the default to be shared between subsequent calls, you can write the function like this instead:
{{{
def f(a, L=None):
    if L is None:
        L = []
    L.append(a)
    return L
}}}
Functions can also be called using keyword arguments of the form keyword = value. For instance, the following function:
{{{
def parrot(voltage, state='a stiff', action='voom', type='Norwegian Blue'):
    print "-- This parrot wouldn't", action,
    print "if you put", voltage, "volts through it."
    print "-- Lovely plumage, the", type
    print "-- It's", state, "!"
}}}
could be called in any of the following ways:
{{{
parrot(1000)
parrot(action = 'VOOOOOM', voltage = 1000000)
parrot('a thousand', state = 'pushing up the daisies')
parrot('a million', 'bereft of life', 'jump')
}}}
but the following calls would all be invalid:
{{{
parrot()                     # required argument missing
parrot(voltage=5.0, 'dead')  # non-keyword argument following keyword
parrot(110, voltage=220)     # duplicate value for argument
parrot(actor='John Cleese')  # unknown keyword
}}}
In general, an argument list must have any positional arguments followed by any keyword arguments, where the keywords must be chosen from the formal parameter names. It’s not important whether a formal parameter has a default value or not. No argument may receive a value more than once — formal parameter names corresponding to positional arguments cannot be used as keywords in the same calls. Here’s an example that fails due to this restriction:
{{{
>>> def function(a):
...     pass
...
>>> function(0, a=0)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: function() got multiple values for keyword argument 'a'
}}}
When a final formal parameter of the form **name is present, it receives a dictionary (see Mapping Types — dict) containing all keyword arguments except for those corresponding to a formal parameter. This may be combined with a formal parameter of the form *name (described in the next subsection) which receives a tuple containing the positional arguments beyond the formal parameter list. (*name must occur before **name.) For example, if we define a function like this:
{{{
def cheeseshop(kind, *arguments, **keywords):
    print "-- Do you have any", kind, "?"
    print "-- I'm sorry, we're all out of", kind
    for arg in arguments: print arg
    print "-" * 40
    keys = keywords.keys()
    keys.sort()
    for kw in keys: print kw, ":", keywords[kw]
}}}
It could be called like this:
{{{
cheeseshop("Limburger", "It's very runny, sir.",
           "It's really very, VERY runny, sir.",
           shopkeeper='Michael Palin',
           client="John Cleese",
           sketch="Cheese Shop Sketch")
}}}
and of course it would print:
{{{
-- Do you have any Limburger ?
-- I'm sorry, we're all out of Limburger
It's very runny, sir.
It's really very, VERY runny, sir.
----------------------------------------
client : John Cleese
shopkeeper : Michael Palin
sketch : Cheese Shop Sketch
}}}
Note that the sort() method of the list of keyword argument names is called before printing the contents of the keywords dictionary; if this is not done, the order in which the arguments are printed is undefined.
There are a number of modules for accessing the internet and processing internet protocols. Two of the simplest are urllib2 for retrieving data from urls and smtplib for sending mail:
{{{
>>> import urllib2
>>> for line in urllib2.urlopen('http://tycho.usno.navy.mil/cgi-bin/timer.pl'):
...     if 'EST' in line or 'EDT' in line:  # look for Eastern Time
...         print line

<BR>Nov. 25, 09:43:32 PM EST

>>> import smtplib
>>> server = smtplib.SMTP('localhost')
>>> server.sendmail('soothsayer@example.org', 'jcaesar@example.org',
... """To: jcaesar@example.org
... From: soothsayer@example.org
...
... Beware the Ides of March.
... """)
>>> server.quit()
}}}
(Note that the second example needs a mailserver running on localhost.)
[[simple_logging.py]]
[[simple_logrotating.py]]
[[simple_loglevels.py]]
When looping through dictionaries, the key and corresponding value can be retrieved at the same time using the iteritems() method.
{{{
>>> knights = {'gallahad': 'the pure', 'robin': 'the brave'}
>>> for k, v in knights.iteritems():
...     print k, v
...
gallahad the pure
robin the brave
}}}
When looping through a sequence, the position index and corresponding value can be retrieved at the same time using the enumerate() function.
{{{
>>> for i, v in enumerate(['tic', 'tac', 'toe']):
...     print i, v
...
0 tic
1 tac
2 toe
}}}
To loop over two or more sequences at the same time, the entries can be paired with the zip() function.
{{{
>>> questions = ['name', 'quest', 'favorite color']
>>> answers = ['lancelot', 'the holy grail', 'blue']
>>> for q, a in zip(questions, answers):
...     print 'What is your {0}?  It is {1}.'.format(q, a)
...
What is your name?  It is lancelot.
What is your quest?  It is the holy grail.
What is your favorite color?  It is blue.
}}}
To loop over a sequence in reverse, first specify the sequence in a forward direction and then call the reversed() function.
{{{
>>> for i in reversed(xrange(1,10,2)):
...     print i
...
9
7
5
3
1
}}}
To loop over a sequence in sorted order, use the sorted() function which returns a new sorted list while leaving the source unaltered.
{{{
>>> basket = ['apple', 'orange', 'apple', 'pear', 'orange', 'banana']
>>> for f in sorted(set(basket)):
...     print f
...
apple
banana
orange
pear
}}}
The rest of the examples in this section will assume that a file object called f has already been created.

To read a file’s contents, call f.read(size), which reads some quantity of data and returns it as a string. size is an optional numeric argument. When size is omitted or negative, the entire contents of the file will be read and returned; it’s your problem if the file is twice as large as your machine’s memory. Otherwise, at most size bytes are read and returned. If the end of the file has been reached, f.read() will return an empty string ("").
{{{
>>> f.read()
'This is the entire file.\n'
>>> f.read()
''
}}}
f.readline() reads a single line from the file; a newline character (\n) is left at the end of the string, and is only omitted on the last line of the file if the file doesn’t end in a newline. This makes the return value unambiguous; if f.readline() returns an empty string, the end of the file has been reached, while a blank line is represented by '\n', a string containing only a single newline.
{{{
>>> f.readline()
'This is the first line of the file.\n'
>>> f.readline()
'Second line of the file\n'
>>> f.readline()
''
}}}
f.readlines() returns a list containing all the lines of data in the file. If given an optional parameter sizehint, it reads that many bytes from the file and enough more to complete a line, and returns the lines from that. This is often used to allow efficient reading of a large file by lines, but without having to load the entire file in memory. Only complete lines will be returned.
{{{
>>> f.readlines()
['This is the first line of the file.\n', 'Second line of the file\n']
}}}
An alternative approach to reading lines is to loop over the file object. This is memory efficient, fast, and leads to simpler code:
{{{
>>> for line in f:
        print line,

This is the first line of the file.
Second line of the file
}}}
The alternative approach is simpler but does not provide as fine-grained control. Since the two approaches manage line buffering differently, they should not be mixed.

f.write(string) writes the contents of string to the file, returning None.
{{{
>>> f.write('This is a test\n')
}}}
To write something other than a string, it needs to be converted to a string first:
{{{
>>> value = ('the answer', 42)
>>> s = str(value)
>>> f.write(s)
}}}
f.tell() returns an integer giving the file object’s current position in the file, measured in bytes from the beginning of the file. To change the file object’s position, use f.seek(offset, from_what). The position is computed from adding offset to a reference point; the reference point is selected by the from_what argument. A from_what value of 0 measures from the beginning of the file, 1 uses the current file position, and 2 uses the end of the file as the reference point. from_what can be omitted and defaults to 0, using the beginning of the file as the reference point.
{{{
>>> f = open('/tmp/workfile', 'r+')
>>> f.write('0123456789abcdef')
>>> f.seek(5)     # Go to the 6th byte in the file
>>> f.read(1)
'5'
>>> f.seek(-3, 2) # Go to the 3rd byte before the end
>>> f.read(1)
'd'
}}}
When you’re done with a file, call f.close() to close it and free up any system resources taken up by the open file. After calling f.close(), attempts to use the file object will automatically fail.
{{{
>>> f.close()
>>> f.read()
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
ValueError: I/O operation on closed file
}}}
It is good practice to use the with keyword when dealing with file objects. This has the advantage that the file is properly closed after its suite finishes, even if an exception is raised on the way. It is also much shorter than writing equivalent try-finally blocks:
{{{
>>> with open('/tmp/workfile', 'r') as f:
...     read_data = f.read()
>>> f.closed
True
}}}
File objects have some additional methods, such as isatty() and truncate() which are less frequently used; consult the Library Reference for a complete guide to file objects.
The os module provides dozens of functions for interacting with the operating system:
{{{
>>> import os
>>> os.system('time 0:02')
0
>>> os.getcwd()      # Return the current working directory
'C:\\Python26'
>>> os.chdir('/server/accesslogs')
}}}
Be sure to use the import os style instead of from os import *. This will keep os.open() from shadowing the builtin open() function which operates much differently.

The builtin dir() and help() functions are useful as interactive aids for working with large modules like os:
{{{
>>> import os
>>> dir(os)
<returns a list of all module functions>
>>> help(os)
<returns an extensive manual page created from the module's docstrings>
}}}
For daily file and directory management tasks, the shutil module provides a higher level interface that is easier to use:
{{{
>>> import shutil
>>> shutil.copyfile('data.db', 'archive.db')
>>> shutil.move('/build/executables', 'installdir')
}}}
{{{open()}}} returns a file object, and is most commonly used with two arguments: open(filename, mode).
{{{
>>> f = open('/tmp/workfile', 'w')
>>> print f
<open file '/tmp/workfile', mode 'w' at 80a0960>
}}}
The first argument is a string containing the filename. The second argument is another string containing a few characters describing the way in which the file will be used. mode can be 'r' when the file will only be read, 'w' for only writing (an existing file with the same name will be erased), and 'a' opens the file for appending; any data written to the file is automatically added to the end. 'r+' opens the file for both reading and writing. The mode argument is optional; 'r' will be assumed if it’s omitted.

On Windows, 'b' appended to the mode opens the file in binary mode, so there are also modes like 'rb', 'wb', and 'r+b'. Windows makes a distinction between text and binary files; the end-of-line characters in text files are automatically altered slightly when data is read or written. This behind-the-scenes modification to file data is fine for ASCII text files, but it’ll corrupt binary data like that in JPEG or EXE files. Be very careful to use binary mode when reading and writing such files. On Unix, it doesn’t hurt to append a 'b' to the mode, so you can use it platform-independently for all binary files.
{{{
def reverseString(s):
      """Reverses a string given to it."""
      return s[::-1]
}}}
{{{
fh = open('filename', 'r')
for line in fh.readlines():
   # use 'xreadlines()' if the file is large and you just want an iterator
   words = line.split(' ')
   # returns an array of every item between the spaces
   # do something else...
fh.close()
}}}
The re module provides regular expression tools for advanced string processing. For complex matching and manipulation, regular expressions offer succinct, optimized solutions:
{{{
>>> import re
>>> re.findall(r'\bf[a-z]*', 'which foot or hand fell fastest')
['foot', 'fell', 'fastest']
>>> re.sub(r'(\b[a-z]+) \1', r'\1', 'cat in the the hat')
'cat in the hat'
}}}
When only simple capabilities are needed, string methods are preferred because they are easier to read and debug:
{{{
>>> 'tea for too'.replace('too', 'two')
'tea for two'
}}}
If you do need to iterate over a sequence of numbers, the built-in function range() comes in handy. It generates lists containing arithmetic progressions:
{{{
>>> range(10)
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
}}}
The given end point is never part of the generated list; range(10) generates a list of 10 values, the legal indices for items of a sequence of length 10. It is possible to let the range start at another number, or to specify a different increment (even negative; sometimes this is called the ‘step’):
{{{
>>> range(5, 10)
[5, 6, 7, 8, 9]
>>> range(0, 10, 3)
[0, 3, 6, 9]
>>> range(-10, -100, -30)
[-10, -40, -70]
}}}
To iterate over the indices of a sequence, you can combine range() and len() as follows:
{{{
>>> a = ['Mary', 'had', 'a', 'little', 'lamb']
>>> for i in range(len(a)):
...     print i, a[i]
...
0 Mary
1 had
2 a
3 little
4 lamb
}}}
In most such cases, however, it is convenient to use the enumerate() function, see Looping Techniques.
The break statement, like in C, breaks out of the smallest enclosing for or while loop.

The continue statement, also borrowed from C, continues with the next iteration of the loop.

Loop statements may have an else clause; it is executed when the loop terminates through exhaustion of the list (with for) or when the condition becomes false (with while), but not when the loop is terminated by a break statement. This is exemplified by the following loop, which searches for prime numbers:
{{{
>>> for n in range(2, 10):
...     for x in range(2, n):
...         if n % x == 0:
...             print n, 'equals', x, '*', n/x
...             break
...     else:
...         # loop fell through without finding a factor
...         print n, 'is a prime number'
...
2 is a prime number
3 is a prime number
4 equals 2 * 2
5 is a prime number
6 equals 2 * 3
7 is a prime number
8 equals 2 * 4
9 equals 3 * 3
}}}
The for statement in Python differs a bit from what you may be used to in C or Pascal. Rather than always iterating over an arithmetic progression of numbers (like in Pascal), or giving the user the ability to define both the iteration step and halting condition (as C), Python’s for statement iterates over the items of any sequence (a list or a string), in the order that they appear in the sequence. For example (no pun intended):
{{{
>>> # Measure some strings:
... a = ['cat', 'window', 'defenestrate']
>>> for x in a:
...     print x, len(x)
...
cat 3
window 6
defenestrate 12
}}}
It is not safe to modify the sequence being iterated over in the loop (this can only happen for mutable sequence types, such as lists). If you need to modify the list you are iterating over (for example, to duplicate selected items) you must iterate over a copy. The slice notation makes this particularly convenient:
{{{
>>> for x in a[:]: # make a slice copy of the entire list
...    if len(x) > 6: a.insert(0, x)
...
>>> a
['defenestrate', 'cat', 'window', 'defenestrate']
}}}
{{{
#!/usr/bin/python

import os

for param in os.environ.keys():
    print "%20s %s" % (param,os.environ[param])

print "Vars 2 use here:"
print os.environ["DB__SERVER"]
print os.environ["MAIL__TO"]
}}}
An example using only Unix style options:
{{{
>>> import getopt
>>> args = '-a -b -cfoo -d bar a1 a2'.split()
>>> args
['-a', '-b', '-cfoo', '-d', 'bar', 'a1', 'a2']
>>> optlist, args = getopt.getopt(args, 'abc:d:')
>>> optlist
[('-a', ''), ('-b', ''), ('-c', 'foo'), ('-d', 'bar')]
>>> args
['a1', 'a2']
}}}
Using long option names is equally easy:
{{{
>>> s = '--condition=foo --testing --output-file abc.def -x a1 a2'
>>> args = s.split()
>>> args
['--condition=foo', '--testing', '--output-file', 'abc.def', '-x', 'a1', 'a2']
>>> optlist, args = getopt.getopt(args, 'x', [
...     'condition=', 'output-file=', 'testing'])
>>> optlist
[('--condition', 'foo'), ('--testing', ''), ('--output-file', 'abc.def'), ('-x', '')]
>>> args
['a1', 'a2']
}}}
In a script, typical usage is something like this:
{{{
import getopt, sys

def main():
    try:
        opts, args = getopt.getopt(sys.argv[1:], "ho:v", ["help", "output="])
    except getopt.GetoptError, err:
        # print help information and exit:
        print str(err) # will print something like "option -a not recognized"
        usage()
        sys.exit(2)
    output = None
    verbose = False
    for o, a in opts:
        if o == "-v":
            verbose = True
        elif o in ("-h", "--help"):
            usage()
            sys.exit()
        elif o in ("-o", "--output"):
            output = a
        else:
            assert False, "unhandled option"
    # ...

if __name__ == "__main__":
    main()
}}}
''Perhaps the most well-known statement type is the if statement. For example:''
{{{
>>> x = int(raw_input("Please enter an integer: "))
Please enter an integer: 42
>>> if x < 0:
...      x = 0
...      print 'Negative changed to zero'
... elif x == 0:
...      print 'Zero'
... elif x == 1:
...      print 'Single'
... else:
...      print 'More'
...
}}}
More

There can be zero or more elif parts, and the else part is optional. The keyword ‘elif‘ is short for ‘else if’, and is useful to avoid excessive indentation. An if ... elif ... elif ... sequence is a substitute for the switch or case statements found in other languages.
The pass statement does nothing. It can be used when a statement is required syntactically but the program requires no action. For example:
{{{
>>> while True:
...     pass  # Busy-wait for keyboard interrupt (Ctrl+C)
...
}}}
This is commonly used for creating minimal classes:
{{{
>>> class MyEmptyClass:
...     pass
...
}}}
Another place pass can be used is as a place-holder for a function or conditional body when you are working on new code, allowing you to keep thinking at a more abstract level. The pass is silently ignored:
{{{
>>> def initlog(*args):
...     pass   # Remember to implement this!
...
}}}
{{{
import os

# Note - see also spawn methods
# Note - see improved / extra facilities in Python 2.4

dothis = "ping -c 5 192.168.200.66"
phand = os.popen(dothis)
while 1:
   line = phand.readline()
   if line == "": break
   print line,
}}}
This example is the implementation of the copytree() function, described above, with the docstring omitted. It demonstrates many of the other functions provided by this module.
{{{
def copytree(src, dst, symlinks=False, ignore=None):
    names = os.listdir(src)
    if ignore is not None:
        ignored_names = ignore(src, names)
    else:
        ignored_names = set()

    os.makedirs(dst)
    errors = []
    for name in names:
        if name in ignored_names:
            continue
        srcname = os.path.join(src, name)
        dstname = os.path.join(dst, name)
        try:
            if symlinks and os.path.islink(srcname):
                linkto = os.readlink(srcname)
                os.symlink(linkto, dstname)
            elif os.path.isdir(srcname):
                copytree(srcname, dstname, symlinks, ignore)
            else:
                copy2(srcname, dstname)
            # XXX What about devices, sockets etc.?
        except (IOError, os.error), why:
            errors.append((srcname, dstname, str(why)))
        # catch the Error from the recursive copytree so that we can
        # continue with other files
        except Error, err:
            errors.extend(err.args[0])
    try:
        copystat(src, dst)
    except WindowsError:
        # can't copy file access times on Windows
        pass
    except OSError, why:
        errors.extend((src, dst, str(why)))
    if errors:
        raise Error, errors
}}}
Another example that uses the ignore_patterns() helper:
{{{
from shutil import copytree, ignore_patterns

copytree(source, destination, ignore=ignore_patterns('*.pyc', 'tmp*'))
}}}
This will copy everything except .pyc files and files or directories whose name starts with tmp.

Another example that uses the ignore argument to add a logging call:
{{{
from shutil import copytree
import logging

def _logpath(path, names):
    logging.info('Working in %s' % path)
    return []   # nothing will be ignored

copytree(source, destination, ignore=_logpath)
}}}
[[tcpserver.py]]
[[socket_server.py]]
[[socket_client.py]]
[[Python - syslog - syslog.py]]
*send_syslog_message.py
{{{
from syslog import syslog
syslog('There were zwei peanuts walking down der strasse...', host='brit.ain')
}}}

*syslog.py
{{{
#!/usr/bin/python
# -*- encoding: iso-8859-1 -*-

"""
Python syslog client.

This code is placed in the public domain by the author.
Written by Christian Stigen Larsen.

This is especially neat for Windows users, who (I think) don't
get any syslog module in the default python installation.

See RFC3164 for more info -- http://tools.ietf.org/html/rfc3164

Note that if you intend to send messages to remote servers, their
syslogd must be started with -r to allow to receive UDP from
the network.
"""

import socket

# I'm a python novice, so I don't know of better ways to define enums

FACILITY = {
	'kern': 0, 'user': 1, 'mail': 2, 'daemon': 3,
	'auth': 4, 'syslog': 5, 'lpr': 6, 'news': 7,
	'uucp': 8, 'cron': 9, 'authpriv': 10, 'ftp': 11,
	'local0': 16, 'local1': 17, 'local2': 18, 'local3': 19,
	'local4': 20, 'local5': 21, 'local6': 22, 'local7': 23,
}

LEVEL = {
	'emerg': 0, 'alert':1, 'crit': 2, 'err': 3,
	'warning': 4, 'notice': 5, 'info': 6, 'debug': 7
}

def syslog(message, level=LEVEL['notice'], facility=FACILITY['daemon'],
	host='localhost', port=514):

	"""
	Send syslog UDP packet to given host and port.
	"""

	sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
	data = '<%d>%s' % (level + facility*8, message)
	sock.sendto(data, (host, port))
	sock.close()
}}}
http://timgolden.me.uk/python-on-windows/programming-areas/security/ownership.html
[[Python - win32security - get ownership]]
[[Python - win32security - take ownership]]
[[Python - win32security - list permissions]]
{{{
import tempfile
import win32api
import win32con
import win32security

f = tempfile.NamedTemporaryFile ()
FILENAME = f.name
try:
  sd = win32security.GetFileSecurity (FILENAME, win32security.OWNER_SECURITY_INFORMATION)
  owner_sid = sd.GetSecurityDescriptorOwner ()
  name, domain, type = win32security.LookupAccountSid (None, owner_sid)

  print "I am", win32api.GetUserNameEx (win32con.NameSamCompatible)
  print "File owned by %s\\%s" % (domain, name)
finally:
  f.close ()
}}}
{{{
import os, sys
import win32security
import tempfile

ftemp = tempfile.NamedTemporaryFile ()
filename = ftemp.name

dacl = win32security.GetNamedSecurityInfo (
  ftemp.name,
  win32security.SE_FILE_OBJECT,
  win32security.DACL_SECURITY_INFORMATION
).GetSecurityDescriptorDacl ()

CONVENTIONAL_ACES = {
  win32security.ACCESS_ALLOWED_ACE_TYPE : "ALLOW", 
  win32security.ACCESS_DENIED_ACE_TYPE : "DENY"
}

for n_ace in range (dacl.GetAceCount ()):
  ace = dacl.GetAce (n_ace)
  (ace_type, ace_flags) = ace[0]
  if ace_type in CONVENTIONAL_ACES:
    mask, sid = ace[1:]
  else:
    mask, object_type, inherited_object_type, sid = ace[1:]
  name, domain, type = win32security.LookupAccountSid (None, sid)
  print "%s %s\\%s %x" % (
    CONVENTIONAL_ACES.get (ace_type, "OTHER"),
    domain, name,
    mask
  )
}}}
{{{
import os, sys
import tempfile
import win32security
import wmi

def owned_by (filename):
  sd = win32security.GetNamedSecurityInfo (
    filename,
    win32security.SE_FILE_OBJECT,
    win32security.OWNER_SECURITY_INFORMATION
  )
  return win32security.LookupAccountSid (None, sd.GetSecurityDescriptorOwner ())

UNPRIVILEGED_USER = "user"
UNPRIVILEGED_PASSWORD = "Passw0rd"
hLogon = win32security.LogonUser (
  UNPRIVILEGED_USER,
  None,
  UNPRIVILEGED_PASSWORD,
  win32security.LOGON32_LOGON_NETWORK,
  win32security.LOGON32_PROVIDER_DEFAULT
)
win32security.ImpersonateLoggedOnUser (hLogon)
try:
  FILENAME = tempfile.mktemp ()
  open (FILENAME, "w").close ()
finally:
  win32security.RevertToSelf ()

print owned_by (FILENAME)

Administrators, domain, type = win32security.LookupAccountName (None, "Administrators")
win32security.SetNamedSecurityInfo (
  FILENAME,
  win32security.SE_FILE_OBJECT,
  win32security.OWNER_SECURITY_INFORMATION,
  Administrators,
  None, 
  None, 
  None
)

print owned_by (FILENAME)

c = wmi.WMI ()
for file in c.CIM_DataFile (Name=FILENAME):
  file.TakeOwnerShip ()

print owned_by (FILENAME)
}}}
[[Sending mail from python]]
[[mail_this.py - send_these_logs.txt]]
----
[[simple_logging.py]]
[[simple_logrotating.py]]
[[simple_loglevels.py]]
----
[[ftplib-example-1.py]]
[[ftplib-example-2.py]]
[[ftplib-example-3.py]]
----
[[datetime-example-3.py]]
[[Python - run an os command in linux]]
----
[[md5sum.py]]
http://effbot.org/librarybook/md5.htm
[[md5-example-1.py]]
[[md5-example-2.py]]
[[md5-example-3.py]]
[[md5-example-4.py]]
http://effbot.org/librarybook/crypt.htm
[[crypt-example-1.py]]
[[crypt-example-2.py]]
----
[[tcpserver.py]]
[[socket_server.py]]
[[socket_client.py]]
----
http://www.db.ripe.net/whois
*http://www.unirecovery.co.uk/RAID-IBM.php
{{{
Recovering from multiple Defunct Dead Disks (DDDs) in a ServeRAID environment

Note: If multiple DDD drives are experienced in a cluster or fault tolerant environment, troubleshooting should start with the cluster or fault tolerant set-up before continuing below. This is particularly indicated if all drives in an external enclosure are DDD.

The ServeRAID controller is designed to tolerate a single Defunct Dead Disk (DDD) failure when configured with redundant RAID levels. There is no guarantee that any multiple disk failure can be recovered with the data intact. The following instructions provide the highest possibility of a successful recovery.

For multiple DDD drives in a RAID 1 and RAID 5 array, data is lost. Data recovery may be attempted by bringing all but the first drive that was marked DDD back to the online state.

Initiate a rebuild for the first drive that was marked DDD. This first drive that was marked DDD has inconsistent data and must be rebuilt.
Once data recovery has been attempted, a cause for the DDD drives, such as a bad cable, backplane, etc., must be identified.
If no cause can be found, physically replace the DDD drives one at a time so that data can be rebuilt each time.
Physically replace all single DDD drives.
Resource requirements

IBM ServeRAID Support CD
ServeRAID command line diskette (available on the IBM ServeRAID Support CD or can be downloaded)
ServeRAID-3x or ServeRAID-4x controller(s)
These procedures depend on certain logging functions enabled in the BIOS/Firmware of the ServeRAID controller which was first implemented in version 4.0 of the IBM ServeRAID Support CD. The ServeRAID controller must have previously been flashed using any 4.x version of the IBM ServeRAID Support CD or diskette(s) prior to the failure.
Click here for capturing configuration and event logs using DUMPLOG and click here for clearing event logs using CLEARLOG.BAT appropriate for your operating system.
Notes:

(1) The IBM ServeRAID Support CD software is backward compatible. If you are prompted to upgrade BIOS/firmware, select cancel. Upgrading BIOS/firmware levels when your system has multiple DDD in a ServeRAID environment is not recommended unless otherwise directed by IBM support.
(2) Diskette images of the ServeRAID downloadable diskettescan be found on the IBM ServeRAID Support CD in the IMAGES directory. You can build a diskette of the ServeRAID Command Line utilities from this image. For more information see the README.TXT file in the IMAGES directory on the IBM ServeRAID Support CD.

Recovery steps ServeRAID systems with multiple disk failures

Capture the ServeRAID logs using DUMPLOG.BAT. There are two methods of capturing these logs, depending on the situation. These logs should be sent to your IBM Support Center as necessary for root cause analysis. This is the best evidence to determine what caused the failure.

Capturing ServeRAID logs method 1 Use Method 1 if the operating system logical drive is off-line. Copy the DUMPLOG.BAT and CLEARLOG.BAT files to the root of the ServeRAID Command Line diskette or the A:\ directory. Boot to the ServeRAID Command line diskette and run the DUMPLOG command using the following syntax:

DUMPLOG <FILENAME.TXT> <Controller#>
Capturing ServeRAID logs method 2 Use Method 2 when a data logical drive is off-line and the operating system is online. Copy or extract the DUMPLOG utility appropriate for your operating system to a local directory or folder.

Use ServeRAID Manager to determine the first DDD under the following two conditions:
Operating system is accessible
Open ServeRAID Manager and notice the DDDs
In ServeRAID Manager highlight the system hostname with DDDs
Right click the system hostname then and choose Save printable configuration and event logs. These logs are saved into the installation directory of ServeRAID Manager, usually "Program Files\RAIDMAN." The log files are saved as RAIDx.LOG where x is the controller number.
Open the correct RAIDx.LOG text file usingin any standard text editor for the controller with DDDs. Go to the last page of the RAIDx.LOG file and you will see a list called ServeRAID defunct drive event log for controller x. This portion of the log will list by date and time stamp all the DDDs by the order in which they went off-line with the most recent failure shown at the bottom of the list. Determine which hard disk drive failed first. The first DDD will be at the at the top of list.

Important: Since the "ServeRAID defunct drive event log" is not cleared, there may be entries from earlier incidents of defunct drives that does not pertain to the problem currently being worked. Review the list of DDDs from the bottom to the top of the list and identify the point where the first drive associated with this incident is logged. The date and time stamps are usually the strongest indicators of where this point is.

There is no guarantee that the "ServeRAID defunct drive event log" will list the drives in the exact order the disks failed under certain circumstances. One example is when an array is setup across multiple ServeRAID channels. In this configuration, the ServeRAID controller issues parallel I/O's to disk devices on each channel. In the event of a catastrophic failure, disks could also be marked defunct in parallel. This could impede the reliability of the date and time stamps as the ServeRAID controller writes events from multiple channels operating in parallel to a single log.

Detach or remove the DDD from the backplane or cable (after the system is powered off). This hard disk drive will need to be replaced.
Exit ServeRAID Manger and power off the system
Operating is not accessible
Reboot your system with the IBM ServeRAID Support CD-ROm in the CD-ROM drive
Highlight Local in ServeRAID Manager, right click and select Save printable configuration and event logs. You will be prompted for a blank diskette to be inserted into Drive A:.
Insert a diskette and ServeRAID Manager will save a RAIDx.LOG file to the diskette. The log files are saved as RAIDx.LOG where x is the controller number.
Take the diskette from Drive A: to another working system and open the RAIDx.LOG text file using any standard text editor. Go to the last page of the RAIDx.LOG file and you will see a list called ServeRAID defunct drive event log for controller x. This portion of the log will list by date and time stamp all the DDDs by the order in which they went off-line with the most recent failure shown at the bottom of the list. Determine which hard disk drive failed first. The first DDD will be at the at the top of list.

Important: Since the "ServeRAID defunct drive event log" is not cleared, there may be entries from earlier incidents of defunct drives that doesn't pertain to the problem currently being worked. Review the list of DDDs from the bottom to the top of the list and identify the point where the first drive associated with this incident is logged. The date and time stamps are usually the strongest indicators of where this point is.

There is no guarantee that the "ServeRAID defunct drive event log" will list the drives in the exact order the disks failed under certain circumstances. One example is when an array is setup across multiple ServeRAID channels. In this configuration, the ServeRAID controller issues parallel I/O's to disk devices on each channel. In the event of a catastrophic failure, disks could also be marked defunct in parallel. This could impede the reliability of the date and time stamps as the ServeRAID controller writes events from multiple channels operating in parallel to a single log.

Detach or remove the first DDD from the backplane (or cable after the system is powered off). This hard disk drive will need to be replaced.
Exit ServeRAID Manger and power off the system

While the system is powered off, reseat the PCI ServeRAID controller(s). Reseat the SCSI cable(s) and the disks against the backplanes. Reseat the power cables to the backplane and SCSI backplane repeater options if they are present. As you are reseating the components, visually inspect each piece for bent pins, nicks, crimps, pinches or other signs of damage. Take extra time to ensure that each component snaps or clicks into place properly.
Reboot the system with the IBM ServeRAID Support CD-ROM in the CD-ROM drive
Using ServeRAID Manager, undefine all hot spare (HSP) drives to avoid an accidental rebuild from starting
Using ServeRAID Manager, set each DDD in the failed array to an "Online" state, (except the first drive marked DDD) as listed in the "ServeRAID defunct drive event log." The failed logical drives should change to a critical state. If there are problems bringing drives online, or if a drive initially goes online then fails to a Defunct state soon after, see the Hardware Troubleshooting sections below before proceeding. The logical drives must be in a critical state before proceeding.
Access the critical logical drive(s)
If you are still in ServeRAID Manager, exit and restart the system
If the operating system logical drive is now critical, attempt to boot into the installed operating system. (If you are prompted to perform any CHKDSK activities or file system integrity tests, choose to skip these tests)
If the data is on the critical logical drive, boot into the operating system and attempt to access the data. (If you are prompted to perform any CHKDSK activities or file system integrity tests, choose to skip these tests)
If the system boots into the operating system, run the appropriate command to do a READ-ONLY file system integrity check on each critical logical drive. If the file system checker determines the file system does not have any data corruption, the data should be good.

For Windows NT or Windows 2000 systems, open a command prompt, type CHKDSK (read only mode) with no parameters for each critical logical drive. If CHKDSK does not report data corruption, the data should be intact.

Locate the IPSSEND.EXE executable on the IBM ServeRAID Support CD or the command line diskette. Run IPSSEND GETBST to determine if the bad stripe table has incremented on any logical drive. If the Bad Stripe Table has incremented to one or more, the array should be removed and recreated.

You can attempt to backup the data, however you may encounter "file corrupted" messages for any files that had data on the stripe that was lost. This data is unfortunately lost forever from the current logical drive.

Plan to restore or rebuild the missing data on each critical logical drive if any of the following problems persists:
The critical logical drive remains inaccessible
Data corruption is found on the critical logical drives
The system continuously fails to boot properly to the operating system
Partition information on the critical logical drives is unknown

If the data is good, initiate a backup of the data.
After the backup completes, replace the remaining physical DDD. An auto-rebuild should initialize when the DDD is replaced.
Redefine hot spares as necessary.
Capture another set of ServeRAID logs using DUMPLOG.
Clear the ServeRAID logs using the following CLEARLOG.BAT command

CLEARLOG <Controller#>

Click here for clearing event logs using CLEARLOG.BAT appropriate for your operating system.

If a case was opened with your IBM Support Center for this problem, complete steps 14 and 15, otherwise you have completed the recovery process.
Plan to capture the ServeRAID logs again using DUMPLOG within 2-3 business days of normal activity (after the ServeRAID logs were cleared in step #12) to confirm the ServeRAID subsystem is fixed. These logs should be emailed to your IBM support center to ensure the ServeRAID controller and SCSI bus activities are operating within normal parameters. Click here for capturing configuration and event logs using DUMPLOG
If additional issues are observed, an action plan will be provided with corrective actions and steps 12 and 13 should be repeated until the system is running optimally.
Hardware Troubleshooting
If you continue to experience problems, DDDs again or a hard disk disk that will not change to an online state, review the following guidelines to assist in identifying the configuration or hardware problem.

The most common cause of multiple disk failures is poor signal quality across the SCSI Bus. Poor signal quality will result in SCSI protocol overhead as it tries to recover from these problems. As the system becomes busier and demand for data increases, the corrective actions of the SCSI protocol increase and the SCSI bus becomes closer to saturation. This overhead will eventually limit the normal device communications bandwidths and if left unchecked, one or more SCSI devices may not be able to respond to the ServeRAID controller in a timely manner resulting in the ServeRAID controller marking the hard disk drive DDDt. These types of signal problems can be caused by improper installation of the ServeRAID controller in a PCI slot, poor cable connections, poor seating of hot swap drives against the SCSI backplane, improper installation or seating of backplane repeaters, and improper SCSI bus termination.

There are many possible reasons for multiple disk failures, however you should be able to isolate most hardware problems using the following isolation techniques:

Check error codes within the ServeRAID Manager when a device fails to respond to a command. Research these codes in the publicly available Hardware Maintenance Manuals.
In non-hot swap systems, make sure the disk devices are attached to the cable starting from the connector closest to the SCSI terminator and work your way forward to the connectors closest to the controller. Also examine each SCSI devices for the proper jumper settings.
While the server is powered off, reseat the ServeRAID controller in its PCI slot and all cables and disk devices on the SCSI bus.
Examine the cable(s) for bent or missing pins, nicks, crimps, pinches or over stretching.
Temporarily attach the disks to an integrated Adaptec controller (or PCI version as available) and boot into the Adaptec BIOS using CTRL-A. As the Adaptec BIOS POSTs, you should see all the expected devices and the negotiated data rates. You can review this information and determine if this is what you should expect to see.
Once you proceed into the BIOS, choose the SCSI Scan option which will list all the devices attached to the controller. Highlight and select one of the disks and initiate a "Media Test" (this is NOT destructive to data). This will test the device and the entire SCSI bus. If you see errors on the Adaptec controller, try to determine if it is the device or the cable by initiating a Media Test on other disks. Test both Online and Defunct disks, to determine if the test results are consistent with the drive states on the ServeRAID controller. You can also move Hot Swap disks to a different position on the backplane and re-test to see if the results change.

If the problem persists, swap out the SCSI cable and retry the Media Tests on the same disks. If the disks test okay, the previous cable is bad. This is a valuable tool to use as you isolate for a failing component in the SCSI path.

Important: The Adaptec controller can produce varying results from the ServeRAID controller because of the way the Adaptec controllers negotiates data rates with LVD/SE SCSI devices. If an Adaptec controller detects errors operating at LVD speeds, it can downgrade the data rates to single-ended speeds and continue to operate with no reported errors. The ServeRAID controller will not necessarily change data rates under the same conditions.

Use the System Diagnostics in F2 Setup to test the ServeRAID subsystem. If the test fails, disconnect the drives from the ServeRAID controller and reset the controller to factory default settings. Retry the Diagnostic tests. If Diagnostics pass then attach the disks to the ServeRAID controller, one channel at a time and retry the tests to isolate the channel of the failing component. If the controller continues to fails diagnostic tests (when using the latest available diagnostics for the server), call your IBM support center for further assistance.

Disconnect or detach the first drive in the array to be marked defunct from the cable or backplane. Restore default settings to the ServeRAID controller. Attempt to import the RAID configuration from the disk drives. Depending on how the failure occurred, this technique may have mixed results. There is a reasonable chance that all the drives will return to an online state, except the first disk which is disconnected.

Move the ServeRAID controller into a different PCI slot or PCI bus and re-test.

When attaching an LVD ServeRAID controller to legacy storage enclosures, set the data rate for the channel to the appropriate data rate supported by the enclosure.

Mixing LVD SCSI devices with Single Ended SCSI devices on the same SCSI bus will result in switching all devices on the channel to Single Ended mode and data rates.

Open a case with your IBM Support Center and submit all the sets of ServeRAID logs captured on the system for interpretation to isolate a failing component.
}}}
db2licm -l
db2licm -a db2ese_c.lic
''How to re-scan the SCSI bus on Linux''
Note to self/Google, here's how to re-scan the SCSI bus on Linux:
{{{
    echo "- - -" > /sys/class/scsi_host/host0/scan
}}}
or script
{{{
#!/bin/bash
# Skript to rescan SCSI bus, using the 
# scsi add-single-device mechanism
# (w) 1998-03-19 Kurt Garloff <kurt@garloff.de> (c) GNU GPL
# (w) 2003-07-16 Kurt Garloff <garloff@suse.de> (c) GNU GPL
# $Id: rescan-scsi-bus.sh,v 1.18 2005/10/08 23:49:29 garloff Exp $

setcolor ()
{
  red="\e[0;31m"
  green="\e[0;32m"
  yellow="\e[0;33m"
  bold="\e[0;1m"
  norm="\e[0;0m"
}

unsetcolor () 
{
  red=""; green=""
  yellow=""; norm=""
}

# Return hosts. sysfs must be mounted
findhosts_26 ()
{
  hosts=
  if ! ls /sys/class/scsi_host/host* >/dev/null 2>&1; then
    echo "No SCSI host adapters found in sysfs"
    exit 1;
    #hosts=" 0"
    #return
  fi 
  for hostdir in /sys/class/scsi_host/host*; do
    hostno=${hostdir#/sys/class/scsi_host/host}
    hostname=`cat $hostdir/proc_name`
    hosts="$hosts $hostno"
    echo "Host adapter $hostno ($hostname) found."
  done  
}

# Return hosts. /proc/scsi/HOSTADAPTER/? must exist
findhosts ()
{
  hosts=
  for driverdir in /proc/scsi/*; do
    driver=${driverdir#/proc/scsi/}
    if test $driver = scsi -o $driver = sg -o $driver = dummy -o $driver = device_info; then continue; fi
    for hostdir in $driverdir/*; do
      name=${hostdir#/proc/scsi/*/}
      if test $name = add_map -o $name = map -o $name = mod_parm; then continue; fi
      num=$name
      driverinfo=$driver
      if test -r $hostdir/status; then
	num=$(printf '%d\n' `sed -n 's/SCSI host number://p' $hostdir/status`)
	driverinfo="$driver:$name"
      fi
      hosts="$hosts $num"
      echo "Host adapter $num ($driverinfo) found."
    done
  done
}

# Get /proc/scsi/scsi info for device $host:$channel:$id:$lun
# Optional parameter: Number of lines (default = 3), result in
# SCSISTR, return code 1 means empty.
procscsiscsi ()
{  
  if test -z "$1"; then LN=2; else LN=$1; fi
  CHANNEL=`printf "%02i" $channel`
  ID=`printf "%02i" $id`
  LUN=`printf "%02i" $lun`
  grepstr="scsi$host Channel: $CHANNEL Id: $ID Lun: $LUN"
  SCSISTR=`cat /proc/scsi/scsi | grep -A$LN -e"$grepstr"`
  if test -z "$SCSISTR"; then return 1; else return 0; fi
}

# Find sg device with 2.6 sysfs support
sgdevice26 ()
{
  SGDEV=`readlink /sys/class/scsi_device/$host\:$channel\:$id\:$lun/device/generic`
  SGDEV=`basename $SGDEV`
}

# Find sg device with 2.4 report-devs extensions
sgdevice24 ()
{
  if procscsiscsi 3; then
    SGDEV=`echo "$SCSISTR" | grep 'Attached drivers:' | sed 's/^ *Attached drivers: \(sg[0-9]*\).*/\1/'`
  fi
}

# Find sg device that belongs to SCSI device $host $channel $id $lun
sgdevice ()
{
  SGDEV=
  if test -d /sys/class/scsi_device; then
    sgdevice26
  else  
    DRV=`grep 'Attached drivers:' /proc/scsi/scsi 2>/dev/null`
    repdevstat=$((1-$?))
    if [ $repdevstat = 0 ]; then
      echo "scsi report-devs 1" >/proc/scsi/scsi
      DRV=`grep 'Attached drivers:' /proc/scsi/scsi 2>/dev/null`
      if [ $? = 1 ]; then return; fi
    fi
    if ! `echo $DRV | grep 'drivers: sg' >/dev/null`; then
      modprobe sg
    fi
    sgdevice24
    if [ $repdevstat = 0 ]; then
      echo "scsi report-devs 0" >/proc/scsi/scsi
    fi
  fi
}       

# Test if SCSI device is still responding to commands
testonline ()
{
  if test ! -x /usr/bin/sg_turs; then return 0; fi
  sgdevice
  if test -z "$SGDEV"; then return 0; fi
  sg_turs /dev/$SGDEV >/dev/null 2>&1
  RC=$?
  #echo -e "\e[A\e[A\e[A${yellow}Test existence of $SGDEV = $RC ${norm} \n\n\n"
  if test $RC = 1; then return $RC; fi
  # OK, device online, compare INQUIRY string
  INQ=`sg_inq -36 /dev/$SGDEV`
  IVEND=`echo "$INQ" | grep 'Vendor identification:' | sed 's/^[^:]*: \(.*\)$/\1/'`
  IPROD=`echo "$INQ" | grep 'Product identification:' | sed 's/^[^:]*: \(.*\)$/\1/'`
  IPREV=`echo "$INQ" | grep 'Product revision level:' | sed 's/^[^:]*: \(.*\)$/\1/'`
  STR=`printf "  Vendor: %-08s Model: %-16s Rev: %-4s" "$IVEND" "$IPROD" "$IPREV"`
  procscsiscsi
  SCSISTR=`echo "$SCSISTR" | grep 'Vendor:'`
  if [ "$SCSISTR" != "$STR" ]; then
    echo -e "\e[A\e[A\e[A\e[A${red}$SGDEV changed: ${bold}\nfrom:${SCSISTR#* } \nto: $STR ${norm}\n\n\n"
    return 1
  fi
  return $RC
}

# Test if SCSI device $host $channen $id $lun exists
# Outputs description from /proc/scsi/scsi, returns SCSISTR 
testexist ()
{
  SCSISTR=
  if procscsiscsi; then
    echo "$SCSISTR" | head -n1
    echo "$SCSISTR" | tail -n2 | pr -o4 -l1
  fi
}

# Perform search (scan $host)
dosearch ()
{
  for channel in $channelsearch; do
    for id in $idsearch; do
      for lun in $lunsearch; do
        SCSISTR=
	devnr="$host $channel $id $lun"
	echo "Scanning for device $devnr ..."
	printf "${yellow}OLD: $norm"
	testexist
	if test ! -z "$remove" -a ! -z "$SCSISTR"; then
	  # Device exists: Test whether it's still online
	  testonline
	  if test $? = 1 -o ! -z "$forceremove"; then
	    echo -en "\r\e[A\e[A\e[A${red}REM: "
	    echo "$SCSISTR" | head -n1
	    echo -e "${norm}\e[B\e[B"
	    echo "scsi remove-single-device $devnr" >/proc/scsi/scsi
	    echo "scsi add-single-device $devnr" >/proc/scsi/scsi
          fi  
	  printf "\r\x1b[A\x1b[A\x1b[A${yellow}OLD: $norm"
	  testexist
	  if test -z "$SCSISTR"; then 
	    printf "\r${red}DEL: $norm\r\n\n\n\n" 
	    let rmvd+=1; 
          fi
	fi
	if test -z "$SCSISTR"; then
	  # Device does not exist, try to add
	  printf "\r${green}NEW: $norm"
	  echo "scsi add-single-device $devnr" >/proc/scsi/scsi
	  testexist
	  if test -z "$SCSISTR"; then
	    # Device not present
	    printf "\r\x1b[A";
  	    # Optimization: if lun==0, stop here (only if in non-remove mode)
	    if test $lun = 0 -a -z "$remove" -a $optscan = 1; then 
	      break;
	    fi  
	  else 
	    let found+=1; 
	  fi
	fi
      done
    done
  done
}
 
# main
if test @$1 = @--help -o @$1 = @-h -o @$1 = @-?; then
    echo "Usage: rescan-scsi-bus.sh [options] [host [host ...]]"
    echo "Options:"
    echo " -l activates scanning for LUNs 0-7    [default: 0]"
    echo " -w scan for target device IDs 0 .. 15 [default: 0-7]"
    echo " -c enables scanning of channels 0 1   [default: 0]"
    echo " -r enables removing of devices        [default: disabled]"
    echo "--remove:        same as -r"
    echo "--forceremove:   Remove and readd every device (dangerous)"
    echo "--nooptscan:     don't stop looking for LUNs is 0 is not found"
    echo "--color:         use coloured prefixes OLD/NEW/DEL"
    echo "--hosts=LIST:    Scan only host(s) in LIST"
    echo "--channels=LIST: Scan only channel(s) in LIST"
    echo "--ids=LIST:      Scan only target ID(s) in LIST"
    echo "--luns=LIST:     Scan only lun(s) in LIST"  
    echo " Host numbers may thus be specified either directly on cmd line (deprecated) or"
    echo " or with the --hosts=LIST parameter (recommended)."
    echo "LIST: A[-B][,C[-D]]... is a comma separated list of single values and ranges"
    echo " (No spaces allowed.)"
    exit 0
fi

expandlist ()
{
    list=$1
    result=""
    first=${list%%,*}
    rest=${list#*,}
    while test ! -z "$first"; do 
	beg=${first%%-*};
	if test "$beg" = "$first"; then
	    result="$result $beg";
    	else
    	    end=${first#*-}
	    result="$result `seq $beg $end`"
	fi
	test "$rest" = "$first" && rest=""
	first=${rest%%,*}
	rest=${rest#*,}
    done
    echo $result
}

if test ! -d /proc/scsi/; then
  echo "Error: SCSI subsystem not active"
  exit 1
fi	

# defaults
unsetcolor
lunsearch="0"
idsearch=`seq 0 7`
channelsearch="0"
remove=
forceremove=
optscan=1
if test -d /sys/class/scsi_host; then 
  findhosts_26
else  
  findhosts
fi  

# Scan options
opt="$1"
while test ! -z "$opt" -a -z "${opt##-*}"; do
  opt=${opt#-}
  case "$opt" in
    l) lunsearch=`seq 0 7` ;;
    w) idsearch=`seq 0 15` ;;
    c) channelsearch="0 1" ;;
    r) remove=1 ;;
    -remove)      remove=1 ;;
    -forceremove) remove=1; forceremove=1 ;;
    -hosts=*)     arg=${opt#-hosts=};   hosts=`expandlist $arg` ;;
    -channels=*)  arg=${opt#-channels=};channelsearch=`expandlist $arg` ;; 
    -ids=*)   arg=${opt#-ids=};         idsearch=`expandlist $arg` ;; 
    -luns=*)  arg=${opt#-luns=};        lunsearch=`expandlist $arg` ;; 
    -color) setcolor ;;
    -nooptscan) optscan=0 ;;
    *) echo "Unknown option -$opt !" ;;
  esac
  shift
  opt="$1"
done    

# Hosts given ?
if test "@$1" != "@"; then 
  hosts=$*; 
fi

echo "Scanning hosts $hosts channels $channelsearch for "
echo " SCSI target IDs " $idsearch ", LUNs " $lunsearch
test -z "$remove" || echo " and remove devices that have disappeared"
declare -i found=0
declare -i rmvd=0
for host in $hosts; do 
  dosearch; 
done
echo "$found new device(s) found.               "
echo "$rmvd device(s) removed.                 "
}}}
[[SAR - Commands]]
[[Plot a graph from SAR report with gnuplot]]
[[sar -u 2 5]]
*''Commands''
|!Command|!Description|
|''mpstat -P ALL''|check stats on all cpu's|
|''sar''|display cpu activity|
|''sar -u 2 5''|CPU utilization; 2 seconds apart; 5 times|
|''sar -o output.file 12 8 >/dev/null 2>&1 &''||
|''nohup sar -o output.file 12 8 >/dev/null 2>&1 &''||
|''sar -f data.file''||

[[SNMP - commands]]
|!Command|!Description|
|snmpwalk -v 1 -c public localhost .1.3.6.1.4.1.2021.9|get disk info|
|snmpwalk -v 1 -c public localhost .1.3.6.1.4.1.2021.4|get mem info|
[[Security - Password generator]]
http://www.goodpassword.com/
http://www.techzoom.net/tools/password-generator.en
{{{
import smtplib
from email.MIMEMultipart import MIMEMultipart
from email.MIMEBase import MIMEBase
from email.MIMEText import MIMEText
from email.Utils import COMMASPACE, formatdate
from email import Encoders
import os

def sendMail(to, subject, text, files=[],server="smtpserverhere"):
    assert type(to)==list
    assert type(files)==list
    fro = "from_this_user <from_this_user@a_server_somewhere>"

    msg = MIMEMultipart()
    msg['From'] = fro
    msg['To'] = COMMASPACE.join(to)
    msg['Date'] = formatdate(localtime=True)
    msg['Subject'] = subject

    msg.attach( MIMEText(text) )

    for file in files:
        part = MIMEBase('application', "octet-stream")
        part.set_payload( open(file,"rb").read() )
        Encoders.encode_base64(part)
        part.add_header('Content-Disposition', 'attachment; filename="%s"'
                       % os.path.basename(file))
        msg.attach(part)

    smtp = smtplib.SMTP(server)
    smtp.sendmail(fro, to, msg.as_string() )
    smtp.close()


sendMail(
        ["send_2_this_user@some_host"],
        "Subject of the mail here...","Inline text here...\n\n",
        ["file01.txt","file02.txt"]
    )
}}}
vanbelleh
[[Format Text]]
[[Format Blockquotes]]
[[Format Tables]]
[[Format Lists]]
[[Format Links and Images]]
[[Miscellaneous formats]]
[[Format ASCII symbols, foreign symbols, math symbols]]
[[4096 Color Wheel]]
[[Coloria Color Names]]
[[Layout Example]]
*Toestel volledig uitzetten.
*Hou de menuknop in gedrukt en zet je toestel aan met de aan/uitknop.
*Hou de menuknop ingedrukt totdat Android is gestart. Je ziet nu safe mode staan.
*Ga naar Settings > Applications > Manage Applications om de software te verwijderen.

|[[WelcomeToTiddlyspot]]|[[GettingStarted]]|[[Google]]|[[Google - Links]]|[[Codes]]|[[Java]]|[[MSWindows]]|
|[[Linux]]|[[Python]]|[[Perl]]|[[WebSphere]]|[[OSX]]|[[HTML]]|[[vi editor]]|
|[[Linux - Commands]]|[[Python Scripts]]|[[Perl Scripts]]|[[Tomcat]]|[[openSolaris]]|[[Emacs]]|[[Hardware]]|
|[[Javascript]]|[[Javascript examples]]|[[VMWare]]|[[Xen]]|[[Android]]|[[svn version control]]|[[Security]]|
|[[Polymorphism]]|[[DB2_Info]]|[[TSM]]|[[Monitoring]]|[[Network Tools]]|[[UTF8]]|[[cygwin]]|
|[[Special formatting]]|[[Awk scripts]]||||||
| [img[http://lh4.ggpht.com/_odP7v2tr9u4/S9DJa4nggHI/AAAAAAAADPc/OSQuYppDU0k/s800/images-8.jpeg][Android]] |
| [img[http://lh6.ggpht.com/_odP7v2tr9u4/S9DJYRqIjRI/AAAAAAAADOo/1f8H7T4v8EQ/s800/camel_head.png][Emacs]] |
| [img[http://lh6.ggpht.com/_odP7v2tr9u4/S9DJZCilFaI/AAAAAAAADO4/HzT-95ykdnY/s144/product_websphere.gif][WebSphere]] |
| [img[http://lh4.ggpht.com/_odP7v2tr9u4/S9DJYoWp7OI/AAAAAAAADOw/4kYTXlfe5sI/s800/tomcat.jpg][Tomcat]] |
| [img[Http://lh5.ggpht.com/_odP7v2tr9u4/S9DJZnSm3mI/AAAAAAAADPA/xqbwSqVMreI/s144/product_logo_db2.gif][DB2_Info]] |
| [img[http://lh5.ggpht.com/_odP7v2tr9u4/S9DJZ4-B8NI/AAAAAAAADPI/CWGvKinPoKM/s800/images-3.jpeg][Javascript]] |''[[Javascript]]''|
| [img[http://lh5.ggpht.com/_odP7v2tr9u4/S9DJZ4-B8NI/AAAAAAAADPI/CWGvKinPoKM/s800/images-3.jpeg][Javascript examples]] |''[[Javascript examples]]|
/*{{{*/
/* a contrasting background so I can see where one tiddler ends and the other begins */
body {
	background: [[ColorPalette::TertiaryLight]];
}

/* sexy colours and font for the header */
.headerForeground {
	color: [[ColorPalette::PrimaryPale]];
}
.headerShadow, .headerShadow a {
	color: [[ColorPalette::PrimaryMid]];
}
.headerForeground, .headerShadow {
	padding: 1em 1em 0;
	font-family: 'Trebuchet MS' sans-serif;
	font-weight:bold;
}
.headerForeground .siteSubtitle {
	color: [[ColorPalette::PrimaryLight]];
}
.headerShadow .siteSubtitle {
	color: [[ColorPalette::PrimaryMid]];
}

/* make shadow go and down right instead of up and left */
.headerShadow {
	left: 1px;
	top: 1px;
}

/* prefer monospace for editing */
.editor textarea {
	font-family: 'Consolas' monospace;
}

/* sexy tiddler titles */
.title {
	font-size: 250%;
	color: [[ColorPalette::PrimaryLight]];
	font-family: 'Trebuchet MS' sans-serif;
}

/* more subtle tiddler subtitle */
.subtitle {
	padding:0px;
	margin:0px;
	padding-left:0.5em;
	font-size: 90%;
	color: [[ColorPalette::TertiaryMid]];
}
.subtitle .tiddlyLink {
	color: [[ColorPalette::TertiaryMid]];
}

/* a little bit of extra whitespace */
.viewer {
	padding-bottom:3px;
}

/* don't want any background color for headings */
h1,h2,h3,h4,h5,h6 {
	background: [[ColorPalette::Background]];
	color: [[ColorPalette::Foreground]];
}

/* give tiddlers 3d style border and explicit background */
.tiddler {
	background: [[ColorPalette::Background]];
	border-right: 2px [[ColorPalette::TertiaryMid]] solid;
	border-bottom: 2px [[ColorPalette::TertiaryMid]] solid;
	margin-bottom: 1em;
	padding-bottom: 2em;
}

/* make options slider look nicer */
#sidebarOptions .sliderPanel {
	border:solid 1px [[ColorPalette::PrimaryLight]];
}


/* the borders look wrong with the body background */
#sidebar .button {
	border-style: none;
}

/* displays the list of a tiddler's tags horizontally. used in ViewTemplate */
.tagglyTagged li.listTitle {
	display:none
}
.tagglyTagged li {
	display: inline; font-size:90%;
}
.tagglyTagged ul {
	margin:0px; padding:0px;
}

/* this means you can put line breaks in SidebarOptions for readability */
#sidebarOptions br {
	display:none;
}
/* undo the above in OptionsPanel */
#sidebarOptions .sliderPanel br {
	display:inline;
}

/* horizontal main menu stuff */
#displayArea {
	margin: 1em 15.7em 0em 1em; /* use the freed up space */
}
#topMenu br {
	display: none;
}
#topMenu {
	background: [[ColorPalette::PrimaryMid]];
	color:[[ColorPalette::PrimaryPale]];
}
#topMenu {
	padding:2px;
}
#topMenu .button, #topMenu .tiddlyLink, #topMenu a {
	margin-left: 0.5em;
	margin-right: 0.5em;
	padding-left: 3px;
	padding-right: 3px;
	color: [[ColorPalette::PrimaryPale]];
	font-size: 115%;
}
#topMenu .button:hover, #topMenu .tiddlyLink:hover {
	background: [[ColorPalette::PrimaryDark]];
}

/* make it print a little cleaner */
@media print {
	#topMenu {
		display: none ! important;
	}
	/* not sure if we need all the importants */
	.tiddler {
		border-style: none ! important;
		margin:0px ! important;
		padding:0px ! important;
		padding-bottom:2em ! important;
	}
	.tagglyTagging .button, .tagglyTagging .hidebutton {
		display: none ! important;
	}
	.headerShadow {
		visibility: hidden ! important;
	}
	.tagglyTagged .quickopentag, .tagged .quickopentag {
		border-style: none ! important;
	}
	.quickopentag a.button, .miniTag {
		display: none ! important;
	}
}
/*}}}*/
Type the text for 'New Tiddler'
*''Priority'', as the name implies is simply a reflection of the urgency of a message and ranges from 0 ("Emergency") down to 7 ("Debug").
|!Priority|!Name|!Meaning|
| 0 | EMERGENCY |system is unusable|
| 1 | ALERT |action must be taken immediately|
| 2 | CRITICAL |critical conditions|
| 3 | ERROR |error conditions|
| 4 | WARNING |warning conditions|
| 5 | NOTICE |normal but signification condition|
| 6 | INFO |informational|
| 7 | DEBUG |debug-level messages|

*The ''Facility code'' is an attempt to identify the source of the message. Internally, on most Unix platforms (inc. Solaris and Linux) the facility is a number in the range 0-23. Generally they are referred to by their name

|!Facility name|!Source|
| KERNEL |	The Unix kernel, including device drivers.|
| USER |User level program - USER is the default facility code for the user level logger(1) program|
| MAIL |The mail subsystem - usually sendmail|
| DAEMON |Daemons (background programs)|
| AUTH |Authentication stuff - login, su, and the like|
| SYSLOG |From syslog itself|
| LPR |The printing system - lpd, lpsched, and CUPS use this|
| NEWS |USENET related daemons|
| CRON |From the cron daemon - see cron for more information about this.|
| LOCAL* |8 codes intended for custom use.|
[[Installing the TSM Version 5 Client for Linux]]
[[TSM Commands]]
[[TSM - dsmc - query]]
[[TSM - dsmc - backup]]
[[TSM - dsmc - restore]]
[[TSM - rc-boot-scripts in Linux]]
{{{
/usr/bin/dsmc backup -se=SERVER1 /backup_dir/backup_file > /tmp/logfile
}}}
{{{
/usr/bin/dsmc query backup -se=SERVER1 /backup_dir/backup_file > /tmp/logfile
}}}
{{{
/usr/bin/dsmc restore -se=SERVER1 /backup_dir/backup_file > /tmp/logfile
}}}
[[tsmacceptor]]
[[tsmsched]]
*Go to tsm-commandline with: 'dsmc'
**query filespace
**query mgmtclass
**query inclexcl
**query schedule
**query node
**query session
**query options
**query systeminfo
/% Invisible comment in a tiddler%/
*&copy; &reg; &trade; &larr; &rarr; &harr; &darr; &uarr; &euro; 
* &ccedil; &egrave; &eacute; &ecirc; &euml; &icirc;
*Greek {&omega; &psi;}
*Html {&pound; &euro;}
*Latin {&auml; &atilde; &aelig;} 
*Mathematics {&sum; &asymp; &le;}
''http://www.vanbellenet.be/images/google.jpg''
http://www.vanbellenet.be/images/google.jpg
[img[http://www.vanbellenet.be/images/google.jpg]]
[img[hvanbelle|http://www.vanbellenet.be/gallery/2006-02_Igls/small/img_2666.jpg]]
Nice way to group some info
> This goes more to the right
> Another one
>> and another one
|Hallo|Ook Hallo||
|>|Nogmaals Hallo||
|Yep Hallo| 2 Hallo | 3 Hallo|
|4 Hallo|||
|Tabel Voorbeeld|c

|>| Volgende tabel |
|>|Volgende tabel|
|[img[hvanbelle|http://www.vanbellenet.be/gallery/2006-02_Igls/small/img_2666.jpg]]|[img[http://www.vanbellenet.be/gallery/2006-02_Igls/small/img_2666.jpg]]|


http://docs.python.org/tutorial/
The HTML specifications technically define the difference between "GET" and "POST" so that former means that form data is to be encoded (by a browser) into a URL while the latter means that the form data is to appear within a message body. 

But the specifications also give the usage recommendation that the "GET" method should be used when the form processing is "idempotent", and in those cases only. 

As a simplification, we might say that "GET" is basically for just getting (retrieving) data whereas "POST" may involve anything, like storing or updating data, or ordering a product, or sending E-mail.
/%
!info
|Name|ToggleFullScreen|
|Source|http://www.TiddlyTools.com/#ToggleFullScreen|
|Version|2.0.1|
|Author|Eric Shulman|
|License|http://www.TiddlyTools.com/#LegalStatements|
|~CoreVersion|2.1|
|Type|transclusion|
|Description|Create a link that shows/hides sidebars and page headers|
Usage
<<<
{{{
<<tiddler ToggleFullScreen>>
<<tiddler ToggleFullScreen with: label altlabel>>
}}}
<<<
Example
<<<
{{{<<tiddler ToggleFullScreen with: fullscreen restore>>}}}
<<tiddler ToggleFullScreen##show with: fullscreen restore>>
<<<
!end

!show
<html><nowiki><a href='javascript:;' title="FULLSCREEN: toggle sidebars and page header"
onmouseover="
	this.href='javascript:void(eval(decodeURIComponent(%22(function(){try{('
	+encodeURIComponent(encodeURIComponent(this.onclick))
	+')()}catch(e){alert(e.description?e.description:e.toString())}})()%22)))';"
onclick="
	var co=config.options;
	co.chkFullScreen=!co.chkFullScreen;
	var showmm=!co.chkFullScreen && co.chkShowLeftSidebar!==false;
	var showsb=!co.chkFullScreen && co.chkShowRightSidebar!==false;
	var showcrumbs=!co.chkFullScreen && co.chkShowBreadcrumbs!==false
		&& config.macros.breadcrumbs && config.macros.breadcrumbs.crumbs.length;
	var cw=document.getElementById('contentWrapper');
	var da=document.getElementById('displayArea');
	var mm=document.getElementById('mainMenu');
	var sb=document.getElementById('sidebar');
	var sm=document.getElementById('storyMenu');
	var bc=document.getElementById('breadCrumbs');
	if (cw){
		var elems=cw.getElementsByTagName('*');
		for (var i=0; i<elems.length; i++) if (hasClass(elems[i],'header')) 
			{ elems[i].style.display=co.chkFullScreen?'none':'block'; break; }
	}
	if (mm) {
		mm.style.display=showmm?'block':'none';
		da.style.marginLeft=showmm?(co.txtDisplayAreaLeftMargin||''):'1em';
	}
	if (sb) {
		sb.style.display=showsb?'block':'none';
		da.style.marginRight=showsb?(co.txtDisplayAreaRightMargin||''):'1em';
	}
	if (sm) sm.style.display=!co.chkFullScreen ?'block':'none';
	if (bc) bc.style.display=showcrumbs?'block':'none';

	this.innerHTML=!co.chkFullScreen?'$1':'$2';
	var b=document.getElementById('restoreFromFullscreenButton');
	if (b) removeNode(b);
	else { 
		setStylesheet(store.getTiddlerText('ToggleFullScreen##styles'),'fullScreenStyles');
		var b=createTiddlyElement(null,'span','restoreFromFullscreenButton','selected');
		b.innerHTML='&loz;';
		b.title='RESTORE: redisplay page header, menu and sidebar';
		b.onclick=this.onclick;
		document.body.insertBefore(b,null);
	}
	return false;
">$1</a></html>
!styles
#restoreFromFullscreenButton {
	position:fixed; top:.3em; right:.3em; z-index:10001;
	cursor:pointer; font-size:8pt; color:ButtonText !important;
	border:2px outset ButtonFace; padding:0px 3px;
	background-color:ButtonFace; -moz-appearance:button;
}
!end
%/<<tiddler {{var src='ToggleFullScreen'; src+(tiddler&&tiddler.title==src?'##info':'##show');}}
with:	{{'$'+'1'!='$1'?'$1':'fullscreen'}}
	{{'$'+'2'!='$2'?'$2':'restore'}}>>
/%
!info
|Name|ToggleLeftSidebar|
|Source|http://www.TiddlyTools.com/#ToggleLeftSidebar|
|Version|2.0.0|
|Author|Eric Shulman|
|License|http://www.TiddlyTools.com/#LegalStatements|
|~CoreVersion|2.1|
|Type|transclusion|
|Description|show/hide left sidebar (MainMenu)|
Usage
<<<
{{{
<<tiddler ToggleLeftSidebar>>
<<tiddler ToggleLeftSidebar with: label tooltip>>
}}}
Try it: <<tiddler ToggleLeftSidebar##show
	with: {{config.options.chkShowLeftSidebar?'◄':'►'}}>>
<<<
Configuration:
<<<
{{{
config.options.chkShowLeftSidebar (true)
config.options.txtToggleLeftSideBarLabelShow (►)
config.options.txtToggleLeftSideBarLabelHide (◄)
}}}
<<<
!end
!show
<<tiddler {{
	var co=config.options;
	if (co.chkShowLeftSidebar===undefined) co.chkShowLeftSidebar=true;
	var mm=document.getElementById('mainMenu');
	var da=document.getElementById('displayArea');
	if (mm) {
		mm.style.display=co.chkShowLeftSidebar?'block':'none';
		da.style.marginLeft=co.chkShowLeftSidebar?'':'1em';
	}
'';}}>><html><nowiki><a href='javascript:;' title="$2"
onmouseover="
	this.href='javascript:void(eval(decodeURIComponent(%22(function(){try{('
	+encodeURIComponent(encodeURIComponent(this.onclick))
	+')()}catch(e){alert(e.description?e.description:e.toString())}})()%22)))';"
onclick="
	var co=config.options;
	var opt='chkShowLeftSidebar';
	var show=co[opt]=!co[opt];
	var mm=document.getElementById('mainMenu');
	var da=document.getElementById('displayArea');
	if (mm) {
		mm.style.display=show?'block':'none';
		da.style.marginLeft=show?'':'1em';
	}
	saveOptionCookie(opt);
	var labelShow=co.txtToggleLeftSideBarLabelShow||'&#x25BA;';
	var labelHide=co.txtToggleLeftSideBarLabelHide||'&#x25C4;';
	if (this.innerHTML==labelShow||this.innerHTML==labelHide) 
		this.innerHTML=show?labelHide:labelShow;
	this.title=(show?'hide':'show')+' left sidebar';
	var sm=document.getElementById('storyMenu');
	if (sm) config.refreshers.content(sm);
	return false;
">$1</a></html>
!end
%/<<tiddler {{
	var src='ToggleLeftSidebar';
	src+(tiddler&&tiddler.title==src?'##info':'##show');
}} with: {{
	var co=config.options;
	var labelShow=co.txtToggleLeftSideBarLabelShow||'&#x25BA;';
	var labelHide=co.txtToggleLeftSideBarLabelHide||'&#x25C4;';
	'$1'!='$'+'1'?'$1':(co.chkShowLeftSidebar?labelHide:labelShow);
}} {{
	var tip=(config.options.chkShowLeftSidebar?'hide':'show')+' left sidebar';
	'$2'!='$'+'2'?'$2':tip;
}}>>
/%
!info
|Name|ToggleRightSidebar|
|Source|http://www.TiddlyTools.com/#ToggleRightSidebar|
|Version|2.0.0|
|Author|Eric Shulman|
|License|http://www.TiddlyTools.com/#LegalStatements|
|~CoreVersion|2.1|
|Type|transclusion|
|Description|show/hide right sidebar (SideBarOptions)|
Usage
<<<
{{{
<<tiddler ToggleRightSidebar>>
<<tiddler ToggleRightSidebar with: label tooltip>>
}}}
Try it: <<tiddler ToggleRightSidebar##show
	with: {{config.options.chkShowRightSidebar?'►':'◄'}}>>
<<<
Configuration:
<<<
{{{
config.options.chkShowRightSidebar (true)
config.options.txtToggleRightSideBarLabelShow (◄)
config.options.txtToggleRightSideBarLabelHide (►)
}}}
<<<
!end
!show
<<tiddler {{
	var co=config.options;
	if (co.chkShowRightSidebar===undefined) co.chkShowRightSidebar=true;
	var sb=document.getElementById('sidebar');
	var da=document.getElementById('displayArea');
	if (sb) {
		sb.style.display=co.chkShowRightSidebar?'block':'none';
		da.style.marginRight=co.chkShowRightSidebar?'':'1em';
	}
'';}}>><html><nowiki><a href='javascript:;' title="$2"
onmouseover="
	this.href='javascript:void(eval(decodeURIComponent(%22(function(){try{('
	+encodeURIComponent(encodeURIComponent(this.onclick))
	+')()}catch(e){alert(e.description?e.description:e.toString())}})()%22)))';"
onclick="
	var co=config.options;
	var opt='chkShowRightSidebar';
	var show=co[opt]=!co[opt];
	var sb=document.getElementById('sidebar');
	var da=document.getElementById('displayArea');
	if (sb) {
		sb.style.display=show?'block':'none';
		da.style.marginRight=show?'':'1em';
	}
	saveOptionCookie(opt);
	var labelShow=co.txtToggleRightSideBarLabelShow||'&#x25C4;';
	var labelHide=co.txtToggleRightSideBarLabelHide||'&#x25BA;';
	if (this.innerHTML==labelShow||this.innerHTML==labelHide) 
		this.innerHTML=show?labelHide:labelShow;
	this.title=(show?'hide':'show')+' right sidebar';
	var sm=document.getElementById('storyMenu');
	if (sm) config.refreshers.content(sm);
	return false;
">$1</a></html>
!end
%/<<tiddler {{
	var src='ToggleRightSidebar';
	src+(tiddler&&tiddler.title==src?'##info':'##show');
}} with: {{
	var co=config.options;
	var labelShow=co.txtToggleRightSideBarLabelShow||'&#x25C4;';
	var labelHide=co.txtToggleRightSideBarLabelHide||'&#x25BA;';
	'$1'!='$'+'1'?'$1':(co.chkShowRightSidebar?labelHide:labelShow);
}} {{
	var tip=(config.options.chkShowRightSidebar?'hide':'show')+' right sidebar';
	'$2'!='$'+'2'?'$2':tip;
}}>>
[[Tomcat - HTTPS]]
[[Tomcat - Benchmark procedure]]
[[Tomcat - PermGen Error]]
http://www.devshed.com/c/a/BrainDump/Tomcat-Benchmark-Procedure/
[[Tomcat Benchmark procedure - page 1]]
[[Tomcat Benchmark procedure - page 2]]
[[Tomcat Benchmark procedure - page 3]]
[[Tomcat Benchmark procedure - page 4]]
Tomcat is using Java Secure Socket Extension (JSSE) for SSL HTTP implementation. Following are steps based on [[Tomcat ssl-howto|http://tomcat.apache.org/tomcat-6.0-doc/ssl-howto.html]] which shows how to enable it:

Certificate key store creation:
{{{
# /usr/java/bin/keytool -genkey -alias tomcat -keyalg RSA -keystore /etc/tomcat6/keystore
}}}
Server configuration (/etc/tomcat6/server.xml) then need uncomment following section and to add in it "keystoreFile" and "keystorePass" attributes:
{{{
<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
maxThreads="150" scheme="https" secure="true"
keystoreFile="/etc/tomcat6/keystore" keystorePass="changeit"
clientAuth="false" sslProtocol="TLS" />
}}}
''Short description of the problem''
When an application is loaded in a container environment, it gets its own ClassLoader. In tomcat this will be a WebAppClassLoader. When the application is undeployed, the container in theory drops all references to that class loader, and expects normal garbage collection to take care of the rest. However, if any object that is loaded by the system or container classloader (StandardClassLoader in tomcat) still has a reference to the application class loader or any object loaded by it, the class loader will not be garbage collected. In that case, all the class objects and every object referenced by a static field in any of the classes will not be garbage collected.

''Problems''
There are two main patterns that cause this situation. The first one is where a library loaded by the container has a cache that keeps strong references to objects or classes in the application. The second one is where the application has ThreadLocal data that is attached to a container thread. In tomcat this thread will be part of the thread pool, so it will never be garbage collected.

http://opensource.atlassian.com/confluence/spring/pages/viewpage.action?pageId=2669
[[Tomcat - Tomcat's new memory leak prevention and detection]]
[[Tomcat - change JAVA_OPTS]]
[[Tomcat - Memory leaks where the classloader cannot be garbage collected]]
Tomcat has long been blamed for causing memory leaks in the permanent generation (PermGen) that lead to OutOfMemoryErrors when re-loading web applications. I was discussing this at the eJUG days conference last year when I made an off-the-cuff remark that these errors were nearly always application bugs rather then Tomcat bugs. This generated a fair amount of debate that ended up with me doing some impromtu debugging of a couple of web applications provided by the audience.

The result of the debugging was that we found a number of root causes for the memory leaks that were fairly evenly split between application code, library code and JVM code. As I was coding some fixes for these issues, I realised that Tomcat could prevent a number of these memory leaks and detect even more. Not only that, in a number of cases it looked to be possible for Tomcat to actually fix the memory leak when it detected it. This lead, ultimately, to the new memory leak prevention and detection in Tomcat 6.

There are two parts to the new memory leak features. The first part handles memory leak prevention and is implemented as a life-cycle listener, the JreMemoryLeakPreventionListener. This listener prevents memory leaks by calling various parts of the Java API that are known to retain a reference to the current context class loader. If a web application is the first code to call one of these standard Java APIs, the web application class loader will be pinned in memory which will cause a memory leak. By making sure that Tomcat code makes the calls first, the memory leaks are prevented. If you want to know the gritty details of what this listener actually does, the source code is pretty well commented.

''http://www.tomcatexpert.com/tags/permgen''
('''!!! Check server capabilities !!!''')
{{{
JAVA_OPTS="-Djava.awt.headless=true -Dfile.encoding=UTF-8 -server -Xms1536m -Xmx1536m
-XX:NewSize=256m -XX:MaxNewSize=256m -XX:PermSize=256m
-XX:MaxPermSize=256m -XX:+DisableExplicitGC"
}}}
''Tomcat Benchmark Procedure
(Page 1 of 4 )

In this third part of a five-part series focusing on Tomcat performance tuning, you will learn benchmarking procedures and some of the qualities of the application that you can benchmark. This article is excerpted from chapter four of Tomcat: The Definitive Guide, Second Edition, written by Jason Brittain and Ian F. Darwin (O'Reilly; ISBN: 0596101066). Copyright © 2008 O'Reilly Media, Inc. All rights reserved. Used with permission from the publisher. Available from booksellers or direct from O'Reilly Media.

Benchmark procedure''

We benchmarked two different types of static resource requests: small text files and 9k image files. For both of these types of benchmark tests, we set the server to be able to handle at least 150 concurrent client connections, and set the benchmark client to open no more than 149 concurrent connections so that it never attempted to use more concurrency than the server was configured to handle. We set the benchmark client to use HTTP keep-alive connections for all tests.

For the small text files benchmark, we’re testing the server’s ability to read the HTTP request and write the HTTP response where the response body is very small. This mainly tests the server’s ability to respond fast while handling many requests concurrently. We set the benchmark client to request the file 100,000 times, with a possible maximum of 149 concurrent connections. This is how we created the text file:

>''$ echo 'Hello world.' > test.html''

We copied this file into Tomcat’sROOTwebapp and also into Apache httpd’s document root directory.

Here is the ab command line showing the arguments we used for the small text file benchmark tests:

>''$ ab -k -n 100000 -c 149 http://192.168.1.2/test.html''

We changed the requested URL appropriately for each test so that it made requests that would benchmark the server we intended to test each time.

For the 9k image files benchmark, we’re testing the server’s ability to serve a larger amount of data in the response body to many clients concurrently. We set the benchmark client to request the file 20,000 times, with a possible maximum of 149 concurrent connections. We specified a lower total number of requests for this test because the size of the data was larger, so we adjusted the number of requests down to compensate somewhat, but still left it high to place a significant load on the server. This is how we created the image file:

>''$ dd if=a-larger-image.jpg of=9k.jpg bs=1 count=9126''

We chose a size of 9k because if we went much higher, both Tomcat and Apache httpd would easily saturate our 1 Mb Ethernet link between the client machine and the server machine. Again, we copied this file into Tomcat’s ROOT webapp and also into Apache httpd’s document root directory.

Here is the ab command line showing the arguments we used for the small text file benchmark tests:

>''$ ab -k -n 20000 -c 149 http://192.168.1.2/20k.jpg''

For each invocation of ab, we obtained the benchmark results by following this procedure:

>1. Configure and restart the Apache httpd and/or Tomcat instances that are being tested.
>2. Make sure the server(s) do not log any startup errors. If they do, fix the problem before proceeding.
>3. Run one invocation of the ab command line to get the servers serving their first requests after the restart.
>4. Run the ab command line again as part of the benchmark.
>5. Make sure that ab reports that there were zero errors and zero non-2xx responses, when all requests are complete.
>6. Wait a few seconds between invocations of ab so that the servers go back to an idle state.
>7. Note the requests per second in the abstatistics.
>8. Go back to step 4 if the requests per second change significantly; otherwise, this iteration’s requests per second are the result of the benchmark. If the numbers continue to change significantly, give up after 10 iterations of ab, and record the last requests per second value as the benchmark result. 

The idea here is that the servers will be inefficient for the first couple or few invocations of ab, but then the server software arrives at a state where everything is well initialized. The Tomcat JVM begins to profile itself and natively compile the most heavily used code for that particular use of the program, which further speeds response time. It takes a few ab invocations for the servers to settle into their more optimal runtime state, and it is this state that we should be benchmarking—the state the servers would be in if they were serving for many hours or days as production servers tend to do. 
''Tomcat Benchmark Procedure - Benchmark results and summary''
(Page 2 of 4 )

We ran the benchmarks and graphed the results data as bar charts, listing the web server configurations in descending performance order (one graph per test per computer). First, we look at how the machines did in the small text files benchmark (see Figures 4-3 and 4-4).

Notice that Figures 4-3 and 4-4 look very similar. On both machines, Tomcat standalone JIO is the fastest web server for serving these static text files, followed by APR, followed by NIO. The two build configurations of Apache httpd came in fourth and fifth fastest, followed by all of the permutations of Apache httpd connected to Tomcat via a connector module. And, dominating the slow end of the graphs is mod_jk.


Figure 4-3.  Benchmark results for serving small text files on the AMD64 laptop


Figure 4-4.  Benchmark results for serving small text files on the EM64T tower

It is also interesting to compare the requests per second results for one web server configuration on both graphs. The AMD64 laptop has one single core processor, and the EM64T has two single core processors; thus, if dual EM64T computer works efficiently, and if the operating system and JVM can effectively take advantage of both processors, the dual EM64T computer should be able to sustain slightly less than double the requests per second that the single processor AMD64 machine could. Of course, this assumes that the two processor models are equally fast at executing instructions; they may not be. But, comparing the results for the two computers, the same web server configuration on the dual EM64T computer does sustain nearly double the requests per second, minus a percent for the overhead of the two processors sharing one set of system resources, such as RAM, data and I/O buses, and so on. This one computer with two processors in it can handle nearly the same number of requests that two single processor computers can, and both Tomcat and Apache httpdare able to take advantage of that.

Next, we examine the results of the 9k image files benchmark on both machines. Figures 4-5 and 4-6 show the results for the AMD64 computer and the dual EM64T computer, respectively.

Figure 4-5.  Benchmark results for serving 9k image files on the AMD64 laptop

In Figure 4-5, you can see that on AMD64, Tomcat standalone JIO wins again, with Apache httpdworker MPM trailing close behind. In this benchmark, their performance is nearly identical, with Tomcat standalone APR in a very close third place. Tomcat standalone NIO is in fourth place, trailing a little behind APR. Apache httpd prefork MPM is fifth fastest again behind all of the Tomcat standalone configurations. Slower still are all of the permutations of Apache httpd connecting to Tomcat via connector modules. This time, we observed mod_jk perform about average among the connector modules, with some configurations of mod_proxy_http performing the slowest.

Figure 4-6 is somewhat different, showing that on the dual EM64T, Apache httpd edges slightly ahead of Tomcat standalone’s fastest connector: JIO. The difference in performance between the two is very small—about 1 percent. This may hint that there is a difference in how EM64T behaves versus AMD64. It appears that Apache httpd is 1 percent faster than Tomcat on EM64T when serving the image files, at least on the computers we benchmarked. You should not assume this is the case with newer computers, as many hardware details change! Also, we observed all three Tomcat standalone connectors performing better than Apache httpd prefork in this set of benchmarks. The configurations where Apache httpd connects to Tomcat via a connector module were again the slowest performing configurations, with mod_jk performing the slowest.

 
Figure 4-6.  Benchmark results for serving 9k image files on the EM64T tower
''Tomcat Benchmark Procedure - Benchmark results and summary continued''
(Page 3 of 4 )

 

Does the dual EM64T again serve roughly double the number of requests per second as the single processor AMD64 when serving the image files? No. For some reason, it’s more like four times the number of requests per second. How could it be possible that by adding one additional processor, the computer can do four times the work? It probably can’t. The only explanation we can think of is that something is slowing down the AMD64 laptop’s ability to serve the image files to the processor’s full potential. This isn’t necessarily a hardware problem; it could be that a device driver in this version of the kernel is performing inefficiently and slowing down the benchmark. This hints that the benchmark results for the 9k image benchmark on the AMD64 computer may not be accurate due to a slow driver. However, this is the observed performance on that computer. Until and unless a different kernel makes it perform better, this is how it will perform. Knowing that, it is unclear whether Tomcat or Apache httpd is faster serving the 9k image files, although we would guess that the EM64T benchmark results are more accurate.

Does the dual EM64T again serve roughly double the number of requests per second as the single processor AMD64 when serving the image files? No. For some reason, it’s more like four times the number of requests per second. How could it be possible that by adding one additional processor, the computer can do four times the work? It probably can’t. The only explanation we can think of is that something is slowing down the AMD64 laptop’s ability to serve the image files to the processor’s full potential. This isn’t necessarily a hardware problem; it could be that a device driver in this version of the kernel is performing inefficiently and slowing down the benchmark. This hints that the benchmark results for the 9k image benchmark on the AMD64 computer may not be accurate due to a slow driver. However, this is the observed performance on that computer. Until and unless a different kernel makes it perform better, this is how it will perform. Knowing that, it is unclear whether Tomcat or Apache   is faster serving the 9k image files, although we would guess that the EM64T benchmark results are more accurate.

Here is a summary of the benchmark results, including some important stats:

>Tomcat standalone was faster than Apache httpd compiled for worker MPM in all of our benchmark tests except the 9k image benchmark test on Intel 64-bit Xeon, and even in that benchmark, httpd was only 1 percent faster than Tomcat. We observed that Tomcat standalone JIO was almost always the fastest way to serve static resources. Tomcat served them between 3 percent and 136 percent faster than Apache httpd in our benchmarks—Tomcat standalone JIO was a minimum of 3 percent faster than Apache httpd (worker MPM) for 9k image files, except for the Intel 64-bit Xeon benchmark, where httpd appeared to perform 1 percent faster than Tomcat. But in the small files benchmark, Tomcat was a minimum of 99 percent faster than Apache httpd and a maximum of 136 percent faster than Apache httpd.

>Apache httpd built to use worker MPM was the fastest configuration of Apache httpd we tested; Apache httpd built to use prefork MPM was slower than worker MPM in all of our standalone tests. We observed worker MPM serving a minimum of 0.4 percent faster than prefork MPM and a maximum of 26 percent faster than prefork MPM. There was almost no difference in performance between the two in our small text files benchmarks, but in the 9k image files benchmark, the difference was at least 22 percent.

>Tomcat standalone (configured to use any HTTP connector implementation) was always faster than Apache httpd built and configured for prefork MPM; Tomcat standalone was a minimum of 21 percent faster than Apache httpd and a maximum of 30 percent faster than Apache httpd for 9k image files, and for small files Tomcat was a minimum of 103 percent faster than Apache httpd and a maximum of 136 percent faster than Apache httpd prefork MPM.

>Apache httpd was quite a bit slower at serving small files. Tomcat standalone’s JIO, APR, and NIO connectors were each faster than Apache httpd—Tomcat’s JIO connector performed as much as 136 percent faster than Apache httpd’s fastest configuration, Tomcat’s APR connector performed 89 percent faster than Apache httpd, and Tomcat 6.0’s NIO connector performed 25 percent faster than Apache httpd. In this common use case benchmark, Apache httpd dropped to fourth place behind all of Tomcat standalone’s three HTTP connectors.

>Serving Tomcat’s resources through Apache httpd was very slow compared to serving them directly from Tomcat. When we compared the benchmark results between Tomcat standalone and Tomcat serving through Apache httpd via mod_proxy, Tomcat standalone consistently served at least 51 percent faster when using only Tomcat’s JIO connector without Apache httpd. (including all three Apache httpd connector modules: mod_jk, mod_proxy_ajp, and mod_proxy_http). In the small text files benchmark, Tomcat standalone was a minimum of 168 percent faster than the Apache httpd to Tomcat configurations and a maximum of 578 percent faster! That’s not a misprint—it’s really 578 percent faster. For the 9k image files benchmark, Tomcat standalone was at least 51 percent faster and at most 274 percent faster.

>AJP outperformed HTTP when using mod_proxy. The benchmark results show that mod_proxy_ajp was consistently faster than mod_proxy_http. The margin between the two protocols was as low as 1 percent and as high as 30 percent when using the same Tomcat connector design, but it was usually smaller, with mod_proxy_ajp averaging about 13 percent faster than mod_proxy_http.

>Serving Tomcat’s static resources through an Apache httpd connector module was never faster than serving the same static resources through just Apache httpd by itself. The benchmark results of serving the resources through an httpdconnector module (from Tomcat) were always somewhat slower than just serving the static resources straight from Apache httpd. This means that benchmarking Apache httpd standalone will tell you a number slightly higher than the theoretical maximum that you could get by serving the same resource(s) through an httpd connector module. This also means that no matter how performant Tomcat is, serving its files through Apache httpd throttles Tomcat down so that Tomcat is slower than Apache httpd.

>mod_jk was not faster than mod_proxy, except in the 9k image benchmark and then only on AMD64. In our tests, serving Tomcat’s resources through Apache httpd via mod_jk was only faster than using mod_proxy on the AMD64 laptop and only in the 9k image benchmark. In all the other benchmarks, mod_jk was slower than mod_proxy_ajp. 

How is it possible for pure-Java Tomcat to serve static resource faster than Apache httpd? The main reason we can think of: because Tomcat is written in Java and because Java bytecode can be natively compiled and highly optimized at runtime, well-written Java code can run very fast when it runs on a mature Java VM that implements many runtime optimizations, such as the Sun Hotspot JVM. After it runs and serves many requests, the JVM knows how to optimize it for that particular use on that particular hardware. On the other hand, Apache httpd is written in C, which is completely compiled ahead of runtime. Even though you can tell the compiler to heavily optimize the binaries, no runtime optimizations can take place. So, there is no opportunity with Apache httpd to take advantage of the many runtime optimizations that Tomcat enjoys.

Another potential reason Tomcat serves the web faster than Apache httpd is that every release of Sun’s JVM seems to run Java code faster, which has gone on for many release cycles of their JVM. That means that even if you’re not actively changing your Java program to perform better, it will likely keep improving every time you run it on a newer, faster JVM if the same progress on JVM performance continues. This does, however, make the assumption that newer JVMs will be compatible enough to run your Java program’s bytecode without any modifications. 
Tomcat Benchmark Procedure - What else we could have benchmarked
(Page 4 of 4 )

In this benchmark, we tested the web server’s performance when serving HTTP. We did not benchmark HTTPS (encrypted HTTP). The performance characteristics are probably significantly different between HTTP and HTTPS because with HTTPS, both the server and the client must encrypt and decrypt the data in both directions over the network. The overhead caused by the encryption slows down the requests and responses to varying degrees on different implementations of the crypto code. We have not benchmarked the HTTPS performance of the above web server configurations. Without benchmarking it, many believe that Apache httpd’s HTTPS performance is higher than that of Tomcat, and usually people base that belief on the idea that C code is faster than Java code. Our HTTP benchmark disproves that in three out of our four benchmark scenarios, and the fourth one is not significantly better on the C side. We do not know which web server configuration would be fastest serving HTTPS without benchmarking them. But, if either the C encryption code or the Java encryption code is the fastest—by a significant margin—Tomcat implements both because you can configure the APR connector to use OpenSSL for HTTPS encryption, which is the same C library that Apache httpd uses. 

We could have benchmarked other metrics such as throughput; there are many more interesting things to learn by watching any particular metric that ab reports. For this benchmark, we define greater performance to mean a higher number of requests per second being handled successfully (a 2xx response code).

We could have benchmarked other static file sizes, including files larger than 9k in size, but with files as large as 100k, all of the involved server configurations saturate the bandwidth of a megabit Ethernet network. This makes it impossible to measure how fast the server software itself could serve the files because the network was not fast enough. For our test, we did not have network bandwidth greater than 1 Mb Ethernet.

We could have tested with mixed file sizes per HTTP request, but what mixture would we choose, and what use case would that particular mixture represent? The results of benchmarks such as these would only be interesting if your own web traffic had a similar enough mixture, which is unlikely. Instead, we focused on benchmarking two file sizes, one file size per benchmark test.

We could have tested with a different number of client threads, but 150 threads is the default (as of this writing) on both Tomcat and Apache httpd, which means many administrators will use these settings—mainly due to lack of time to learn what the settings do and how to change them in a useful way. We ended up raising some of the limits on the Apache httpd side to try to find a way to make httpd perform better when the benchmark client sends a maximum of 149 concurrent requests; it worked.

There are many other things we could have benchmarked and many other ways we could have benchmarked. Even covering other common use cases is beyond the scope of this book. We’re trying to show only one example of a benchmark that yields some useful information about how the performance of Tomcat’s web server implementations compares with that of Apache httpd in a specific limited environment and for specific tests.
/***
Description: Contains the stuff you need to use Tiddlyspot
Note, you also need UploadPlugin, PasswordOptionPlugin and LoadRemoteFileThroughProxy
from http://tiddlywiki.bidix.info for a complete working Tiddlyspot site.
***/
//{{{

// edit this if you are migrating sites or retrofitting an existing TW
config.tiddlyspotSiteId = 'vanbelleh';

// make it so you can by default see edit controls via http
config.options.chkHttpReadOnly = false;
window.readOnly = false; // make sure of it (for tw 2.2)
window.showBackstage = true; // show backstage too

// disable autosave in d3
if (window.location.protocol != "file:")
	config.options.chkGTDLazyAutoSave = false;

// tweak shadow tiddlers to add upload button, password entry box etc
with (config.shadowTiddlers) {
	SiteUrl = 'http://'+config.tiddlyspotSiteId+'.tiddlyspot.com';
	SideBarOptions = SideBarOptions.replace(/(<<saveChanges>>)/,"$1<<tiddler TspotSidebar>>");
	OptionsPanel = OptionsPanel.replace(/^/,"<<tiddler TspotOptions>>");
	DefaultTiddlers = DefaultTiddlers.replace(/^/,"[[WelcomeToTiddlyspot]] ");
	MainMenu = MainMenu.replace(/^/,"[[WelcomeToTiddlyspot]] ");
}

// create some shadow tiddler content
merge(config.shadowTiddlers,{

'WelcomeToTiddlyspot':[
 "This document is a ~TiddlyWiki from tiddlyspot.com.  A ~TiddlyWiki is an electronic notebook that is great for managing todo lists, personal information, and all sorts of things.",
 "",
 "@@font-weight:bold;font-size:1.3em;color:#444; //What now?// &nbsp;&nbsp;@@ Before you can save any changes, you need to enter your password in the form below.  Then configure privacy and other site settings at your [[control panel|http://" + config.tiddlyspotSiteId + ".tiddlyspot.com/controlpanel]] (your control panel username is //" + config.tiddlyspotSiteId + "//).",
 "<<tiddler TspotControls>>",
 "See also GettingStarted.",
 "",
 "@@font-weight:bold;font-size:1.3em;color:#444; //Working online// &nbsp;&nbsp;@@ You can edit this ~TiddlyWiki right now, and save your changes using the \"save to web\" button in the column on the right.",
 "",
 "@@font-weight:bold;font-size:1.3em;color:#444; //Working offline// &nbsp;&nbsp;@@ A fully functioning copy of this ~TiddlyWiki can be saved onto your hard drive or USB stick.  You can make changes and save them locally without being connected to the Internet.  When you're ready to sync up again, just click \"upload\" and your ~TiddlyWiki will be saved back to tiddlyspot.com.",
 "",
 "@@font-weight:bold;font-size:1.3em;color:#444; //Help!// &nbsp;&nbsp;@@ Find out more about ~TiddlyWiki at [[TiddlyWiki.com|http://tiddlywiki.com]].  Also visit [[TiddlyWiki.org|http://tiddlywiki.org]] for documentation on learning and using ~TiddlyWiki. New users are especially welcome on the [[TiddlyWiki mailing list|http://groups.google.com/group/TiddlyWiki]], which is an excellent place to ask questions and get help.  If you have a tiddlyspot related problem email [[tiddlyspot support|mailto:support@tiddlyspot.com]].",
 "",
 "@@font-weight:bold;font-size:1.3em;color:#444; //Enjoy :)// &nbsp;&nbsp;@@ We hope you like using your tiddlyspot.com site.  Please email [[feedback@tiddlyspot.com|mailto:feedback@tiddlyspot.com]] with any comments or suggestions."
].join("\n"),

'TspotControls':[
 "| tiddlyspot password:|<<option pasUploadPassword>>|",
 "| site management:|<<upload http://" + config.tiddlyspotSiteId + ".tiddlyspot.com/store.cgi index.html . .  " + config.tiddlyspotSiteId + ">>//(requires tiddlyspot password)//<br>[[control panel|http://" + config.tiddlyspotSiteId + ".tiddlyspot.com/controlpanel]], [[download (go offline)|http://" + config.tiddlyspotSiteId + ".tiddlyspot.com/download]]|",
 "| links:|[[tiddlyspot.com|http://tiddlyspot.com/]], [[FAQs|http://faq.tiddlyspot.com/]], [[blog|http://tiddlyspot.blogspot.com/]], email [[support|mailto:support@tiddlyspot.com]] & [[feedback|mailto:feedback@tiddlyspot.com]], [[donate|http://tiddlyspot.com/?page=donate]]|"
].join("\n"),

'TspotSidebar':[
 "<<upload http://" + config.tiddlyspotSiteId + ".tiddlyspot.com/store.cgi index.html . .  " + config.tiddlyspotSiteId + ">><html><a href='http://" + config.tiddlyspotSiteId + ".tiddlyspot.com/download' class='button'>download</a></html>"
].join("\n"),

'TspotOptions':[
 "tiddlyspot password:",
 "<<option pasUploadPassword>>",
 ""
].join("\n")

});
//}}}
''Char-table:'' 
>http://www.utf8-chartable.de/
''Sample page:'' 
>http://www.columbia.edu/kermit/utf8.html
''UTF-8 and Unicode FAQ for Unix/Linux''
>http://www.cl.cam.ac.uk/~mgk25/unicode.html
[[Linux-Commands - howto convert iso-8859-1 charset html files into utf-8 charset files]]
| !date | !user | !location | !storeUrl | !uploadDir | !toFilename | !backupdir | !origin |
| 18/08/2010 13:48:07 | hvanbelle | [[vanbelleh.html|file:///home/vanbelleh/Download/vanbelleh.html]] | [[store.cgi|http://vanbelleh.tiddlyspot.com/store.cgi]] | . | [[index.html | http://vanbelleh.tiddlyspot.com/index.html]] | . | ok |
| 18/08/2010 14:54:47 | hvanbelle | [[vanbelleh.html|file:///home/vanbelleh/Download/vanbelleh.html]] | [[store.cgi|http://vanbelleh.tiddlyspot.com/store.cgi]] | . | [[index.html | http://vanbelleh.tiddlyspot.com/index.html]] | . | ok |
| 18/08/2010 16:17:55 | hvanbelle | [[vanbelleh.html|file:///home/vanbelleh/Download/vanbelleh.html]] | [[store.cgi|http://vanbelleh.tiddlyspot.com/store.cgi]] | . | [[index.html | http://vanbelleh.tiddlyspot.com/index.html]] | . | ok |
| 19/08/2010 13:30:24 | hvanbelle | [[vanbelleh.html|file:///home/vanbelleh/Download/vanbelleh.html]] | [[store.cgi|http://vanbelleh.tiddlyspot.com/store.cgi]] | . | [[index.html | http://vanbelleh.tiddlyspot.com/index.html]] | . | ok |
| 06/09/2010 14:57:03 | hvanbelle | [[vanbelleh.html|file:///home/vanbelleh/Download/vanbelleh.html]] | [[store.cgi|http://vanbelleh.tiddlyspot.com/store.cgi]] | . | [[index.html | http://vanbelleh.tiddlyspot.com/index.html]] | . | ok |
| 08/09/2010 13:14:32 | hvanbelle | [[vanbelleh.html|file:///home/vanbelleh/Download/vanbelleh.html]] | [[store.cgi|http://vanbelleh.tiddlyspot.com/store.cgi]] | . | [[index.html | http://vanbelleh.tiddlyspot.com/index.html]] | . | ok |
| 28/09/2010 14:03:02 | hvanbelle | [[vanbelleh.html|file:///home/vanbelleh/Download/vanbelleh.html]] | [[store.cgi|http://vanbelleh.tiddlyspot.com/store.cgi]] | . | [[index.html | http://vanbelleh.tiddlyspot.com/index.html]] | . | ok |
| 28/09/2010 14:04:50 | hvanbelle | [[vanbelleh.html|file:///home/vanbelleh/Download/vanbelleh.html]] | [[store.cgi|http://vanbelleh.tiddlyspot.com/store.cgi]] | . | [[index.html | http://vanbelleh.tiddlyspot.com/index.html]] | . | ok |
| 19/10/2010 09:16:57 | hvanbelle | [[vanbelleh.html|file:///home/vanbelleh/Download/vanbelleh.html]] | [[store.cgi|http://vanbelleh.tiddlyspot.com/store.cgi]] | . | [[index.html | http://vanbelleh.tiddlyspot.com/index.html]] | . |
| 03/02/2011 22:52:23 | vanbelleh | [[/|http://vanbelleh.tiddlyspot.com/]] | [[store.cgi|http://vanbelleh.tiddlyspot.com/store.cgi]] | . | [[index.html | http://vanbelleh.tiddlyspot.com/index.html]] | . |
/***
|''Name:''|UploadPlugin|
|''Description:''|Save to web a TiddlyWiki|
|''Version:''|4.1.3|
|''Date:''|Feb 24, 2008|
|''Source:''|http://tiddlywiki.bidix.info/#UploadPlugin|
|''Documentation:''|http://tiddlywiki.bidix.info/#UploadPluginDoc|
|''Author:''|BidiX (BidiX (at) bidix (dot) info)|
|''License:''|[[BSD open source license|http://tiddlywiki.bidix.info/#%5B%5BBSD%20open%20source%20license%5D%5D ]]|
|''~CoreVersion:''|2.2.0|
|''Requires:''|PasswordOptionPlugin|
***/
//{{{
version.extensions.UploadPlugin = {
	major: 4, minor: 1, revision: 3,
	date: new Date("Feb 24, 2008"),
	source: 'http://tiddlywiki.bidix.info/#UploadPlugin',
	author: 'BidiX (BidiX (at) bidix (dot) info',
	coreVersion: '2.2.0'
};

//
// Environment
//

if (!window.bidix) window.bidix = {}; // bidix namespace
bidix.debugMode = false;	// true to activate both in Plugin and UploadService
	
//
// Upload Macro
//

config.macros.upload = {
// default values
	defaultBackupDir: '',	//no backup
	defaultStoreScript: "store.php",
	defaultToFilename: "index.html",
	defaultUploadDir: ".",
	authenticateUser: true	// UploadService Authenticate User
};
	
config.macros.upload.label = {
	promptOption: "Save and Upload this TiddlyWiki with UploadOptions",
	promptParamMacro: "Save and Upload this TiddlyWiki in %0",
	saveLabel: "save to web", 
	saveToDisk: "save to disk",
	uploadLabel: "upload"	
};

config.macros.upload.messages = {
	noStoreUrl: "No store URL in parmeters or options",
	usernameOrPasswordMissing: "Username or password missing"
};

config.macros.upload.handler = function(place,macroName,params) {
	if (readOnly)
		return;
	var label;
	if (document.location.toString().substr(0,4) == "http") 
		label = this.label.saveLabel;
	else
		label = this.label.uploadLabel;
	var prompt;
	if (params[0]) {
		prompt = this.label.promptParamMacro.toString().format([this.destFile(params[0], 
			(params[1] ? params[1]:bidix.basename(window.location.toString())), params[3])]);
	} else {
		prompt = this.label.promptOption;
	}
	createTiddlyButton(place, label, prompt, function() {config.macros.upload.action(params);}, null, null, this.accessKey);
};

config.macros.upload.action = function(params)
{
		// for missing macro parameter set value from options
		if (!params) params = {};
		var storeUrl = params[0] ? params[0] : config.options.txtUploadStoreUrl;
		var toFilename = params[1] ? params[1] : config.options.txtUploadFilename;
		var backupDir = params[2] ? params[2] : config.options.txtUploadBackupDir;
		var uploadDir = params[3] ? params[3] : config.options.txtUploadDir;
		var username = params[4] ? params[4] : config.options.txtUploadUserName;
		var password = config.options.pasUploadPassword; // for security reason no password as macro parameter	
		// for still missing parameter set default value
		if ((!storeUrl) && (document.location.toString().substr(0,4) == "http")) 
			storeUrl = bidix.dirname(document.location.toString())+'/'+config.macros.upload.defaultStoreScript;
		if (storeUrl.substr(0,4) != "http")
			storeUrl = bidix.dirname(document.location.toString()) +'/'+ storeUrl;
		if (!toFilename)
			toFilename = bidix.basename(window.location.toString());
		if (!toFilename)
			toFilename = config.macros.upload.defaultToFilename;
		if (!uploadDir)
			uploadDir = config.macros.upload.defaultUploadDir;
		if (!backupDir)
			backupDir = config.macros.upload.defaultBackupDir;
		// report error if still missing
		if (!storeUrl) {
			alert(config.macros.upload.messages.noStoreUrl);
			clearMessage();
			return false;
		}
		if (config.macros.upload.authenticateUser && (!username || !password)) {
			alert(config.macros.upload.messages.usernameOrPasswordMissing);
			clearMessage();
			return false;
		}
		bidix.upload.uploadChanges(false,null,storeUrl, toFilename, uploadDir, backupDir, username, password); 
		return false; 
};

config.macros.upload.destFile = function(storeUrl, toFilename, uploadDir) 
{
	if (!storeUrl)
		return null;
		var dest = bidix.dirname(storeUrl);
		if (uploadDir && uploadDir != '.')
			dest = dest + '/' + uploadDir;
		dest = dest + '/' + toFilename;
	return dest;
};

//
// uploadOptions Macro
//

config.macros.uploadOptions = {
	handler: function(place,macroName,params) {
		var wizard = new Wizard();
		wizard.createWizard(place,this.wizardTitle);
		wizard.addStep(this.step1Title,this.step1Html);
		var markList = wizard.getElement("markList");
		var listWrapper = document.createElement("div");
		markList.parentNode.insertBefore(listWrapper,markList);
		wizard.setValue("listWrapper",listWrapper);
		this.refreshOptions(listWrapper,false);
		var uploadCaption;
		if (document.location.toString().substr(0,4) == "http") 
			uploadCaption = config.macros.upload.label.saveLabel;
		else
			uploadCaption = config.macros.upload.label.uploadLabel;
		
		wizard.setButtons([
				{caption: uploadCaption, tooltip: config.macros.upload.label.promptOption, 
					onClick: config.macros.upload.action},
				{caption: this.cancelButton, tooltip: this.cancelButtonPrompt, onClick: this.onCancel}
				
			]);
	},
	options: [
		"txtUploadUserName",
		"pasUploadPassword",
		"txtUploadStoreUrl",
		"txtUploadDir",
		"txtUploadFilename",
		"txtUploadBackupDir",
		"chkUploadLog",
		"txtUploadLogMaxLine"		
	],
	refreshOptions: function(listWrapper) {
		var opts = [];
		for(i=0; i<this.options.length; i++) {
			var opt = {};
			opts.push();
			opt.option = "";
			n = this.options[i];
			opt.name = n;
			opt.lowlight = !config.optionsDesc[n];
			opt.description = opt.lowlight ? this.unknownDescription : config.optionsDesc[n];
			opts.push(opt);
		}
		var listview = ListView.create(listWrapper,opts,this.listViewTemplate);
		for(n=0; n<opts.length; n++) {
			var type = opts[n].name.substr(0,3);
			var h = config.macros.option.types[type];
			if (h && h.create) {
				h.create(opts[n].colElements['option'],type,opts[n].name,opts[n].name,"no");
			}
		}
		
	},
	onCancel: function(e)
	{
		backstage.switchTab(null);
		return false;
	},
	
	wizardTitle: "Upload with options",
	step1Title: "These options are saved in cookies in your browser",
	step1Html: "<input type='hidden' name='markList'></input><br>",
	cancelButton: "Cancel",
	cancelButtonPrompt: "Cancel prompt",
	listViewTemplate: {
		columns: [
			{name: 'Description', field: 'description', title: "Description", type: 'WikiText'},
			{name: 'Option', field: 'option', title: "Option", type: 'String'},
			{name: 'Name', field: 'name', title: "Name", type: 'String'}
			],
		rowClasses: [
			{className: 'lowlight', field: 'lowlight'} 
			]}
};

//
// upload functions
//

if (!bidix.upload) bidix.upload = {};

if (!bidix.upload.messages) bidix.upload.messages = {
	//from saving
	invalidFileError: "The original file '%0' does not appear to be a valid TiddlyWiki",
	backupSaved: "Backup saved",
	backupFailed: "Failed to upload backup file",
	rssSaved: "RSS feed uploaded",
	rssFailed: "Failed to upload RSS feed file",
	emptySaved: "Empty template uploaded",
	emptyFailed: "Failed to upload empty template file",
	mainSaved: "Main TiddlyWiki file uploaded",
	mainFailed: "Failed to upload main TiddlyWiki file. Your changes have not been saved",
	//specific upload
	loadOriginalHttpPostError: "Can't get original file",
	aboutToSaveOnHttpPost: 'About to upload on %0 ...',
	storePhpNotFound: "The store script '%0' was not found."
};

bidix.upload.uploadChanges = function(onlyIfDirty,tiddlers,storeUrl,toFilename,uploadDir,backupDir,username,password)
{
	var callback = function(status,uploadParams,original,url,xhr) {
		if (!status) {
			displayMessage(bidix.upload.messages.loadOriginalHttpPostError);
			return;
		}
		if (bidix.debugMode) 
			alert(original.substr(0,500)+"\n...");
		// Locate the storeArea div's 
		var posDiv = locateStoreArea(original);
		if((posDiv[0] == -1) || (posDiv[1] == -1)) {
			alert(config.messages.invalidFileError.format([localPath]));
			return;
		}
		bidix.upload.uploadRss(uploadParams,original,posDiv);
	};
	
	if(onlyIfDirty && !store.isDirty())
		return;
	clearMessage();
	// save on localdisk ?
	if (document.location.toString().substr(0,4) == "file") {
		var path = document.location.toString();
		var localPath = getLocalPath(path);
		saveChanges();
	}
	// get original
	var uploadParams = new Array(storeUrl,toFilename,uploadDir,backupDir,username,password);
	var originalPath = document.location.toString();
	// If url is a directory : add index.html
	if (originalPath.charAt(originalPath.length-1) == "/")
		originalPath = originalPath + "index.html";
	var dest = config.macros.upload.destFile(storeUrl,toFilename,uploadDir);
	var log = new bidix.UploadLog();
	log.startUpload(storeUrl, dest, uploadDir,  backupDir);
	displayMessage(bidix.upload.messages.aboutToSaveOnHttpPost.format([dest]));
	if (bidix.debugMode) 
		alert("about to execute Http - GET on "+originalPath);
	var r = doHttp("GET",originalPath,null,null,username,password,callback,uploadParams,null);
	if (typeof r == "string")
		displayMessage(r);
	return r;
};

bidix.upload.uploadRss = function(uploadParams,original,posDiv) 
{
	var callback = function(status,params,responseText,url,xhr) {
		if(status) {
			var destfile = responseText.substring(responseText.indexOf("destfile:")+9,responseText.indexOf("\n", responseText.indexOf("destfile:")));
			displayMessage(bidix.upload.messages.rssSaved,bidix.dirname(url)+'/'+destfile);
			bidix.upload.uploadMain(params[0],params[1],params[2]);
		} else {
			displayMessage(bidix.upload.messages.rssFailed);			
		}
	};
	// do uploadRss
	if(config.options.chkGenerateAnRssFeed) {
		var rssPath = uploadParams[1].substr(0,uploadParams[1].lastIndexOf(".")) + ".xml";
		var rssUploadParams = new Array(uploadParams[0],rssPath,uploadParams[2],'',uploadParams[4],uploadParams[5]);
		var rssString = generateRss();
		// no UnicodeToUTF8 conversion needed when location is "file" !!!
		if (document.location.toString().substr(0,4) != "file")
			rssString = convertUnicodeToUTF8(rssString);	
		bidix.upload.httpUpload(rssUploadParams,rssString,callback,Array(uploadParams,original,posDiv));
	} else {
		bidix.upload.uploadMain(uploadParams,original,posDiv);
	}
};

bidix.upload.uploadMain = function(uploadParams,original,posDiv) 
{
	var callback = function(status,params,responseText,url,xhr) {
		var log = new bidix.UploadLog();
		if(status) {
			// if backupDir specified
			if ((params[3]) && (responseText.indexOf("backupfile:") > -1))  {
				var backupfile = responseText.substring(responseText.indexOf("backupfile:")+11,responseText.indexOf("\n", responseText.indexOf("backupfile:")));
				displayMessage(bidix.upload.messages.backupSaved,bidix.dirname(url)+'/'+backupfile);
			}
			var destfile = responseText.substring(responseText.indexOf("destfile:")+9,responseText.indexOf("\n", responseText.indexOf("destfile:")));
			displayMessage(bidix.upload.messages.mainSaved,bidix.dirname(url)+'/'+destfile);
			store.setDirty(false);
			log.endUpload("ok");
		} else {
			alert(bidix.upload.messages.mainFailed);
			displayMessage(bidix.upload.messages.mainFailed);
			log.endUpload("failed");			
		}
	};
	// do uploadMain
	var revised = bidix.upload.updateOriginal(original,posDiv);
	bidix.upload.httpUpload(uploadParams,revised,callback,uploadParams);
};

bidix.upload.httpUpload = function(uploadParams,data,callback,params)
{
	var localCallback = function(status,params,responseText,url,xhr) {
		url = (url.indexOf("nocache=") < 0 ? url : url.substring(0,url.indexOf("nocache=")-1));
		if (xhr.status == 404)
			alert(bidix.upload.messages.storePhpNotFound.format([url]));
		if ((bidix.debugMode) || (responseText.indexOf("Debug mode") >= 0 )) {
			alert(responseText);
			if (responseText.indexOf("Debug mode") >= 0 )
				responseText = responseText.substring(responseText.indexOf("\n\n")+2);
		} else if (responseText.charAt(0) != '0') 
			alert(responseText);
		if (responseText.charAt(0) != '0')
			status = null;
		callback(status,params,responseText,url,xhr);
	};
	// do httpUpload
	var boundary = "---------------------------"+"AaB03x";	
	var uploadFormName = "UploadPlugin";
	// compose headers data
	var sheader = "";
	sheader += "--" + boundary + "\r\nContent-disposition: form-data; name=\"";
	sheader += uploadFormName +"\"\r\n\r\n";
	sheader += "backupDir="+uploadParams[3] +
				";user=" + uploadParams[4] +
				";password=" + uploadParams[5] +
				";uploaddir=" + uploadParams[2];
	if (bidix.debugMode)
		sheader += ";debug=1";
	sheader += ";;\r\n"; 
	sheader += "\r\n" + "--" + boundary + "\r\n";
	sheader += "Content-disposition: form-data; name=\"userfile\"; filename=\""+uploadParams[1]+"\"\r\n";
	sheader += "Content-Type: text/html;charset=UTF-8" + "\r\n";
	sheader += "Content-Length: " + data.length + "\r\n\r\n";
	// compose trailer data
	var strailer = new String();
	strailer = "\r\n--" + boundary + "--\r\n";
	data = sheader + data + strailer;
	if (bidix.debugMode) alert("about to execute Http - POST on "+uploadParams[0]+"\n with \n"+data.substr(0,500)+ " ... ");
	var r = doHttp("POST",uploadParams[0],data,"multipart/form-data; ;charset=UTF-8; boundary="+boundary,uploadParams[4],uploadParams[5],localCallback,params,null);
	if (typeof r == "string")
		displayMessage(r);
	return r;
};

// same as Saving's updateOriginal but without convertUnicodeToUTF8 calls
bidix.upload.updateOriginal = function(original, posDiv)
{
	if (!posDiv)
		posDiv = locateStoreArea(original);
	if((posDiv[0] == -1) || (posDiv[1] == -1)) {
		alert(config.messages.invalidFileError.format([localPath]));
		return;
	}
	var revised = original.substr(0,posDiv[0] + startSaveArea.length) + "\n" +
				store.allTiddlersAsHtml() + "\n" +
				original.substr(posDiv[1]);
	var newSiteTitle = getPageTitle().htmlEncode();
	revised = revised.replaceChunk("<title"+">","</title"+">"," " + newSiteTitle + " ");
	revised = updateMarkupBlock(revised,"PRE-HEAD","MarkupPreHead");
	revised = updateMarkupBlock(revised,"POST-HEAD","MarkupPostHead");
	revised = updateMarkupBlock(revised,"PRE-BODY","MarkupPreBody");
	revised = updateMarkupBlock(revised,"POST-SCRIPT","MarkupPostBody");
	return revised;
};

//
// UploadLog
// 
// config.options.chkUploadLog :
//		false : no logging
//		true : logging
// config.options.txtUploadLogMaxLine :
//		-1 : no limit
//      0 :  no Log lines but UploadLog is still in place
//		n :  the last n lines are only kept
//		NaN : no limit (-1)

bidix.UploadLog = function() {
	if (!config.options.chkUploadLog) 
		return; // this.tiddler = null
	this.tiddler = store.getTiddler("UploadLog");
	if (!this.tiddler) {
		this.tiddler = new Tiddler();
		this.tiddler.title = "UploadLog";
		this.tiddler.text = "| !date | !user | !location | !storeUrl | !uploadDir | !toFilename | !backupdir | !origin |";
		this.tiddler.created = new Date();
		this.tiddler.modifier = config.options.txtUserName;
		this.tiddler.modified = new Date();
		store.addTiddler(this.tiddler);
	}
	return this;
};

bidix.UploadLog.prototype.addText = function(text) {
	if (!this.tiddler)
		return;
	// retrieve maxLine when we need it
	var maxLine = parseInt(config.options.txtUploadLogMaxLine,10);
	if (isNaN(maxLine))
		maxLine = -1;
	// add text
	if (maxLine != 0) 
		this.tiddler.text = this.tiddler.text + text;
	// Trunck to maxLine
	if (maxLine >= 0) {
		var textArray = this.tiddler.text.split('\n');
		if (textArray.length > maxLine + 1)
			textArray.splice(1,textArray.length-1-maxLine);
			this.tiddler.text = textArray.join('\n');		
	}
	// update tiddler fields
	this.tiddler.modifier = config.options.txtUserName;
	this.tiddler.modified = new Date();
	store.addTiddler(this.tiddler);
	// refresh and notifiy for immediate update
	story.refreshTiddler(this.tiddler.title);
	store.notify(this.tiddler.title, true);
};

bidix.UploadLog.prototype.startUpload = function(storeUrl, toFilename, uploadDir,  backupDir) {
	if (!this.tiddler)
		return;
	var now = new Date();
	var text = "\n| ";
	var filename = bidix.basename(document.location.toString());
	if (!filename) filename = '/';
	text += now.formatString("0DD/0MM/YYYY 0hh:0mm:0ss") +" | ";
	text += config.options.txtUserName + " | ";
	text += "[["+filename+"|"+location + "]] |";
	text += " [[" + bidix.basename(storeUrl) + "|" + storeUrl + "]] | ";
	text += uploadDir + " | ";
	text += "[[" + bidix.basename(toFilename) + " | " +toFilename + "]] | ";
	text += backupDir + " |";
	this.addText(text);
};

bidix.UploadLog.prototype.endUpload = function(status) {
	if (!this.tiddler)
		return;
	this.addText(" "+status+" |");
};

//
// Utilities
// 

bidix.checkPlugin = function(plugin, major, minor, revision) {
	var ext = version.extensions[plugin];
	if (!
		(ext  && 
			((ext.major > major) || 
			((ext.major == major) && (ext.minor > minor))  ||
			((ext.major == major) && (ext.minor == minor) && (ext.revision >= revision))))) {
			// write error in PluginManager
			if (pluginInfo)
				pluginInfo.log.push("Requires " + plugin + " " + major + "." + minor + "." + revision);
			eval(plugin); // generate an error : "Error: ReferenceError: xxxx is not defined"
	}
};

bidix.dirname = function(filePath) {
	if (!filePath) 
		return;
	var lastpos;
	if ((lastpos = filePath.lastIndexOf("/")) != -1) {
		return filePath.substring(0, lastpos);
	} else {
		return filePath.substring(0, filePath.lastIndexOf("\\"));
	}
};

bidix.basename = function(filePath) {
	if (!filePath) 
		return;
	var lastpos;
	if ((lastpos = filePath.lastIndexOf("#")) != -1) 
		filePath = filePath.substring(0, lastpos);
	if ((lastpos = filePath.lastIndexOf("/")) != -1) {
		return filePath.substring(lastpos + 1);
	} else
		return filePath.substring(filePath.lastIndexOf("\\")+1);
};

bidix.initOption = function(name,value) {
	if (!config.options[name])
		config.options[name] = value;
};

//
// Initializations
//

// require PasswordOptionPlugin 1.0.1 or better
bidix.checkPlugin("PasswordOptionPlugin", 1, 0, 1);

// styleSheet
setStylesheet('.txtUploadStoreUrl, .txtUploadBackupDir, .txtUploadDir {width: 22em;}',"uploadPluginStyles");

//optionsDesc
merge(config.optionsDesc,{
	txtUploadStoreUrl: "Url of the UploadService script (default: store.php)",
	txtUploadFilename: "Filename of the uploaded file (default: in index.html)",
	txtUploadDir: "Relative Directory where to store the file (default: . (downloadService directory))",
	txtUploadBackupDir: "Relative Directory where to backup the file. If empty no backup. (default: ''(empty))",
	txtUploadUserName: "Upload Username",
	pasUploadPassword: "Upload Password",
	chkUploadLog: "do Logging in UploadLog (default: true)",
	txtUploadLogMaxLine: "Maximum of lines in UploadLog (default: 10)"
});

// Options Initializations
bidix.initOption('txtUploadStoreUrl','');
bidix.initOption('txtUploadFilename','');
bidix.initOption('txtUploadDir','');
bidix.initOption('txtUploadBackupDir','');
bidix.initOption('txtUploadUserName','');
bidix.initOption('pasUploadPassword','');
bidix.initOption('chkUploadLog',true);
bidix.initOption('txtUploadLogMaxLine','10');


// Backstage
merge(config.tasks,{
	uploadOptions: {text: "upload", tooltip: "Change UploadOptions and Upload", content: '<<uploadOptions>>'}
});
config.backstageTasks.push("uploadOptions");


//}}}

[[VMWare - Virtual Switches]]
[[VMWare - Port Groups]]
[[VMWare - VMkernel services]]
[[VMWare - IP Storage]]
[[VMWare - iSCSI]]
[[VMWare - VMotion]]
[[VMWare - VLAN]]
[[VMWare - NIC teaming]]
[[VMWare - Migration]]



*refers to any form of storage that uses TCP/IP network communication
*iSCSI
*NFS
*''Migration'' = Moving a virtual machine from one host to another
*ESX Server 3 doesn’t support virtual machine migration between hosts in different broadcast domains
*''NIC teaming'' requires both Ethernet devices to be on the same Ethernet broadcast domain
*Port groups aggregate multiple ports under a common configuration and provide a stable anchor point for virtual machines connecting to labeled networks. 
*Each port group is identified by a network label, which is unique to the current host.
*maximum: ''512 port groups'' on a single host
*a VLAN ID is optional
*For a port group to reach port groups located on other VLANs, set the ''VLAN ID'' to ''4095''
*VLAN ID:''1- 4094''
>If you enter ''0'' or leave the field blank, the port group can see ''only untagged (non‐VLAN) traffic''. 
>If you enter ''4095'', the port group can see traffic on ''any VLAN'' while ''leaving the VLAN tags intact''.
NFS
iSCSI
VMotion
This TCP/IP stack is completely separate from the TCP/IP stack used in the service console.
*''VMotion'' = Migrating a virtual machine that is powered
*only one VMotion and IP storage port group for each ESX Server 3 host
*If VMotion property is not enabled for any port group, migration with VMotion to this host is not possible

*maximum: 127 vSwitches on a single host
*default: 56 logical ports per vSwitch
*maximum: 1016 logical ports per switch in ESX Server 3
*You can connect one network adapter of a virtual machine to each port.
*Each uplink adapter associated with a vSwitch uses one port.
*Each logical port on the vSwitch is a member of a single port group.
*Each vSwitch can also have one or more port groups assigned to it.
*You can create a new vSwitch with or without Ethernet adapters
*Virtual machines reach physical networks through uplink adapters
*iSCSI has a service console component, so networks that are used to reach iSCSI targets must be accessible to both service console and VMkernel TCP/IP stacks
http://en.wikipedia.org/wiki/WebScarab
[[WebSphere Application Server default ports]]
[[WebSphere Applications on localhost]]
[[WebSphere - Change hostname]]
*''http://www-01.ibm.com/support/docview.wss?uid=swg27005391&aid=1''
*''Procedure to alter the hostName property of ND node''

1. Always perform backupConfig before making significant configuration changes.

2. Ensure that Deployment Manager, nodeagent, jmsserver and all server processes has been stopped in the entire Cell. Also verify that no WebSphere java process or WASService.exe process is running.
{{{
<WAS_ND_HOME>/bin/stopManager (.bat/.sh) -username <name> -password <password>
<WAS_HOME>/bin/stopNode (.bat/.sh) -username <name> -password <password>
<WAS_HOME>/bin/stopServer (.bat/.sh) <server> -username <name> -password <password>
}}}
Note: On Windows platform, if Windows Service is used to start Deployment Manager, nodeagent, jmsserver and servers then use Windows Services panel to stop them.

3. In the ''serverindex.xml'' file for the ND being modified, alter the value of the hostName property for the ServerIndex element in the file. Search for string ''“hostName=”'' to find this property.
{{{
<WAS_ND_HOME>/config/cells/<cell>/nodes/<nodeManager>/serverindex.xml
}}}
Also in the serverindex.xml file for the node being modified, alter the host property for every EndPoint in the file. Search all occurrences of ''“host=”'' string in following ''serverindex.xml''
{{{
<WAS_ND_HOME>/config/cells/<cell>/nodes/<nodeManager>/serverindex.xml
}}}
4. In ND server.xml file on the node being modified, alter the host property everywhere it is used in the document. If ''host=””'' specified, do not alter it.
{{{
<WAS_ND_HOME>/config/cells/<cell>/nodes/<nodeManager>/servers/dmgr/server.xml
}}}
5. Edit the ''wsadmin.properties'' file in the properties subdirectory under the installation root. Change the value of the ''com.ibm.ws.scripting.host'' property in that file to the new host address.
{{{
<WAS_ND_HOME>/properties/wsadmin.properties
}}}
Repeat above step for every Node in the Cell; since wsadmin utility on all nodes in the Cell should connect to ND.
{{{
<WAS_HOME>/properties/wsadmin.properties
}}}
6. Edit the ''orb.properties'' file in the subdirectory ''java/jre/lib'' under the installation root. Change the value of the com.ibm.CORBA.LocalHost property in that file to the new host address.
{{{
<WAS_ND_HOME>/java/jre/lib/orb.properties
}}}
7. Delete the following sub-directories entirely.
{{{
<WAS_ND_HOME>/wstemp
<WAS_ND_HOME>/config/temp
}}}
8. After all documents for the ND and nodes have been updated, start Deployment Manager by
{{{
<WAS_ND_HOME>/bin/startManager (.bat/.sh) -username <name> -password <password>
}}}
Note: On Windows platform, if Windows Services is used to stop Deployment Manager; then use Windows Services panel to start it.

9. Once DMGR process is running, execute the ''syncNode'' tool on each node in the cell containing the node being modified. SyncNode will replicate the configuration containing the changed hostName property to the local node. Once syncNode has been executed, the node should be functional again within the cell, with a new hostName property.
{{{
<WAS_HOME>/bin/syncNode (.bat/.sh) <dmgr_host> <dmgr_soap_port> -username <name> -password <password>
}}}
Note: syncNode command may take substantial time based on the size of the Cell, so give it enough time to complete.

10. Start each nodeagent by following command and verify that nodeagent is visible in the ND Administrative Console.
{{{
<WAS_HOME>/bin/startNode (.bat/.sh) -username <name> -password <password>
}}}
Note: On Windows platform, if Windows Services is used to stop nodeagent, use Windows Services panel to start it.

11. Start servers on each node by following command.
{{{
<WAS_HOME>/bin/startServer (.bat/.sh) <server> -username <name> -password <password>
}}}
Note: On Windows platform, if Windows Services is used to stop servers, use Windows Services panel to start them.
''Web container port (HTTP_TRANSPORT)''
>Default value: ''9080''
>Configuration file: server.xml, plugin-cfg.xml, virtualhosts.xml
>Description: The TCP/IP port on which the Web container listens for requests from the Web server. You can specify this port with the administrative console or with the chgwassvr script. For more information, see The chgwassvr script. If you change this port, you must regenerate the Web server plug-in configuration for the application server.
''Web container secure port (HTTPS_TRANSPORT)''
>Default value: ''9443''
>Configuration file: server.xml, plugin-cfg.xml, virtualhosts.xml
>Description: The TCP/IP port on which the Web container listens for secure requests from the Web server. You can specify this port with the administrative console or with the chgwassvr script. For more information, see The chgwassvr script. If you change this port number, remember the following information:
>To use secure (SSL enabled) ports you must have the OS/400 Digital Certificate Manager product (5722SS1 option 34) and a Cryptographic Access Provider product (such as 5722AC3) installed.
>If you change this port, you must regenerate the Web server plug-in configuration for the application server.
''Administrative console port (HTTP_TRANSPORT_ADMIN)''
>Default value: ''9090''
>Configuration file: server.xml, virtualhosts.xml
>Description: The TCP/IP port on which the Web container listens for requests for the administrative application. You can specify this port with the administrative console or with the chgwassvr script. For more information, see The chgwassvr script.
''Adminstrative console secure port (HTTPS_TRANSPORT_ADMIN)''
>Default value: ''9043''
>Configuration file: server.xml, virtualhosts.xml
>Description: The TCP/IP port on which the Web container listens for secure requests for the administrative application. You can specify this port with the administrative console or with the chgwassvr script. For more information, see The chgwassvr script.
''Name service or RMI connector port (BOOTSTRAP_ADDRESS)''
>Default value: ''2809''
>Configuration file: serverindex.xml
>Description: The TCP/IP port on which the name service listens. This port is also the RMI connector port. Specify this port with the administrative console or with the chgwassvr script. For more information, see The chgwassvr script.
''Simple Object Access Protocol (SOAP) port (SOAP_CONNECTOR_ADDRESS)''
>Default value: ''8880''
>Configuration file: serverindex.xml
>Description: The TCP/IP port that your server uses for Simple Object Access Protocol (SOAP). Specify this port with the administrative console or with the chgwassvr script. For more information, see The chgwassvr script.
''Data replication service client port (DRS_CLIENT_ADDRESS)''
>Default value: ''7873''
>Configuration file: serverindex.xml
>Description: The TCP/IP port that your server uses for the Data Replication Service (DRS) client. Specify this port with the administrative console or with the chgwassvr script. For more information, see The chgwassvr script.
''Java Message Service (JMS) queued port (JMSSERVER_QUEUED_ADDRESS)''
>Default value: ''5558''
>Configuration file: serverindex.xml
>Description: The TCP/IP port that the internal JMS provider's WebSphere MQ listener uses. This listener is used by JMS connections to communicate with the internal JMS provider. Specify this port with the administrative console or with the chgwassvr script. For more information, see The chgwassvr script.
''MS security port (JMSSERVER_SECURITY_PORT)''
>Default value: ''5557''
>Configuration file: serverindex.xml
>Description: The TCP/IP port that the internal JMS provider uses to communicate with the internal JMS provider to verify authorizations to resources when WebSphere Application Server security is enabled. Specify this port with the administrative console or with the chgwassvr script. For more information, see The chgwassvr script.
''JMS direct port (JMSSERVER_DIRECT_ADDRESS)''
>Default value: ''5559''
>Configuration file: serverindex.xml
>Description: The TCP/IP port that the internal JMS provider uses to communicate with the internal JMS provider for JMS publish/subscribe connections when the WebSphere Topic Connection Factory resource port is set to DIRECT. Specify this port with the administrative console or with the chgwassvr script. For more information, see The chgwassvr script.
''Secure Association Services (SAS) SSL server authentication port (SAS_SSL_SERVERAUTH_LISTENER_ADDRESS)''
>Default value: ''9501''
>Configuration file: serverindex.xml
>Description: The TCP/IP port on which the Secure Association Services (SAS) listen for inbound authentication requests. The default value of 0 indicates that the next available port should be used. Specify this port with the administrative console or with the chgwassvr script. For more information, see The chgwassvr script.
''Common Secure Interoperability Version 2 (CSIV2) server transport port (CSIV2_SSL_SERVERAUTH_LISTENER_ADDRESS)''
>Default value: ''9503''
>Configuration file: serverindex.xml
>Description: The TCP/IP port on which the Common Secure Interoperability Verison 2 (CSIV2) Service listens for inbound server authentication requests. The default value of 0 indicates that the next available port should be used. Specify this port with the administrative console or with the chgwassvr script. For more information, see The chgwassvr script.
''CSIV2 client transport port (CSIV2_SSL_MUTUALAUTH_LISTENER_ADDRESS)''
>Default value: ''9502''
>Configuration file: serverindex.xml
>Description: The TCP/IP port on which the Common Secure Interoperability Verison 2 (CSIV2) Service listens for inbound client authentication requests. The default value of 0 indicates that the next available port should be used. Specify this port with the administrative console or with the chgwassvr script. For more information, see The chgwassvr script.



http://localhost:9080/snoop/
http://localhost:9080/HelloHTML.jsp
http://localhost:9080/HitCount.jsp
http://localhost:9080/WSsamples/en/index.html
http://localhost:9090/admin/
[img[http://lh4.ggpht.com/_odP7v2tr9u4/SmdbpAXsu0I/AAAAAAAACc8/jIA5L5rOWB0/s640/IMG_2128.JPG][http://picasaweb.google.com/hvanbelle/Werfenweg2008#slideshow]]
[[domains]]
[[Xen - Commands]]
|!Command|!Description|
|xend start|start the xen-deamon|
|xend stop|stop the xen-deamon|
|xend restart|restart the xen-deamon|
|xend status|get the status of the deamon|
|xm create -c myvmconf vmid=1|create a new virtual machine using config file myvmconf ans pass paramater vmid to script|
|xm list|list all domains|
|xm list -l|list all domains long format|
|xm console myVM|get access to the console of machine myVM|
{{{
HANDY ONE-LINERS FOR AWK                                  22 July 2003
compiled by Eric Pement <pemente@northpark.edu>           version 0.22
   Latest version of this file is usually at:
   http://www.student.northpark.edu/pemente/awk/awk1line.txt


USAGE:

    Unix:  awk '/pattern/ {print "$1"}'    # standard Unix shells
 DOS/Win:  awk '/pattern/ {print "$1"}'    # okay for DJGPP compiled
           awk "/pattern/ {print \"$1\"}"  # required for Mingw32

Most of my experience comes from version of GNU awk (gawk) compiled for
Win32. Note in particular that DJGPP compilations permit the awk script
to follow Unix quoting syntax '/like/ {"this"}'. However, the user must
know that single quotes under DOS/Windows do not protect the redirection
arrows (<, >) nor do they protect pipes (|). Both are special symbols
for the DOS/CMD command shell and their special meaning is ignored only
if they are placed within "double quotes." Likewise, DOS/Win users must
remember that the percent sign (%) is used to mark DOS/Win environment
variables, so it must be doubled (%%) to yield a single percent sign
visible to awk.

If I am sure that a script will NOT need to be quoted in Unix, DOS, or
CMD, then I normally omit the quote marks. If an example is peculiar to
GNU awk, the command 'gawk' will be used. Please notify me if you find
errors or new commands to add to this list (total length under 65
characters). I usually try to put the shortest script first.

FILE SPACING:

 # double space a file
 awk '1;{print ""}'
 awk 'BEGIN{ORS="\n\n"};1'

 # double space a file which already has blank lines in it. Output file
 # should contain no more than one blank line between lines of text.
 # NOTE: On Unix systems, DOS lines which have only CRLF (\r\n) are
 # often treated as non-blank, and thus 'NF' alone will return TRUE.
 awk 'NF{print $0 "\n"}'

 # triple space a file
 awk '1;{print "\n"}'

NUMBERING AND CALCULATIONS:

 # precede each line by its line number FOR THAT FILE (left alignment).
 # Using a tab (\t) instead of space will preserve margins.
 awk '{print FNR "\t" $0}' files*

 # precede each line by its line number FOR ALL FILES TOGETHER, with tab.
 awk '{print NR "\t" $0}' files*

 # number each line of a file (number on left, right-aligned)
 # Double the percent signs if typing from the DOS command prompt.
 awk '{printf("%5d : %s\n", NR,$0)}'

 # number each line of file, but only print numbers if line is not blank
 # Remember caveats about Unix treatment of \r (mentioned above)
 awk 'NF{$0=++a " :" $0};{print}'
 awk '{print (NF? ++a " :" :"") $0}'

 # count lines (emulates "wc -l")
 awk 'END{print NR}'

 # print the sums of the fields of every line
 awk '{s=0; for (i=1; i<=NF; i++) s=s+$i; print s}'

 # add all fields in all lines and print the sum
 awk '{for (i=1; i<=NF; i++) s=s+$i}; END{print s}'

 # print every line after replacing each field with its absolute value
 awk '{for (i=1; i<=NF; i++) if ($i < 0) $i = -$i; print }'
 awk '{for (i=1; i<=NF; i++) $i = ($i < 0) ? -$i : $i; print }'

 # print the total number of fields ("words") in all lines
 awk '{ total = total + NF }; END {print total}' file

 # print the total number of lines that contain "Beth"
 awk '/Beth/{n++}; END {print n+0}' file

 # print the largest first field and the line that contains it
 # Intended for finding the longest string in field #1
 awk '$1 > max {max=$1; maxline=$0}; END{ print max, maxline}'

 # print the number of fields in each line, followed by the line
 awk '{ print NF ":" $0 } '

 # print the last field of each line
 awk '{ print $NF }'

 # print the last field of the last line
 awk '{ field = $NF }; END{ print field }'

 # print every line with more than 4 fields
 awk 'NF > 4'

 # print every line where the value of the last field is > 4
 awk '$NF > 4'


TEXT CONVERSION AND SUBSTITUTION:

 # IN UNIX ENVIRONMENT: convert DOS newlines (CR/LF) to Unix format
 awk '{sub(/\r$/,"");print}'   # assumes EACH line ends with Ctrl-M

 # IN UNIX ENVIRONMENT: convert Unix newlines (LF) to DOS format
 awk '{sub(/$/,"\r");print}

 # IN DOS ENVIRONMENT: convert Unix newlines (LF) to DOS format
 awk 1

 # IN DOS ENVIRONMENT: convert DOS newlines (CR/LF) to Unix format
 # Cannot be done with DOS versions of awk, other than gawk:
 gawk -v BINMODE="w" '1' infile >outfile

 # Use "tr" instead.
 tr -d \r <infile >outfile            # GNU tr version 1.22 or higher

 # delete leading whitespace (spaces, tabs) from front of each line
 # aligns all text flush left
 awk '{sub(/^[ \t]+/, ""); print}'

 # delete trailing whitespace (spaces, tabs) from end of each line
 awk '{sub(/[ \t]+$/, "");print}'

 # delete BOTH leading and trailing whitespace from each line
 awk '{gsub(/^[ \t]+|[ \t]+$/,"");print}'
 awk '{$1=$1;print}'           # also removes extra space between fields

 # insert 5 blank spaces at beginning of each line (make page offset)
 awk '{sub(/^/, "     ");print}'

 # align all text flush right on a 79-column width
 awk '{printf "%79s\n", $0}' file*

 # center all text on a 79-character width
 awk '{l=length();s=int((79-l)/2); printf "%"(s+l)"s\n",$0}' file*

 # substitute (find and replace) "foo" with "bar" on each line
 awk '{sub(/foo/,"bar");print}'           # replaces only 1st instance
 gawk '{$0=gensub(/foo/,"bar",4);print}'  # replaces only 4th instance
 awk '{gsub(/foo/,"bar");print}'          # replaces ALL instances in a line

 # substitute "foo" with "bar" ONLY for lines which contain "baz"
 awk '/baz/{gsub(/foo/, "bar")};{print}'

 # substitute "foo" with "bar" EXCEPT for lines which contain "baz"
 awk '!/baz/{gsub(/foo/, "bar")};{print}'

 # change "scarlet" or "ruby" or "puce" to "red"
 awk '{gsub(/scarlet|ruby|puce/, "red"); print}'

 # reverse order of lines (emulates "tac")
 awk '{a[i++]=$0} END {for (j=i-1; j>=0;) print a[j--] }' file*

 # if a line ends with a backslash, append the next line to it
 # (fails if there are multiple lines ending with backslash...)
 awk '/\\$/ {sub(/\\$/,""); getline t; print $0 t; next}; 1' file*

 # print and sort the login names of all users
 awk -F ":" '{ print $1 | "sort" }' /etc/passwd

 # print the first 2 fields, in opposite order, of every line
 awk '{print $2, $1}' file

 # switch the first 2 fields of every line
 awk '{temp = $1; $1 = $2; $2 = temp}' file

 # print every line, deleting the second field of that line
 awk '{ $2 = ""; print }'

 # print in reverse order the fields of every line
 awk '{for (i=NF; i>0; i--) printf("%s ",i);printf ("\n")}' file

 # remove duplicate, consecutive lines (emulates "uniq")
 awk 'a !~ $0; {a=$0}'

 # remove duplicate, nonconsecutive lines
 awk '! a[$0]++'                     # most concise script
 awk '!($0 in a) {a[$0];print}'      # most efficient script

 # concatenate every 5 lines of input, using a comma separator
 # between fields
 awk 'ORS=%NR%5?",":"\n"' file



SELECTIVE PRINTING OF CERTAIN LINES:

 # print first 10 lines of file (emulates behavior of "head")
 awk 'NR < 11'

 # print first line of file (emulates "head -1")
 awk 'NR>1{exit};1'

  # print the last 2 lines of a file (emulates "tail -2")
 awk '{y=x "\n" $0; x=$0};END{print y}'

 # print the last line of a file (emulates "tail -1")
 awk 'END{print}'

 # print only lines which match regular expression (emulates "grep")
 awk '/regex/'

 # print only lines which do NOT match regex (emulates "grep -v")
 awk '!/regex/'

 # print the line immediately before a regex, but not the line
 # containing the regex
 awk '/regex/{print x};{x=$0}'
 awk '/regex/{print (x=="" ? "match on line 1" : x)};{x=$0}'

 # print the line immediately after a regex, but not the line
 # containing the regex
 awk '/regex/{getline;print}'

 # grep for AAA and BBB and CCC (in any order)
 awk '/AAA/; /BBB/; /CCC/'

 # grep for AAA and BBB and CCC (in that order)
 awk '/AAA.*BBB.*CCC/'

 # print only lines of 65 characters or longer
 awk 'length > 64'

 # print only lines of less than 65 characters
 awk 'length < 64'

 # print section of file from regular expression to end of file
 awk '/regex/,0'
 awk '/regex/,EOF'

 # print section of file based on line numbers (lines 8-12, inclusive)
 awk 'NR==8,NR==12'

 # print line number 52
 awk 'NR==52'
 awk 'NR==52 {print;exit}'          # more efficient on large files

 # print section of file between two regular expressions (inclusive)
 awk '/Iowa/,/Montana/'             # case sensitive


SELECTIVE DELETION OF CERTAIN LINES:

 # delete ALL blank lines from a file (same as "grep '.' ")
 awk NF
 awk '/./'


CREDITS AND THANKS:

Special thanks to Peter S. Tillier for helping me with the first release
of this FAQ file.

For additional syntax instructions, including the way to apply editing
commands from a disk file instead of the command line, consult:

"sed & awk, 2nd Edition," by Dale Dougherty and Arnold Robbins
  O'Reilly, 1997
"UNIX Text Processing," by Dale Dougherty and Tim O'Reilly
  Hayden Books, 1987
"Effective awk Programming, 3rd Edition." by Arnold Robbins
  O'Reilly, 2001

To fully exploit the power of awk, one must understand "regular
expressions." For detailed discussion of regular expressions, see
"Mastering Regular Expressions, 2d edition" by Jeffrey Friedl
   (O'Reilly, 2002).

The manual ("man") pages on Unix systems may be helpful (try "man awk",
"man nawk", "man regexp", or the section on regular expressions in "man
ed"), but man pages are notoriously difficult. They are not written to
teach awk use or regexps to first-time users, but as a reference text
for those already acquainted with these tools.

USE OF '\t' IN awk SCRIPTS: For clarity in documentation, we have used
the expression '\t' to indicate a tab character (0x09) in the scripts.
All versions of awk, even the UNIX System 7 version should recognize
the '\t' abbreviation.

#---end of file---
}}}
awk 'NR % 2' data
{{{
#!/usr/bin/perl -w                                      # camel code
use strict;

                                           $_='ev
                                       al("seek\040D
           ATA,0,                  0;");foreach(1..3)
       {<DATA>;}my               @camel1hump;my$camel;
  my$Camel  ;while(             <DATA>){$_=sprintf("%-6
9s",$_);my@dromedary           1=split(//);if(defined($
_=<DATA>)){@camel1hum        p=split(//);}while(@dromeda
 ry1){my$camel1hump=0      ;my$CAMEL=3;if(defined($_=shif
        t(@dromedary1    ))&&/\S/){$camel1hump+=1<<$CAMEL;}
       $CAMEL--;if(d   efined($_=shift(@dromedary1))&&/\S/){
      $camel1hump+=1  <<$CAMEL;}$CAMEL--;if(defined($_=shift(
     @camel1hump))&&/\S/){$camel1hump+=1<<$CAMEL;}$CAMEL--;if(
     defined($_=shift(@camel1hump))&&/\S/){$camel1hump+=1<<$CAME
     L;;}$camel.=(split(//,"\040..m`{/J\047\134}L^7FX"))[$camel1h
      ump];}$camel.="\n";}@camel1hump=split(/\n/,$camel);foreach(@
      camel1hump){chomp;$Camel=$_;y/LJF7\173\175`\047/\061\062\063\
      064\065\066\067\070/;y/12345678/JL7F\175\173\047`/;$_=reverse;
       print"$_\040$Camel\n";}foreach(@camel1hump){chomp;$Camel=$_;y
        /LJF7\173\175`\047/12345678/;y/12345678/JL7F\175\173\0 47`/;
         $_=reverse;print"\040$_$Camel\n";}';;s/\s*//g;;eval;   eval
           ("seek\040DATA,0,0;");undef$/;$_=<DATA>;s/\s*//g;(   );;s
             ;^.*_;;;map{eval"print\"$_\"";}/.{4}/g; __DATA__   \124
               \1   50\145\040\165\163\145\040\157\1 46\040\1  41\0
                    40\143\141  \155\145\1 54\040\1   51\155\  141
                    \147\145\0  40\151\156 \040\141    \163\16 3\
                     157\143\   151\141\16  4\151\1     57\156
                     \040\167  \151\164\1   50\040\      120\1
                     45\162\   154\040\15    1\163\      040\14
                     1\040\1   64\162\1      41\144       \145\
                     155\14    1\162\       153\04        0\157
                      \146\     040\11     7\047\         122\1
                      45\15      1\154\1  54\171          \040
                      \046\         012\101\16            3\16
                      3\15           7\143\15             1\14
                      1\16            4\145\163           \054
                     \040            \111\156\14         3\056
                    \040\         125\163\145\14         4\040\
                    167\1        51\164\1  50\0         40\160\
                  145\162                              \155\151
                \163\163                                \151\1
              57\156\056
}}}
{{{
#!/usr/bin/perl

use File::Find;

$dir = "c:/web";
find(\&edits, $dir);

sub edits() {
    $seen = 0;
    if ( -f and /.html?/ ) {
        $file = $_;
        open FILE, $file;
        @lines = <FILE>;
        close FILE;

        for $line ( @lines ) {
            if ( $line =~ s/Lesson/Chapter/  ) {
                $seen++;
            }
        }
        open FILE, ">$file";
        print @lines;
        close FILE;
    }
}

print "Found in $File::Find::name\n" if $seen > 0;
}}}
{{{
#!/usr/local/bin/perl
#
# Change raw timecode data to different format
#
# timecode data event looks like:
# 
# Event: 1
# 00:01:05:23
# 00:01:27:21
# a-2-9
# 
# Event: 2
# 00:01:56:13
# 00:02:03:19
# a-3-9
# 
# ...and so on...
#
# Want to change it to the form:
#
# a-2-9 = 21.93 seconds = 658 frames
# a-3-9 = 7.20 seconds = 216 frames
#

open(FP,"<log.txt");

$first = 1;
$total = 0;

while($line = <FP>) {

    if ($line =~ /^\d\d/ && $first) {
	$in = $line;
	$first = 0;
    } elsif ($line =~ /^\d\d/ && !$first) {
	$out = $line;
	$first = 1;
    } elsif ($line =~ /^\w-/) {
	$shot = $line;
	chop($shot);

	# parse timecodes and
	# translate in and out into seconds
	$in =~ /(\d\d):(\d\d):(\d\d):(\d\d)/;
	$hrs = $1;
	$mns = $2;
	$scs = $3;
	$fms = $4;
	$inSecs = $hrs * 3600 + $mns * 60 + $scs + $fms / 30;

	$out =~ /(\d\d):(\d\d):(\d\d):(\d\d)/;
	$hrs = $1;
	$mns = $2;
	$scs = $3;
	$fms = $4;
	$outSecs = $hrs * 3600 + $mns * 60 + $scs + $fms / 30;

	# calc duration
	$dur = $outSecs - $inSecs;
	$total += $dur;

	# print line
	printf("$shot = %.2f seconds = %d frames\n", $dur, $dur * 30);
    }
}

print "total = ".($total / 60)." mins\n";

close FP;
}}}
{{{
sub copy_directory {
my ($source, $dest) = @_;
my $start = time;

# get the contents of the directory.
opendir(D, $source);
my @f = readdir(D);
closedir(D);

# recurse through the directory structure and copy files.
foreach my $file (@f) {
    # Setup the full path to the source and dest files.
    my $filename = $source . "\\" . $file;
    my $destfile = $dest . "\\" . $file;

    # get the file info for the 2 files.
    my $sourceInfo = stat( $filename );
    my $destInfo = stat( $destfile );

    # make sure the destinatin directory exists.
    mkdir( $dest, 0777 );

    if ($file eq '.' || $file eq '..') {
    } elsif (-d $filename) { # if it's a directory then recurse into it.
        #print "entering $filename\n";
        copy_directory($filename, $destfile); 
    } else { 
        # Only backup the file if it has been created/modified since the last backup 
        if( (not -e $destfile) || ($sourceInfo->mtime > $destInfo->mtime ) ) {
            #print $filename . " -> " . $destfile . "\n";
            copy( $filename, $destfile ) or print "Error copying $filename: $!\n";
        } 
    } 
}

print "$source copied in " . (time - $start) . " seconds.\n";           
}
}}}
{{{
#!/usr/local/bin/perl
#
# create a series of directories
#
if ($#ARGV != 2) {
    print "usage: mkdirs base start stop\n";
    exit;
}

$base = $ARGV[0];
$start = $ARGV[1];
$stop = $ARGV[2];

for ($i=$start; $i <= $stop; $i++) {

    $num = $i;
    if($i<10) {	$num = "00$i"; }
    elsif($i<100) { $num = "0$i"; }

    $cmd = "mkdir $base$num";
    print $cmd."\n";
    if(system($cmd)) { print "mkdir failed\n"; }
}
}}}
{{{
# File: crypt-example-1.py

import crypt

import random, string

def getsalt(chars = string.letters + string.digits):
    # generate a random 2-character 'salt'
    return random.choice(chars) + random.choice(chars)

print crypt.crypt("bananas", getsalt())
}}}
{{{
# File: crypt-example-2.py

import pwd, crypt

def login(user, password):
    "Check if user would be able to login using password"
    try:
        pw1 = pwd.getpwnam(user)[1]
        pw2 = crypt.crypt(password, pw1[:2])
        return pw1 == pw2
    except KeyError:
        return 0 # no such user

user = raw_input("username:")
password = raw_input("password:")

if login(user, password):
    print "welcome", user
else:
    print "login failed"

}}}
*edit/create .profile
>''ln -s /cygdrive/d/appl/cygwin/ /usr''
http://effbot.org/librarybook/datetime.htm
{{{
# File: python datetime-example-3.py

import datetime
import time

now = datetime.datetime.now()

print now
print now.ctime()
print now.isoformat()
print now.strftime("%Y%m%dT%H%M%S")
}}}

$ python datetime-example-3.py
2003-08-05 21:36:11.590000
Tue Aug  5 21:36:11 2003
2003-08-05T21:36:11.590000
20030805T213611
*domain 0
**is th first domain
**created automatically when the system boots
**has special management privileges
**builds other domains 
**manages other domains virtual devices
**performs administrative tasks such as ''suspending'', ''resuming'' and ''migrating'' other virtual machines
**Within domain 0, a process called xend runs to manage the system
**provide access to other domains consoles
**Commands are issued to xend over an HTTP interface, via a command-line tool
{{{
#!/usr/local/bin/perl
#
# convert series of images from one format to another
#
if ($#ARGV != 5) {
    print "usage: fconvert intype outtype old new start stop\n";
    exit;
}

$intype = $ARGV[0];
$outtype = $ARGV[1];
$old = $ARGV[2];
$new = $ARGV[3];
$start = $ARGV[4];
$stop = $ARGV[5];

for ($i=$start; $i <= $stop; $i++) {

    $num = $i;
    if($i<10) {	$num = "00$i"; }
    elsif($i<100) { $num = "0$i"; }

    $cmd = "imgcvt -i $intype -o $outtype $old.$num $new.$num";
    print $cmd."\n";
    if(system($cmd)) { print "imgcvt failed\n"; }
}
}}}
{{{
#!/usr/local/bin/perl
#
# search for a file in all subdirectories
#
if ($#ARGV != 0) {
    print "usage: findfile filename\n";
    exit;
}

$filename = $ARGV[0];

# look in current directory
$dir = `pwd`;
chop($dir);
&searchDirectory($dir);

sub searchDirectory {
    local($dir);
    local(@lines);
    local($line);
    local($file);
    local($subdir);

    $dir = $_[0];

    # check for permission
    if(-x $dir) {

	# search this directory
	@lines = `cd $dir; ls -l | grep $filename`;
	foreach $line (@lines) {
	    $line =~ /\s+(\S+)$/;
	    $file = $1;
	    print "Found $file in $dir\n";
	}
	
	# search any sub directories
	@lines = `cd $dir; ls -l`;
	foreach $line (@lines) {
	    if($line =~ /^d/) {
		$line =~ /\s+(\S+)$/;
		$subdir = $dir."/".$1;
		&searchDirectory($subdir);
	    }
	}
    }
}
}}}
{{{
#!/usr/local/bin/perl
#
# search list of machines for machines with no users logged on
#
$machines = `systems sgi`;
chop($machines);
@sgis = split(/ /, $machines);
@sgis = sort(@sgis);

foreach $machine (@sgis) {

    if(!(`rusers $machine`)) {
	print "$machine\n";
    }
}
}}}
{{{
#!/usr/local/bin/perl
#
# search for processes running on machines
#

if ($#ARGV != 0) {
    print "usage: findprocess process\n";
    exit;
}

$process = $ARGV[0];
$machines = `systems sgi`;
chop($machines);
@sgis = split(/ /,$machines);
@sgis = sort(@sgis);

foreach $machine (@sgis) {

    print "Checking $machine...\n";

    @lines = `rsh $machine \"ps -ef | grep $process | grep -v findprocess | grep -v grep\"`;

    if(@lines) {
	foreach $line (@lines) {
	    $line =~ /^\s*(\w+)\s+(\d+)/;
	    $user = $1;
	    $pid = $2;
	    print "$user on $machine  pid: $pid\n";
	}
    }
}
}}}
{{{
#!/usr/local/bin/perl
#
# check whether user is logged on
#

if ($#ARGV != 0) {
    print "usage: finduser username\n";
    exit;
}

$username = $ARGV[0];
$machines = "insanity ".`systems sgi`;
chop($machines);
@machines = split(/ /,$machines);
@machines = sort(@machines);

foreach $machine (@machines) {
    
    if(`rusers $machine | grep $username`) {
	print "$username logged on $machine\n";
    }
}
}}}
Using the ftplib module to get a directory listing
{{{
# File: ftplib-example-1.py

import ftplib

ftp = ftplib.FTP("www.python.org")
ftp.login("anonymous", "ftplib-example-1")

data = []

ftp.dir(data.append)

ftp.quit()

for line in data:
    print "-", line
}}}
Using the ftplib module to retrieve files
{{{
# File: ftplib-example-2.py

import ftplib
import sys

def gettext(ftp, filename, outfile=None):
    # fetch a text file
    if outfile is None:
        outfile = sys.stdout
    # use a lambda to add newlines to the lines read from the server
    ftp.retrlines("RETR " + filename, lambda s, w=outfile.write: w(s+"\n"))

def getbinary(ftp, filename, outfile=None):
    # fetch a binary file
    if outfile is None:
        outfile = sys.stdout
    ftp.retrbinary("RETR " + filename, outfile.write)

ftp = ftplib.FTP("www.python.org")
ftp.login("anonymous", "ftplib-example-2")

gettext(ftp, "README")
getbinary(ftp, "welcome.msg")
}}}
Using the ftplib module to store files
{{{
# File: ftplib-example-3.py

import ftplib
import os

def upload(ftp, file):
    ext = os.path.splitext(file)[1]
    if ext in (".txt", ".htm", ".html"):
        ftp.storlines("STOR " + file, open(file))
    else:
        ftp.storbinary("STOR " + file, open(file, "rb"), 1024)

ftp = ftplib.FTP("ftp.fbi.gov")
ftp.login("mulder", "trustno1")

upload(ftp, "trixie.zip")
upload(ftp, "file.txt")
upload(ftp, "sightings.jpg")
}}}
{{{
#!/usr/local/bin/perl
#
# create n html files linked together in slide show
#

if ($#ARGV != 1) {
    print "usage: htmlslides base num\n";
    exit;
}

$base = $ARGV[0];
$num = $ARGV[1];

for ($i=1; $i <= $num; $i++) {

    open(HTML, ">$base$i.html");

    if($i==$num) {
	$next = 1;
    } else {
	$next = $i+1;
    }

    print HTML "<html>\n<head>\n<title>$base$i</title>\n</head>\n<body>\n";
    print HTML "<a href=\"$base$next.html\"><img src=\"$base$i.jpg\"></a>\n";
    print HTML "</body>\n</html>\n";

    close(HTML);
}
}}}
*check tiddler: CodeFormatter 
**CodeFormatter should appear in PluginManager (ShadowedTiddlers)
<code>
#!/usr/local/bin/perl
#
# composite series of images over a background image
#

if ($#ARGV != 4) {
 print "usage: compem bg.rgb inbase outbase startNum stopNum\n";
 exit;
}

$bg = $ARGV[0];
$inbase = $ARGV[1];
$outbase = $ARGV[2];
$start = $ARGV[3];
$stop = $ARGV[4];

# for each image
for ($i=$start; $i <= $stop; $i++) {

    # pad numbers
    $num = $i;
    if($i<10) { $num = "00$i"; }
    elsif($i<100) { $num = "0$i"; }

    # call unix command "over"
    $cmd = "over $bg $inbase.$num $outbase.$num 0 0";
    print $cmd."\n";
    if(system($cmd)) { print "over failed\n"; }
}
</code>
<code>
/*
 * LogTest.java
 *
 * Created on 18 January 2004, 11:34
 */

package logtest;

import java.util.logging.*;

/**
 *
 * @author  hvanbelle
 */
public class LogTest {
    
    /** Creates a new instance of LogTest */
    public static void main(String argv[]) {
        Logger logger = Logger.getLogger("logtest.LogTest");
        
        logger.severe("Power lost - running on backup!");
        logger.warning("Database conneciton lost, retrying...");
        logger.info("Startup complete.");
        logger.config("Server configuration: standalone, JVM version 1.4");
        logger.fine("Loading graphing package.");
        logger.finer("Doing pie chart");
        logger.finest("Starting bubble sort: value = " +42);  
    }
}
</code>
{{{
#!/usr/bin/perl
#
# Get a list of file & directory permissions recursively
#

use Win32::FileSecurity qw(Get EnumerateRights);

$startpath = shift;
$startpath = '.' unless $startpath;
$startpath =~ s/\//\\/g;  # change / to 
&showdir ($startpath);
exit;

sub showdir {  # We're recursive, protect vars with local.
    local ($path) = @_;
    local (@dir, $entry, $fullpath);

    opendir (DIR, $path);
    @dir = readdir(DIR);  # get list of current directory
    closedir (DIR);
    foreach $entry (sort {lc($a) cmp lc($b)} @dir) {
        if ($entry eq '.' or $entry eq '..') { next; }
        $fullpath = "$path\\$entry";
        if (-d $fullpath) {
		# Directory here...
		&checkDirSecurity_list($fullpath);
		showdir ($fullpath);  # recursive directory listing
        } else {
		# File here...
		&checkFileSecurity_list($fullpath);
        }
    }
}

sub checkDirSecurity_list {
	local($name);
	local($mask);
	local(@happy);
	local(%hash);
		
	$check_this_entry = $_[0];
	
	if ( Get( $check_this_entry, \%hash ) ) {	    
		while( ($name, $mask) = each %hash ) {
			print "\"D\",";			
			print "\"$check_this\\";			
			print "$check_this_entry\",";
			print "\"$name\",\"";
			EnumerateRights( $mask, \@happy ) ;
			print join( "\",\"", @happy ), "\"\n";
		}
	}
	else {
		print( "Error #", int( $! ), ": $!" ) ;
	}
	
}

sub checkFileSecurity_list {
	local($name);
	local($mask);
	local(@happy);
	local(%hash);
		
	$check_this_entry = $_[0];
	
	if ( Get( $check_this_entry, \%hash ) ) {	    
		while( ($name, $mask) = each %hash ) {
			print "\"F\",";
			print "\"$check_this\\";
			print "$check_this_entry\",";
			print "\"$name\",\"";
			EnumerateRights( $mask, \@happy ) ;
			print join( "\",\"", @happy ), "\"\n";
		}
	}
	else {
		print( "Error #", int( $! ), ": $!" ) ;
	}
}
}}}
*''mail_this.py''
{{{
#!/usr/bin/python

import smtplib
from email.MIMEMultipart import MIMEMultipart
from email.MIMEBase import MIMEBase
from email.MIMEText import MIMEText
from email.Utils import COMMASPACE, formatdate
from email import Encoders
import os

# Settings here...
hostname=os.environ['HOSTNAME']
smtpserver="192.168.0.10"
sendthese_filename="send_these_logs.txt"
files2send = ['','']
send2these = ['some_user@somecompany']
mail_subject_1="Report from "+hostname
mail_inline_text=""
mail_from = hostname+"_admin <"+hostname+"_admin@"+hostname+">"


# Functions...
def sendMail(to, subject, text, files=[],server=smtpserver):
    assert type(to)==list
    assert type(files)==list
    fro = mail_from

    msg = MIMEMultipart()
    msg['From'] = fro
    msg['To'] = COMMASPACE.join(to)
    msg['Date'] = formatdate(localtime=True)
    msg['Subject'] = subject

    msg.attach( MIMEText(text) )

    for file in files:
        part = MIMEBase('application', "octet-stream")
        part.set_payload( open(file,"rb").read() )
        Encoders.encode_base64(part)
        part.add_header('Content-Disposition', 'attachment; filename="%s"'
                       % os.path.basename(file))
        msg.attach(part)

    smtp = smtplib.SMTP(server)
    smtp.sendmail(fro, to, msg.as_string() )
    smtp.close()

# Start processing...
f = open(sendthese_filename,'r')
for line in f:
        if line[0] <> "#" and line[0] <> " " and line[0] <> "\n" and line[0] <> "\r": # don't process these
                linesplit=line.split('\t')
                fpath=linesplit[0].strip()
                fname=linesplit[1].strip()
                emaild=linesplit[2].strip()
                ffname=fpath+"/"+fname
                a = [emaild]
                b = [ffname]
                mail_subject=mail_subject_1+"-"+fname
                sendMail(a,mail_subject,mail_inline_text,b)

f.close()
}}}
*''send_these_logs.txt''
{{{
# List of files to send
# 
# Fields seperated by TAB
# Field 1: filepath where file is located
# Field 2: filename to send by mail
# Field 3: email to send the file to

/tmp/dir2     some_log_file_2_send.log   send_to_this_user@somecompany
}}}
{{{
# File: md5-example-1.py

import md5

hash = md5.new()
hash.update("spam, spam, and eggs")

print repr(hash.digest())
}}}
{{{
# File: md5-example-2.py

import md5
import string
import base64

hash = md5.new()
hash.update("spam, spam, and eggs")

value = hash.digest()

print hash.hexdigest()

# in Python 1.5.2 and earlier, use this instead:
# print string.join(map(lambda v: "%02x" % ord(v), value), "")

print base64.encodestring(value)
}}}
{{{
# File: md5-example-3.py

import md5
import string, random

def getchallenge():
    # generate a 16-byte long random string.  (note that the built-
    # in pseudo-random generator uses a 24-bit seed, so this is not
    # as good as it may seem...)
    challenge = map(lambda i: chr(random.randint(0, 255)), range(16))
    return string.join(challenge, "")

def getresponse(password, challenge):
    # calculate combined digest for password and challenge
    m = md5.new()
    m.update(password)
    m.update(challenge)
    return m.digest()

#
# server/client communication

# 1. client connects.  server issues challenge.

print "client:", "connect"

challenge = getchallenge()

print "server:", repr(challenge)

# 2. client combines password and challenge, and calculates
# the response

client_response = getresponse("trustno1", challenge)

print "client:", repr(client_response)

# 3. server does the same, and compares the result with the
# client response.  the result is a safe login in which the
# password is never sent across the communication channel.

server_response = getresponse("trustno1", challenge)

if server_response == client_response:
    print "server:", "login ok"
}}}
{{{
# File: md5-example-4.py

import md5
import array

class HMAC_MD5:
    # keyed MD5 message authentication

    def __init__(self, key):
        if len(key) > 64:
            key = md5.new(key).digest()
        ipad = array.array("B", [0x36] * 64)
        opad = array.array("B", [0x5C] * 64)
        for i in range(len(key)):
            ipad[i] = ipad[i] ^ ord(key[i])
            opad[i] = opad[i] ^ ord(key[i])
        self.ipad = md5.md5(ipad.tostring())
        self.opad = md5.md5(opad.tostring())

    def digest(self, data):
        ipad = self.ipad.copy()
        opad = self.opad.copy()
        ipad.update(data)
        opad.update(ipad.digest())
        return opad.digest()

#
# simulate server end

key = "this should be a well-kept secret"
message = open("samples/sample.txt").read()

signature = HMAC_MD5(key).digest(message)

# (send message and signature across a public network)

#
# simulate client end

key = "this should be a well-kept secret"

client_signature = HMAC_MD5(key).digest(message)

if client_signature == signature:
    print "this is the original message:"
    print
    print message
else:
    print "someone has modified the message!!!"
}}}
{{{
#!/usr/bin/env python

## md5hash
##
## 2004-01-30
##
## Nick Vargish
##
## Simple md5 hash utility for generating md5 checksums of files. 
##
## usage: md5hash <filename> [..]
##
## Use '-' as filename to sum standard input.

import md5
import sys

def sumfile(fobj):
    '''Returns an md5 hash for an object with read() method.'''
    m = md5.new()
    while True:
        d = fobj.read(8096)
        if not d:
            break
        m.update(d)
    return m.hexdigest()


def md5sum(fname):
    '''Returns an md5 hash for file fname, or stdin if fname is "-".'''
    if fname == '-':
        ret = sumfile(sys.stdin)
    else:
        try:
            f = file(fname, 'rb')
        except:
            return 'Failed to open file'
        ret = sumfile(f)
        f.close()
    return ret


# if invoked on command line, print md5 hashes of specified files.
if __name__ == '__main__':
    for fname in sys.argv[1:]:
        print '%32s  %s' % (md5sum(fname), fname)

}}}
{{{
#!/usr/local/bin/perl
#
# change all occurances of a string in a file to another string
#

if ($#ARGV != 3) {
    print "usage: chstring oldfile newfile oldstring newstring\n";
    exit;
}

$oldfile = $ARGV[0];
$newfile = $ARGV[1];
$old = $ARGV[2];
$new = $ARGV[3];

open(OF, $oldfile);
open(NF, ">$newfile");

# read in each line of the file
while ($line = <OF>) {
    $line =~ s/$old/$new/;
    print NF $line;
}

close(OF);
close(NF);
}}}
{{niceTable{
|!Title/link|[[TiddlyWiki|http://www.tiddlywiki.com]]|
|!Creator|Jeremy Ruston|
|!Description/notes|The official home of TiddlyWiki|
|!Screenshot|[img[http://www.giffmex.org/twinactionimgs/tiddlywiki.png]]|
}}}
[[openSolaris - Install a VirtualBox]]
[[openSolaris - lan - wlan config]]
[[openSolaris - permit root login]]
[[openSolaris - Downloading and Installing Packages]]
[[openSolaris - Commands]]
[[openSolaris - NFS service]]
[[openSolaris - FTP Service]]

[[openSolaris - Check this blog]]
[[openSolaris - Observability]]

[[openSolaris - mpstat]]
[[openSolaris - prstat -mL]]

[[openSolaris - ZFS]]
http://blogs.sun.com/DanX/entry/upgrading_a_linux_server_to
|!Command|!Description|
| NFS mount |''mount -F nfs -o vers=3 venus:/export /mnt''|
| NTP Time Service |''svcadm enable ntp''|
| FTP File Service |''svcadm enable ftp''|
| SSH Service start |''svcadm enable network/ssh''|
| SSH Service stop |''svcadm disable network/ssh''|
| Install a new package |''pkginfo -d package2remove''|
| List package |''pkginfo -l package2remove''|
| Remove a package |''pkgrm package2remove''|
| View the existing users and roles |''cat /etc/user_attr''|
| Delete a user |''userdel username''|
| Create a user |''useradd username''|
| Assign a password |''passwd username''|
| Assign root role |''usermod -R root username''|
| check mac addresses |''pfexec /usr/sbin/ifconfig -a''|
||''ps -ef |grep bash''|
||''kill 689''|
||''kill -KILL 689''|
||''ps -fp `pgrep -d, sendmail`''|
||''pkill -9 sendmai''l|
| report status |''svcs -p network/smtp:sendmail''|
| report status |''svcs -d network/smtp:sendmail''|
||''prstat -mL''|
||''mpstat 10 5''|
*''Download''
>When downloading a file, make sure you are saving in binary (not text) mode. 
>Check that the filesize matches the size listed above after downloading.
*''Uncompress''
>First unzip the package file. 
>This creates a file without the .zip extension. 
>This is a package "datastream" file, which is suitable for installation by pkgadd. 
>For example, ''unzip fortune-off-5.2-i86pc-solaris5.7.zip;''
>Note: If you are running an old version of Solaris (2.5.1 or earlier), you may not have unzip. 
>Download unzip for Solaris from here for SPARC or here for Intel/x86. 
>Rename the unzip program as ''unzip'' and make it executable: ''chmod +x unzip''
*''Install''
>Become root (''login'' or ''su -''). 
>Change to the directory containing the package. 
>Use ''/usr/sbin/pkgadd'' to install packages after they are uncompressed. 
>For example, ''pkgadd -d fortune-off-5.2-i86pc-solaris5.7''
>Use ''pkginfo -l'' to verify the package is installed 
>For example, ''pkginfo -l fortune''
>The files you installed from the package are listed at the end of file ''/var/sadm/install/contents'' to list information about the pac 
FTP File Service
{{{
useradd -c "FTP server" -d /export/home/ftp -m -s /bin/false ftp
svcadm enable ftp
svcs ftp
# cat >>/etc/ftpd/ftpaccess << FTPACCESS_EOF
xferlog format  %T %Xt %R %Xn %XP %Xy %Xf %Xd %Xm %U ftp %Xa %u %Xc %Xs %Xr
log transfers real,guest,anonymous inbound,outbound log syslog+xferlog
FTPACCESS_EOF 
}}}
*Login as root using the "su" command.
*Install the VirtualBox kernel interface package:
**''pkgadd -G -d VirtualBoxKern-2.2.0-SunOS-r45846.pkg''
*Install the main VirtualBox package:
**''pkgadd -d VirtualBox-2.2.0-SunOS-r45846.pkg''
* Start VirtualBox by typing ''VirtualBox'' from the terminal.
*NFS mount: ''mount -F nfs -o vers=3 venus:/export /mnt''
or
{{{
# /etc/vfstab
venus:/export - /venus-export nfs - no vers=3
}}}
*NFS File Server
{{{
# sharemgr add-share -s /backup -r backup -d "backup drive" default
}}}
http://hub.opensolaris.org/bin/view/Community+Group+observability/
|!Process Observability|
|DTrace|	A fantastic tool that can observe process and system behavior and tie it all together. Check out the DTrace community for more information.|
|truss|	A tool for examining system calls as well library calls made by an application.|
|ptools|	A suite of process observability tools.|
|libproc|	A common library used to simplify examining and manipulating processes.|
|procfs|	The /proc filesystem, upon which libproc and all process tools are built.|
|MDB|	The modular debugger, the standard debugger for Solaris. See the MDB community for more information|
|ps|	Basic process monitoring tool. Displays a snapshot of current process state on the machine.|
|prstat|	The standard process monitoring tool for Solaris, similar to top.|
|plockstat|	The userland equiavlent of lockstat(1M), used to monitor lock events and aid in MT scalability. Built on top of DTrace|

|!System Observability|
|DTrace|	Once again, the indispensible system monitoring tool.|
|kstat|	A kernel statistics framework used by a variety of tools to examine system wide statistics.|
|NUMA|	Tools for examining NUMA (Non Uniform Memory Architecture) characteristics on Solaris.|
|ctfs|	The contract filesystem, used to observe and manipulate process contracts.|
|objfs|	The object filesystem, used to examine kernel module symbols and CTF data from userland.|
|mpstat iostat vmstat|	Tools to report on basic system statistics.|
|lockstat|	Tools to examine kernel locking statistic, as well as basic profiling data. Implemented using DTrace|
|intrstat|	Tools to examine kernel interrupt statistics. Implemented using DTrace|
|trapstat|	SPARC-only tool to examine trap statistics.|

|!Network Observability|
|snoop|	The standard tool for observing network packets.|
|netstat|	Tool for observing network connection status.|
|nfsstat|	Basic tool for monitoring NFS statistics.|

|!Hardware Observability|
|FMA|	Fault Management Architecture, a unified system of hardware fault diagnosis, repair, and reporting.|
|CPC|	A system to gather and report CPU performance counter information. Consists of kernel components, libcpc, cpustat, and cputrack|
|psrinfo|	Report on current processor status and configuration|
|prtconf|	Display the system device tree, optionally in excrutiating detail.|
|prtpicl|	Similar to prtconf, prints out the state of the device nodes maintained by the PICL daemon.|
|prtdiag|	Display summary of attached hardware components.|
|prtfru|	SPARC only - Display FRUID information for system or domain.|

|!Post Mortem Observability|
|MDB|	The standard debugger. See the MDB community for more information.|
|dumpadm|	Configures kernel crash dump generation.|
|coreadm|	Configures process core file generation.|
|CTF|	Compact C Type Format, the format used to store type information in the kernel and userland. Consumed by MDB and DTrace, among others.|
|process core generation|	The elfcore() routine, which is responsible for the nuts and bolts of core file generation.|
|kernel panic code|	The entry point to the kernel panic code.|
|gcore|	The gcore(1) utility for taking a core dump of a live running process without perturbing the process.|
http://www.sun.com/bigadmin/topics/zfs/?cid=e9697

[[openSolaris - ZFS - Displaying Basic ZFS Storage Pool Information]]
[[openSolaris - ZFS - Viewing ZFS Storage Pool I/O Statistics]]
[[openSolaris - ZFS - Determining the Health Status of ZFS Storage Pools]]
[[openSolaris - ZFS - Migrating ZFS Storage Pools]]
[[openSolaris - ZFS - Managing ZFS File Systems]]
[[openSolaris - ZFS - Working With ZFS Snapshots and Clones]]
zpool status -x
zpool status -v tank
zpool online tank c1t0d0
zpool status -x
zpool list
zpool list tank
zpool list -o name,size
zpool list -Ho name
zpool list -H -o name,size
zpool history
zpool history mypool
zpool history -l mypool
zpool history -i mypool
zfs create tank/home/bonwick
zfs create -o mountpoint=/export/zfs tank/home

zfs destroy tank/home/tabriz
zfs destroy tank/home/ahrens
zfs destroy -f tank/home/ahrens
zfs destroy tank/ws
zfs destroy -r tank/ws
zfs destroy -r tank/home/schrock
zfs destroy -R tank/home/schrock

zfs rename tank/home/kustarz tank/home/kustarz_old
zfs rename tank/home/maybee tank/ws/maybee

{{{
# zpool create userpool mirror c0t5d0 c1t6d0
# zfs set canmount=off userpool
# zfs set mountpoint=/export/home userpool
# zfs set compression=on userpool
# zfs create userpool/user1
# zfs create userpool/user2
# zfs mount
userpool/user1                  /export/home/user1
userpool/user2                  /export/home/user2
}}}
{{{
# zfs set dept:users=finance userpool/user1
# zfs set dept:users=general userpool/user2
# zfs set dept:users=itops userpool/user3
}}}
zfs get -r dept:users userpool
zfs inherit -r dept:users userpool

zfs list
zfs list -r pool/home/marks
zfs list /pool/home/marks
zfs list -r tank/home/chua
zfs list -o name,sharenfs,mountpoint
zfs list -t filesystem -o name,used
zfs list -H -o name

zfs set atime=off tank/home
zfs create -o atime=off tank/home

{{{
# zfs set quota=50G tank/home/marks
# zfs set quota=50g tank/home/marks
# zfs set quota=50GB tank/home/marks
# zfs set quota=50gb tank/home/marks
}}}
{{{
# zfs set compression=on tank/home/bonwick
# zfs get -r compression tank
NAME             PROPERTY      VALUE                    SOURCE
tank             compression   off                      default
tank/home        compression   off                      default
tank/home/bonwick compression   on                      local
# zfs inherit compression tank/home/bonwick
# zfs get -r compression tank
NAME             PROPERTY      VALUE                    SOURCE
tank             compression   off                      default
tank/home        compression   off                      default
tank/home/bonwick compression  off                      default
}}}
zfs inherit -r compression tank/home
zfs get all pool
zfs get -s local all pool
zfs get -r -s temporary all tank
zfs get -s local all
zfs get -H -o value compression tank/home
zfs get -H -o value -p used tank/home
zfs get -H -o name,value -r used export/home

{{{
# zfs create pool/filesystem
# zfs get mountpoint pool/filesystem
NAME             PROPERTY      VALUE                      SOURCE
pool/filesystem  mountpoint    /pool/filesystem           default
# zfs get mounted pool/filesystem
NAME             PROPERTY      VALUE                      SOURCE
pool/filesystem  mounted       yes              
}}}
{{{
# zfs set mountpoint=/mnt pool/filesystem
# zfs get mountpoint pool/filesystem
NAME             PROPERTY      VALUE                      SOURCE
pool/filesystem  mountpoint    /mnt                       local
# zfs get mounted pool/filesystem
NAME             PROPERTY      VALUE                      SOURCE
pool/filesystem  mounted       yes                        -
}}}
{{{
# zfs set mountpoint=legacy tank/home/eschrock
# mount -F zfs tank/home/eschrock /mnt
}}}
zfs mount
zfs mount -a
zfs mount tank/home/lalt
zfs mount -O tank/home/lalt
zfs mount pool/home/billm
mount -F zfs tank/home/billm

zfs mount -o ro tank/home/perrin
zfs mount -o remount,noatime tank/home/perrin
zfs get atime tank/home/perrin

zfs unmount tank/home/tabriz
zfs unmount /export/home/tabriz
zfs unmount tank/home/eschrock
zfs unmount -f tank/home/eschrock
umount /export/home/bob

zfs set sharenfs=on tank/home/eschrock
{{{
# zfs set sharenfs=on tank/home
# zfs create tank/home/bricker
# zfs create tank/home/tabriz
# zfs set sharenfs=ro tank/home/tabriz
}}}
zfs unshare tank/home/tabriz
zfs unshare -a
zfs share tank/home/tabriz
zfs share -a

zfs set quota=10G tank/home/bonwick
zfs get quota tank/home/bonwick

zfs set quota=10K tank/home/bonwick
zfs set refquota=10g students/studentA
zfs snapshot students/studentA@today
zfs set quota=20g students/studentA
zfs get refquota,quota students/studentA

{{{
# zfs create students/compsci
# zfs set userquota@student1=10G students/compsci
# zfs create students/labstaff
# zfs set groupquota@staff=20GB students/labstaff
}}}

zfs get userquota@student1 students/compsci
zfs get groupquota@staff students/labstaff
zfs userspace students/compsci
zfs groupspace students/labstaff
zfs get userused@student1 students/compsci
zfs get groupused@staff students/labstaff

zfs set userquota@user1=none students/compsci
zfs set groupquota@staff=none students/labstaff

zfs set userquota@student1=10m students/compsci   
zfs userspace students/compsci
quota student1

zfs set userquota@student1=10GB students/compsci
zfs userspace students/compsci
quota student1
quota -v student1

zfs set reservation=5G tank/home/moore
zfs get reservation tank/home/moore
zfs set quota=5G pool/filesystem
zfs set reservation=10G pool/filesystem/user1

zfs set reservation=10G tank/home/moore
zfs set reservation=5G tank/home/moore
zfs get reservation tank/home/moore

zfs set refreservation=10g profs/prof1
zfs set reservation=20g profs/prof1
zfs get reservation,refreserv profs/prof1
zpool export tank
zpool export tank
zpool export -f tank
zpool import

zpool create dozer mirror /file/a /file/b
zpool export dozer
zpool import -d /file
zpool import -d /file dozer

zpool import tank
zpool import dozer zeepool

zpool destroy tank

zpool import -D

zpool import -D tank
zpool status tank

zpool destroy dozer
zpool import -D

zpool import -Df dozer
zpool status -x
zpool online dozer c2t11d0
zpool status -x

zpool upgrade -v
zpool upgrade -a

zpool iostat
zpool iostat tank 2
zpool iostat -v
*commands
**''dladm -show-wifi''
**''dladm -show-linkprop''
**''dladm -show-ether''
**''dladm -show-phys''
**''wificonfig -i iwk0 scan''
The mpstat program presents a high-level view of kernel activity.

{{{
mpstat 10 5
CPU minf mjf xcal  intr ithr  csw icsw migr smtx  srw syscl  usr sys  wt idl
0   17   0    2   428  225  240    7   25    2    0   407    3   0   0  97
1   15   0    1   149  141  225   10   26    2    0   308    2   2   0  96
CPU minf mjf xcal  intr ithr  csw icsw migr smtx  srw syscl  usr sys  wt idl
0    3   0    0   428  219  245  103    3   11    0   732   99   1   0   0
1   21   0    0   242  140  425  196    3    9    0  1320   98   2   0   0
CPU minf mjf xcal  intr ithr  csw icsw migr smtx  srw syscl  usr sys  wt idl
0    0   0    0   432  227  240  100    3   12    0   751   99   1   0   0
1    0   0    0   243  140  443  207    4    9    0  1324   98   2   0   0
CPU minf mjf xcal  intr ithr  csw icsw migr smtx  srw syscl  usr sys  wt idl
0    0   0    0   455  248  264  112    4    9    0   734   99   1   0   0
1    0   0    0   246  140  448  205    4   12    0  1336   98   2   0   0
}}}
where
{{{
minf   page faults satisfied from memory
mjf    page faults satisfied from disk
xcal   cross calls
intr   interrupts
ithr   interrupts threads
csw    context switches
icsw   involuntary context switches
migr   thread migrations
smtx   spins on mutex locks
srw    spins on read/writer locks
syscl  system calls
usr    CPU time in user mode
sys    CPU time in kernel mode
wt     wait on IO
idl    idle
}}}
After you install the OpenSolaris 2008.11 release, if you wish to manually change the installed system to permit root logins, remove root as an assigned role for users. 

Then, type the following at the command line:

''# rolemod -K type=normal root''

This command converts root to a normal account.
The prstat tool is another tool that that provides useful first-level analysis metrics, providing similar information as mpstat but at a thread level.

{{{
PID USERNAME  USR SYS TRP TFL DFL LCK SLP LAT VCX ICX SCL SIG PROCESS/LWPID
3040 rw8775   0.8 0.2 0.0 0.0 0.0 0.0  99 0.0  19   7 750   0 madplay/1
3030 root     0.1 0.2 0.0 0.0 0.0 0.0 100 0.0  30   1 400   0 nx/1
1311 rw8775   0.3 0.0 0.0 0.0 0.0 0.0 100 0.0  78  40 273   0 iobar.i386/1
700 rw8775    0.2 0.0 0.0 0.0 0.0 0.0 100 0.0 321   7  1K 129 Xorg/1
303 rw8775    0.1 0.0 0.0 0.0 0.0 0.0 100 0.0  20   4 170   0 xterm/1
310 rw8775    0.0 0.1 0.0 0.0 0.0 0.0 100 0.0 117  20 273   0 netbar.i386/1
2972 rw8775   0.1 0.0 0.0 0.0 0.0 0.0 100 0.0 167  16 673   0 soffice.bin/1
3042 rw8775   0.0 0.0 0.0 0.0 0.0 0.0 100 0.0  24   2 386   0 prstat/1
1305 rw8775   0.0 0.0 0.0 0.0 0.0 0.0 100 0.0 174  57 552   0 perfbar/1
1296 rw8775   0.0 0.0 0.0 0.0 0.0 0.0 100 0.0   2   0  31   0 xterm/1
Total: 105 processes, 231 lwps, load averages: 0.06, 0.06, 0.04
}}}
where
{{{
USR   Percent CPU in USR per thread 
SYS   Percent CPU in SYS per thread
TRP   Percent CPU spent trapping into the kernel
TFL   Percent CPU spent servicing Text page faults
DFL   Percent CPU spent servicing Data page faults
LCK   Percent CPU spent waiting for locks
SLP   Percent CPU spent asleep... using IO
LAT   Percent CPU spent on a run
VCX   Number of voluntary context switches per interval
ICX   Number of involuntary context switches per interval
SCL   Number of system calls per interval
SIG   Number of signals per interval 
}}}
{{{
#!/usr/local/bin/perl
#
# pad file numbers with zeros
#
if ($#ARGV != 2) {
    print "usage: pad base start stop\n";
    exit;
}

$base = $ARGV[0];
$start = $ARGV[1];
$stop = $ARGV[2];

for ($i=$start; $i <= $stop; $i++) {

    $num = $i;
    if($i<10) {	$num = "00$i"; }
    elsif($i<100) { $num = "0$i"; }

    $cmd = "mv $base$i $base$num";

    # to unpad, use this instead:
    # $cmd = "mv $base$num $base$i";

    print $cmd."\n";
    if(system($cmd)) { print "pad failed\n"; }
}
}}}
{{{
#!/usr/bin/perl -w

opendir(DIR, ".");
@files = readdir(DIR);
closedir(DIR);

foreach $file (@files) {
   print "$file\n";
}
}}}
{{{
my $d = shift;

opendir(D, "$d") || die "Can't opedir $d: $!\n";
my @list = readdir(D);
closedir(D);

foreach my $f (@list) {
  print "\$f = $f\n";
}
}}}
{{{
use IO::Dir;
$d = IO::Dir->new(".");
if (defined $d) {
    while (defined($_ = $d->read)) { something($_); }
    $d->rewind;
    while (defined($_ = $d->read)) { something_else($_); }
    undef $d;
}

tie %dir, 'IO::Dir', ".";
foreach (keys %dir) {
    print $_, " " , $dir{$_}->size,"\n";
}
}}}
{{{
#!/usr/bin/perl -w

$LOGFILE = "access.log";
open(LOGFILE) or die("Could not open log file.");
foreach $line (<LOGFILE>) {
    ($site, $logName, $fullName, $date, $gmt,$req, $file, $proto, $status, $length) = split(' ',$line);
    $time = substr($date, 13);
    $date = substr($date, 1, 11);
    $req  = substr($req, 1);
    chop($gmt);
    chop($proto);
    # do line-by-line processing.
}
close(LOGFILE);
}}}
{{{
#!/usr/local/bin/perl
#
# rename series of frames
#
if ($#ARGV != 3) {
    print "usage: rename old new start stop\n";
    exit;
}

$old = $ARGV[0];
$new = $ARGV[1];
$start = $ARGV[2];
$stop = $ARGV[3];

for ($i=$start; $i <= $stop; $i++) {

    $num = $i;
    if($i<10) {	$num = "00$i"; }
    elsif($i<100) { $num = "0$i"; }

    $cmd = "mv $old.$num $new.$num";
    print $cmd."\n";
    if(system($cmd)) { print "rename failed\n"; }
}
}}}
*''sar -u 2 5'' (CPU utilization; 2 seconds apart; 5 times): Report CPU utilization. The following values are displayed
|!Value|!Description|
|''%user''|Percentage of CPU utilization that occurred while executing at the user level (application)|
|''%nice''|Percentage of CPU utilization that occurred while executing at the user level with nice priority|
|''%system''|Percentage of CPU utilization that occurred while executing at the system level (kernel)|
|''%iowait''|Percentage of time that the CPU or CPUs were idle during which the system had an outstanding disk I/O request|
|''%idle''|Percentage of time that the CPU or CPUs were idle and the system did not have an outstanding disk I/O request|

{{{
import logging
LOG_FILENAME = '/tmp/logging_example.out'
logging.basicConfig(filename=LOG_FILENAME,level=logging.DEBUG,)

logging.debug('This message should go to the log file')
}}}
{{{
import logging
import sys

LEVELS = {'debug': logging.DEBUG,
          'info': logging.INFO,
          'warning': logging.WARNING,
          'error': logging.ERROR,
          'critical': logging.CRITICAL}

if len(sys.argv) > 1:
    level_name = sys.argv[1]
    level = LEVELS.get(level_name, logging.NOTSET)
    logging.basicConfig(level=level)

logging.debug('This is a debug message')
logging.info('This is an info message')
logging.warning('This is a warning message')
logging.error('This is an error message')
logging.critical('This is a critical error message')
}}}
{{{
import glob
import logging
import logging.handlers

LOG_FILENAME = '/tmp/logging_rotatingfile_example.out'

# Set up a specific logger with our desired output level
my_logger = logging.getLogger('MyLogger')
my_logger.setLevel(logging.DEBUG)

# Add the log message handler to the logger
handler = logging.handlers.RotatingFileHandler(
              LOG_FILENAME, maxBytes=20, backupCount=5)

my_logger.addHandler(handler)

# Log some messages
for i in range(20):
    my_logger.debug('i = %d' % i)

# See what files are created
logfiles = glob.glob('%s*' % LOG_FILENAME)

for filename in logfiles:
    print filename
}}}
{{{
#!/usr/bin/python
#client

from socket import *
import thread

def receiver(clientSocket, ADDR):
        while 1:
                data = clientSocket.recv(BUFF)
                print data

HOST = '192.168.1.6'
PORT = 2000
BUFF = 1024
ADDR = (HOST, PORT)

clientSocket = socket(AF_INET, SOCK_STREAM)
clientSocket.connect(ADDR)

thread.start_new_thread(receiver, (clientSocket, ADDR))

while 1:
        data = raw_input()
        if (data == '/quit'):
                clientSocket.send('/quit')
                break
        clientSocket.send(data)

clientSocket.close()

}}}
{{{
#!/usr/bin/python
#server

from socket import *
from copy import copy
import thread

class socketClass:
        active = 0

def handler(index,zero):
        send("Server message: " + str(socketArray[index].ADDR) + " connected.")

        while 1:
                data = socketArray[index].socket.recv(BUFF)
                if(data == '/quit'): break
                send (str(socketArray[index].ADDR) + " : " + data)

        send("Server message: " + str(socketArray[index].ADDR) + " disconnected.")

        socketArray[index].active = 0
        socketArray[index].socket.close()

def send(message):
        print message

        for i in range(len(socketArray)):
                if socketArray[i].active:
                        socketArray[i].socket.send(message)

HOST = '192.168.1.6'
PORT = 2000
BUFF = 1024
ADDR = (HOST, PORT)

print "Binding serverSocket to: ", ADDR

serverSocket = socket(AF_INET, SOCK_STREAM)
serverSocket.bind(ADDR)
serverSocket.listen(5)

socketArray = list()

print "Server message: Server ready."

while 1:
        socketArray.append(socketClass())
        socketArray[len(socketArray) - 1].socket, socketArray[len(socketArray) - 1].ADDR = copy(serverSocket.accept())
        socketArray[len(socketArray) - 1].active = 1;

        thread.start_new_thread(handler, ((len(socketArray) - 1),0))

serverSocket.close()

}}}
http://svnbook.red-bean.com/
http://svnbook.red-bean.com/en/1.5/index.html
http://svnbook.red-bean.com/en/1.5/svn.intro.quickstart.html
http://svnbook.red-bean.com/en/1.5/svn.tour.cycle.html#svn.tour.cycle.commit
*Update your working copy.
**''svn update''
*Make changes.
**''svn add''
**''svn delete''
**''svn copy''
**''svn move''
*Examine your changes.
**''svn status''
**''svn diff''
*Possibly undo some changes.
**''svn revert''
*Resolve conflicts (merge others' changes).
**''svn update''
**''svn resolve''
*Commit your changes.
**''svn commit''
{{{
#!/usr/bin/perl
#tcpserver.pl

use IO::Socket;

$| = 1;

$socket = new IO::Socket::INET (
                                  LocalHost => '192.168.1.6',
                                  LocalPort => '44444',
                                  Proto => 'tcp',
                                  Listen => 5,
                                  Reuse => 1
                               );
                                
die "Coudn't open socket" unless $socket;

print "\nTCPServer Waiting for client on port 44444";

while(1)
{
        $client_socket = "";
        $client_socket = $socket->accept();

        $peer_address = $client_socket->peerhost();
        $peer_port = $client_socket->peerport();

        print "\n I got a connection from ( $peer_address , $peer_port ) ";


         while (1)
         {
                 
                 print "\n SEND( TYPE q or Q to Quit):";
                 
                 $send_data = <STDIN>;
                 chop($send_data); 
                 
                 
                 
                 if ($send_data eq 'q' or $send_data eq 'Q')
                    {
                            
                        $client_socket->send ($send_data);
                        close $client_socket;
                        last;
                        }

                 else
                    {
                        $client_socket->send($send_data);
                    }
                    
                    $client_socket->recv($recieved_data,1024);
                    
                    if ( $recieved_data eq 'q' or $recieved_data eq 'Q')
                    {
                            close $client_socket;
                            last;
                    }
                    
                    else
                    {
                            print "\n RECIEVED: $recieved_data";
                    }                    

        }
}

}}}
{{{
#!/usr/bin/python
# TCP server example
import socket
server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server_socket.bind(("192.168.1.6", 44444))
server_socket.listen(5)

print "TCPServer Waiting for client on port 50004"

while 1:
        client_socket, address = server_socket.accept()
        print "I got a connection from ", address
        while 1:
                data = raw_input ( "SEND( TYPE q or Q to Quit):" )
                if (data == 'Q' or data == 'q'):
                        client_socket.send (data)
                        client_socket.close()
                        break;
                else:
                        client_socket.send(data)
 
                data = client_socket.recv(512)
                if ( data == 'q' or data == 'Q'):
                        client_socket.close()
                        break;
                else:
                        print "RECIEVED:" , data

}}}
|!SIte|
|http://tiddlyspot.com/|
|http://giffmex.tiddlyspot.com/|
|http://tidhelp.tiddlyspot.com/|
{{{
#!/bin/sh
#
# tsmacceptor                     This script starts or stops local configurations
#
### BEGIN INIT INFO
# Provides: tsmacceptor
# Default-Start: 3 5
# Default-Stop: 0 1 2 6
# Description: Start local config
### END INIT INFO  
                             
# Source function library
. /etc/rc.status               # For SuSE, enables setting from /etc/rc.config
rc_reset

case "$1" in
    start)
        echo -n "Starting TSM Client Acceptor Service"
        startproc /opt/tivoli/tsm/client/ba/bin/dsmcad >/dev/null 2>&1 &
        rc_status -v
        ;;

    stop)
        echo -n "Shutting down TSM Client Acceptor Service"
        killproc /opt/tivoli/tsm/client/ba/bin/dsmcad 
        rc_status -v
        ;;

    status)
        echo -n "Checking for service tsmacceptor (dsmcad)"
        checkproc /opt/tivoli/tsm/client/ba/bin/dsmcad 
        rc_status -v
        ;;

    *)
        echo "Usage: tsm {start|stop|status}"
        exit 1
esac
rc_exit
}}}
{{{
#!/bin/sh
#
# tsmsched                     This script starts or stops local configurations
#
### BEGIN INIT INFO
# Provides: tsmsched
# Default-Start: 3 5
# Default-Stop: 0 1 2 6
# Description: Start local config
### END INIT INFO  
                             
# Source function library.
. /etc/rc.status                # For SuSE, enables setting from /etc/rc.config
rc_reset
                                
case "$1" in
    start)
        echo  -n "Starting TSM scheduler"
        startproc /opt/tivoli/tsm/client/ba/bin/dsmc sched >/dev/null 2>&1 &
        rc_status -v
        ;;

    stop)
        echo -n "Shutting down TSM scheduler"
        killproc /opt/tivoli/tsm/client/ba/bin/dsmc sched 
        rc_status -v
        ;;

    status)
        echo -n "Checking for service tsmsched (dsmc sched)"
        checkproc /opt/tivoli/tsm/client/ba/bin/dsmc sched 
        rc_status -v
        ;;

    *)
        echo "Usage: tsm {start|stop|status}"
        exit 1
esac
rc_exit
}}}
|*|r|replace single character under cursor (no <Esc> needed)|
||R|replace characters, starting with current cursor position, until <Esc> hit|
||cw|change the current word with new text, starting with the character under cursor, until <Esc> hit|
||cNw|change N words beginning with character under cursor, until <Esc> hit; e.g., c5w changes 5 words|
||C|change (replace) the characters in the current line, until <Esc> hit|
||cc|change (replace) the entire current line, stopping when <Esc> is hit|
||Ncc or cNc|change (replace) the next N lines, starting with the current line, stopping when <Esc> is hit|
|yy|copy (yank, cut) the current line into the buffer|
|Nyy or yNy|copy (yank, cut) the next N lines, including the current line, into the buffer|
|p|put (paste) the line(s) in the buffer into the text after the current line|
|*|x|delete single character under cursor|
||Nx|delete N characters, starting with character under cursor|
||dw|delete the single word beginning with character under cursor|
||dNw|delete N words beginning with character under cursor; e.g., d5w deletes 5 words|
||D|delete the remainder of the line, starting with current cursor position|
|*|dd|delete entire current line|
||Ndd or dNd|delete N lines, beginning with the current line; e.g., 5dd deletes 5 lines|
|:.=|returns line number of current line at bottom of screen|
|:=|returns the total number of lines at bottom of screen|
|^g|provides the current line number, along with the total number of lines, in the file at the bottom of the screen|
|*|i|insert text before cursor, until <Esc> hit|
||I|insert text at beginning of current line, until <Esc> hit|
|*|a|append text after cursor, until <Esc> hit|
||A|append text to end of current line, until <Esc> hit|
|*|o|open and put text in a new line below current line, until <Esc> hit|
|*|O|open and put text in a new line above current line, until <Esc> hit|
|*|j or <Return> [or down-arrow]|move cursor down one line|
|*|k [or up-arrow]|move cursor up one line|
|*|h or <Backspace> [or left-arrow]|move cursor left one character|
|*|l or <Space> [or right-arrow]|move cursor right one character|
|*|0 (zero)|move cursor to start of current line (the one with the cursor)|
|*|$|move cursor to end of current line|
||w|move cursor to beginning of next word|
||b|move cursor back to beginning of preceding word|
||:0<Return> or 1G|move cursor to first line in file|
||:n<Return> or nG|move cursor to line n|
||:$<Return> or G|move cursor to last line in file|
|:r filename<Return>|read file named filename and insert after current line (the line with cursor)|
|:w<Return>|write current contents to file named in original vi call|
|:w newfile<Return>|write current contents to a new file named newfile|
|:12,35w smallfile<Return>|write the contents of the lines numbered 12 through 35 to a new file named smallfile|
|:w! prevfile<Return>|write current contents over a pre-existing file named prevfile|
|^f|move forward one screen|
|^b|move backward one screen|
|^d|move down (forward) one half screen|
|^u|move up (back) one half screen|
|^l|redraws the screen|
|^r|redraws the screen, removing deleted lines|
|/string|search forward for occurrence of string in text|
|?string|search backward for occurrence of string in text|
|n|move to next occurrence of search string|
|N|move to next occurrence of search string in opposite direction|
{{{
The Quick'n'dirty way to do this in vi is as follows:

1.  Open the dos text file in vi.
	vi dosfile.txt
2.  Type the following:
	:%s/^M//g
...where you "compose" the ^M character by pressing Ctrl+v then Ctrl+m
3.  Save the file:
	:w New.Unix.File.txt

The above :%s/^M//g means "replace (substitute) every ^M character with no
character".  More generally, you can do :%s/old/new/g to replace every
instance of "old" with "new"; it's the final "g" after the last slash
makes it replace every instance, not just the first instance.

Note: This will replace any instance of the sequence of letters "old"; it
will replace the "old" in sold with "new" to form snew, and gold will
become gnew. :-)
}}}
|!Filename|!File content|
|.vimrc|syntax on|

|*|vi filename|edit filename starting at line 1|
||vi -r filename|recover filename that was being edited when system crashed|
|*|:x<Return>|quit vi, writing out modified file to file named in original invocation|
||:wq<Return>|quit vi, writing out modified file to file named in original invocation|
||:q<Return>|quit (or exit) vi|
|*|:q!<Return>|quit vi even though latest changes have not been saved for this vi call|
|*|u|UNDO WHATEVER YOU JUST DID; a simple toggle|
[[vi - start]]
[[vi - stop]]
[[vi - undo]]
[[vi - Moving the Cursor]]
[[vi - Screen Manipulation]]
[[vi - Inserting or Adding Text]]
[[vi - Changing Text]]
[[vi - Deleting Text]]
[[vi - Cutting and Pasting Text]]
[[vi - Searching Text]]
[[vi - Determining Line Numbers]]
[[vi - Saving and Reading Files]]
[[vi - dos2unix]]