Chris S.
|
(MM club member)
|
2002-12-04 06:39 PM
|
|
|
|
|
beta - KiXforms: ProcessMon
|
|
I've been developing this script (rather slowly) for a while now and I thought it was time to solicit some feedback.
It uses WMI to monitor processes and report back some of the raw data in a nice little GUI. The look and feel is complete ripped off of Task Manager.
Anyway, I was just looking for some response on how useful this might be and what features or changes should be made.
Thanks...
Screen Shots:
Code:
Break On ;--------------------------------------------------------------------------- ; Process Listing Form ;--------------------------------------------------------------------------- $frmProcesses = CreateObject("Kixtart.Form") $frmProcesses.Size = 400,350 $frmProcesses.Text = "Process List" $frmProcesses.FontName = "Veranda" $lvwProcessList = $frmProcesses.ListView() $lvwProcessList.Left = 5 $lvwProcessList.Top = 10 $lvwProcessList.Width = $frmProcesses.ClientWidth - 10 $lvwProcessList.Bottom = $frmProcesses.ClientHeight - 35 $lvwProcessList.FullRowSelect = True $lvwProcessList.Sorted = 1 $nul = $lvwProcessList.Columns.Add("Process Name",130) $nul = $lvwProcessList.Columns.Add("PID",54,1) $nul = $lvwProcessList.Columns.Add("CPU Time",90,1) $nul = $lvwProcessList.Columns.Add("Mem Usage",90,1) $cboComputer = $frmProcesses.ComboBox(,20,30,200) $cboComputer.Top = $lvwProcessList.Bottom + 5 $cboComputer.Left = 5 $cboComputer.Additem (@WKSTA) $cboComputer.Value = "@WKSTA" $cboComputer.Sorted = 1 $btnListProcesses = $frmProcesses.Button $btnListProcesses.Text = "Refresh" $btnListProcesses.Top = $lvwProcessList.Bottom + 5 $btnListProcesses.Left = $cboComputer.Right + 5 $btnListProcesses.Size = 60,25 $btnListProcesses.OnClick = "$$nul=fnGetProcessList($$cboComputer.Value)" $btnListProcesses.ToolTip = "Refresh the process listing" $btnMonProcess = $frmProcesses.Button $btnMonProcess.Text = "Monitor" $btnMonProcess.Top = $lvwProcessList.Bottom + 5 $btnMonProcess.Left = $btnListProcesses.Right + 5 $btnMonProcess.Size = 60,25 $btnMonProcess.OnClick = "$$nul=fnMonProcess()" $btnMonProcess.ToolTip = "Monitor the currently selected process" ;--------------------------------------------------------------------------- ; Process Monitor Form ;--------------------------------------------------------------------------- $frmProcess = CreateObject("Kixtart.Form") $frmProcess.Size = 420,300 $frmProcess.Topmost = True $frmProcess.Text = "Monitoring Process" $frmProcess.FontName = "Veranda" $frmProcess.MinButton = 1 $fraCPUUsage = $frmProcess.GroupBox $fraCPUUsage.Size = 80,80 $fraCPUUsage.Text = "CPU Usage" $fraCPUUsage.Top = 5 $fraCPUUsage.Left = 5 $picCPUUsage = $fraCPUUsage.PictureBox $picCPUUsage.ScaleHeight = 51 $picCPUUsage.Width = 60 $picCPUUsage.BackColor = Black $picCPUUsage.Top = 15 $picCPUUsage.Left = 10 $prgCPUUsage = $picCPUUsage.ProgressBar $prgCPUUsage.Height = 30 $prgCPUUsage.Width = 30 $prgCPUUsage.Center $prgCPUUsage.Top = 5 $prgCPUUsage.ForeColor = Lawngreen $prgCPUUsage.BackColor = Black $prgCPUUsage.BorderStyle = 1 $prgCPUUsage.Orientation = 1 $prgCPUUsage.Style = 1 $prgCPUUsage.Max = 100 $lblCPUUsage = $picCPUUsage.Label $lblCPUUsage.Height = 15 $lblCPUUsage.Width = 28 $lblCPUUsage.Center $lblCPUUsage.Top = $prgCPUUsage.Bottom $lblCPUUsage.ForeColor = Lawngreen $lblCPUUsage.BackColor = Black $lblCPUUsage.BorderStyle = 1 $lblCPUUsage.Alignment = 1 $lblCPUUsage.Text = "%" $lblCPUUsage.FontName = "Lucida Console" $lblCPUUsage.FontSize = 8 $fraCPUHist = $frmProcess.GroupBox $fraCPUHist.Size = 320,80 $fraCPUHist.Text = "CPU Usage History" $fraCPUHist.Top = 5 $fraCPUHist.Left = $fraCPUUsage.Right + 5 $picCPUHist = $fraCPUHist.PictureBox $picCPUHist.ScaleHeight = 51 $picCPUHist.ScaleWidth = 300 $picCPUHist.BackColor = Black $picCPUHist.Top = 15 $picCPUHist.Left = 10 $fraMEMUsage = $frmProcess.GroupBox $fraMEMUsage.Size = 80,80 $fraMEMUsage.Text = "MEM Usage" $fraMEMUsage.Top = $fraCPUUsage.Bottom $fraMEMUsage.Left = 5 $picMEMUsage = $fraMEMUsage.PictureBox $picMEMUsage.ScaleHeight = 51 $picMEMUsage.Width = 60 $picMEMUsage.BackColor = Black $picMEMUsage.Top = 15 $picMEMUsage.Left = 10 $prgMEMUsage = $picMEMUsage.ProgressBar $prgMEMUsage.Height = 30 $prgMEMUsage.Width = 30 $prgMEMUsage.Center $prgMEMUsage.Top = 5 $prgMEMUsage.ForeColor = Lawngreen $prgMEMUsage.BackColor = Black $prgMEMUsage.BorderStyle = 1 $prgMEMUsage.Orientation = 1 $prgMEMUsage.Style = 1 $prgMEMUsage.Max = 100 $lblMEMUsage = $picMEMUsage.Label $lblMEMUsage.Height = 15 $lblMEMUsage.Width = 50 $lblMEMUsage.Center $lblMEMUsage.Top = $prgMEMUsage.Bottom $lblMEMUsage.ForeColor = Lawngreen $lblMEMUsage.BackColor = Black $lblMEMUsage.BorderStyle = 1 $lblMEMUsage.Alignment = 2 $lblMEMUsage.FontName = "Lucida Console" $lblMEMUsage.FontSize = 8 $fraMEMHist = $frmProcess.GroupBox $fraMEMHist.Size = 320,80 $fraMEMHist.Text = "MEM Usage History" $fraMEMHist.Top = $fraCPUHist.Bottom $fraMEMHist.Left = $fraMEMUsage.Right + 5 $picMEMHist = $fraMEMHist.PictureBox $picMEMHist.ScaleHeight = 51 $picMEMHist.ScaleWidth = 300 $picMEMHist.BackColor = Black $picMEMHist.Top = 15 $picMEMHist.Left = 10 $fraTotals = $frmProcess.GroupBox $fraTotals.Size = 200,80 $fraTotals.Text = "Totals" $fraTotals.Top = $fraMEMHist.Bottom $fraTotals.Left = $fraMEMUsage.Left $lblHandles = $fraTotals.Label $lblHandles.Size = 80,15 $lblHandles.Top = 15 $lblHandles.Left = 10 $lblHandles.Text = "Handles" $lblHandlesCount = $fraTotals.Label $lblHandlesCount.Size = 80,15 $lblHandlesCount.Top = $lblHandles.Top $lblHandlesCount.Left = $lblHandles.Right + 20 $lblHandlesCount.Alignment = 1 $lblThreads = $fraTotals.Label $lblThreads.Size = 80,15 $lblThreads.Top = $lblHandles.Bottom $lblThreads.Left = $lblHandles.Left $lblThreads.Text = "Threads" $lblThreadsCount = $fraTotals.Label $lblThreadsCount.Size = 80,15 $lblThreadsCount.Top = $lblThreads.Top $lblThreadsCount.Left = $lblThreads.Right + 20 $lblThreadsCount.Alignment = 1 $lblElapsedTime = $fraTotals.Label $lblElapsedTime.Size = 80,15 $lblElapsedTime.Top = $lblThreads.Bottom $lblElapsedTime.Left = $lblThreads.Left $lblElapsedTime.Text = "Elapsed Time" $lblElapsedTimeCount = $fraTotals.Label $lblElapsedTimeCount.Size = 80,15 $lblElapsedTimeCount.Top = $lblElapsedTime.Top $lblElapsedTimeCount.Left = $lblElapsedTime.Right + 20 $lblElapsedTimeCount.Alignment = 1 $fraOperations = $frmProcess.GroupBox $fraOperations.Size = 200,80 $fraOperations.Text = "Data Operations" $fraOperations.Top = $fraTotals.Top $fraOperations.Left = $fraTotals.Right +5 $lblDataPerSec = $fraOperations.Label("Data Bytes/Sec",10,15,90,15) $lblDataPerSecCount = $fraOperations.Label("",$lblDataPerSec.Right+20,$lblDataPerSec.Top,70,15) $lblDataPerSecCount.Alignment = 1 $lblReadsPerSec = $fraOperations.Label("Read Bytes/Sec",10,$lblDataPerSec.Bottom,90,15) $lblReadsPerSecCount = $fraOperations.Label("",$lblReadsPerSec.Right+20,$lblReadsPerSec.Top,70,15) $lblReadsPerSecCount.Alignment = 1 $lblWritesPerSec = $fraOperations.Label("Write Bytes/Sec",10,$lblReadsPerSec.Bottom,90,15) $lblWritesPerSecCount = $fraOperations.Label("",$lblWritesPerSec.Right+20,$lblWritesPerSec.Top,70,15) $lblWritesPerSecCount.Alignment = 1 ;--------------------------------------------------------------------------- ; Start Application ;--------------------------------------------------------------------------- fnGetProcessList($cboComputer.Value) $frmProcesses.Center $frmProcesses.Show While $frmProcesses.Visible $nul=Execute($frmProcesses.DoEvents) Loop $objWMIService="" Exit(1) ;--------------------------------------------------------------------------- ; Functions ;--------------------------------------------------------------------------- Function fnGetProcessList(Optional $sComputer) If $sComputer="" $sComputer = "." EndIf $frmProcesses.Text = "Process List for "+$sComputer $frmProcesses.MousePointer = 11 $lvwProcessList.Items.Clear $lvwProcessList.BeginUpdate $objWMIService = GetObject("winmgmts:\\"+$sComputer+"\root\cimv2") If @ERROR $nul = $frmProcesses.MsgBox(@SERROR,"Error",16) $frmProcesses.MousePointer=0 Exit(1) EndIf $colItems = $objWMIService.ExecQuery("Select * from Win32_Process",,48) For each $objItem in $colItems $Item=$lvwProcessList.Items.Add($objItem.Name) $Item.SubItems(1).Text=$objItem.ProcessID $Item.SubItems(2).Text=fnSecondsToHMMSS(CInt((CDbl($objItem.UserModeTime) +CDbl($objItem.KernelModeTime))/10000000)) $Item.SubItems(3).Text=""+FormatNumber(CDbl($objItem.WorkingSetSize)/1024,0)+" K" Next $frmProcesses.MousePointer=0 $lvwProcessList.EndUpdate EndFunction Function fnMonProcess() $frmProcesses.Hide fnDrawGrid() $frmProcess.Center $frmProcess.Show For Each $Item in $lvwProcessList.SelectedItems $sProcess=$Item.SubItems(0).Text $sPID=$Item.SubItems(1).Text Next $colItems = $objWMIService.ExecQuery("Select * from Win32_LogicalMemoryConfiguration",,48) For each $objItem in $colItems $lMEMMax=CDbl($objItem.TotalPageFileSpace) ;"TotalPhysicalMemory: " + $objItem.TotalPhysicalMemory Next $objProcess = $objWMIService.ExecQuery("Select * from Win32_PerfRawData_PerfProc_Process " +'WHERE IDProcess = $sPID AND Name <> "_Total"',,48) For Each $objItem in $objProcess $frmProcess.Caption="Monitoring "+$sProcess+" (PID: "+$objItem.IDProcess+") on " +$cboComputer.Value Next $prgCPUUsage.Refresh $prgMEMUsage.Refresh $tl=-6 :MonitorLoop For $x = $tl to $picCPUHist.ScaleWidth step 5 $objProcess = $objWMIService.ExecQuery("Select * from Win32_PerfRawData_PerfProc_Process " +'WHERE IDProcess = $sPID AND Name <> "_Total"',,48) For Each $objItem in $objProcess $sProcessName=$objItem.Name $dP2=CDbl($objItem.PercentProcessorTime) $dT2=CDbl($objItem.Timestamp_Sys100NS) $prgMEMUsage.Value=Int(CDBL($objItem.WorkingSet)/1024/$lMEMMax*100) $lblMEMUsage.Text=CDBL($objItem.WorkingSet)/1024 $lblHandlesCount.Text = $objItem.HandleCount $lblThreadsCount.Text = $objItem.ThreadCount $lblElapsedTimeCount.Text = fnSecondsToHMMSS(CInt((CDbl($objItem.Timestamp_Object) -CDbl($objItem.ElapsedTime))/CDbl($objItem.Frequency_Object))) $xDO2=CDbl($objItem.IODataBytesPerSec) $xRO2=CDbl($objItem.IOReadBytesPerSec) $xWO2=CDbl($objItem.IOWriteBytesPerSec) $yDO2=CDbl($objItem.Timestamp_PerfTime) Next $lCPercent=Fix((($dP2-$dP1) / ($dT2-$dT1))*100) If $lCPercent>100 $lCPercent=100 EndIf $prgCPUUsage.Value = $lCPercent $lblCPUUsage.Text = ""+$lCPercent+"%" $yM2=50-$prgMEMUsage.Value/2 $yC2=50-$lCPercent/2 $picMEMHist.Line($x,$yM1,$x+5,$yM2) $picCPUHist.Line($x,$yC1,$x+5,$yC2) ;Debug On $lblDataPerSecCount.Caption = FormatNumber(Int(($xDO2-$xDO1)/(($yDO2-$yDO1)/3579545)),0) $lblReadsPerSecCount.Caption = FormatNumber(Int(($xRO2-$xRO1)/(($yDO2-$yDO1)/3579545)),0) $lblWritesPerSecCount.Caption = FormatNumber(Int(($xWO2-$xWO1)/(($yDO2-$yDO1)/3579545)),0) ;Debug Off If Not $frmProcess.Visible or $sProcessName='' $frmProcess.Hide $frmProcesses.Show fnGetProcessList($cboComputer.Value) Exit() EndIf $yM1=$yM2 $yC1=$yC2 $dP1=$dP2 $dT1=$dT2 $xDO1=$xDO2 $xRO1=$xRO2 $xWO1=$xWO2 $yDO1=$yDO2 $sProcessName='' Sleep 0.5 Next fnDrawGrid() $tl=0 Goto "MonitorLoop" EndFunction Function fnDrawGrid() $picCPUHist.Clear $picMEMHist.Clear $picCPUHist.ForeColor = Green $picMEMHist.ForeColor = Green For $y=10 to $picCPUHist.ScaleHeight step 10 $picCPUHist.Line(0,$y,$picCPUHist.ScaleWidth,$y) $picMEMHist.Line(0,$y,$picMEMHist.ScaleWidth,$y) Next For $x=-11 to $picCPUHist.ScaleWidth step 10 $picCPUHist.Line($x,0,$x,$picCPUHist.ScaleWidth) $picMEMHist.Line($x,0,$x,$picMEMHist.ScaleWidth) Next $picCPUHist.ForeColor = Lawngreen $picMEMHist.ForeColor = Lawngreen EndFunction Function fnSecondsToHMMSS($lSeconds) If Not VarType($lSeconds)=3 $fnSecondsToHMMSS="Invalid VarType: "+VarType($lSeconds) Exit(1) EndIf If $lSeconds < 0 $fnSecondsToHMMSS="Error" Exit(1) EndIf Select Case $lSeconds<60 If $lSeconds<10 $lSeconds="0"+$lSeconds EndIf $fnSecondsToHMMSS="0:00:"+$lSeconds Case $lSeconds<3600 $lMinutes=$lSeconds/60 $lSeconds=$lSeconds-$lMinutes*60 If $lMinutes<10 $lMinutes="0"+$lMinutes EndIf If $lSeconds<10 $lSeconds="0"+$lSeconds EndIf $fnSecondsToHMMSS="0:"+$lMinutes+":"+$lSeconds Case 1 $lHours=$lSeconds/3600 $lSeconds=$lSeconds-$lHours*3600 $lMinutes=$lSeconds/60 $lSeconds=$lSeconds-$lMinutes*60 If $lMinutes<10 $lMinutes="0"+$lMinutes EndIf If $lSeconds<10 $lSeconds="0"+$lSeconds EndIf $fnSecondsToHMMSS=""+$lHours+":"+$lMinutes+":"+$lSeconds EndSelect EndFunction
|
Chris S.
|
(MM club member)
|
2002-12-04 07:57 PM
|
|
|
|
|
Re: beta - KiXforms: ProcessMon
|
|
Sorry, I've been running this pretty much exclusively on W2K systems. I found a little glitch in the one of the data types when I ran it over the network on a XP machine. Edited code above.
|
Shawn
|
(KiX Supporter)
|
2002-12-04 09:01 PM
|
|
|
|
|
Re: beta - KiXforms: ProcessMon
|
|
Man - thats a beautiful thing - your an ar-teest my friend.
|
Chris S.
|
(MM club member)
|
2002-12-04 09:16 PM
|
|
|
|
|
Re: beta - KiXforms: ProcessMon
|
|
Well, thanks for supplying the canvas. I thought that doing something like this would be resource intensive, but it isn't. When it monitors it's own process you only see it use about 3% CPU every 4 seconds or so, then it goes back to 0%.
I used it to monitor a process over the WAN in Texas, an it responds pretty well. Heck, I even used it on someone over a dial-up and it worked OK, although the response was slowed down by .5 seconds or so.
Any ideas on improvements?
|
Shawn
|
(KiX Supporter)
|
2002-12-04 09:20 PM
|
|
|
|
|
Re: beta - KiXforms: ProcessMon
|
|
Yes - I do have one or two thoughts - but I got one foot out the door at the office here - and thats after staying a little late so that I could scrounge an XP box & dl & checkout your script ... will be back in a couple of hours ... after I get whipped by the Wife ...
[edit]
anyone hear a "ka-chaa" sound ? [ 04. December 2002, 21:21: Message edited by: Shawn ]
|
Lonkero
|
(KiX Master Guru)
|
2002-12-04 09:43 PM
|
|
|
|
|
Re: beta - KiXforms: ProcessMon
|
|
chris, any change to remove the cls?
|
Chris S.
|
(MM club member)
|
2002-12-04 09:58 PM
|
|
|
|
|
Re: beta - KiXforms: ProcessMon
|
|
The CLS is just in there while I develop the script. It won't be a permanent fixture.
As always, WKixers must remove the CLS to prevent the console window from appearing.
|
Lonkero
|
(KiX Master Guru)
|
2002-12-04 10:00 PM
|
|
|
|
|
Re: beta - KiXforms: ProcessMon
|
|
is there any way to determine which one is used? like version macro which shows it? haven't seen...
|
Chris S.
|
(MM club member)
|
2002-12-04 10:01 PM
|
|
|
|
|
Re: beta - KiXforms: ProcessMon
|
|
I don't think so. Actually, I think that would make a good item for the suggestion box.
|
Kdyer
|
(KiX Supporter)
|
2002-12-04 10:05 PM
|
|
|
|
|
Re: beta - KiXforms: ProcessMon
|
|
Chris,
Sweet code!
A thought.. When you are looking at Mem Usage, PID, etc... Can it change the sort order to show what processes are hogs?
{Edit} Looks like just the PID and Mem Usage. {/Edit}
Kent [ 04. December 2002, 22:07: Message edited by: kdyer ]
|
krabourn
|
(Hey THIS is FUN)
|
2002-12-04 10:08 PM
|
|
|
|
|
Re: beta - KiXforms: ProcessMon
|
|
Looks pretty good so far.
I would add a "Kill Process" button, just off the top of my head.
I also noticed that I can't monitor a single process on a NT 4 computer. The computers have WMI 1.5 installed.
$objProcess does not contain any info.
code:
$objProcess = $objWMIService.ExecQuery("Select * from Win32_PerfRawData_PerfProc_Process " +'WHERE IDProcess = $sPID AND Name <> "_Total"',,48)
Probably something to do with NT 4. [ 04. December 2002, 22:10: Message edited by: krabourn ]
|
Chris S.
|
(MM club member)
|
2002-12-04 10:11 PM
|
|
|
|
|
Re: beta - KiXforms: ProcessMon
|
|
Code edit. Had to squish another bug related to the IO Read/Write data types. The data types in WMI are uint64. There are slight differences in the way they're handled in W2K vs. XP. Anyway, I found it and fixed it. The 'Data Operations' should work now.
Kent, you can click the columns to sort them, but there is a 'bug' in the ListView column sort. All column items are string values, so they don't always sort correctly.
|
Chris S.
|
(MM club member)
|
2002-12-04 10:13 PM
|
|
|
|
|
Re: beta - KiXforms: ProcessMon
|
|
krabourn, you hit the nail on the head. The performance counter classes were added with W2K. I should do some error checking on that and provide the appropriate feedback.
|
Kdyer
|
(KiX Supporter)
|
2002-12-04 10:25 PM
|
|
|
|
|
Re: beta - KiXforms: ProcessMon
|
|
Couple of more things..
Monitoring a Domain Controller(2k) on the same Domain - Flashes back to the process list Monitoring a Domain Controller(2k) on a Child Domain - Works fine Could not Monitor local machine (XP), but process list works fine.
Kent
|
Chris S.
|
(MM club member)
|
2002-12-04 11:53 PM
|
|
|
|
|
Re: beta - KiXforms: ProcessMon
|
|
Kent, was that using the currently posted script?
|
Kdyer
|
(KiX Supporter)
|
2002-12-05 06:53 AM
|
|
|
|
|
Re: beta - KiXforms: ProcessMon
|
|
Yes.. at the time of the last post..
Have not tried any updates.
Kent
|
Kdyer
|
(KiX Supporter)
|
2002-12-05 04:47 PM
|
|
|
|
|
Re: beta - KiXforms: ProcessMon
|
|
ok..
Status.
Monitoring a Domain Controller(2k) on the same Domain - Flashes back to the process list Monitoring a Domain Controller(2k) on a Child Domain - Works fine Local machine (XP)works fine for both the Monitor and process list.
Kent [ 05. December 2002, 16:47: Message edited by: kdyer ]
|
Jochen
|
(KiX Supporter)
|
2002-12-05 09:00 PM
|
|
|
|
|
Re: beta - KiXforms: ProcessMon
|
|
Chris,
I will definetly have a run with this .. tomorrow, when back to work
Hmmm .. The Sort bug with listviews should have been gone in build 37 ... time for a release, eh Shawn ?
|
Chris S.
|
(MM club member)
|
2002-12-05 09:03 PM
|
|
|
|
|
Re: beta - KiXforms: ProcessMon
|
|
I'm using build 37. Still there.
|
Shawn
|
(KiX Supporter)
|
2002-12-05 09:11 PM
|
|
|
|
|
Re: beta - KiXforms: ProcessMon
|
|
Not too sure if its really a bug. ListView can only sort on strings right now - Have yet to implement the key and keytype properties for numeric sorting.
[ps] And the sort routine is not Alignment aware - so thats just another wrinkle. And after running with Chris's tskmgr script - must be sure to watch-out for numeric strings with commas in them - not too sure how thats going to play-out. [ 05. December 2002, 21:14: Message edited by: Shawn ]
|
Chris S.
|
(MM club member)
|
2002-12-05 09:15 PM
|
|
|
|
|
Re: beta - KiXforms: ProcessMon
|
|
Yeah. I agree. Thats why I said 'bug' in quotes. I does, actually, sort correctly, just as a string which.
|
Shawn
|
(KiX Supporter)
|
2002-12-06 07:00 PM
|
|
|
|
|
Re: beta - KiXforms: ProcessMon
|
|
Chris
With your permission - may we include this as a demonstration script published on the Kixforms.org website ? Like bbChecker and a couple others, this script demonstrates a varied array of forms features (listviews, buttons, graphics, dialogs, events, ) ... great script ...
-Shawn
|
Chris S.
|
(MM club member)
|
2002-12-06 09:14 PM
|
|
|
|
|
Re: beta - KiXforms: ProcessMon
|
|
Absolutely. I'd be honored. I'm not completely done with it yet, though. I'd like to add some more features. Clean up the code. Etc.
BTW, you mentioned the other day that you had some ideas. Anything you'd like to share?
|
Shawn
|
(KiX Supporter)
|
2002-12-06 09:37 PM
|
|
|
|
|
Re: beta - KiXforms: ProcessMon
|
|
great - will watch this space for your gold edition script.
suggestions: yeah just a couple right now. small stuff really:
1) Suggest you BeginUpdate/EndUpdate on the form rather than on the control, specifically I changed this line:
; $lvwProcessList.EndUpdate $frmProcesses.BeginUpdate
and
; $lvwProcessList.EndUpdate $frmProcesses.EndUpdate
Im not completely satisfied yet with the control level Begin/EndUpdates ... for some reason (and I think its a windows problem) when the EndUpdate is executed on a control, the desktop does a refresh as well. You may or may not have noticed this - and it may be OS dependent - but try running your script standalone against the desktop, might see it. Using Begin/EndUpdate with the form itself is much better - only caveat is that the whole form frozen, which is usually ok unless you got a progressbar happening while your loading the listview.
2) Moved the $frmProcess.Show down to just before the loop, and commented out the proggy refreshes (was there a reason for those?), like this:
; $prgCPUUsage.Refresh ; $prgMEMUsage.Refresh $frmProcess.Show
Find that the form flips a little better with this configuration ... just some thoughts ...
-Shawn
|
Chris S.
|
(MM club member)
|
2002-12-06 09:41 PM
|
|
|
|
|
Re: beta - KiXforms: ProcessMon
|
|
I put the refreshes in there becuase I found that if I monitored a process with no activity the progress bar was 'grey' until the progressbar value changed.
|
Shawn
|
(KiX Supporter)
|
2002-12-06 09:43 PM
|
|
|
|
|
Re: beta - KiXforms: ProcessMon
|
|
Was thinking that was the case - is there any way to repro this in a scriptlet ? or using your script ?
|
Chris S.
|
(MM club member)
|
2002-12-06 09:48 PM
|
|
|
|
|
Re: beta - KiXforms: ProcessMon
|
|
I double checked before I posted to verify I wasn't talking out of my ___. For me, it does it everytime I monitor a process in which either one of the CPU or MEM usage values doesn't change.
|
Shawn
|
(KiX Supporter)
|
2002-12-06 09:50 PM
|
|
|
|
|
Re: beta - KiXforms: ProcessMon
|
|
Even if you move the Show down to after the commented-out Refreshes ?
|
Chris S.
|
(MM club member)
|
2002-12-06 09:52 PM
|
|
|
|
|
Re: beta - KiXforms: ProcessMon
|
|
Ah. That was the part I missed. Yeah, that works better.
Anyway to complete remove the 'frame' from around the progressbar?
|
Shawn
|
(KiX Supporter)
|
2002-12-06 10:00 PM
|
|
|
|
|
Re: beta - KiXforms: ProcessMon
|
|
Yeah - give it a shot - might look a little more tskmgr-like.
|
Shawn
|
(KiX Supporter)
|
2002-12-06 10:09 PM
|
|
|
|
|
Re: beta - KiXforms: ProcessMon
|
|
You've probaly already noticed that there are issues with changing the borderstyle ? Working on it ...
|
Shawn
|
(KiX Supporter)
|
2002-12-06 10:33 PM
|
|
|
|
|
Re: beta - KiXforms: ProcessMon
|
|
Try moving BorderStyle as the last setting:
code:
$prgCPUUsage = $picCPUUsage.ProgressBar $prgCPUUsage.Height = 30 $prgCPUUsage.Width = 30 $prgCPUUsage.Center $prgCPUUsage.Top = 5 $prgCPUUsage.ForeColor = Lawngreen $prgCPUUsage.BackColor = Black $prgCPUUsage.Orientation = 1 $prgCPUUsage.Style = 1 $prgCPUUsage.Max = 100 $prgCPUUsage.BorderStyle = 0
already fixed in next released.
|
Shawn
|
(KiX Supporter)
|
2002-12-06 10:38 PM
|
|
|
|
|
Re: beta - KiXforms: ProcessMon
|
|
By the way - think it looks pretty cool with the border or without - so its your call.
|
Chris S.
|
(MM club member)
|
2002-12-06 10:40 PM
|
|
|
|
|
Re: beta - KiXforms: ProcessMon
|
|
Thanks, Shawn. Actually, now that I see it, I think I like it better with the line border.
|
Lonkero
|
(KiX Master Guru)
|
2003-04-26 03:07 PM
|
|
|
|
|
Re: beta - KiXforms: ProcessMon
|
|
chris... is there updates to this? I get from monitoring all the time processor values around 80-95 whereas the taskman next to this shows 20-40...
|
Lonkero
|
(KiX Master Guru)
|
2003-04-27 12:45 AM
|
|
|
|
|
Re: beta - KiXforms: ProcessMon
|
|
k, think I was lost there for a while...
it does not work the same way as task manager and that got me confused. it works just perfectly on that part.
|
Chris S.
|
(MM club member)
|
2006-01-24 07:02 PM
|
|
|
|
|
Re: beta - KiXforms: ProcessMon
|
|
Edited code to work with the latest build of KF 2 (not dot net yet).
Please forgive the blatant disregard of best practices for the use of the goto statement. What can I say, but I was young and stupid.
|
Shawn
|
(KiX Supporter)
|
2006-01-24 10:47 PM
|
|
|
|
|
Re: beta - KiXforms: ProcessMon
|
|
Added some snaps (without Chris's permission, hope you no mind) for folks that want to check it out but not install the stuff.
|
NTDOC
|
(KiX Master)
|
2006-01-24 11:02 PM
|
|
|
|
|
Re: beta - KiXforms: ProcessMon
|
|
What's with the 39MB of memory for FireFox there Shawn?
Did you fix the GOTO code for Chris ?
|
Shawn
|
(KiX Supporter)
|
2006-01-24 11:41 PM
|
|
|
|
|
Re: beta - KiXforms: ProcessMon
|
|
idk man, I was downloading something from kixhelp.com and firefox started spasming about non-standard html and java code - idk man ;0)
You saying my process list looks odd ? ;0)
|
Chris S.
|
(MM club member)
|
2006-01-25 12:07 AM
|
|
|
|
|
Re: beta - KiXforms: ProcessMon
|
|
Thanks for the screenies. I know what you mean by those dl's from KiXhelp.com. I got a virus from there once.
<Just kidding - in case anyone takes me seriously>
|
Shawn
|
(KiX Supporter)
|
2006-01-25 12:35 AM
|
|
|
|
|
Re: beta - KiXforms: ProcessMon
|
|
Doc knows I'm just kidding. I'm just getting back at him for laughing at my runnas slip-up... anyway, looks like Internet Explorer isn't no light-weight either ...
|
NTDOC
|
(KiX Master)
|
2006-01-25 01:52 AM
|
|
|
|
|
Re: beta - KiXforms: ProcessMon
|
|
LOL - I'd get that whole computer replaced Shawn. Install FreeBSD or something to get it working correctly.
At least get FireFox updated. Heck if it thinks theirs JAVA running on KiXhelp.com then it's really screwed up browser. I don't know how to write any Java code for it
|
Lonkero
|
(KiX Master Guru)
|
2006-01-25 12:13 PM
|
|
|
|
|
Re: beta - KiXforms: ProcessMon
|
|
wtf. shawn, you have nice amount of mem there and considering the amount of CPU time by IE, your system has been booted around 1997 last time...
|
Chris S.
|
(MM club member)
|
2006-01-25 01:22 PM
|
|
|
|
|
Re: beta - KiXforms: ProcessMon
|
|
I personally liked the process ID, but what a stable product that can run that long.
|
Shawn
|
(KiX Supporter)
|
2006-01-25 01:33 PM
|
|
|
|
|
Re: beta - KiXforms: ProcessMon
|
|
Actually to be serious for sec. I remember under Windows NT that when you started IE - a process called iexplore.exe shows in taskmgr. Right now on my XP box I actually dont get that process anymore ... I assume its running as a new thread of something else ? maybe explorer.exe ?
Do you guys see iexplore.exe running anymore ? Is it a setting in IE somewhere that controls this ? Anyone know what the scoop is ? Where did iexplore.exe go :0(
|
Chris S.
|
(MM club member)
|
2006-01-25 04:50 PM
|
|
|
|
|
Re: beta - KiXforms: ProcessMon
|
|
Dunno. Shows up as iexplore.exe for me.
|
Shawn
|
(KiX Supporter)
|
2006-01-25 05:16 PM
|
|
|
|
|
Re: beta - KiXforms: ProcessMon
|
|
hmmm, talk about your stealth-ware ... When I start Internet Explorer, my explorer.exe thread count goes up by one. Think this is a setting somewhere, wonder if it has something to do with that "open in new window" setting. idk.
|
Arend_
|
(MM club member)
|
2006-01-26 08:44 AM
|
|
|
|
|
Re: beta - KiXforms: ProcessMon
|
|
On every Windows machine Internet Explorer is still iexplore.exe. I've tested it here at work, 1 98 machine, 3 2K machines and 4 XP machines. All show iexplore.exe popping up as soon as you fire up the browser.
[edit] All machines have the latest windows updates btw. [/edit]
|
Lonkero
|
(KiX Master Guru)
|
2006-01-26 11:12 AM
|
|
|
|
|
Re: beta - KiXforms: ProcessMon
|
|
shawn, in any case, are you sure you haven't accidentally deleted your iexplore.exe in your mozilla based hype?
also, how you start your ie?
|
Arend_
|
(MM club member)
|
2006-01-27 02:00 PM
|
|
|
|
|
Re: beta - KiXforms: ProcessMon
|
|
About the monitor I love it, but a kill button would be cool I took the liberty of writing a UDF for it based on your code. I hope you find it usefull. Code:
Function KillProcess($sProcessname, Optional $sComputer) Dim $x, $objWMIService, $colItems, $objItem If $sComputer = "" $sComputer = "." EndIf
$objWMIService = GetObject("winmgmts:\\" + $sComputer + "\root\cimv2")
If @ERROR $x = MessageBox(@SERROR,"Error",0) Exit(1) EndIf
$colItems = $objWMIService.ExecQuery("Select * from Win32_Process",,48)
For Each $objItem In $colItems If $objItem.Name = $sProcessname $strWBEMPath = "Win32_Process.Handle=" + $objItem.ProcessID $objInstance = $objWMIService.Get($strWBEMPath) $intStatus = $objInstance.Terminate(1) If $intStatus <> 0 $x = MessageBox("Killing Process " + $sProcessName + " Failed" + @CRLF + @SERROR,"Error",0) EndIf EndIf Next EndFunction
|
|
Re: beta - KiXforms: ProcessMon
|
|
shawn, have you tried ProcessExplorer from sysinternals.com ?
if you choose view by tree, you can see which process is the parent of the iexplore process.
|
Les
|
(KiX Master)
|
2006-01-28 07:35 PM
|
|
|
|
|
Re: beta - KiXforms: ProcessMon
|
|
Doesn't MS have a PTree that does that too?
|
Shawn
|
(KiX Supporter)
|
2006-01-28 08:27 PM
|
|
|
|
|
Re: beta - KiXforms: ProcessMon
|
|
Thanks Christophe, will try that. This problem I have with iexplore.exe not showing up is not "uncommon", if you search the web there is discussion about it but thats all its seems to be - talk ... its controled by some setting somewhere I think ... haven't nailed it yet.
|
|
Re: beta - KiXforms: ProcessMon
|
|
Les,
maybe MS provides a similar tool but tools from Mark Russinovitch at Sysinternals are for me, some of the best admin tools.
Filemon, regmon, processexplorer, listdlls, loardord, autorun, pstools (psexec, pslist, etc...) or rootkitrevealer are very useful and many of them are provided with source.
|
sand
|
(Lurker)
|
2006-08-03 02:55 PM
|
|
|
|
|
Re: beta - KiXforms: ProcessMon
|
|
thanks thats a great thing.
i'm tried add ownername on processview
I'm testing vbs running Code:
strComputer = "." set processes = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2").ExecQuery("Select * from Win32_Process")
For Each process In processes RT = process.GetOwner(NameOfUser) Wscript.Echo "--"& NameOfUser &"--" Next
kix not running Code:
$strComputer = "." $processes = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" + $strComputer + "\root\cimv2").ExecQuery("Select * from Win32_Process")
For Each $process In $processes $RT = $process.GetOwner($NameOfUser) ? "--"+ $NameOfUser +"--" Next
I hope conversion are right. in KiXtart version $NameOfUser empy KiXtart can $NameOfUser reread?
Thanks for Help Thanks for KiX...
sand
|
Lonkero
|
(KiX Master Guru)
|
2006-08-03 03:36 PM
|
|
|
|
|
Re: beta - KiXforms: ProcessMon
|
|
hmm... that's pass byref thingie. kixtart does not support that.
|
Benny69
|
(MM club member)
|
2006-08-03 05:51 PM
|
|
|
|
|
Re: beta - KiXforms: ProcessMon
|
|
try this:
$RT = $process.GetOwner("NameOfUser") ? "--"+ $RT +"--"
but Jooel is prolly right.
[edit] nope don't try that. yep, Jooel is right, not very often is wrong, Jooel the man. [/edit]
|
sand
|
(Lurker)
|
2006-08-04 04:22 PM
|
|
|
|
|
Re: beta - KiXforms: ProcessMon
|
|
thanks for answer
@benny69 $RT not returns Username
GetOwner: http://msdn.microsoft.com/library/defaul...n32_process.asp
@Jooel
|
|
Re: beta - KiXforms: ProcessMon
|
|
I've been asking for the ByRef support in KiXtart for a long time now
|
Arend_
|
(MM club member)
|
2006-08-08 08:56 AM
|
|
|
|
|
Re: beta - KiXforms: ProcessMon
|
|
As of today I second that suggestion I couln't find a way to get the owner of a process either
|
krabourn
|
(Hey THIS is FUN)
|
2006-08-08 09:16 PM
|
|
|
|
|
Re: beta - KiXforms: ProcessMon
|
|
Here you go.
Code:
$strComputer = "." $processes = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" + $strComputer + "\root\cimv2").ExecQuery("Select * from Win32_Process") FOR EACH $process IN $processes $RT = $process.Methods_.Item("GetOwner")
$oOutParam = $process.ExecMethod_("GetOwner") $ProcessDomain = $oOutParam.Domain $ProcessUser = $oOutParam.User
? $process.Name + "--" + $ProcessDomain + "--" + $ProcessUser NEXT
|
krabourn
|
(Hey THIS is FUN)
|
2006-08-08 09:21 PM
|
|
|
|
|
Re: beta - KiXforms: ProcessMon
|
|
Posted to fast. Here is another way. Code:
$strComputer = "." $processes = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" + $strComputer + "\root\cimv2").ExecQuery("Select * from Win32_Process") FOR EACH $process IN $processes
$ProcessDomain = $process.ExecMethod_("GetOwner").Domain $ProcessUser = $process.ExecMethod_("GetOwner").User
? $process.Name + "--" + $ProcessDomain + "--" + $ProcessUser NEXT
|
Chris S.
|
(MM club member)
|
2006-08-09 05:11 AM
|
|
|
|
|
Re: beta - KiXforms: ProcessMon
|
|
Nice one, Kelly (and on-topic to boot).
|
krabourn
|
(Hey THIS is FUN)
|
2006-08-09 03:54 PM
|
|
|
|
|
Re: beta - KiXforms: ProcessMon
|
|
Now here is my off topic post...
I learned more than I ever wanted to know about interacting with WMI thru kix thanks to SMS.
Oh! And I also would love to see byref.
|
Arend_
|
(MM club member)
|
2006-08-10 09:10 AM
|
|
|
|
|
Re: beta - KiXforms: ProcessMon
|
|
Wow very nice find man Never thought of ExecMethod... never knew it existed.
|
therob
|
(Starting to like KiXtart)
|
2007-03-06 07:00 PM
|
|
|
|
|
Re: beta - KiXforms: ProcessMon
|
|
very nice script and thanks for pointing me here.
|
Radimus
|
(KiX Supporter)
|
2009-05-29 05:13 PM
|
|
|
|
|
Re: beta - KiXforms: ProcessMon
|
|
Hey all... Long time no post
This thread came in very handy for a project of mine at work. Basically, the next step in monitoring app licenses, is to track app usage...
$FilterList = '\windows\','iexplore.exe'
$objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
$colMonitored = $objWMIService.ExecNotificationQuery("select * from __instancecreationevent within 1 where TargetInstance isa 'Win32_Process'")
While 1
$NextProcess = $colMonitored.NextEvent
$Filtered = 0
$Name = $NextProcess.TargetInstance.Name
$Path = $NextProcess.TargetInstance.executablepath
$User = $NextProcess.TargetInstance.ExecMethod_("GetOwner").User
If not $user = 'SYSTEM' and not instr($user,'SERVICE')
For each $Filter in $filterList
if instr($Path,$filter)
$Filtered = 1
EndIf
Next
If not $Filtered
$OldDate1 = ReadProfileString('%windir%\ProcList.ini',$Path,'Date')
if not @oldDate1 = @date ; Only log once per day and keep the last 3 usages
$oldTime1 = ReadProfileString('%windir%\ProcList.ini',$Path,'Time')
$oldDate2 = ReadProfileString('%windir%\ProcList.ini',$Path,'oldDate1')
$oldTime2 = ReadProfileString('%windir%\ProcList.ini',$Path,'oldTime1')
$nul = WriteProfileString('%windir%\ProcList.ini',$Path,'Name',$Name)
$nul = WriteProfileString('%windir%\ProcList.ini',$Path,'User',$User)
$nul = WriteProfileString('%windir%\ProcList.ini',$Path,'Date',@date)
$nul = WriteProfileString('%windir%\ProcList.ini',$Path,'Time',@time)
$nul = WriteProfileString('%windir%\ProcList.ini',$Path,'oldDate1',$OldDate1)
$nul = WriteProfileString('%windir%\ProcList.ini',$Path,'oldTime1',$oldTime1)
$nul = WriteProfileString('%windir%\ProcList.ini',$Path,'oldDate2',$OldDate2)
$nul = WriteProfileString('%windir%\ProcList.ini',$Path,'oldTime2',$oldTime2)
endif
EndIf
EndIf
Loop
|
Benny69
|
(MM club member)
|
2009-05-29 08:09 PM
|
|
|
|
|
Re: beta - KiXforms: ProcessMon
|
|
Rad, I luv your signature lol
|