Finne ut hvor Oracle errorloggen ligger (alert.log)

Ved feilsøking av oracle servere er det ikke alltid like lett å se hvor loggen ligger. Oracle definerer en alert.log for hver database, som kan hete alert-databasenavn.log, ha et brukerdefinert navn eller bare alert.log. For å identifisere stien til denne kan man bruke følgende kommando:

select value from v$parameter where name = 'background_dump_dest';

Dersom denne ikke gir noe svar, brukes standardmappen som er $ORACLE_HOME/RDBMS/trace. Husk at stien som kommer opp er en lokal sti på den serveren databasen kjører på.

List MAC-address for wired ethernet cards

The script tries to identify wired network cards and list the mac address(es) to a file. By default it creates one file in the current directory per computer name, but you can change it to write everything to one large file. This can lead to write locks if you try to run the script at login, but if you let it run for a couple of days you should get most of them. The script was created to aid in importing computers into MS CCM collections. The idea was to put the script on a flashdrive, run around to all the computers being added and run the script manually. This was to make sure that every computer was logged.

Please note: Disabled or disconnected ethernet cards are not listed, so make sure the card for which you want the mac address is connected and enabled when you run the script.

 

 

'***************************************************************************
'** List LAN MAC addresses and output them to a file named [Computername] **
'** Output format tailored for CCM (csv): ComputerName, , MAC, CardName   ** 
'**                             Jan Kåre Lokna                         **
'***************************************************************************
option explicit
on error goto 0

'Get computername for filename.
Dim wshShell
Set wshShell = WScript.CreateObject( "WScript.Shell" )
Dim strFilename
strFilename = wshShell.ExpandEnvironmentStrings( "%COMPUTERNAME%" ) 'change this to a filename on a network share if you want to use a common file for all computers, e.g strFilename="\\server\share\filename.txt"

'Get cards from WMI
Dim objWMIService
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2") 
Set colItems = objWMIService.ExecQuery ("SELECT * FROM Win32_NetworkAdapter where MACAddress != null AND AdapterTypeID like '0'") 
'Create / open file
Dim fso
Dim objFile
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Set fso = CreateObject("Scripting.FileSystemObject")
If Not fso.FileExists(strFilename) Then
	Set objFile = fso.CreateTextFile(strFilename)
Else
	Set objFile = fso.OpenTextFile(strFilename, ForReading, True)
	Dim strReadFile
	strReadFile = objFile.ReadAll
	objFile.Close
	Set objFile = fso.OpenTextFile(strFilename, ForAppending, True)
  End If
'Process cards
Dim colItems
Dim objItem
For Each objItem in colItems 
	Dim strMAC
	strMAC = objItem.MACAddress
	Dim strName 
	strName = objItem.Name
	'Check for bluetooth or wifi
	If InStr(strName, "Bluetooth") > 0 Then
		'Do nothing
	ElseIf InStr(strName, "WiFi") > 0 Then
		'Do nothing
	else
		'Format output
		Dim strInfo
		strInfo = objItem.SystemName & ", " & "," & strMAC & "," & strName
		wscript.echo strInfo
		'write file
		'Check if MAC exists in file
		If InStr(strReadFile, strMAC) = 0 Then
			'if not, then append to file
			objFile.WriteLine strInfo
			wscript.echo (strMAC & " written to " & strFileName)
		 End If
	 end if
Next
'Close file
objFile.Close


Check if processes are running

Intended for use as part of a bigger script where you need to check if a process or processes are running or closed. Checks if an array of processes are running on the system, and counts how many of them are running in an integer variable.

#Declare variables
[Int]$intRunning = 0
[bool]$Debug = $true

#Main logic
function Main
{
	$menucolor = [System.ConsoleColor]::white
	write-host '-------------------------------------------------------------------'-ForegroundColor $menucolor
	write-host '|                 Check if processes are running                  |'-ForegroundColor $menucolor
	write-host '|                      Jan Kåre Lokna                          |'-ForegroundColor $menucolor
	write-host '|                     v 1.0                                       |'-ForegroundColor $menucolor
	write-host '-------------------------------------------------------------------'-ForegroundColor $menucolor
	write-host 
	checkProcesses
}

#Check processes
function checkProcesses
{
	$processes = "iexplore", "winamp", "Opera", "dfdsafs"
	
	foreach ($process in $processes)
	{
		try
		{
			$s= Get-Process $process -ErrorAction stop
			if($Debug -eq $true) {write-host $process 'is running'-ForegroundColor Green}
			$intRunning = $intRunning + 1
		}
		catch
		{
			if($Debug) {write-host $process 'is not running' -ForegroundColor Magenta}
		}
	}
	if($Debug) {Write-host "Running processes: " $intRunning "of" $processes.count}
}
. Main

Mailbox database status script

For Exchange 2010.

Current functions:

  • Find database copies with failed content index
  • Fix database copies with failed content index
  • List active database copies
  • List passive database copies
  • List backup status

This script keeps returning to the main menu until exit is selected.

Use at your own risk. Don’t blame me if something goes horribly wrong.

 

The script

#Main logic
function main
{
	$menucolor = [System.ConsoleColor]::white
	write-host '-------------------------------------------------------------------'-ForegroundColor $menucolor
	write-host '|                     Mailbox database status                     |'-ForegroundColor $menucolor
	write-host '|                      Jan Kåre Lokna                          |'-ForegroundColor $menucolor
	write-host '|                     v 1.2                                       |'-ForegroundColor $menucolor
	write-host '-------------------------------------------------------------------'-ForegroundColor $menucolor
	write-host 
	write-host '** MENU **' -ForegroundColor $menucolor
	write-host '1) Find database copies with failed ContentIndex State' -ForegroundColor $menucolor
	write-host '2) Check backup status' -ForegroundColor $menucolor
	write-host '3) Find active database copies' -ForegroundColor $menucolor
	write-host '4) Find passive database copies' -ForegroundColor $menucolor
	write-host '5) Overwrite failed ContentIndex' -ForegroundColor $menucolor
	write-host '6) Exit' -ForegroundColor darkgreen
	write-host
	$menu = Read-Host "Select an option [1-6]"
	switch ($menu)
	{
		1{GetContentIndexState}
		2{GetBackupState}
		3{GetActiveCopies}
		4{GetPassiveCopies}
		5{FixContentIndex}
		6{exitMenu}
		default{. main}
	}
}



##Check backup status
function GetBackupState
{
	Get-MailboxDatabase | where {$_.Recovery -eq $False } `
		| Select-Object -Property Server, Name , LastFullBackup, LastIncrementalBackup, BackupInProgess `
		| Sort-Object -Property Server,  Name | ft -AutoSize

	Get-PublicFolderDatabase `
		| Select-Object -Property Server, Name , LastFullBackup, LastIncrementalBackup, BackupInProgess `
		| Sort-Object -Property Server, Name | ft -AutoSize
	. GoToMenu
}

##Fix contentindex
function FixContentIndex
{
	write-host 'Trying to repair failed ContentIndex:'
	$destCopy = read-host "Input destination database copy: "
	Update-MailboxDatabaseCopy $destCopy –CatalogOnly 
	. GoToMenu
}

##Find passive database copies 
function GetPassiveCopies{
	write-host 'Passive database copies:'
	try
		{
		#Get mailbox servers
		$Servers = Get-ExchangeServer | Where-Object {($_.ServerRole -match "Mailbox") }
		foreach($Server in $Servers)
		{
			Get-MailboxDatabaseCopyStatus -Server $Server.Name | Where-Object{($_.Status -ne "Mounted")}| out-default #Out-default needed to work around bug http://connect.microsoft.com/PowerShell/feedback/details/152205/bug-with-default-formatter.
		}
	}
	catch [Exception]
	{
		Write-Host "Something went horribly wrong..."
		Write-Host $_.Exception.TosSTring()
	}
	. GoToMenu
}

##Find active database copies 
function GetActiveCopies{
	write-host 'Active database copies:'
	try
		{
		#Get mailbox servers
		$Servers = Get-ExchangeServer | Where-Object {($_.ServerRole -match "Mailbox") }
		foreach($Server in $Servers)
		{
			Get-MailboxDatabaseCopyStatus -Server $Server.Name | Where-Object{($_.Status -eq "Mounted")}| out-default
		}
	}
	catch [Exception]
	{
		Write-Host "Something went horribly wrong..."
		Write-Host $_.Exception.TosSTring()
	}
	. GoToMenu
}	
	
##Find database copies with failed ContentIndex State 
function GetContentIndexState
{
	write-host 'Database copies with failed ContentIndex State:'
	try
		{
		#Get mailbox servers
		$Servers = Get-ExchangeServer | Where-Object {($_.ServerRole -match "Mailbox") }
		foreach($Server in $Servers)
		{
			Get-MailboxDatabaseCopyStatus -Server $Server.Name | Where-Object{($_.ContentIndexState -ne "Healthy")}| out-default
		}
	}
	catch [Exception]
	{
		Write-Host "Something went horribly wrong..."
		Write-Host $_.Exception.TosSTring()
	}
	. GoToMenu
}

#Exit script
function exitMenu
{
	exit
}

#Go back to menu
function GoToMenu
{
	write-host
	write-host 'Press any key to continue...' | out-default
	$s=[Console]::ReadKey($true)
	. main
}

#Start script
. main


Reparere søkeindeksen på en databasekopi

Problem

Forsøk på å gjøre passiv databasekopi aktiv feiler med følgende melding:

Database copy [navn] on server [server] has content index catalog files in the following state: ‘Failed’.

Løsning

Sjekk om det gjelder flere baser ved å kjøre følgende script:

###############################################################################
###			Find database copies with failed ContentIndex State       		###
###			 Jan Kåre Lokna												###
###			v 1																###	
###############################################################################
try
	{
	#Get mailbox servers
	$Servers = Get-ExchangeServer | Where-Object {($_.ServerRole -match "Mailbox") }
	foreach($Server in $Servers)
	{
		Get-MailboxDatabaseCopyStatus -Server $Server.Name | Where-Object{($_.ContentIndexState -ne "Healthy")}
	}
}
catch [Exception]
{
	Write-Host "Something went horribly wrong..."
	Write-Host $_.Exception.TosSTring()
}

Eksempel på output:

Name Status CopyQueue ReplayQueue LastInspectedLogTime ContentIndex 
Length Length State 
---- ------ --------- ----------- -------------------- ------------ 
DB2\EXCserver2 Healthy 0 0 27.05.2011 13:51:07 Failed 

Kjør følgende kommando for å hente data fra aktiv kopi:

Update-MailboxDatabaseCopy [name] -CatalogOnly 

Name hentes fra output av skriptet over. Vær obs på at kommandoen kasnkje må kjøres på den server som eier databasekopien (EXCServer2 i eksempelet over).

The Autochanger is disabled

Problem

Når man skal sjekke status på backup i Networker så oppdager man at alle jobber knyttet til et bibliotek fortsatt står på 0% og venter på ledige kasetter, selv om man vet at det ble satt inn dagen før. Biblioteket virker å være i orden, og en omstart av biblioteket hjelper ikke.

image

Når man klikker seg inn på biblioteket i Networker får man følgende feilmelding:

“The autochanger is disabled”

image

Dersom man høyreklikker på biblioteket og velger Enable/Disable får man styre biblioteket, men backupjobbene går fortsatt ikke.

image

Løsninger

Dette er en feil som kan ha flere årsaker.

En kassett sitter fast

I så fall er det gjerne bare ett bibliotek som er kranglete. Kontroller biblioteket fysisk, og sjekk om det sitter fast kassetter i gripearmen eller i båndstasjonene.

Problemer med å aktivere biblioteker

Av og til nekter Networker å lagre at bibliotekene er aktivert. I så fall prøv følgende:

Høyreklikk på biblioteket, velg properties og velg enable der.

image

Dersom dette ikke hjelper trengs videre feilsøking.

Event ID 4005 from Winlogon every 30 seconds on load balanced server

Problem

Event 4005 from source Winlogon is logged in the System log every 30 seconds on the second:

SNAGHTML48f6ab89

Event details:

SNAGHTML48f508e5

Other than this, no error is logged and no complaints from users, everything seems to be working as expected.

Continue reading “Event ID 4005 from Winlogon every 30 seconds on load balanced server”

Prosessor Overcommit på VMware

Om feilsøking av prosessorrelaterte ytelsesproblemer på virtuelle gjester som kjører i et VMware miljø.

Jeg har skrevet en del om hvordan tilgang på fysiske minne- og prosessorressurser påvirker ytelsen til virtuelle gjester på generell basis her og her. Som jeg nevner er det primært mengden fysisk minne som avgjør hvor mange/store gjester man kan ha på en vertsmaskin. Dersom man først oversubscriber, som gjerne er hele poenget med virtualisering av servere, vil man selvsagt oversubscribe prosessorene også. Når det gjelder minne er det egentlig ganske enkelt å se når det oppstår overcommit, siden det medfører såpass store ytelsesmessige konsekvenser. På prosessorsiden oppstår feilen dog mer gradvis. Jeg har i det siste jobbet litt med å identifisere årsak til en del rare problemer på virtuelle gjester, og har i den sammenheng forsøkt å sette meg inn i hvordan man på VMWare vCenter 4 henter inn de nødvendige grunnlagsdata og analyserer disse.

Continue reading “Prosessor Overcommit på VMware”

Local System Certificate store pooched after windows update

Problem

After patching one of our SQL servers it was acting strange. Suddenly, the reporting services service refused to service https requests, and the SCOM monitoring agent refused to start. The error message from the reporting server website as reported by opera was “Secure connection: fatal error 552”. This could be translated to either “Requested file action aborted, storage allocation exceeded”, which is an FTP status code, or “552 – Unknown authentication service call-back”, which is a more likely explanation.

Continue reading “Local System Certificate store pooched after windows update”

Listing enterprise voice enabled users and their assigned numbers

I wanted a list containing all OCS users enabled for enterprise voice, and found the answer at UCSpotting. Being difficult, I also wanted to list the pone numbers assigned as Line URIs. I changed the query from UCSpotting and ended up with this:

SELECT r.UserAtHost, p.PhoneNum FROM RTC.dbo.ResourceDirectory c
INNER JOIN RTC.dbo.Resource r ON c.ResourceId = r.ResourceId
INNER JOIN rtc.dbo.ResourcePhone p ON c.ResourceId = p.ResourceId
WHERE (c.OptionFlags & 128) = 128
ORDER BY r.UserAtHost

which returns all enterprise voice enabled users who has an assigned Line URI. But then I thought, what about users with no Line URI? The list containing phone numbers were shorter than the list of voice enabled users, ergo there had to be some users enabled for voice without an assigned Line URI. Experiments showed that such a user could dial out, so listing these users as well seemed pertinent. Changing the last join to a left join instead did the trick:

SELECT r.UserAtHost, p.PhoneNum FROM RTC.dbo.ResourceDirectory c
INNER JOIN RTC.dbo.Resource r ON c.ResourceId = r.ResourceId
LEFT JOIN rtc.dbo.ResourcePhone p ON c.ResourceId = p.ResourceId
WHERE (c.OptionFlags & 128) = 128
ORDER BY p.PhoneNum