Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
Help us understand the problem. What is going on with this article?

New Relic をバージョンアップした話

More than 3 years have passed since last update.

NewRelic Server Monitorが使えなくなると言うんで、
NewRelic Server Monitorの代わりにNewrelic Infrastructureを導入することになったらしい。
Azure上の仮想マシンはPowershellDSC、CloudServiceはPowershellで自動化していたインストールのScriptを書き換えてみようと思います。

NewRelicServerMonitorのときは、、、

chkNRSM.ps1
$r = Get-WmiObject -Class Win32_Product | Where-Object {$_.Name -match "New Relic Server Monitor"}
if ($r -ne $null)
{......

installNRSM.ps1

Write-Verbose "Installing NewRelic module ... Downloading ..."

# download module files
$sourceContainer = $installSourceStorageUrl + "installmodules";
C:\AzCopy\AzCopy.exe /Source:$sourceContainer /Dest:"c:\Users\newrelicusr" /Y /sourceKey:$installSourceStorageKey /Pattern:$installNewRelicFile

$package = "c:\Users\newrelicusr\$installNewRelicFile"
$license_key = "NR_LICENSE_KEY="+$installNewRelicKey

#install NewRelic
Write-Verbose "Start .. NewRelic install"
Start-Process -FilePath "msiexec.exe" -ArgumentList /i , $package,'/L*v c:\Users\newrelicusr\installNewRelic.log',/qn ,$license_key -Wait

Write-Verbose "Success."

#Delete temporary msi.
Remove-Item -Force -Recurse -Path $package -ErrorAction Ignore

unInstallNRSM.ps1

Write-Verbose "NewRelic module ... Deleting ..."

#Get NewRelic module
$r = Get-WmiObject -Class Win32_Product | Where-Object {$_.Name -match "newrelic-infra"}
if ($r -ne $null)
{
    $r.Uninstall()
}

と、まぁこんな感じです。

NewRelic Infrastructureを導入するには、、、

installNRI.ps1

#Downloading New Relic client
Write-Output "Downloading New Relic Client"
$File = "$env:temp\newrelic-infra.msi"

#Downloading the file
(New-Object System.Net.WebClient).DownloadFile($NewRelicClientUrl, $File)   
Write-Output "Downloaded to: $File"

#Installing client
Write-Output "Installing Client"
Start-Process msiexec.exe -Wait -ArgumentList "/I `"$File`" TARGETDIR=`"$InstallDir`" /qn"
Write-Output "Client Installed"

#Updating license file
Write-Output "Updating License file"
(Get-Content "$InstallDir\newrelic-infra\newrelic-infra.yml").Replace("<ENTER YOUR NEW RELIC KEY HERE>", $NewRelicKey) | Set-Content "$InstallDir\newrelic-infra\newrelic-infra.yml"

#Wait a bit to get the service registered properly
Start-Sleep 5

#Restarting service
Get-Service -Name newrelic-infra | Restart-Service

#Cleaning up
Write-Output "Cleaning up"
Remove-Item $File -Force

とまぁこんな感じで、、、

おわり

見ての通り、まだ開発途中なんでインストールしか書いていませんが(アンインストールはなしにするかもしれませんが)、、、
とにかく、NewRelicは結構便利なのでみなさん試しに触ってみましょう。
あとできちんと記事の追記を行います。
※Azureの情報少ないなー

sat0tabe
フルスタックエンジニア/ソリューションアーキテクト C#/Azure/ReactNative/SQLServer/Java/Windows/VB/Powershell
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away