cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Not a customer? Start a free trial

Click the Start a free trial link to start a 15-day SaaS trial of our product and join our community as a trial user. If you are an existing customer do not start a free trial.

AppDynamics customers and established members should click the sign in button to authenticate.

End User Monitoring (EUM)

Unable to create the extension for monitoring chrome browser

Shivansh.Sharma
Explorer

Unable to create the extension for monitoring chrome browser

Hi Appdynamics Community 

I am creating extension using Powershell script for monitoring chrome session running in any particular application 

I have created a script in the Powershell which is giving the desired output . But I have to make that script compatible to Appdynamics so that data can be shown in the form of Metrics and we can create Dashboard and Alert out of it .

This is the script I have created :- 

 

  • Powershell script which is created

[int]$runTimethreshold = 0

 

#Get all executing chrome processes

 

$allChromes = Get-Process chrome

 

## Code for Sorting the Output

 

$CPU = Get-Process chrome | Sort-Object -Property CPU | Select-Object -Last 20

$WS = Get-Process chrome | Sort-Object -Property WS | Select-Object -Last 20

$PM = Get-Process chrome | Sort-Object -Property PM | Select-Object -Last 20

#$MS = get-process chrome | select-object PrivateMemorySize, Description -Last 20

 

## Code to fetch the Parent Process ID

 

$ParentProcessIds = Get-CimInstance -Class Win32_Process -Filter "Name = 'chrome.exe'"

$s = Write-Output PPID $ParentProcessIds[0].ParentProcessId

 

#Code to fetch the thread which are in hung state

 

function Thread_Hung_State_Chrome ($waitProc, $idleTimeout) {

    Get-CimInstance -Class Win32_Process -Filter "Name = 'chrome.exe'"

    if($allChromes -eq $null){

        $script:allChromes=New-Object -TypeName System.Collections.Stack

    }

    if($idleTimeout -gt 0){

        $lastMemUsageCount=Get-chromeMemoryUsage $waitProc.ID

        $memUsageStack.Push($lastMemUsageCount)

        if($lastMemUsageCount -eq 0 -or (($memUsageStack.ToArray() | ? { $_ -ne $lastMemUsageCount }) -ne $null)){

            $memUsageStack.Clear()

        }

        if($memUsageStack.Count -gt $idleTimeout){

            KillTree $waitProc.ID

            throw "TASK:`r`n$command`r`n`r`nIs likely in a hung state."

        }

    }

    Start-Sleep -Second 1

}

 

$Thread = Thread_Hung_State_Chrome

 

## Code to post custom event when a chrome process is running for more than 10 mins (user defined)

## Iterate through all the chrome processes and find the elapsed time

 

foreach ($cp in $allChromes){

  $startTime = $cp.StartTime

  $elapsedTime = $(get-date) - $startTime }

 

#$totalTime = "{0:mm:ss}" -f ([datetime]$elapsedTime.Ticks)

 

$totalTime= [int]$elapsedTime.Minutes

 

## Code to post custom event when a chrome process is running for more than 10 mins

 

If ($totalTime -gt $runTimethreshold){

    $id = $cp.Id

    Write-Host Host_ID $cp.Id}

 

 

## Code for Printing the Output

 

Write-Output All_Chromes CustomMetric/Chromes $allChromes

Write-Output CPU_Usage CustomMetric/CPU $CPU

Write-Output Working_Set_Process CustomMetric/Working_Set_Process $WS

Write-Output Pageable_Memory CustomMetric/Pageable_Memory $PM

#Write-Output Chrome_MemorySize $MS

Write-Output Chrome_Thread_Hung_State CustomMetric/Hung_Threads $Thread

Write-Output Elapsed_Time CustomMetric/ $elapsedTime

Write-Output Total_Time CustomMetric/ $totalTime

 

Monitor .xml file which is created 

 

<monitor>

    <name>ChromeExtension</name>

    <type>managed</type>

    <description>Chrome Memory Usage  </description>

    <monitor-configuration>

    </monitor-configuration>

    <monitor-run-task>

        <execution-style>continuous</execution-style>

        <name>Run</name>

        <type>executable</type>

        <task-arguments>

        </task-arguments>

        <executable-task>

            <type>file</type>

            <file>Chrome_Test.ps</file>

        </executable-task>

    </monitor-run-task>

</monitor>

 

--> I have also made the necessary configuration and restarted the machine agent but desired result is not coming

 

-->> Please suggest where I am going wrong ..

 

Thanks 

-------------------

 

Tags (2)
By replying you agree to the Terms and Conditions of the AppDynamics Community.
Unable to create the extension for monitoring chrome browser