nmdelrio wrote: ↑November 18th, 2023, 1:12 am
I decided to to do just a simple ping meter to indicate if the target computer is UP or DOWN. None of the scripting Mr.Ol'BigNutsAIOpenChatGPT has suggested.
The intention is just to have a meter to indicate if the target computer is UP or DOWN, pinging it once every hour, and if DOWN play an audible alert every 5 seconds, else do nothing.
If you can bother yourself to look into the scripting, I'd be happy.
Not sure if I need
IfCondition Mode=1 in
[AudibleAlert].
Here's the Ping part of the skin.
Code: Select all
[Rainmeter]
Update=200
...
[PingMEDIASERVER]
Measure=Plugin
Plugin=PingPlugin
DestAddress=HPMediaServer
IfCondition=#CURRENTSECTION# = 30000
IfTrueAction=!SetOption MeterMEDIASERVERSTATUS Text "MEDIA SERVER STATUS#CRLF#DOWN"
IfFalseAction=!SetOption MeterMEDIASERVERSTATUS Text "MEDIA SERVER STATUS#CRLF#UP"
UpdateRate=18000
[AudibleAlert]
Measure=CALC
Formula=MeasurePingMediaServer
IfCondition=#CURRENTSECTION# = 30000
IfTrueAction=Play #@#\Audio\themediaserverisdown-reverb.wav
UpdateDivider=25
[MeterMEDIASERVERSTATUS]
Meter=STRING
MeterStyle=MeterHOSTNAME|MeterADAPTER_RECEIVE
MeasureName=PingMEDIASERVER
Text=MEDIA SERVER STATUS#CRLF#%1
It would be nice to add an
Uptime meter of the target computer, but I don't think Rainmeter can do a remote access of another computer.
(BTW FYI the target computer is a old PC (intel Core i7 870) that I converted into a home media server.)
First, sorry for the delay in responding, had some things to do today and took a little break from the forum related stuff.
You could adjust a bit your code to (yes, IfConditionMode is needed here, since you want to check that condition on every update of AudibleAlert):
Code: Select all
[Rainmeter]
Update=200
...
AccurateText=1
DynamicWindowSize=1
BackgroundMode=2
SolidColor=47,47,47,255
[Variables]
HPMediaServer=www.goxogle.com
[MeterHOSTNAME]
FontColor=255,255,255,255
FontFace=Consolas
FontSize=16
Padding=5,5,5,5
[MeterADAPTER_RECEIVE]
AntiAlias=1
...
[PingMEDIASERVER]
Measure=Plugin
Plugin=PingPlugin
DestAddress=#HPMediaServer#
RegExpSubstitute=1
Substitute="^(0)$":"WAIT (\1 ms)","^(30000)$":"DOWN (\1 ms)","^(\d+)$":"UP (\1 ms)"
OnChangeAction=[PlayStop][!PauseMeasure AudibleAlert][!UnpauseMeasure AudibleAlert][!UpdateMeasure AudibleAlert][!UpdateMeter MeterMEDIASERVERSTATUS][!Redraw]
UpdateRate=18000
[AudibleAlert]
Measure=CALC
Formula=PingMEDIASERVER
IfCondition=(#CURRENTSECTION#=30000)
IfTrueAction=[Play "#@#\Audio\themediaserverisdown-reverb.wav"]
IfConditionMode=1
UpdateDivider=25
[MeterMEDIASERVERSTATUS]
Meter=STRING
MeterStyle=MeterHOSTNAME|MeterADAPTER_RECEIVE
MeasureName=PingMEDIASERVER
Text=MEDIA SERVER STATUS#CRLF#%1
LeftMouseUpAction=[PlayStop][!TogglePauseMeasure AudibleAlert]
The parts between the ... are mainly to add the meter styles I didn't have so the code can be tested, but also to include a HPMediaServer variable where you can store the actual address or IP of your target computer (the HPMediaServer string you had in your code did precisely nothing as it wasn't a valid address / IP). As you can see, I defined the HPMediaServer variable to some easy to change from valid to invalid and viceversa address, but you can define it based on your case.
I replaced your otherwise correct IfCondition with a regular expression substitute doing more or less the same thing, without the need to set the Text in MeterMEDIASERVERSTATUS (that Text option will display the substituted string value of PingMEDIASERVER anyway). The substitute basically replaces 0 with WAIT (0 ms), 30000 with DOWN (30000 ms) and any other N number with UP (N ms) for conveniency - feel free to adjust to your preference or keep the earlier IfCondition if it feels more comfortable. For the record, in the regular expressions ^ means the start of the string, $ means the end of the string, \d means a digit, \d+ means one or more digits, and the ( and ) round brackets capture the enclosed part of the string to substitute so that the said capture can then be referenced in the sustituted string using \1, \2 and so on depending on whether you reference the 1st, the 2nd and so on capture.
I also stopped sound playing, paused and unpaused AudibleAlert on receiving the new ping response value in PingMEDIASERVER's OnChangeAction in order to "reset & resume" both the sound playing and the repeated checking of the said response in AudibleAlert. This suits well with toggling the sound playing on demand via left click in MeterMEDIASERVERSTATUS.
Most of these changes (bar the DestAddress value being an actual address or IP and the IfConditionMode, which are mandatory) are optional and reflect how I would approach this, so it's up to you if you want to keep them or not. Again, sorry for the delay in responding to such a simple question, but occasionally there's real life too, so...
P.S. Yeah, Rainmeter can't do remote Uptime, but if you find a way to do it via command prompt, PowerShell or any other actual scripting tools, Rainmeter can display that outcome (if any) via a RunCommand measure. Either that, or updating some (online) webpage from the target computer, that you can then scrape using a WebParser measure from your skin on the main computer. Or, the email method, if you can make it work. Basically, you need to solve the computer to computer communication problem, before Rainmeter skins can handle the other part...