It is currently March 28th, 2024, 10:08 pm

NUT UPS Monitoring

General topics related to Rainmeter.
Craash
Posts: 27
Joined: October 17th, 2017, 4:37 pm

NUT UPS Monitoring

Post by Craash »

My UPS is controlled by my pfSense box, and is advertised by NUT (Network UPS Tool). http://networkupstools.org/

Is there any way to be able to display the results in a meter? Load and run time would be most helpful.
mak_kawa
Posts: 908
Joined: December 30th, 2015, 9:47 am

Re: NUT UPS Monitoring

Post by mak_kawa »

I am really not sure about UPS monitoring. So, maybe this is irrelevant comment. But generally speaking...

1. Execute commandline tool (upsc?) via RunCommand Plugin.
2. Pass output string to String measures.
3. Parse them using RegExpSubstitute=1.
4. Display results in meters.

Or...

1. Execute commandline tool via RunCommand Plugin.
2. Redirect output string to text file.
3. Parse it using Webparser plugin.
4. Display results in meters.
Craash
Posts: 27
Joined: October 17th, 2017, 4:37 pm

Re: NUT UPS Monitoring

Post by Craash »

I might be on the right course, after your help. Thank you, @mak_kawa.

My end result is to have a bar meter and a text meter in a skin that will update every 5 seconds or so, without user interaction.

I have RunCommand working, but it requires a 'click' to retrieve the value and then doesn't update.

Is this something I can do with RunCommand (autoupdate my meter)?

This code is very rough, it's just to simply see if I can get it to work. A click DOES retrieve the correct UPS Load value.

Code: Select all

[Rainmeter]
Update=1000
AccurateText=1
SkinWidth=171
SkinHeight=244
BackgroundMode=2
SolidColor=255,0,0,0

[Variables]
@Include1="#@#GeneralVariables.inc"

[MeasureUPSLoad]
Measure=Plugin
Plugin=RunCommand
Parameter=upsc SMT2200RM2U@pfsense ups.load
OutputType=ANSI
State=Hide
StartInFolder=C:\Program Files (x86)\NUT\bin
FinishAction=[!UpdateMeter Output][!Redraw]
UpdateDivider=1

[MeterAllBackground]
Meter=Shape
Shape=Rectangle 1,1,169,#BackHeight#,12 | Fill Color #BackgroundColor# | StrokeWidth 1 | Stroke Color #LabelColor#
W=171
DynamicVariables=1
UpdateDivider=-1

[MeterUPSLoadText]
Meter=String
Text=UPS Load
X=15
Y=10
StringAlign=Left
InlineSetting=Face | #TextFont#
InlineSetting2=Size | 11
InlineSetting3=Color | #LabelColor#
AntiAlias=1
DynamicVariables=1
LeftMouseUpAction=!CommandMeasure MeasureUPSLoad Run

[MeterUPSLoad]
MeasureName=MeasureUPSLoad
Meter=String
X=154
Y=0r
StringAlign=Right
NumOfDecimals=0
Percentual=1
InlineSetting=Face | #TextFont#
InlineSetting2=Size | 11
InlineSetting3=Color | #ValueColor#
AntiAlias=1
Text="%1%"
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: NUT UPS Monitoring

Post by balala »

Craash wrote:I have RunCommand working, but it requires a 'click' to retrieve the value and then doesn't update.

Is this something I can do with RunCommand (autoupdate my meter)?
Yes, you can create a proper Calc measure, which executes the appropriate !CommandMeasure bangs, so often as you wish. Add the following measure to your code:

Code: Select all

[MeasureTimer]
Measure=Calc
Formula=( COUNTER % #Rep# )
IfCondition=(#CURRENTSECTION#=0)
IfTrueAction=[!CommandMeasure "MeasureUPSLoad" "Run"]
In this measure I've used a Rep variable, which must be defined into the [Variables] section. Add it there:

Code: Select all

[Variables]
Rep=5
The higher the value is, the less often will be executed the IfTrueAction option.
Craash
Posts: 27
Joined: October 17th, 2017, 4:37 pm

Re: NUT UPS Monitoring

Post by Craash »

Wonderful!!

Ok, so I'll have several Measures, MeasureUPSCharge, MeasureUPSTemp, etc.

Can I just append each of them to the IfTrueAction on my MeasureTimer?

Code: Select all

IfTrueAction=[!CommandMeasure "MeasureUPSLoad" "Run",!CommandMeasure "MeasureUPSTemp" "Run",!CommandMeasure "MeasureUPSTemp" "Run"]
Again, thank you so very much.
Craash
Posts: 27
Joined: October 17th, 2017, 4:37 pm

Re: NUT UPS Monitoring

Post by Craash »

Progress!

Code: Select all

Measure=Calc
Formula=( COUNTER % #Rep# )
IfCondition=(#CURRENTSECTION#=0)
IfTrueAction=[!CommandMeasure "MeasureUPSLoad" "Run"],[!CommandMeasure "MeasureUPSTemp" "Run"]
Triggers and update for each of my meters!

So, the last issue that I seem to have, the values returned LOOK like they are correct, but they wrap the % (UPS Load) to the next line and just the little tiniest bit of green is on the bar graph. So, I assume I need to do some type of formatting with the return value??
Craash
Posts: 27
Joined: October 17th, 2017, 4:37 pm

Re: NUT UPS Monitoring

Post by Craash »

RegExpSubstitute=1
Substitute="#CRLF#":""

Got rid of my spacing after the returned values, but my bar guages still don't work . . .

Code: Select all

[Rainmeter]
Update=1000
AccurateText=1
SkinWidth=171
SkinHeight=244
BackgroundMode=2
SolidColor=255,0,0,0

[Variables]
@Include1="#@#GeneralVariables.inc"
Rep=2
[MeasureTimer]
Measure=Calc
Formula=( COUNTER % #Rep# )
IfCondition=(#CURRENTSECTION#=0)
IfTrueAction=[!CommandMeasure "MeasureUPSLoad" "Run"],[!CommandMeasure "MeasureUPSTemp" "Run"]

[MeasureUPSLoad]
Measure=Plugin
Plugin=RunCommand
Parameter=upsc SMT2200RM2U@pfsense ups.load
OutputType=ANSI
State=Hide
StartInFolder=C:\Program Files (x86)\NUT\bin
FinishAction=[!UpdateMeter MeterUPSLoad][!Redraw]
DynamicVariables=1
UpdateDivider=1
MinValue=0
MaxValue=100
RegExpSubstitute=1
Substitute="#CRLF#":""

[MeasureUPSTemp]
Measure=Plugin
Plugin=RunCommand
Parameter=upsc SMT2200RM2U@pfsense battery.temperature
OutputType=ANSI
State=Hide
StartInFolder=C:\Program Files (x86)\NUT\bin
FinishAction=[!UpdateMeter MeterUPSTemp][!Redraw]
DynamicVariables=1
UpdateDivider=1
MinValue=0
MaxValue=100
RegExpSubstitute=1
Substitute="#CRLF#":""

[MeterAllBackground]
Meter=Shape
Shape=Rectangle 1,1,169,#BackHeight#,12 | Fill Color #BackgroundColor# | StrokeWidth 1 | Stroke Color #LabelColor#
W=171
DynamicVariables=1
UpdateDivider=-1


[MeterUPSLoadText]
Meter=String
X=15
Y=10
StringAlign=Left
InlineSetting=Face | #TextFont#
InlineSetting2=Size | 11
InlineSetting3=Color | #LabelColor#
AntiAlias=1
Text=UPS Load

[MeterUPSLoad]
MeasureName=MeasureUPSLoad
Meter=String
X=154
Y=0r
StringAlign=Right
NumOfDecimals=1
;Percentual=1
InlineSetting=Face | #TextFont#
InlineSetting2=Size | 11
InlineSetting3=Color | #ValueColor#
AntiAlias=1
Text="%1%"
[MeterUPSLoadBar]
Meter=Bar
MeasureName=MeasureUPSLoad
BarOrientation=Horizontal
BarImage=#ImagePath#138x2Bar.jpg
SolidColor=#BarBackColor#
X=15
Y=2R
W=127
H=2

[MeterUPSTempText]
Meter=String
X=15
Y=5R
StringAlign=Left
InlineSetting=Face | #TextFont#
InlineSetting2=Size | 11
InlineSetting3=Color | #LabelColor#
AntiAlias=1
Text=UPS Temp

[MeterUPSTemp]
MeasureName=MeasureUPSTemp
Meter=String
X=154
Y=0r
StringAlign=Right
NumOfDecimals=0
Percentual=1
InlineSetting=Face | #TextFont#
InlineSetting2=Size | 11
InlineSetting3=Color | #ValueColor#
AntiAlias=1
Text="%1%"
[MeterUPSTempBar]
Meter=Bar
MeasureName=MeasureUPSTemp
BarOrientation=Horizontal
BarImage=#ImagePath#138x2Bar.jpg
SolidColor=#BarBackColor#
X=15
Y=2R
W=127
H=2
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: NUT UPS Monitoring

Post by balala »

Incorrect: IfTrueAction=[!CommandMeasure "MeasureUPSLoad" "Run"][color=#FF0000],[/color][!CommandMeasure "MeasureUPSTemp" "Run"].
Correctly it would be without the comma: IfTrueAction=[!CommandMeasure "MeasureUPSLoad" "Run"][!CommandMeasure "MeasureUPSTemp" "Run"].
You can use as many bangs as you want into one single option, but don't add commas between them.
Craash
Posts: 27
Joined: October 17th, 2017, 4:37 pm

Re: NUT UPS Monitoring

Post by Craash »

Weird. It's working that way.

I'll take them out. Done. Still working. Great!

Any idea on my bar graph?

My percentage is up around 37, but I see just a little pixel of green flash on and off on the graph. I'm not really sure of the next step.

I though the issue might be the ansi value I'm using, but I'm not sure.
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: NUT UPS Monitoring

Post by balala »

Craash wrote:Any idea on my bar graph?

My percentage is up around 37, but I see just a little pixel of green flash on and off on the graph. I'm not really sure of the next step.
I'm not sure and I can't check, because I don't have the needed hardware, but I can imagine two reasons why the bars are not working correctly:
  • Maybe the appropriate measures (in this case [MeasureUPSLoad] and [MeasureUPSTemp]) don't return the values in the specified range. First try to remove the MinValue and MaxValue options of both measure, which will make them to use the default values (MinValue=0 and MaxValue=1). Are the Bar meters working now?
  • If they still don't, try to convert the values returned by the measures, through two Calc measures. Add the following measures to your code:

    Code: Select all

    [MeasureUPSLoadNum]
    Measure=Calc
    Formula=[MeasureUPSLoad]
    DynamicVariables=1
    MinValue=0
    MaxValue=100
    
    [MeasureUPSTempNum]
    Measure=Calc
    Formula=[MeasureUPSTemp]
    DynamicVariables=1
    MinValue=0
    MaxValue=100
    Now replace the measure names used in the MeasureName options of the two Bar meters with the names of the new measures:

    Code: Select all

    [MeterUPSLoadBar]
    ...
    MeasureName=MeasureUPSLoadNum
    
    [MeterUPSTempBar]
    ...
    MeasureName=MeasureUPSTempNum
    At this point, if these aren't working either, you have try again to remove the MinValue and MaxValue options of the new Calc measures, to make them to use the default values.
Did you get them working with any of the above solutions? If so, with which one of them?