Tuesday, October 25, 2011

powershell parsing data mms

set-Executionpolicy unrestricted
# above allows it to run
$readthefile = (Get-Content C:\Users\NigelDude\Documents\channels.txt)
#$readthefiletwo = ((Get-Content c:\nigel2.txt))
write customers that exist in both > c:\out.txt

#read each line of file 1 nigel
# outer loop

foreach ($i in $readthefile)
{
#write-host TheData
#write-host $i
# inner loop
#write-host "I = " $i
#$mystring = $i
#$mystring -match 'mms'
#$matches[1]
$mystring = $i.Split()
$mystring -match 'mms'



$matches[1]
}

Thursday, October 20, 2011

powershell

compare two files

set-Executionpolicy unrestricted
# above allows it to run
$readthefile = (Get-Content c:\nigel.txt)
$readthefiletwo = ((Get-Content c:\nigel2.txt))
write customers that exist in both > c:\out.txt

#read each line of file 1 nigel
# outer loop

foreach ($i in $readthefile)
{
write-host TheData
write-host $i
# inner loop
write-host "I = " $i
foreach ($b in $readthefiletwo)
{
write-host "B = " $b

if ($i -eq $b)
{
write $i >> c:\out.txt
write-host I found a customer that exists in both
}

}
}

# End of Program Nigel


#write-host contents of file 1


#write-host $readthefile
#write-host contents of file 2
#write-host $readthefiletwo

Thursday, October 06, 2011

Powershell calling a web service

$results2=6

switch ($results2)
{
36 {write-host the value be thirty36}
}




get-help date

$mydate = get-date | Out-String

$mydate = get-date
$mydate = $mydate.ToString()

$mydate
get-date
# HI 96801 - Honolulu
# AK 99501
# NY 10001
# AZ 85001


#Generated Form Function
function GenerateForm {
########################################################################
# Generated By: niglen
########################################################################

#region Import the Assemblies
[reflection.assembly]::loadwithpartialname("System.Drawing") | Out-Null
[reflection.assembly]::loadwithpartialname("System.Windows.Forms") | Out-Null
#endregion

# setup proxy NIGEL
#$ws=New-WebServiceProxy -uri http://ws.cdyne.com/WeatherWS/Weather.asmx?WSDL





#region Generated Form Objects
$form1 = New-Object System.Windows.Forms.Form
$groupBox2 = New-Object System.Windows.Forms.GroupBox
$pictureBox2 = New-Object System.Windows.Forms.PictureBox
$pictureBox1 = New-Object System.Windows.Forms.PictureBox
$groupBox1 = New-Object System.Windows.Forms.GroupBox
$richTextBox1 = New-Object System.Windows.Forms.RichTextBox
$progressBar1 = New-Object System.Windows.Forms.ProgressBar
$label1 = New-Object System.Windows.Forms.Label
$button1 = New-Object System.Windows.Forms.Button
$textBox1 = New-Object System.Windows.Forms.TextBox
$InitialFormWindowState = New-Object System.Windows.Forms.FormWindowState
#endregion Generated Form Objects

#$pictureBox2 | get-member

#----------------------------------------------
#Generated Event Script Blocks
#----------------------------------------------
#Provide Custom Code for events specified in PrimalForms.
$button1_OnClick=
{
$progressBar1.PerformStep()
$progressBar1.PerformStep()
$ws2=New-WebServiceProxy -uri http://ws.cdyne.com/WeatherWS/Weather.asmx?WSDL
$progressBar1.PerformStep()
write-host completed making the proxy
$ws2 | get-member

write-host you clicked the button I am working...
$thezip = $textBox1.text
write-host the value you keyed into the text box is
write-host $thezip

$results = $ws2.getcityweatherbyZip($thezip)
write-host made it here
$results.State
$results.Description
$results.Temperature
$results.Wind
$results.City

$myresults=$results
$progressBar1.PerformStep()
$richTextBox1.text = "State: "
$richTextBox1.text += $results.State+"`n"
$richTextBox1.text += "Description: "
$richTextBox1.text += $results.Description+"`n"
$richTextBox1.text += "Temperature "
$richTextBox1.text += $results.Temperature+"`n"
$richTextBox1.text += "Wind Speed and Direction "
$richTextBox1.text += $results.Wind+"`n"
$richTextBox1.text += "City: "
$richTextBox1.text += $results.City+"`n"


if ($results.Temperature -lt 60) {
$pictureBox2.BackgroundImage = [System.Drawing.Image]::FromFile('G:\FILES\nigel_dressed_warm.jpg')
$pictureBox2.BackgroundImageLayout = 2 }

if ($results.Temperature -gt 59) {
$pictureBox2.BackgroundImage = [System.Drawing.Image]::FromFile('G:\FILES\nigel_hot_weather2.jpg')
$pictureBox2.BackgroundImageLayout = 2 }

$pictureBox2 | get-member

if ($results.Description -like "*rain*") {
$pictureBox1.BackgroundImage = [System.Drawing.Image]::FromFile('G:\FILES\rain.jpg')
$pictureBox1.BackgroundImageLayout = 2 }

if ($results.Description -like "*Cloudy*") {
$pictureBox1.BackgroundImage = [System.Drawing.Image]::FromFile('G:\FILES\cloud.jpg')
$pictureBox1.BackgroundImageLayout = 2 }

if ($results.Description -like "*partly*") {
$pictureBox1.BackgroundImage = [System.Drawing.Image]::FromFile('G:\FILES\partly.jpg')
$pictureBox1.BackgroundImageLayout = 1 }

$progressbar1.Value=0

}

$OnLoadForm_StateCorrection=
{#Correct the initial state of the form to prevent the .Net maximized form issue
$form1.WindowState = $InitialFormWindowState
}

#----------------------------------------------
#region Generated Form Code
$form1.Text = "The Nigel Weather Application a Web Services Example "
$form1.Name = "form1"
$form1.BackgroundImage = [System.Drawing.Image]::FromFile('G:\FILES\bluebackground2.jpg')
$form1.DataBindings.DefaultDataSourceUpdateMode = 0
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = 1169
$System_Drawing_Size.Height = 768
$form1.ClientSize = $System_Drawing_Size

$groupBox2.Name = "groupBox2"

$groupBox2.Text = "Clothing Suggested"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = 694
$System_Drawing_Size.Height = 590
$groupBox2.Size = $System_Drawing_Size
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 397
$System_Drawing_Point.Y = 137
$groupBox2.Location = $System_Drawing_Point
$groupBox2.TabStop = $False
$groupBox2.TabIndex = 5
$groupBox2.DataBindings.DefaultDataSourceUpdateMode = 0

$form1.Controls.Add($groupBox2)
$pictureBox2.TabIndex = 1
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = 373
$System_Drawing_Size.Height = 350
$pictureBox2.Size = $System_Drawing_Size


$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 195
$System_Drawing_Point.Y = 203
$pictureBox2.Location = $System_Drawing_Point


$pictureBox2.TabStop = $False
$pictureBox2.Name = "pictureBox2"
$pictureBox2.DataBindings.DefaultDataSourceUpdateMode = 0

$groupBox2.Controls.Add($pictureBox2)

$pictureBox1.TabIndex = 0
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = 370
$System_Drawing_Size.Height = 141
$pictureBox1.Size = $System_Drawing_Size


$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 199
$System_Drawing_Point.Y = 39
$pictureBox1.Location = $System_Drawing_Point


$pictureBox1.TabStop = $False
$pictureBox1.Name = "pictureBox1"
$pictureBox1.DataBindings.DefaultDataSourceUpdateMode = 0

$groupBox2.Controls.Add($pictureBox1)


$groupBox1.Name = "groupBox1"

$groupBox1.Text = "Weather Details"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = 337
$System_Drawing_Size.Height = 551
$groupBox1.Size = $System_Drawing_Size
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 41
$System_Drawing_Point.Y = 126
$groupBox1.Location = $System_Drawing_Point
$groupBox1.TabStop = $False
$groupBox1.TabIndex = 4
$groupBox1.DataBindings.DefaultDataSourceUpdateMode = 0

$form1.Controls.Add($groupBox1)
$richTextBox1.Name = "richTextBox1"
$richTextBox1.Text = ""
$richTextBox1.DataBindings.DefaultDataSourceUpdateMode = 0
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 14
$System_Drawing_Point.Y = 30
$richTextBox1.Location = $System_Drawing_Point
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = 310
$System_Drawing_Size.Height = 505
$richTextBox1.Size = $System_Drawing_Size
$richTextBox1.TabIndex = 0

$groupBox1.Controls.Add($richTextBox1)


$progressBar1.DataBindings.DefaultDataSourceUpdateMode = 0
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = 267
$System_Drawing_Size.Height = 23
$progressBar1.Size = $System_Drawing_Size
$progressBar1.TabIndex = 3
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 403
$System_Drawing_Point.Y = 50
$progressBar1.Location = $System_Drawing_Point
$progressBar1.Name = "progressBar1"
$progressBar1.Step = 50

$form1.Controls.Add($progressBar1)

$label1.TabIndex = 2
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = 84
$System_Drawing_Size.Height = 20
$label1.Size = $System_Drawing_Size
$label1.Text = "ZIP CODE"
$label1.Font = New-Object System.Drawing.Font("MS Reference Sans Serif",9.75,0,3,0)

$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 54
$System_Drawing_Point.Y = 54
$label1.Location = $System_Drawing_Point
$label1.DataBindings.DefaultDataSourceUpdateMode = 0
$label1.Name = "label1"

$form1.Controls.Add($label1)

$button1.TabIndex = 1
$button1.Name = "button1"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = 34
$System_Drawing_Size.Height = 33
$button1.Size = $System_Drawing_Size
$button1.UseVisualStyleBackColor = $True

$button1.Image = [System.Drawing.Image]::FromFile('G:\FILES\Search.PNG')
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 345
$System_Drawing_Point.Y = 47
$button1.Location = $System_Drawing_Point
$button1.DataBindings.DefaultDataSourceUpdateMode = 0
$button1.add_Click($button1_OnClick)

$form1.Controls.Add($button1)

$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = 195
$System_Drawing_Size.Height = 20
$textBox1.Size = $System_Drawing_Size
$textBox1.DataBindings.DefaultDataSourceUpdateMode = 0
$textBox1.Name = "textBox1"
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 144
$System_Drawing_Point.Y = 54
$textBox1.Location = $System_Drawing_Point
$textBox1.TabIndex = 0
$textBox1.Text = "96801"
$form1.Controls.Add($textBox1)

#endregion Generated Form Code

#Save the initial state of the form
$InitialFormWindowState = $form1.WindowState
#Init the OnLoad event to correct the initial state of the form
$form1.add_Load($OnLoadForm_StateCorrection)
#Show the Form
$form1.ShowDialog()| Out-Null

} #End Function

#Call the Function
GenerateForm

Tuesday, October 04, 2011

Check Memory Processors LOGPARSER

Check memory processors, etc...




echo off
CLS
color 12

echo ####################################################
echo # Performance Analysis #
echo # Analyzes customer perfmon counter logs for PPS #
echo # By Nigel Glenwood #
echo ####################################################
echo

echo ^ > targets_perf.html
echo ^ >> targets_perf.html
echo ^ >> targets_perf.html
echo ^ >> targets_perf.html
echo ^Targets Live Performance Data >> targets_perf.html
echo ^ >> targets_perf.html
echo data refreshed approximately every 5 minutes >> targets_perf.html
echo ^ >> targets_perf.html





rem #####################################
REM Variable Declaration Section
rem #####################################
set async=aitpiis203
set mainsql=co1aitpsql500
set olap=co1aitpolap500
set iisone=aitpiis203

set app_name=targets


set loglocation=\\bakerx\D$\perflogs\targets\*.csv



rem EXTRACT_TOKEN(Strings, 0, '|')

REM send servername to this and it will create all graphs

rem #####################################################################################################
rem # M A I N #
rem #####################################################################################################



rem ########################################################################################################
rem first grab all the data and place into file for querying, this helps the graphs have the times
rem from left to right as most people would default to reading the graphs
rem ########################################################################################################

echo grabbing data to create initial subset that all other queries hit That are past 24 hours

rem past 24 Hours PROCESSOR


logparser "Select top 288 to_string([(PDH-CSV 4.0) (Pacific Standard Time)(480)]) AS DATE, avg( [\\%iisone%\PerformancePoint:SessionManagement\Total User Sessions]) AS %iisone%_Sessions, avg( [\\%async%\Processor(_Total)\%% Processor Time]) as ASYNCPROC, avg([\\%olap%\Processor(_Total)\%% Processor Time]) as OLAPPROC, avg([\\%mainsql%\Processor(_Total)\%% Processor Time]) as SQLPROC, avg([\\%iisone%\Processor(_Total)\%% Processor Time]) as IISPROC,avg( [\\%async%\Memory\%% Committed Bytes In Use]) AS ASYNCMemory from %loglocation% group by DATE order by DATE DESC" -i:csv -q -o:csv -headers:on > temporary2.csv


rem past 24 Hours MEMORY

logparser "Select top 288 to_string([(PDH-CSV 4.0) (Pacific Standard Time)(480)]) AS DATE, avg([\\%iisone%\PerformancePoint:SessionManagement\Total User Sessions]) AS %iisone%_Sessions , avg([\\aitpiis203\Memory\%% Committed Bytes In Use]) as IISMEM , avg([\\co1aitpolap500\Memory\%% Committed Bytes In Use]) as OLAPMEM, avg([\\co1aitpsql500\Memory\%% Committed Bytes In Use]) as SQLMEM from %loglocation% group by DATE order by DATE DESC" -i:csv -q -o:csv -headers:on > temporary_mem.csv


rem past 7 days

logparser "Select top 2016 to_string([(PDH-CSV 4.0) (Pacific Standard Time)(480)]) AS DATE, avg( [\\%iisone%\PerformancePoint:SessionManagement\Total User Sessions]) AS %iisone%_Sessions, avg( [\\%async%\Processor(_Total)\%% Processor Time]) as ASYNCPROC, avg([\\%olap%\Processor(_Total)\%% Processor Time]) as OLAPPROC, avg([\\%mainsql%\Processor(_Total)\%% Processor Time]) as SQLPROC, avg([\\%iisone%\Processor(_Total)\%% Processor Time]) as IISPROC,avg( [\\%async%\Memory\%% Committed Bytes In Use]) AS ASYNCMemory from %loglocation% group by DATE order by DATE DESC" -i:csv -q -o:csv -headers:on > temporary_week.csv


rem Past 2 Hours

logparser "Select top 26 to_string([(PDH-CSV 4.0) (Pacific Standard Time)(480)]) AS DATE, avg( [\\%iisone%\PerformancePoint:SessionManagement\Total User Sessions]) AS %iisone%_Sessions, avg( [\\%async%\Processor(_Total)\%% Processor Time]) as ASYNCPROC, avg([\\%olap%\Processor(_Total)\%% Processor Time]) as OLAPPROC, avg([\\%mainsql%\Processor(_Total)\%% Processor Time]) as SQLPROC, avg([\\%iisone%\Processor(_Total)\%% Processor Time]) as IISPROC,avg( [\\%async%\Memory\%% Committed Bytes In Use]) AS ASYNCMemory from %loglocation% group by DATE order by DATE DESC" -i:csv -q -o:csv -headers:on > temporary4.csv


rem Past 1 Hour

logparser "Select top 14 to_string([(PDH-CSV 4.0) (Pacific Standard Time)(480)]) AS DATE, avg( [\\%iisone%\PerformancePoint:SessionManagement\Total User Sessions]) AS %iisone%_Sessions, avg( [\\%async%\Processor(_Total)\%% Processor Time]) as ASYNCPROC, avg([\\%olap%\Processor(_Total)\%% Processor Time]) as OLAPPROC, avg([\\%mainsql%\Processor(_Total)\%% Processor Time]) as SQLPROC, avg([\\%iisone%\Processor(_Total)\%% Processor Time]) as IISPROC,avg( [\\%async%\Memory\%% Committed Bytes In Use]) AS ASYNCMemory from %loglocation% group by DATE order by DATE DESC" -i:csv -q -o:csv -headers:on > temporary5.csv



rem ########################################################################################################


rem #####################################################################################
rem # ALL Servers Total User Sessions and Percent Processor By Hour #
rem #####################################################################################


Echo All Servers Sessions and Processor By Hour
rem logparser "Select top 24 substr([(PDH-CSV 4.0) (Pacific Standard Time)(480)],0,2) AS MONTH, substr([(PDH-CSV 4.0) (Pacific Standard Time)(480)],3,2) AS DAY, substr([(PDH-CSV 4.0) (Pacific Standard Time)(480)],6,4) AS YEAR,substr([(PDH-CSV 4.0) (Pacific Standard Time)(480)],11,2) AS Hour, avg( [\\%iisone%\PerformancePoint:SessionManagement\Total User Sessions]) AS %iisone%_Sessions, avg( [\\%async%\Processor(_Total)\%% Processor Time]) as ASYNCPROC, avg([\\%olap%\Processor(_Total)\%% Processor Time]) as OLAPPROC, avg([\\%mainsql%\Processor(_Total)\%% Processor Time]) as SQLPROC, avg([\\%iisone%\Processor(_Total)\%% Processor Time]) as IISPROC from %loglocation% group by MONTH,DAY,YEAR, Hour order by MONTH,DAY ,YEAR, Hour DESC" -i:csv -q -o:csv -headers:on > temporary.csv
rem rem rem rem rem pause




rem rem rem rem rem pause




rem logparser "Select top 26 to_string([(PDH-CSV 4.0) (Pacific Standard Time)(480)]) AS DATE, avg( [\\%iisone%\PerformancePoint:SessionManagement\Total User Sessions]) AS %iisone%_Sessions, avg( [\\%async%\Processor(_Total)\%% Processor Time]) as ASYNCPROC, avg([\\%olap%\Processor(_Total)\%% Processor Time]) as OLAPPROC, avg([\\%mainsql%\Processor(_Total)\%% Processor Time]) as SQLPROC, avg([\\%iisone%\Processor(_Total)\%% Processor Time]) as IISPROC from %loglocation% group by DATE order by DATE DESC" -i:csv -q -o:csv -headers:on > temporary3.csv


rem creating chart Processor past 24 hours close up


logparser "Select DATE ,avg(aitpiis203_Sessions),avg(ASYNCPROC),avg(OLAPPROC),avg(SQLPROC),avg(IISPROC) into %app_name%usersessionsandprocessorbyHOUR.gif from temporary2.csv group by DATE order by DATE " -i:csv -q -charttype:line -groupSize:1024x800 -values:off -legend:on -chartTitle:"Targets PROCESSOR Usage Past 24 Hours Close Up View"


rem memory close up 24 hours


logparser "Select DATE ,avg(%iisone%_Sessions),avg(IISMEM),avg(OLAPMEM),avg(SQLMEM) into %app_name%usersessionsandprocessorbyHOUR_MEMORY.gif from temporary_mem.csv group by DATE order by DATE " -i:csv -q -charttype:line -groupSize:1024x800 -values:off -legend:on -chartTitle:"Targets MEMORY Usage Past 24 Hours Close Up View"

%iisone%_Sessions


rem line3d looks cool but not sure how good to read


logparser "Select DATE ,avg(aitpiis203_Sessions),avg(ASYNCPROC),avg(OLAPPROC),avg(SQLPROC),avg(IISPROC) into %app_name%usersessionsandprocessorbyHOUR3d_1.gif from temporary2.csv group by DATE order by DATE " -i:csv -q -charttype:line3d -groupSize:1024x800 -values:off -legend:on -config:chartconfig5.js -chartTitle:"Targets Usage Past 24 Hours Close Up View"

rem pause

logparser "Select DATE ,avg(aitpiis203_Sessions),avg(ASYNCPROC),avg(OLAPPROC),avg(SQLPROC),avg(IISPROC) into %app_name%usersessionsandprocessorbyHOUR3d_2.gif from temporary2.csv group by DATE order by DATE " -i:csv -q -charttype:line3d -groupSize:1024x800 -values:off -legend:on -config:chartconfig11.vbs -chartTitle:"Targets Usage Past 24 Hours Close Up View"

rem pause

logparser "Select DATE ,avg(aitpiis203_Sessions),avg(ASYNCPROC),avg(OLAPPROC),avg(SQLPROC),avg(IISPROC) into %app_name%usersessionsandprocessorbyHOUR3d_3.gif from temporary2.csv group by DATE order by DATE " -i:csv -q -charttype:line3d -groupSize:1024x800 -values:off -legend:on -chartTitle:"Targets Usage Past 24 Hours Close Up View"

rem pause

logparser "Select DATE ,avg(aitpiis203_Sessions),avg(ASYNCPROC),avg(OLAPPROC),avg(SQLPROC),avg(IISPROC) into %app_name%usersessionsandprocessorbyHOUR100.gif from temporary2.csv group by DATE order by DATE " -i:csv -q -charttype:line -groupSize:1024x800 -values:off -legend:on -config:chartconfig11.vbs -chartTitle:"Targets Usage Past 24 Hours Based on 100"

rem pause

logparser "Select DATE ,avg(aitpiis203_Sessions),avg(ASYNCPROC),avg(OLAPPROC),avg(SQLPROC),avg(IISPROC) into %app_name%usersessionsandprocessorbyHOURlast2Hours.gif from temporary4.csv group by DATE order by DATE " -i:csv -q -charttype:column3d -groupSize:1024x800 -values:off -legend:on -config:chartconfig11.vbs -chartTitle:"Targets Usage Past 2 Hours"

rem pause


rem rem rem rem rem pause





rem #####################################################################################
rem # ASYNC Percent Committed Bytes in Use #
rem #####################################################################################

echo ASYNC Memory

logparser "Select top 288 Date,avg(ASYNCMemory) into %app_name%async_memory.gif from temporary2.csv group by Date order by Date " -i:csv -q -charttype:line -groupSize:1024x800 -legend:off -config:chartconfig.js -chartTitle:"Async Memory Committed Bytes in Use Past 24 Hours"

rem rem rem rem rem pause

rem #####################################################################################
rem # SQL Server Total User Sessions and Percent Processor #
rem #####################################################################################

Echo Total User Sessions


logparser "Select Date, avg(SQLPROC), avg(aitpiis203_Sessions) into %app_name%usersessionsandSQL_processorpast60minutes.gif from temporary5.csv group by date order by Date " -i:csv -q -charttype:column3d -groupSize:1024x800 -legend:off -config:chartconfig.js -chartTitle:"Sql Processor VS PPS User Sessions Past 1 Hour"

rem rem rem rem rem pause





rem #####################################################################################
rem # ALL Servers Total User Sessions and Percent Processor By Minute #
rem #####################################################################################


Echo All Servers Sessions and Processor



logparser "Select top 288 Date, avg(aitpiis203_Sessions),avg(ASYNCPROC),avg(OLAPPROC),avg(SQLPROC),avg(IISPROC) into %app_name%usersessionsandprocessorALL.gif from temporary2.csv group by date order by Date " -i:csv -q -charttype:line -groupSize:1024x800 -legend:on -config:chartconfig11.vbs -chartTitle:"Targets Usage Past 24 Hours "

rem #####################################################################################
rem # System Usage Past 2 Hours #
rem #####################################################################################




logparser "Select Date, avg(ASYNCPROC),avg(OLAPPROC),avg(SQLPROC),avg(IISPROC), avg(%iisone%_Sessions) into %app_name%usersessionsandprocessorALL2hours.gif from temporary4.csv group by Date order by Date" -i:csv -q -charttype:line -groupSize:1024x800 -legend:on -config:chartconfig11.vbs -chartTitle:"Targets Usage Past 2 Hours "



rem rem rem rem rem pause

rem #####################################################################################
rem # ALL Servers Total User Sessions and Percent Processor Past 60 Minutes #
rem #####################################################################################

Echo All Servers Sessions and Processor Past 60 Minutes


logparser "Select Date, avg(ASYNCPROC),avg(OLAPPROC),avg(SQLPROC),avg(IISPROC) into %app_name%usersessionsandprocessorpast60minutes.gif from temporary5.csv group by date order by Date" -i:csv -q -charttype:line -groupSize:1024x768 -legend:on -chartTitle:"Users and Processor(Percentage) Usage Past 60 Minutes" -config:chartconfig5.js -chartTitle:"Targets Usage Past 1 Hour"

rem rem rem rem rem pause


rem #####################################################################################
rem # Max users of the system #
rem #####################################################################################

rem do not run this one all the time as its purpose is to run through the entire log files
rem of the system and come up with max users that have been on a certain system for its life
rem time, it would really just need to be run once a week for comparison


rem logparser "Select max([\\%iisone%\PerformancePoint:SessionManagement\Total User Sessions]) AS Maxusersessionsever from \\niglen1\scripts\services*.csv" -i:csv -q -o:csv > maxusers.csv

rem rem rem rem rem pause

rem #####################################################################################
rem # Total Users of System over all time #
rem #####################################################################################

rem logparser "Select [(PDH-CSV 4.0) (Pacific Standard Time)(480)] AS TIME, [\\%iisone%\PerformancePoint:SessionManagement\Total User Sessions] AS PPTotalUserSessions into usersessions.gif from \\NIGLEN1\services_logs_all\*.csv order by TIME desc" -i:csv -q -charttype:column3d -groupSize:1024x768 -legend:off

rem #####################################################################################
rem # Sessions and IIS Processor #
rem #####################################################################################

Echo IIS Sessions and Processor By all

logparser "Select top 288 Date, avg(aitpiis203_Sessions),avg(IISPROC) into %app_name%usersessionsiisprocessor.gif from temporary2.csv group by date order by Date" -i:csv -q -charttype:column3d -groupSize:1024x768 -legend:off -config:chartconfig11.vbs -chartTitle:"Targets PPS Users VS IIS Processor past 24 Hours"


rem rem rem rem rem pause

rem #####################################################################################
rem # average iis processor and users all time #
rem #####################################################################################

rem logparser "Select avg([\\%iisone%\PerformancePoint:SessionManagement\Total User Sessions]) AS PPTotalUserSessions, avg([\\%iisone%\Processor(_Total)\%% Processor Time]) as IISPROC into usersessionsiisprocessoravgerage.gif from \\NIGLEN1\services_logs_all\*.csv" -i:csv -q -charttype:column3d -groupSize:1024x768 -legend:off

rem #####################################################################################
rem # async memory past 1 HOUR #
rem #####################################################################################

echo async memory past hour

logparser "Select Date, avg(ASYNCMemory) into %app_name%asyncmemorypast10minutes.gif from temporary5.csv group by date order by Date " -i:csv -q -charttype:column3d -groupSize:1024x768 -legend:off -chartTitle:"Targets ASYNC Usage Past 1 Hour"


rem ### past 7 days usage ###


logparser "Select DATE ,avg(aitpiis203_Sessions),avg(ASYNCPROC),avg(OLAPPROC),avg(SQLPROC),avg(IISPROC) into %app_name%usersessionsandprocessorbyHOUR100_week.gif from temporary_week.csv group by DATE order by DATE " -i:csv -q -charttype:line -groupSize:1024x800 -values:off -legend:on -config:chartconfig11.vbs -chartTitle:"Targets Usage Past 7 Days Based on 100"

logparser "Select DATE ,avg(aitpiis203_Sessions),avg(ASYNCPROC),avg(OLAPPROC),avg(SQLPROC),avg(IISPROC) into %app_name%usersessionsandprocessorbyHOUR100_week_close.gif from temporary_week.csv group by DATE order by DATE " -i:csv -q -charttype:line -groupSize:2024x600 -values:off -legend:on -chartTitle:"Targets Usage Past 7 Days Close Up View"




rem #####################################################################################
rem # Build A WEb Page Based on Images we Just Created #
rem #####################################################################################


echo ^ >> targets_perf.html
echo ^ >> targets_perf.html
echo ^ >> targets_perf.html
echo ^ >> targets_perf.html
echo ^ >> targets_perf.html
echo ^ >> targets_perf.html
echo ^ >> targets_perf.html
echo ^ >> targets_perf.html
echo ^ >> targets_perf.html
echo ^ >> targets_perf.html
echo ^ >> targets_perf.html
echo ^ >> targets_perf.html
echo ^ >> targets_perf.html
echo ^ >> targets_perf.html
echo ^ >> targets_perf.html
echo ^ >> targets_perf.html
echo ^ >> targets_perf.html
echo ^ >> targets_perf.html
echo ^ >> targets_perf.html
echo ^ >> targets_perf.html
echo ^ >> targets_perf.html
echo ^ >> targets_perf.html
echo ^ >> targets_perf.html
echo ^ >> targets_perf.html
echo ^ >> targets_perf.html
echo ^ >> targets_perf.html


echo ^ >> targets_perf.html
echo ^Created %date% %time% >> targets_perf.html



rem rem rem rem rem pause

rem #####################################################################################################
rem # E N D M A I N #
rem #####################################################################################################


ROBOCOPY C:\Users\niglen\Documents\Scripts\targets_perf_analyze\ \\bakerx\d$\mumar *.html /zb /R:3 /Log:nigellog2%random%.txt
ROBOCOPY C:\Users\niglen\Documents\Scripts\targets_perf_analyze\ \\bakerx\d$\mumar *.gif /zb /R:3 /Log:nigellog2%random%.txt

Friday, December 01, 2006

Uptime Tool

Uptime Tool

Description: Analyzes lists of servers, and produces report output of the uptime of these servers.  

Reasoning: One time a tool was being used which randomly rebooted hundreds of servers, in order to quickly identify those afflicted, I wrote this tool.

FileName: Uptime.cmd

rem -------------------------------rem Uptime Tool V1.0rem -------------------------------rem Description: Reads a file containing a list of servers and rem dynamically creates a web page that displays the uptime of each serverrem Script could be adjusted to display much more information on each serverrem Author: Nigel Glenwood October 26, 2006remrem *****************************************************************************rem technical desc:rem 1 display the web page, inside web page refresh every 5 secondsrem read server file, and run system information, parse out up timerem pipe this into dynamic web pagerem *****************************************************************************
clsecho off
rem create web page startup
copy /y clock2.gif clock
rem set thedir=c:\dat\*.*
rem echo directory set to %thedir%
rem use template to startcopy /y template.htm thepage.html
echo Analysis Start Time: %DATE% %TIME% >> thepage.html
sleep 2
rem open up the IE startup page, which displays # server uptime informationstart /b c:\progra~1\intern~1\iexplore.exe C:\dat\thepage.html
rem :looprem echo looping...
rem read the a server, and create web pagerem %%z passes into create, we pick it up as %1
for /F %%z in (servers.txt) do call create.cmd %%z
echo Analysis Complete >> thepage.htmlecho ^ >> thepage.htmlecho Uptime tool v1.0 by Nigel Glenwood >> thepage.htmlrem change the image on the page to finished.copy /y finish.jpg clockecho ^<^/i^> >> thepage.html
rem sleep 5
rem goto loop


==========================================================
filename: Create.cmd


echo ^Server: %1 ^<^/B^> >> thepage.html
srvinfo -nf \\%1 find "Up Time" >> thepage.html


DAT (Directory Analysis Tool) By: Nigel Glenwood


DAT (Directory Analysis Tool) By: Nigel Glenwood

filename: file.cmd
rem -------------------------------
rem Directory Alert Tool (DAT)
rem -------------------------------
rem Description: Monitors number of files in a directory, original developed
rem to monitor biz talk, but it could be utilized to monitor directories and
rem ensure there are not more than 25,000 files, or to monitor smtp mail
rem
rem Author: Nigel Glenwood
rem
rem *****************************************************************************
rem technical desc:
rem -q = quite mode, so we do not get headings, andstatistical data in our result
rem -Recurse, 0 do not go through sub-dirs, if -1, goes through all, if 2 would
rem go to 2 iterations, etc...
rem place result into my output file out.txt, to be placed into variable later
rem -i:FS, means we are hitting the FS, not an IIS log, or Event Log etc..
rem *****************************************************************************
rem How does it freakin work?
rem first we have a dynamic web page, intially we copy the start.gif
rem overlaying my.gif, just for startup
rem then we display the webpage, while we are running the background
rem the web page refreshed itself every 5 seconds, in header tag
rem on subsequent loads, my.gif is generated with the latest data
rem when the threshold is reached, a warning gif is displayed
rem when the threshold goes back down, it replaces it back with the my.gif
rem *****************************************************************************


cls
echo off

rem create web page startup
rem overwrite in case warning message present.

copy /y start.gif my.gif

set thedir=c:\dat\*.*

echo directory set to %thedir%
rem open up the IE startup page, which displays # of files
start /b c:\progra~1\intern~1\iexplore.exe C:\dat\warning.htm


:loop
echo looping...

rem chart types: Column3d

rem create the graph
logparser "SELECT count(name) as [Number of Files] into my.gif FROM %%thedir%% where attributes like '%%A%%' " -i:FS -Recurse:0 -q:on -o:CHART -values:on -chartType:Column3d -chartTitle:"Files" -groupSize:600x480

rem place count into out.txt, read later on
logparser "SELECT count(name) as [ ] FROM %%thedir%% where attributes like '%%A%%' " -i:FS -rtp:-1 -Recurse:0 -q:on > out.txt

logparser "SELECT attributes, COUNT(*) AS files INTO graph.jpg FROM %%thedir%% where attributes like '%%A%%' GROUP BY attributes ORDER BY attributes ASC" -i:FS -o:CHART -values:on -chartType:pieexploded3d -chartTitle:"%1" -groupSize:1400x800

rem logparser "SELECT * FROM %%thedir%% " -i:FS -q:on >> theoutput.txt


pause

rem file creator, to check application/test
rem this keeps creating files in the directory, turn off after Testing
echo creating file
echo %random% > %random%.txt


rem read the count we placed into out.txt pass it as a variable
rem in display.cmd we will pick up %%Z as %1 and perform processing

for /F %%z in (out.txt) do call display.cmd %%z




sleep 5

goto loop


=============================================================================
Filename: display.cmd
rem -------------------------------
rem Directory Alert Tool (DAT)
rem -------------------------------
rem By: Nigel G.

cls
echo off
echo you sent me %1


rem convert to arithmitic, so it knows it is a number, how ya like dem apples

set /a thefiles=%1
set /a threshold=70
set /a thresholdb=%threshold%+1

echo the files now is %thefiles%

rem perform ifs to determine if value is greater than threshold
rem if %thefiles% GTR %threshold% start c:\progra~1\intern~1\iexplore.exe C:\dat\warning2.htm
if %thefiles% GTR %threshold% copy /Y one.GIF my.gif
if %thefiles% GTR %threshold% echo Threshold Reached Warning displayed sleeping now...
if %thefiles% GTR %threshold% sleep 1


if %thefiles% LSS %thresholdb% echo Files currently within contraints



=============================================================================
Filename: Warning.html (This dynamically refreshed itself ever 5 secs)

*html*
*head**meta http-equiv="Content-Language" content="en-us"**meta http-equiv="Content-Type" content="text/html; charset=windows-1252"**meta http-equiv="refresh" content="5" * *title*Warning*/title**/head*
*body**p align="center"**img border="0" src="triangle.gif" width="95" height="82"**p align="center"**font face="Trebuchet MS" color="#FF0000"*Monitoring Files...*/font**/p*
*p align="center"**img border="0" src="my.gif" width="600" height="480"**/p*
*/body*
*/html*



***END***


Monday, October 23, 2006

Nigel at Work, October 2006

Very useful Code and Scripts

I wanted to have a repository of scripts that I work on and use. Here it is! I have been utilizing log parser 2.2 much lately, along with .cmd scripts.

Hope some of this helps you out,

Nigel