Your data. Anywhere you go.

New Relic for iOS or Android


Download on the App Store    Android App on Google play


New Relic Insights App for iOS


Download on the App Store


Learn more

Close icon

Feature Idea: Add w3wp check to the .Net APM agent install and make message more user friendly

feature-idea

#1

Please add a check to the .Net APM agent install to ensure you are on an active node with w3wp processes running and make the message more user friendly.

Here is my example. Not guaranteed to run. may need a few tweaks. :slight_smile:

Author John Monroe

function Is-Current-User-Admin() {
return ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] “Administrator”)
}

function check-w3wp-active-process() {
$rtn = get-process w3wp -ErrorAction SilentlyContinue
write-host “Checking for w3wp” $rtn
if($rtn = ‘’){
write-host “w3wp not running on this system. Make sure this is the active node.”
exit
}
return $rtn
}

function write-event($source, $eventid, $entrytype, $message) {
$SourceExists = [System.Diagnostics.EventLog]::SourceExists(“New Relic Agent Install”)
if (! $SourceExists) {
New-EventLog -LogName Application -Source “New Relic .net APM Agent Install”
}
write-host "source: ", $source, "eventid: ", $eventid, "message: ", $message
Write-EventLog –LogName Application –Source $source –EntryType $entrytype –EventID $eventid –Message $message
}

function check_temp_new_relic_path(){
if (!(test-path -path $pathname)) {
new-item -ItemType directory -Path $pathname -force
}
if (!(test-path $pathname)){
write-message “Could not create c:\temp\new_relic_agent. Please check manually”
}
$message = ‘Ran the check_temp_new_relic_path Function’
write-event -source ‘New Relic Agent Install’ -eventid ‘7020’ -entrytype ‘Information’ -message $message
return
}

function download_files(){
if (!(test-path -path $pathname)) {
new-item -ItemType directory -Path $path -force
}
cd $pathname
Invoke-WebRequest -uri ‘http://download.newrelic.com/dot_net_agent/release/NewRelicDotNetAgent_x64.msi’ -outfile ‘newrelic-dotnet-x64-agent.msi’
}

function Install-MSIFile($msiFile) {
$arguments = @(
“/i”
"$msiFile”"
“/qn AcceptEndUserLicenseAgreement=1”
“/norestart”
“/lv c:\temp\new_relic_agent\install.log”
“USE_SETTINGS_FROM_AD=1”
“NR_LICENSE_KEY=” + $newreliclicensekey
“NR_PROXY_ADDRESS=changeme”
)

if ($targetDir){      
  if (!(Test-Path $targetDir)){      
  throw "Path to the Installation Directory $($targetDir) is invalid. Please supply a valid installation directory"      
  }      
  $arguments += "INSTALLDIR=`"$targetDir`""      
}      
Write-Verbose "Installing $msiFile....."      
$process = Start-Process -FilePath msiexec.exe -ArgumentList $arguments -Wait -PassThru      
if ($process.ExitCode -eq 0){      
  Write-Verbose "$msiFile has been successfully installed"      
}      
else {      
  Write-Verbose "installer exit code $($process.ExitCode) for file $($msifile)"      
}      

}

function clean_temp_files($msiFile){
if (test-path $pathName){
write-host “finding path”
$file = Get-ChildItem -Path $msiFile
remove-item $file
set-location -path c:\temp
get-location
remove-item -path $pathName
}
$message = ‘Ran the clean_temp_files Function’
write-event -source ‘New Relic Agent Install’ -eventid ‘7029’ -entrytype ‘Information’ -message $message
return
}

function CheckAgentVersion() {
$rtn = get-wmiobject win32_operatingsystem -computer localhost | select-object -expandproperty OSArchitecture
write-host “Returning X64Version” $rtn
if(!($rtn = ‘64-bit’)){
write-host “This is only for 64bit systems”
exit
}
return $rtn
}

function restart-Service {
$check = (get-service -name ).Status
if($check = ‘Running’){
write-host “stopping service”
stop-service -name newrelic-infra
write-host “starting service”
start-service -name newrelic-infra
}
}

Variables.

$msiFile = ‘c:\temp\new_relic_agent\newrelic-dotnet-x64-agent.msi’
$pathName = ‘c:\temp\new_relic_agent’
$newRelicLicenseKey = ‘CHANGEME’
$isAdmin = Is-Current-User-Admin
$checkw3wp = check-w3wp-active-process

CheckAgentVersion

Functions

check_temp_new_relic_path
download_files
Install-MSIFile -msiFile $msiFile
restart-service
clean_temp_files


New Relic edit

  • I want this, too
  • I have more info to share (reply below)
  • I have a solution for this

0 voters

We take feature ideas seriously and our product managers review every one when plotting their roadmaps. However, there is no guarantee this feature will be implemented. This post ensures the idea is put on the table and discussed though. So please vote and share your extra details with our team.


#2

Hey @john.monroe! Thank you for adding so much detail! Our Product Team will be excited to look this over. :blush: