Skip to content
This repository has been archived by the owner on Nov 21, 2022. It is now read-only.

Commit

Permalink
Added: Width and Height settings for RRDTool Graphs
Browse files Browse the repository at this point in the history
Fixed: Removed hardcoded graphs size for serverstats.
Fixed: Resize of contents inside Climate and Serverstarts forms.
  • Loading branch information
cyberjunky committed Nov 24, 2014
1 parent fdd6e0b commit 7bfa1dc
Show file tree
Hide file tree
Showing 21 changed files with 133 additions and 69 deletions.
Binary file modified DomotiGa3.gambas
Binary file not shown.
3 changes: 1 addition & 2 deletions DomotiGa3/.src/FClimate.class
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ End

Public Sub Form_Resize()

vpnlGraphs.Move(5, 31, Me.ClientWidth - 10, Me.ClientHeight - 33)
svGraphs.Move(4, 30, Me.ClientWidth - 8, Me.ClientHeight - 31)
svGraphs.Move(0, 35, Me.ClientWidth, Me.ClientHeight - 35)

End

Expand Down
40 changes: 21 additions & 19 deletions DomotiGa3/.src/FClimate.form
Original file line number Diff line number Diff line change
@@ -1,73 +1,75 @@
# Gambas Form File 3.0
{ Form Form

{ Form Form
MoveScaled(0,0,120,69)
Background = Color.TextBackground
Text = ("Climate")
Icon = Picture["icons/climate.png"]
{ ToolBar1 ToolBar
{ ToolBar1 ToolBar
MoveScaled(0,0,110,4)
{ HBox1 HBox
{ HBox1 HBox
MoveScaled(0,0,108,4)
Spacing = True
{ btnRefresh Button
{ btnRefresh Button
MoveScaled(0,0,12,4)
Text = ("Refresh")
}
{ tbtnRefresh ToggleButton
{ tbtnRefresh ToggleButton
MoveScaled(13,0,12,4)
Text = ("AutoRefresh")
}
{ btnOverview Button
{ btnOverview Button
MoveScaled(26,0,12,4)
Text = ("Overview")
}
{ btnGraphs2h Button
{ btnGraphs2h Button
MoveScaled(39,0,6,4)
Text = ("2h")
}
{ btnGraphs1d Button
{ btnGraphs1d Button
MoveScaled(46,0,6,4)
Text = ("1d")
}
{ btnGraphs2d Button
{ btnGraphs2d Button
MoveScaled(53,0,6,4)
Text = ("2d")
}
{ btnGraphs1w Button
{ btnGraphs1w Button
MoveScaled(60,0,6,4)
Text = ("1w")
}
{ btnGraphs2w Button
{ btnGraphs2w Button
MoveScaled(67,0,6,4)
Text = ("2w")
}
{ btnGraphs1m Button
{ btnGraphs1m Button
MoveScaled(74,0,6,4)
Text = ("1m")
}
{ btnGraphs1y Button
{ btnGraphs1y Button
MoveScaled(81,0,6,4)
Text = ("1y")
}
{ HBox2 HBox
{ HBox2 HBox
MoveScaled(89,0,4,3)
}
{ txtRange TextBox
{ txtRange TextBox
MoveScaled(93,0,8,4)
}
{ btnShow Button
{ btnShow Button
MoveScaled(102,0,6,4)
Text = ("Show")
}
}
}
{ svGraphs ScrollView
{ svGraphs ScrollView
MoveScaled(1,5,96,61)
Expand = True
Border = False
{ vpnlGraphs VPanel
{ vpnlGraphs VPanel
MoveScaled(0,3,94,56)
Expand = True
AutoResize = True
}
}
}
}
3 changes: 1 addition & 2 deletions DomotiGa3/.src/FServerStats.class
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ End

Public Sub Form_Resize()

svGraphs.Move(4, 30, Me.ClientWidth - 8, Me.ClientHeight - 31)
' vpnlGraphs.Move(5, 31, ME.ClientWidth - 10, ME.ClientHeight - 33)
svGraphs.Move(0, 35, Me.ClientWidth, Me.ClientHeight - 35)

End

Expand Down
45 changes: 24 additions & 21 deletions DomotiGa3/.src/FServerStats.form
Original file line number Diff line number Diff line change
@@ -1,71 +1,74 @@
# Gambas Form File 3.0
{ Form Form

{ Form Form
MoveScaled(0,0,121,71)
Background = Color.TextBackground
Text = ("System Stats")
Icon = Picture["icons/serverstats.png"]
{ svGraphs ScrollView
MoveScaled(1,5,95,49)
{ svGraphs ScrollView
MoveScaled(0,4,102,49)
Border = False
{ vpnlGraphs VPanel
MoveScaled(0,0,92,56)
{ vpnlGraphs VPanel
MoveScaled(0,0,92,44)
Expand = True
AutoResize = True
}
}
{ ToolBar1 ToolBar
{ ToolBar1 ToolBar
MoveScaled(0,0,110,4)
{ HBox1 HBox
{ HBox1 HBox
MoveScaled(0,0,108,4)
Spacing = True
{ btnRefresh Button
{ btnRefresh Button
MoveScaled(0,0,12,4)
Text = ("Refresh")
}
{ tbtnRefresh ToggleButton
{ tbtnRefresh ToggleButton
MoveScaled(13,0,12,4)
Text = ("AutoRefresh")
}
{ btnOverview Button
{ btnOverview Button
MoveScaled(26,0,12,4)
Text = ("Overview")
}
{ btnGraphs2h Button
{ btnGraphs2h Button
MoveScaled(39,0,6,4)
Text = ("2h")
}
{ btnGraphs1d Button
{ btnGraphs1d Button
MoveScaled(46,0,6,4)
Text = ("1d")
}
{ btnGraphs2d Button
{ btnGraphs2d Button
MoveScaled(53,0,6,4)
Text = ("2d")
}
{ btnGraphs1w Button
{ btnGraphs1w Button
MoveScaled(60,0,6,4)
Text = ("1w")
}
{ btnGraphs2w Button
{ btnGraphs2w Button
MoveScaled(67,0,6,4)
Text = ("2w")
}
{ btnGraphs1m Button
{ btnGraphs1m Button
MoveScaled(74,0,6,4)
Text = ("1m")
}
{ btnGraphs1y Button
{ btnGraphs1y Button
MoveScaled(81,0,6,4)
Text = ("1y")
}
{ HBox2 HBox
{ HBox2 HBox
MoveScaled(88,0,4,3)
}
{ txtRange TextBox
{ txtRange TextBox
MoveScaled(92,0,8,4)
}
{ btnShow Button
{ btnShow Button
MoveScaled(101,0,6,4)
Text = ("Show")
}
}
}
}
}
4 changes: 4 additions & 0 deletions DomotiGa3/.src/Main.module
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ Public sVideoServerChannel4 As String
' RRDTool
Public bRRDToolEnabled As Boolean
Public iRRDToolPollTime As Integer
Public iRRDToolWidth As Integer
Public iRRDToolHeight As Integer
Public sRRDToolRRA As String
Public bRRDToolDebug As Boolean

Expand Down Expand Up @@ -700,6 +702,8 @@ Public Sub GetSettings()
rResult = GetSettingTable("rrdtool")
bRRDToolEnabled = rResult!enabled
iRRDToolPollTime = rResult!polltime
iRRDToolWidth = rResult!width
iRRDToolHeight = rResult!height
sRRDToolRRA = rResult!rra
bRRDToolDebug = rResult!debug

Expand Down
6 changes: 4 additions & 2 deletions DomotiGa3/.src/RRDTool.module
Original file line number Diff line number Diff line change
Expand Up @@ -289,9 +289,11 @@ Public Sub CreateGraph(iId As Integer, sTime As String)
sRRD = Main.sBaseDir &/ "rrd" &/ sRRDName & ".rrd"
For Each rDevice
If rDevice!device_value_valuerrddsname Then
If Main.bRRDToolDebug Then Main.WriteDebugLog(LogLabel & "Device with address '" & rDevice!device_address & "' named '" & rDevice!device_name & "' has graphing enabled for " & rDevice!device_value_valuerrddsname & ".")
If Main.bRRDToolDebug Then
Main.WriteDebugLog(LogLabel & "Device with address '" & rDevice!device_address & "' named '" & rDevice!device_name & "' has graphing enabled for " & rDevice!device_value_valuerrddsname & ".")
Endif
sGraphImage = Main.sBaseDir &/ "rrd/graphs/" &/ sRRDName & "-" & rDevice!device_value_valuerrddsname & "-" & sTime & ".png"
sRRDCmd = "rrdtool graph " & sGraphImage & " --lazy --start -" & sTime & " -c SHADEA#FFFFFF -c SHADEB#FFFFFF -c BACK#FFFFFF -t '" & rDevice!device_name & " " & Main.Caps(rDevice!device_value_valuerrddsname) & "' -v '" & rDevice!device_value_units & "' DEF:" & rDevice!device_value_valuerrddsname & "=" & sRRD & ":" & rDevice!device_value_valuerrddsname & ":AVERAGE LINE1:" & rDevice!device_value_valuerrddsname & "#00FF00:'" & Main.Caps(rDevice!device_value_valuerrddsname) & "'"
sRRDCmd = "rrdtool graph " & sGraphImage & " -w " & Main.iRRDToolWidth & " -h " & Main.iRRDToolHeight & " --lazy --start -" & sTime & " -c SHADEA#FFFFFF -c SHADEB#FFFFFF -c BACK#FFFFFF -t '" & rDevice!device_name & " " & Main.Caps(rDevice!device_value_valuerrddsname) & "' -v '" & rDevice!device_value_units & "' DEF:" & rDevice!device_value_valuerrddsname & "=" & sRRD & ":" & rDevice!device_value_valuerrddsname & ":AVERAGE LINE1:" & rDevice!device_value_valuerrddsname & "#00FF00:'" & Main.Caps(rDevice!device_value_valuerrddsname) & "'"
sRRDCmd &= " GPRINT:" & rDevice!device_value_valuerrddsname & ":MIN:'Min\\:%1.1lf' GPRINT:" & rDevice!device_value_valuerrddsname & ":MAX:'Max\\:%1.1lf' GPRINT:" & rDevice!device_value_valuerrddsname & ":AVERAGE:'Avg\\:%1.1lf' GPRINT:" & rDevice!device_value_valuerrddsname & ":LAST:'Last\\:%1.1lf'"
If Main.bRRDToolDebug Then
Main.WriteDebugLog(LogLabel & "" & sRRDCmd)
Expand Down
6 changes: 3 additions & 3 deletions DomotiGa3/.src/ServerStats.module
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ Private Sub UpdateRRDs()
Exec ["rrdtool", "update", Main.sBaseDir &/ "rrd/servermemory.rrd", sRRDCmd]

Catch
Main.WriteDebugLog(LogLabel & "ERROR: " & Error.Text & " at " & Error.Where)
Main.WriteDebugLog(LogLabel & "ERROR: '" & Error.Text & "' at '" & Error.Where & "'")

End

Expand All @@ -180,14 +180,14 @@ Public Sub CreateGraphs(sTime As String)

sRRD = Main.sBaseDir &/ "rrd/serverload.rrd"
sGraphImage = Main.sBaseDir &/ "rrd/graphs/server-load" & "-" & sTime & ".png"
sRRDCmd = "rrdtool graph " & sGraphImage & " --slope-mode --font DEFAULT:7: --lazy --units-exponent=0 --width 600 --height 100 --start -" & sTime & " -c SHADEA#FFFFFF -c SHADEB#FFFFFF -c BACK#FFFFFF -t '" & Main.sServerStatsName & " " & ("System Load") & "' -v Load DEF:load1=" & sRRD & ":load1:AVERAGE LINE1:load1#8080ff:'1 Minute load average' DEF:load5=" & sRRD & ":load5:AVERAGE LINE1:load5#ff8080:'5 Minute load average' DEF:load15=" & sRRD & ":load15:AVERAGE LINE1:load15#000000:'15 Minutes load average'"
sRRDCmd = "rrdtool graph " & sGraphImage & " --slope-mode --font DEFAULT:7: --lazy --units-exponent=0 --width " & Main.iRRDToolWidth & " --height " & Main.iRRDToolHeight & " --start -" & sTime & " -c SHADEA#FFFFFF -c SHADEB#FFFFFF -c BACK#FFFFFF -t '" & Main.sServerStatsName & " " & ("System Load") & "' -v Load DEF:load1=" & sRRD & ":load1:AVERAGE LINE1:load1#8080ff:'1 Minute load average' DEF:load5=" & sRRD & ":load5:AVERAGE LINE1:load5#ff8080:'5 Minute load average' DEF:load15=" & sRRD & ":load15:AVERAGE LINE1:load15#000000:'15 Minutes load average'"
sRRDCmd &= " 2>&1 >/dev/null"
If Main.bServerStatsDebug Then Main.WriteDebugLog(LogLabel & sRRDCmd)
Shell sRRDCmd Wait

sRRD = Main.sBaseDir &/ "rrd/servermemory.rrd"
sGraphImage = Main.sBaseDir &/ "rrd/graphs/server-memory" & "-" & sTime & ".png"
sRRDCmd = "rrdtool graph " & sGraphImage & " --slope-mode --font DEFAULT:7: --width 600 --height 100 --lazy --base=1024 --alt-autoscale-max --lower-limit=0 --start -" & sTime & " -c SHADEA#FFFFFF -c SHADEB#FFFFFF -c BACK#FFFFFF -t '" & Main.sServerStatsName & " " & ("Memory Usage") & "' -v MBytes DEF:a=" & sRRD & ":used:AVERAGE AREA:a#6666FF:'Used' DEF:b=" & sRRD & ":free:AVERAGE STACK:b#99FF66:'Free' DEF:c=" & sRRD & ":buffers:AVERAGE LINE2:c#FFFF00:'Buffers' DEF:d=" & sRRD & ":cached:AVERAGE LINE2:d#663300:'Cached'"
sRRDCmd = "rrdtool graph " & sGraphImage & " --slope-mode --font DEFAULT:7: --width " & Main.iRRDToolWidth & " --height " & Main.iRRDToolHeight & " --lazy --base=1024 --alt-autoscale-max --lower-limit=0 --start -" & sTime & " -c SHADEA#FFFFFF -c SHADEB#FFFFFF -c BACK#FFFFFF -t '" & Main.sServerStatsName & " " & ("Memory Usage") & "' -v MBytes DEF:a=" & sRRD & ":used:AVERAGE AREA:a#6666FF:'Used' DEF:b=" & sRRD & ":free:AVERAGE STACK:b#99FF66:'Free' DEF:c=" & sRRD & ":buffers:AVERAGE LINE2:c#FFFF00:'Buffers' DEF:d=" & sRRD & ":cached:AVERAGE LINE2:d#663300:'Cached'"
sRRDCmd &= " 2>&1 >/dev/null"
If Main.bServerStatsDebug Then Main.WriteDebugLog(LogLabel & sRRDCmd)
Shell sRRDCmd Wait
Expand Down
21 changes: 19 additions & 2 deletions DomotiGa3/.src/Settings/FSettingsRRDTool.class
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,18 @@ Public Sub txtPollTime_KeyPress()

End

Public Sub vbWidth_KeyPress()

btnSave.Enabled = True

End

Public Sub vbHeight_KeyPress()

btnSave.Enabled = True

End

Public Sub btnDefaults_Click()

LoadSettings(0)
Expand All @@ -65,12 +77,14 @@ Public Sub btnSave_Click()
Dim rResult As Result

' save new RRDTool settings
rResult = Main.hDB.Exec("UPDATE settings_rrdtool SET debug = &1, enabled = &2, polltime = &3 WHERE id = 1", chkDebug.Value, chkEnabled.Value, txtPollTime.Text)
rResult = Main.hDB.Exec("UPDATE settings_rrdtool SET debug = &1, enabled = &2, polltime = &3, width = &4, height = &5 WHERE id = 1", chkDebug.Value, chkEnabled.Value, txtPollTime.Text, vbWidth.Value, vbHeight.Value)

rResult = Main.GetSettingTable("rrdtool") ' reload settings
If rResult.Count Then
Main.bRRDToolEnabled = rResult!enabled
Main.iRRDToolPollTime = rResult!polltime
Main.iRRDToolWidth = rResult!width
Main.iRRDToolHeight = rResult!height
Main.bRRDToolDebug = rResult!debug
Endif

Expand Down Expand Up @@ -102,6 +116,8 @@ Private Sub LoadSettings(iRow As Integer) As Boolean
If rResult.Count Then
chkEnabled.Value = rResult!enabled
txtPollTime.Text = rResult!polltime
vbWidth.Value = rResult!width
vbHeight.Value = rResult!height
chkDebug.Value = rResult!debug
Return True
Else
Expand All @@ -115,8 +131,9 @@ End
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Private Sub EnableDisableSettings()

vbWidth.Enabled = chkEnabled.Value
vbHeight.Enabled = chkEnabled.Value
txtPollTime.Enabled = chkEnabled.Value
chkDebug.Enabled = chkEnabled.Value

End

32 changes: 25 additions & 7 deletions DomotiGa3/.src/Settings/FSettingsRRDTool.form
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Gambas Form File 3.0

{ Form Form
MoveScaled(0,0,45,26)
MoveScaled(0,0,45,35)
Background = Color.TextBackground
Text = ("Setup")
Icon = Picture["icons/charts.png"]
Resizable = False
{ frameSettingsRRDTool Frame
MoveScaled(1,1,43,24)
MoveScaled(1,1,43,33)
Text = ("RRDTool Settings")
{ TextLblModuleEnabled TextLabel
MoveScaled(20,2,17,4)
Expand All @@ -31,26 +31,44 @@
Alignment = Align.Normal
}
{ TextLblDebug TextLabel
MoveScaled(2,12,15,4)
MoveScaled(2,22,15,4)
Text = ("Debug")
Alignment = Align.Normal
}
{ chkDebug CheckBox
MoveScaled(18,12,3,4)
MoveScaled(18,22,3,4)
ToolTip = ("Enable debug output")
}
{ btnDefaults Button
MoveScaled(2,18,12,4)
MoveScaled(2,28,12,4)
Text = ("Defaults")
}
{ btnSave Button
MoveScaled(16,18,12,4)
MoveScaled(16,28,12,4)
Enabled = False
Text = ("Save")
}
{ btnCancel Button
MoveScaled(29,18,12,4)
MoveScaled(29,28,12,4)
Text = ("Cancel")
}
{ TextLblUpdateInterval2 TextLabel
MoveScaled(2,12,15,4)
Text = ("Graph Width")
Alignment = Align.Normal
}
{ TextLblUpdateInterval3 TextLabel
MoveScaled(2,17,15,4)
Text = ("Graph Height")
Alignment = Align.Normal
}
{ vbWidth ValueBox
MoveScaled(18,12,7,4)
Text = ("ValueBox1")
}
{ vbHeight ValueBox
MoveScaled(18,17,7,4)
Text = ("ValueBox1")
}
}
}
Binary file modified DomotiGaServer3.gambas
Binary file not shown.
Loading

0 comments on commit 7bfa1dc

Please sign in to comment.