I wrote some basic skin to check the stability (latency) of the internet.
I don't know if this project would be useful to anyone, i'm just sharing it.
It is still under development, but the basic idea of mine is working.
It comes together from 3 different files. First and basic is the skin file, then a LUA file, and a log.txt file.
The Skin.ini file is this:
There are some leftover codes remained, need some polishing and cleaning.
Mainly i used the Ping plugin for testing the stability of the internet latency, pinging the 8.8.8.8 (google dns address) ip.
The basic idea was to get the time (hours,minutes,seconds) with measure, and ping the IP in every second, then with another measure make everything in a single variable in this form: "HH:MM:SS - X ms".
My first "design" thought was to make the text scroll one line up at every new ping, but then i found a LUA script for tailing the lines of a text file. Meaning, if there is a text file with multiple lines, the LUA script takes all those lines, reverse it, and make it look like scroling from top to bottom.
This is the LUA script currently:
This script file also has lots of leftovers, needs cleaning as well.
Currently we can declare in the Skin.ini file how many entries would store in the log.txt with "logsize=59". Above that number it clears the txt file completely, and the logging starts again. Later the plan would be to when it reaches the number, the script should remove only the oldest entry, and add new one to the end.
My point was to not use any [Variables] in the log file, to be absolutely clear with displaying the log file.
Finally i quickly added a histogram to the skin, so even after clearing the txt file, we can still see significant spikes in latency.
I attached the rmskin also here.
I hope this will be usefull for someone.
I don't know if this project would be useful to anyone, i'm just sharing it.
It is still under development, but the basic idea of mine is working.
It comes together from 3 different files. First and basic is the skin file, then a LUA file, and a log.txt file.
The Skin.ini file is this:
Code:
[Rainmeter]Update=1000AccurateText=1OnRefreshAction=[!CommandMeasure "LuaDel" "Run"]SkinHeight=110[Variables]rel=0MyFile=#CURRENTPATH#log.txtonoff=0Run=1LinesToTail=5ChildPrefix=MeasureLinetmping=logsize=59[DateTimeMes]Measure=TimeFormat=%H:%M:%S[MeasurePing]Measure=PluginPlugin=PingPluginDestAddress=8.8.8.8MinValue=0MaxValue=300UpdateRate=1OnUpdateAction=[!UpdateMeasure SendingVar]Disabled=#onoff#[SendingVar]Measure=StringString=[&DateTimeMes] - [&MeasurePing] msOnUpdateAction=[!SetVariable tmping "[&SendingVar]"];[!UpdateMeasure LuaData]DynamicVariables=1UpdateDivider=-1[LuaData]Measure=ScriptScriptFile="LuaText.lua"FileToRead=#CURRENTPATH#log.txt;OnUpdateAction=[!UpdateMeter MeterPing][!Redraw]UpdateDivider=1Disabled=0[Countdown]Measure=CalcFormula=[LuaData]IfAboveValue=#logsize#IfAboveAction=[!CommandMeasure "LuaDel" "Run"]DynamicVariables=1Disabled=#onoff#[LuaDel]Measure=PluginPlugin=RunCommandParameter=break > "#MyFile#"State=HideOutputType=ANSI[MeasureLine1]Measure=StringUpdateDivider=-1[MeasureLine2]Measure=StringUpdateDivider=-1[MeasureLine3]Measure=StringUpdateDivider=-1[MeasureLine4]Measure=StringUpdateDivider=-1[MeasureLine5]Measure=StringUpdateDivider=-1[BaseBackground]Meter=ImageSolidColor=0,0,0X=0Y=0W=200H=140LeftMouseUpAction=[!CommandMeasure "LuaDel" "Run"][StyleText]X=5Y=5RW=200H=16FontColor=255,255,255,255FontSize=11AntiAlias=1[MeterLine1]Meter=StringMeasureName=MeasureLine1MeterStyle=StyleTextY=5[MeterLine2]Meter=StringMeasureName=MeasureLine2MeterStyle=StyleText[MeterLine3]Meter=StringMeasureName=MeasureLine3MeterStyle=StyleText[MeterLine4]Meter=StringMeasureName=MeasureLine4MeterStyle=StyleText[MeterLine5]Meter=StringMeasureName=MeasureLine5MeterStyle=StyleText[MeterCPUHistogram]Meter=HistogramMeasureName=MeasurePingX=200Y=0W=200H=110PrimaryColor=255,255,255,255SolidColor=0,0,0,255AntiAlias=1
Mainly i used the Ping plugin for testing the stability of the internet latency, pinging the 8.8.8.8 (google dns address) ip.
The basic idea was to get the time (hours,minutes,seconds) with measure, and ping the IP in every second, then with another measure make everything in a single variable in this form: "HH:MM:SS - X ms".
My first "design" thought was to make the text scroll one line up at every new ping, but then i found a LUA script for tailing the lines of a text file. Meaning, if there is a text file with multiple lines, the LUA script takes all those lines, reverse it, and make it look like scroling from top to bottom.
This is the LUA script currently:
Code:
function Initialize()sFileToRead = SELF:GetOption('FileToRead')slinesToTail = SKIN:GetVariable('LinesToTail')childPrefix = SKIN:GetVariable('ChildPrefix')endfunction Update()sTmping = SKIN:GetVariable('tmping')hWritingFile = io.open(sFileToRead, "a")io.output(hWritingFile)io.write(sTmping, "\n")io.close(hWritingFile)hReadingFile = io.open(sFileToRead, "r")linesTable = {}for line in hReadingFile:lines() dotable.insert (linesTable, line);endio.close(hReadingFile)--if #linesTable>90 then --function remove()--endfor i = 1, slinesToTail doSKIN:Bang('!SetOption', childPrefix..i, 'String', linesTable[(#linesTable + 1) - i])SKIN:Bang('!UpdateMeasure', childPrefix..i)endSKIN:Bang('!UpdateMeter', '*')SKIN:Bang('!Redraw')return #linesTableendfunction remove( filename, starting_line, num_lines ) local fp = io.open( sFileToRead, "r" ) if fp == nil then return nil end content = {} i = 1; for line in fp:lines() do if i < starting_line or i >= starting_line + num_lines then content[#content+1] = lineendi = i + 1 end if i > starting_line and i < starting_line + num_lines thenprint( "Warning: Tried to remove lines after EOF." ) end fp:close() fp = io.open( sFileToRead, "w+" ) for i = 1, #content dofp:write( string.format( "%s\n", content[i] ) ) end fp:close()end
Currently we can declare in the Skin.ini file how many entries would store in the log.txt with "logsize=59". Above that number it clears the txt file completely, and the logging starts again. Later the plan would be to when it reaches the number, the script should remove only the oldest entry, and add new one to the end.
My point was to not use any [Variables] in the log file, to be absolutely clear with displaying the log file.
Finally i quickly added a histogram to the skin, so even after clearing the txt file, we can still see significant spikes in latency.
I attached the rmskin also here.
I hope this will be usefull for someone.
Statistics: Posted by rbriddickk84 — Yesterday, 8:45 pm — Replies 0 — Views 33