It is currently April 23rd, 2024, 4:38 pm

Perfmon Ram monitoring with some if's confusion

Get help with creating, editing & fixing problems with skins
elbrick
Posts: 4
Joined: October 24th, 2010, 1:28 am

Perfmon Ram monitoring with some if's confusion

Post by elbrick »

hi everyone got a lil problem its probs something simple im missing but having trouble getting this chunk of code below to work, it shows all 5 images constantly yet when ive got task manager open im not using that much, got a similar one for cpu but that worked fine first time, anywho i just cant get it it maybie someone here can suggest a way of sorting it,

Code: Select all

[Rainmeter]
Simplesentence
Author=Ben Docherty
Update=1000

[Metadata]
Name=Planet Express | CPU Bar  
Config=
Description=CPU Bar for planet express skin 
Instructions=
Version=0.0.1
Tags=
License=
Variant=
Preview=

[MeasureRAM1]
Measure=Plugin
Plugin=Perfmon.dll
PerfMonObject="Memory"
PerfMonInstance=""
PerfMonCounter="% Committed Bytes In Use"
PerfMonDifference=0
IfAboveValue=0
IfAboveAction=!Execute [!RainmeterShowMeter MeterRAMImg1Of5]
IfBelowValue=1
IfBelowAction=!Execute [!RainmeterHideMeter MeterRAMImg1Of5]

[MeasureRAM2]
Measure=Plugin
Plugin=Perfmon.dll
PerfMonObject="Memory"
PerfMonInstance=""
PerfMonCounter="% Committed Bytes In Use"
PerfMonDifference=0
IfAboveValue=19
IfAboveAction=!Execute [!RainmeterShowMeter MeterRAMImg2Of5]
IfBelowValue=21
IfBelowAction=!Execute [!RainmeterHideMeter MeterRAMImg2Of5]

[MeasureRAM3]
Measure=Plugin
Plugin=Perfmon.dll
PerfMonObject="Memory"
PerfMonInstance=""
PerfMonCounter="% Committed Bytes In Use"
PerfMonDifference=0
IfAboveValue=39
IfAboveAction=!Execute [!RainmeterShowMeter MeterRAMImg3Of5]
IfBelowValue=41
IfBelowAction=!Execute [!RainmeterHideMeter MeterRAMImg3Of5]

[MeasureRAM4]
Measure=Plugin
Plugin=Perfmon.dll
PerfMonObject="Memory"
PerfMonInstance=""
PerfMonCounter="% Committed Bytes In Use"
PerfMonDifference=0
IfAboveValue=59
IfAboveAction=!Execute [!RainmeterShowMeter MeterRAMImg4Of5]
IfBelowValue=61
IfBelowAction=!Execute [!RainmeterHideMeter MeterRAMImg4Of5]

[MeasureRAM5]
Measure=Plugin
Plugin=Perfmon.dll
PerfMonObject="Memory"
PerfMonInstance=""
PerfMonCounter="% Committed Bytes In Use"
PerfMonDifference=0
IfAboveValue=79
IfAboveAction=!Execute [!RainmeterShowMeter MeterRAMImg5Of5]
IfBelowValue=81
IfBelowAction=!Execute [!RainmeterHideMeter MeterRAMImg5Of5]

[MeterRAMImg1Of5]
Meter=Image
X=10
Y=75
W=640
H=200
ImageName=RAMRevBar1.png

[MeterRAMImg2Of5]
Meter=Image
X=10
Y=75
W=640
H=200
ImageName=RAMRevBar2.png

[MeterRAMImg3Of5]
Meter=Image
X=10
Y=75
W=640
H=200
ImageName=RAMRevBar3.png

[MeterRAMImg4Of5]
Meter=Image
X=10
Y=75
W=640
H=200
ImageName=RAMRevBar4.png

[MeterRAMImg5Of5]
Meter=Image
X=10
Y=75
W=640
H=200
ImageName=RAMRevBar5.png
Last edited by Alex2539 on October 24th, 2010, 2:53 am, edited 1 time in total.
Reason: Please use the [code][/code] tags for large amounts of code.
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Perfmon Ram monitoring with some if's confusion

Post by jsmorley »

You quite sure that is the perfmon measurement you want?

"% Committed Bytes In Use is the ratio of Memory\\Committed Bytes to the Memory\\Commit Limit. Committed memory is the physical memory in use for which space has been reserved in the paging file should it need to be written to disk. The commit limit is determined by the size of the paging file. If the paging file is enlarged, the commit limit increases, and the ratio is reduced). This counter displays the current percentage value only; it is not an average."

For me it is returning a big number like 420250 and doesn't really change that much in normal usage of my PC. This is weird as it does seem to return a percentage in the PerfMon app, (which also doesn't change much even if I run big apps like Photoshop) but it it possible that the PerfMon app is doing something to get the percentage that Rainmeter isn't. You can see what Rainmeter is returning for any measure in the context menu "About".

So my first question is, "what are you trying to measure?" If you are trying to measure the amount or percentage of free or used RAM, there are better ways to get it.
elbrick
Posts: 4
Joined: October 24th, 2010, 1:28 am

Re: Perfmon Ram monitoring with some if's confusion

Post by elbrick »

was trying to measure the % of ram in use , if im calling the incorrect measure from perfmon that would be the mistake then. so any idea how i call the % of RAM in use tried the Measure=PhysicalMemory but that returns the actual value what im after is a percentage 0-100 so i can then use the if's to display the correct amount of images for the digital style angular rev counter that i want.

similar to this one for the cpu

Code: Select all


[MeasureCPU1]
Measure=CPU
Processor=0
UpdateDivider=2
IfAboveValue=0
IfAboveAction=!Execute [!RainmeterShowMeter MeterCPUImg1Of5]
IfBelowValue=1
IfBelowAction=!Execute [!RainmeterHideMeter MeterCPUImg1Of5]

[MeasureCPU2]
Measure=CPU
Processor=0
UpdateDivider=2
IfAboveValue=19
IfAboveAction=!Execute [!RainmeterShowMeter MeterCPUImg2Of5]
IfBelowValue=21
IfBelowAction=!Execute [!RainmeterHideMeter MeterCPUImg2Of5]

[MeasureCPU3]
Measure=CPU
Processor=0
UpdateDivider=2
IfAboveValue=39
IfAboveAction=!Execute [!RainmeterShowMeter MeterCPUImg3Of5]
IfBelowValue=41
IfBelowAction=!Execute [!RainmeterHideMeter MeterCPUImg3Of5]

[MeasureCPU4]
Measure=CPU
Processor=0
UpdateDivider=2
IfAboveValue=59
IfAboveAction=!Execute [!RainmeterShowMeter MeterCPUImg4Of5]
IfBelowValue=61
IfBelowAction=!Execute [!RainmeterHideMeter MeterCPUImg4Of5]

[MeasureCPU5]
Measure=CPU
Processor=0
UpdateDivider=2
IfAboveValue=79
IfAboveAction=!Execute [!RainmeterShowMeter MeterCPUImg5Of5]
IfBelowValue=81
IfBelowAction=!Execute [!RainmeterHideMeter MeterCPUImg5Of5]

[MeterCPUImg1Of5]
Meter=Image
X=10
Y=75
W=640
H=200
ImageName=CpuRevBar1.png

[MeterCPUImg2Of5]
Meter=Image
X=10
Y=75
W=640
H=200
ImageName=CpuRevBar2.png

[MeterCPUImg3Of5]
Meter=Image
X=10
Y=75
W=640
H=200
ImageName=CpuRevBar3.png

[MeterCPUImg4Of5]
Meter=Image
X=10
Y=75
W=640
H=200
ImageName=CpuRevBar4.png

[MeterCPUImg5Of5]
Meter=Image
X=10
Y=75
W=640
H=200
ImageName=CpuRevBar5.png
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Perfmon Ram monitoring with some if's confusion

Post by jsmorley »

elbrick wrote:was trying to measure the % of ram in use , if im calling the incorrect measure from perfmon that would be the mistake then. so any idea how i call the % of RAM in use tried the Measure=PhysicalMemory but that returns the actual value what im after is a percentage 0-100 so i can then use the if's to display the correct amount of images for the digital style angular rev counter that i want.
Can you post a link to a .zip of the images you want to use and the full code you are using now so I can see what you are trying to do?
elbrick
Posts: 4
Joined: October 24th, 2010, 1:28 am

Re: Perfmon Ram monitoring with some if's confusion

Post by elbrick »

ok ill add the .rar here oh and the png's are just the test ones havent made the full ones yet lots more work to do first
You do not have the required permissions to view the files attached to this post.
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Perfmon Ram monitoring with some if's confusion

Post by jsmorley »

Ok, here is one way to approach it:

Code: Select all

[Rainmeter]
Simplesentence
Author=Ben Docherty
Update=1000

[Metadata]
Name=Planet Express | RAM Bar  
Config=
Description=RAM Bar for planet express skin 
Instructions=
Version=1.0.0
Tags=
License=
Variant=
Preview=

; Measures]========================================================================

[MeasurePhysMemTotal]
Measure=PhysicalMemory
Total=1

[MeasurePhysMemUsed]
Measure=PhysicalMemory

[MeasurePercentUsed]
Measure=Calc
Formula=(Round((MeasurePhysMemUsed / MeasurePhysMemTotal) * 100))
Substitute=".00000":""

[MeasureGetImageNumber]
Measure=Calc
Formula=MeasurePercentUsed <= 20 ? 1 : (((MeasurePercentUsed > 20) && (MeasurePercentUsed < 40)) ? 2 : (((MeasurePercentUsed >= 40) && (MeasurePercentUsed < 60)) ? 3 : (((MeasurePercentUsed >= 60) && (MeasurePercentUsed < 80)) ? 4 : 5)))

[MeasureShow1]
Measure=Calc
Formula=MeasureGetImageNumber
IfAboveValue=0
IfAboveAction=!Execute [!RainmeterShowMeter MeterImage1]
IfBelowValue=2
IfBelowAction=!Execute [!RainmeterHideMeter MeterImage2][!RainmeterHideMeter MeterImage3][!RainmeterHideMeter MeterImage4][!RainmeterHideMeter MeterImage5]

[MeasureShow2]
Measure=Calc
Formula=MeasureGetImageNumber
IfAboveValue=1
IfAboveAction=!Execute [!RainmeterShowMeter MeterImage1][!RainmeterShowMeter MeterImage2]
IfBelowValue=3
IfBelowAction=!Execute [!RainmeterHideMeter MeterImage3][!RainmeterHideMeter MeterImage4][!RainmeterHideMeter MeterImage5]

[MeasureShow3]
Measure=Calc
Formula=MeasureGetImageNumber
IfAboveValue=2
IfAboveAction=!Execute [!RainmeterShowMeter MeterImage1][!RainmeterShowMeter MeterImage2][!RainmeterShowMeter MeterImage3]
IfBelowValue=4
IfBelowAction=!Execute [!RainmeterHideMeter MeterImage4][!RainmeterHideMeter MeterImage5]

[MeasureShow4]
Measure=Calc
Formula=MeasureGetImageNumber
IfAboveValue=3
IfAboveAction=!Execute [!RainmeterShowMeter MeterImage1][!RainmeterShowMeter MeterImage2][!RainmeterShowMeter MeterImage3][!RainmeterShowMeter MeterImage4]
IfBelowValue=5
IfBelowAction=!Execute [!RainmeterHideMeter MeterImage5]

[MeasureShow5]
Measure=Calc
Formula=MeasureGetImageNumber
IfAboveValue=4
IfAboveAction=!Execute [!RainmeterShowMeter MeterImage1][!RainmeterShowMeter MeterImage2][!RainmeterShowMeter MeterImage3][!RainmeterShowMeter MeterImage4][!RainmeterShowMeter MeterImage5]

; Meters]==========================================================================

[MeterImage1]
Meter=Image
X=0
Y=0
ImageName=RAMRevBar1.png
Hidden=1
DynamicVariables=1

[MeterImage2]
Meter=Image
X=0
Y=0
ImageName=RAMRevBar2.png
Hidden=1
DynamicVariables=1

[MeterImage3]
Meter=Image
X=0
Y=0
ImageName=RAMRevBar3.png
Hidden=1
DynamicVariables=1

[MeterImage4]
Meter=Image
X=0
Y=0
ImageName=RAMRevBar4.png
Hidden=1
DynamicVariables=1

[MeterImage5]
Meter=Image
X=0
Y=0
ImageName=RAMRevBar5.png
Hidden=1
DynamicVariables=1
The [MeasurePercentUsed] measure is turning those raw numbers from PhysicalMemory into a percentage you can use later.

I added that [MeasureGetImageNumber] calc measure mostly just to have the values turned into the same as the number on the files (1,2,3,4,5) just to make it easier to follow. This is a "conditional" formula that in effect is saying "if the number is less than 20, return 1, else if the number is less than 40 return 2, else if the number is less than 60 return 3, else if the number is less than 80 return 4, otherwise it must be higher than 80, so return 5"

You can use the value in [MeasurePercentUsed] directly instead if you want. Just change the IfAbove IfBelow values appropriately as well as changing the Formula= statements in all those Above/Below measures to use the right source measure.

Take a look at what this is doing. I hope it is reasonably clear. It is really just a forward / reverse pyramid of hide and show meters based on the above and below values. Feel free to ask if you don't see what it is doing somewhere.

=================================
P.S. This is one way to do this, although to be honest I'm not sure I would take the approach you are. I would be tempted to create the 5 images like this, where the "*" chars represent the triangles / colored blocks you are displaying.

RAMRevBar1.png
*
RAMRevBar2.png
**
RAMRevBar3.png
***
RAMRevBar4.png
****
RAMRevBar5.png
*****

Then you just get the percentage of memory used, do a formula like I did to translate it to 1, 2, 3, 4 or 5, and just display that image with something like:

[MeasureGetImageNumber]
Measure=Calc
Formula=MeasurePercentUsed <= 20 ? 1 : (((MeasurePercentUsed > 20) && (MeasurePercentUsed < 40)) ? 2 : (((MeasurePercentUsed >= 40) && (MeasurePercentUsed < 60)) ? 3 : (((MeasurePercentUsed >= 60) && (MeasurePercentUsed < 80)) ? 4 : 5)))

[MeterImage]
Meter=Image
X=0
Y=0
ImageName=RAMRevBar[MeasureGetImageNumber].png
DynamicVariables=1

Then you don't really need ANY IfAbove/IfBelow stuff, don't need all that hiding & unhiding, and only need one display meter.
elbrick
Posts: 4
Joined: October 24th, 2010, 1:28 am

Re: Perfmon Ram monitoring with some if's confusion

Post by elbrick »

excellent im gonna go have a play with the code now thanks man, i didn't even realize you could do a calculation this should help in a few of my other parts to the skin that ive had trouble with formulas on. Again much thanks man,