Is the Nanny state crying wolf?

Please excuse the mixed metaphors in the title of this post. I’ve found my self thinking about this regularly in recent weeks, prompted by two observations.

<rant>

    • I’m constantly required to slow down on motorways for apparently non-existent hazards. I don’t mind slowing down when it is obvious that traffic is building up or when there is likely to be congestion, but I’m increasingly finding that Matrix signs display a temporary speed limit for no apparent reason.

Signs in operation for the M62 motorway 4th lane between junctions 27 and 28

I slow down, everybody else slows down. We drive for a few miles and then all speed up again. As well as increasing wear and tear on cars, increasing pollution and frustrating drivers, this has implications for safety. The more often this happens, the less notice drivers tend to take of the warnings, increasing the chance that when something actually happens and the signs are needed, people will ignore the warnings.

  • The Met Office continually announces “yellow weather warnings” which fail to materialise. Over the last 2 weeks, the North of England must have had at least 3 or 4 warnings of hazardous conditions. These continually fail to materialise.
    This is the dire warning on my phone one days last week, next to the distinctly “frost free” view from my bedroom window.

    The weather reality consistently fails to be as bad as the forecast. Although this is more of a frustration, than a hazard, unlike my first observation. It still annoys me.

    </rant>

Local traffic for Edenfield

Killing a stalled process and leaving others running using PowerShell

Since I wrote my post “Using Loadrunner / Performance Center to kill a rogue process“, some colleagues have asked if I could kill a stalled process and leave others up and running. After some “Googling”, I have found that this is possible.

I modified some PowerShell scripts that I found online so that they do what we want. If you paste the code below into a PowerShell script called for example “KillStalledProcesses.ps1”, it will scan through all the processes on a machine and “kill” any that are not responding.

I’ve tested it using SysInternals “Process Explorer” which allows you to “suspend” a running process like in the image below. I suspended the “notepad.exe” process and tested the PowerShell code.

The code correctly identified the suspended process and “killed” it.

(When I tested this with two other running “notepad” processes, it left the two other processes running.)

My thoughts are that we could add the PowerShell script into the “Extra Files” portion of a LoadRunner or Performance Center script and call it on error using the system (command); function described in the initial blog post. This would kill for example a rogue Citrix or SAPGUI client and leave others running during a performance test.

 


[CmdletBinding()]     

( [string[]]$ComputerName = $env:ComputerName)           

($Computer in $ComputerName)

if(!(Test-Connection -ComputerName $Computer -Count 1 -quiet))

Write-Host "$Computer : OFFLINE"           

Continue           

try {

$Processes = Get-Process -ComputerName $Computer -EA Stop

$nProcesses = @($Processes | ? { $_.Responding -eq $false })

catch {

Write-Error "Failed to query processes. $_"

if($nProcesses)

foreach($nProcess in $nProcesses)

$nProcess | select Name, id, MainWindowTitle, Responding

Write-host "Attempting to kill stalled process"

if ($nProcess.Id -ne $PID)

Stop-Process $nProcess.Id}

else

Write-host "No non-responding processes found"