Well, made it a working proggie....
I know it's really dirty... But it's a work in progress.
I know there are apps that do this, but what's the fun in just installing them?
Code: Select all
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
;#######################
; GLOBALS
;#######################
URL=192.168.1.70
NasServer=%URL%
;#######################
; GET DATA
;#######################
; Starting cleanup
if FileExist("spaceballs.txt")
FileDelete, spaceballs.txt
if FileExist("splitballs.txt")
FileDelete, splitballs.txt
Sleep 50
; Get them infos brah
Run, plink.exe -ssh -pw "xxxxxxxxx" xxxxxxxx@%NasServer% df > /srv/dev-disk-by-label-MainMirror/NasX/.spacespecs/spaceballs.txt, ,Hide
sleep 500
FileMove, \\NASBOX\Main\.spacespecs\spaceballs.txt, %A_ScriptDir%
sleep 500
;#######################
; DATA HANDLE
;#######################
; Strip yo data bitch!
Trash := "Sist.fichs"
Trash2 := "folder2ram"
Trash3 := "tmpfs"
Trash4 := "udev"
Trash5 := "/dev/sdf1"
Sleep 50
FileRead, var, spaceballs.txt
FileDelete, spaceballs.txt
Sleep 50
Loop, Parse, var, `n, `r
If not instr(A_LoopField, Trash)
If not instr(A_LoopField, Trash2)
If not instr(A_LoopField, Trash3)
If not instr(A_LoopField, Trash4)
If not instr(A_LoopField, Trash5)
New_data .= A_LoopField "`n"
FileAppend, %New_data%, splitballs.txt
New_data := ""
Sleep 50
FileReadLine, Sda1, splitballs.txt, 1
FileReadLine, Sda2, splitballs.txt, 2
FileReadLine, Sda3, splitballs.txt, 3
FileReadLine, Md0, splitballs.txt, 4
Sleep 50
RegExMatch(Sda1, "\d+`%", Perc1) ; Percentagem - sda1 (RED1)
RegExMatch(Sda2, "\d+`%", Perc2) ; Percentagem - sda2 (MOV1)
RegExMatch(Sda3, "\d+`%", Perc3) ; Percentagem - sda3 (BACKUPS)
RegExMatch(Md0, "\d+`%", Perc4) ; Percentagem - md0 (Main RAID)
Sleep 50
;#######################
; GUI WORKS
;#######################
Gui, +AlwaysOnTop
Gui, font, s8 cBlack
Gui, Show, w200 h270
; GuiBoxes
Gui,Add, GroupBox, x10 y10 w180 h150, Dados
Gui,Add, GroupBox, x10 y160 w180 h80, NAS Ping
; Endereço NAS
Gui, Add, Text, x20 y220 w160 h20 vIpnas, NAS Address: %URL%
; percentagens
Gui, Add, Text, x20 y30 w30 h20 +BackgroundTrans Right, %Perc1%
Gui, Add, Text, x20 y60 w30 h20 +BackgroundTrans Right, %Perc2%
Gui, Add, Text, x20 y90 w30 h20 +BackgroundTrans Right, %Perc3%
Gui, Add, Text, x20 y120 w30 h20 +BackgroundTrans Right, %Perc4%
; barras
Gui, Add, Progress, x55 y30 w100 h20 vPerc1 cRed, %Perc1%
Gui, Add, Progress, x55 y60 w100 h20 vPerc2 cRed, %Perc2%
Gui, Add, Progress, x55 y90 w100 h20 vPerc3 cRed, %Perc3%
Gui, Add, Progress, x55 y120 w100 h20 vPerc4 cRed, %Perc4%
; barras ping
Gui, Add, Progress, x20 y180 w10 h10 vPing1 cGreen Backgroundf0f0f0, 100
Gui, Add, Progress, x30 y180 w10 h10 vPing2 cGreen Backgroundf0f0f0, 100
Gui, Add, Progress, x40 y180 w10 h10 vPing3 cYellow Backgroundf0f0f0, 100
Gui, Add, Progress, x50 y180 w10 h10 vPing4 cRed Backgroundf0f0f0, 100
; Ping response
Gui, Add, Text, x20 y195 w150 h20 vStatusPing
; botões
Gui, Add, Button, x10 y240 w70 h25 gGtfo, Sair
Sleep 500
;#######################
; PING PONG
;#######################
Loop:
while(1) {
Ping := SimplePing(URL)
GuiControl,, Text, Ping: %Ping%ms
If (Ping == "No response."){
GuiControl,, Text, No Response from Server :(
Ping = 1000
}
UpdateBar(Ping)
comp := URL
gui, submit, NoHide
if(URL <> comp)
GuiControl,, Text, Retrieving Initial Ping...
}
SimplePing(URL, timeout = 3000)
{
Runwait,%comspec% /c ping -w %timeout% %url%>ping.log,,hide
fileread , StrTemp, ping.log
if RegExMatch(StrTemp, "Average = (\d+)", result)
speed:=result1
else
speed := "No response."
return speed
filedelete ping.log
}
Sleep 50
UpdateBar(ping)
{
If (ping 0)
{
GuiControl,, Ping1, %Ping%
GuiControl,, Ping2, 0
GuiControl,, Ping3, 0
GuiControl,, Ping4, 0
GuiControl,,StatusPing, ONLINE %Ping% ms
return
}
If (ping < 10)
{
Ping:=Ping-10
GuiControl,, Ping1, 100
GuiControl,, Ping2, %Ping%
GuiControl,, Ping3, 0
GuiControl,, Ping4, 0
GuiControl,,StatusPing, FULL SPEED %Ping%ms
return
}
If (ping < 30)
{
Ping:=Ping-30
GuiControl,, Ping1, 100
GuiControl,, Ping2, 100
GuiControl,, Ping3, %Ping%
GuiControl,, Ping4, 0
GuiControl,,StatusPing, SLOW SPEED %Ping%ms
return
}
If (ping < 50)
{
Ping:=Ping-50
GuiControl,, Ping1, 100
GuiControl,, Ping2, 100
GuiControl,, Ping3, 100
GuiControl,, Ping4, %Ping%
GuiControl,,StatusPing, PROBLEMS %Ping%ms
}
If (ping > 999)
{
Ping:=Ping-999
GuiControl,, Ping1, 100
GuiControl,, Ping2, 100
GuiControl,, Ping3, 100
GuiControl,, Ping4, 100
GuiControl,,StatusPing, OFFLINE
}
}
Gui, Show
Gui, +LastFound
Winset, Redraw
return
GuiClose:
GuiEscape:
ExitApp
Gtfo:
ExitApp