Skip to content

Commit

Permalink
New Memory Tab
Browse files Browse the repository at this point in the history
  • Loading branch information
eloaders committed Jan 20, 2014
1 parent 61ecb31 commit 9dc677f
Show file tree
Hide file tree
Showing 3 changed files with 142 additions and 126 deletions.
66 changes: 43 additions & 23 deletions getusage.c
Original file line number Diff line number Diff line change
@@ -1,35 +1,55 @@
#include <sys/sysinfo.h>
//#include <sys/sysinfo.h>
#include <stdio.h>

#include <unistd.h>
#include <malloc.h>
#include <sys/sysinfo.h>
int main() {
int days, hours, mins;
struct sysinfo sys_info;
struct mallinfo sys_infoggg;
if(sysinfo(&sys_info) != 0)
perror("sysinfo");

long long physMemUsed = sys_info.totalram - sys_info.freeram;
//Multiply in next statement to avoid int overflow on right hand side...
physMemUsed *= sys_info.mem_unit;
long long totalVirtualMem = sys_info.totalram;
//Add other values in next statement to avoid int overflow on right hand side...
totalVirtualMem += sys_info.totalswap;
totalVirtualMem *= sys_info.mem_unit;
unsigned long total_bytes;
total_bytes = sys_info.mem_unit * sys_info.totalram;
days = sys_info.uptime / 86400;
hours = (sys_info.uptime / 3600) - (days * 24);
mins = (sys_info.uptime / 60) - (days * 1440) - (hours * 60);

printf("{\n"); //
printf(" \"UPTIME_DAYS\": %d ,\n", days); //
printf(" \"UPTIME_HOURS\": %d ,\n", hours); //
printf(" \"UPTIME_MINUTES\": %d ,\n", mins); //
printf(" \"UPTIME_SECONDS\": %ld ,\n", sys_info.uptime % 60); //
printf(" \"LOAD_AVG_1MIN\": %ld ,\n", sys_info.loads[0]); //
printf(" \"LOAD_AVG_5MIN\": %ld ,\n", sys_info.loads[1]); //
printf(" \"LOAD_AVG_15MIN\": %ld ,\n", sys_info.loads[2]); //
printf(" \"TOTAL_RAM\": %ld ,\n", sys_info.totalram / 1024); //
printf(" \"FREE_RAM\": %ld ,\n", sys_info.freeram / 1024); //
printf(" \"SHARED_RAM\": %ld ,\n", sys_info.sharedram / 1024); //
printf(" \"BUFFERED_RAM\": %ld ,\n", sys_info.bufferram / 1024); //
printf(" \"TOTAL_RAM_UNIT\": %llu ,\n", sys_info.totalram *(unsigned long long)sys_info.mem_unit / 1024); //
printf(" \"FREE_RAM_UNIT\": %llu ,\n", sys_info.freeram *(unsigned long long)sys_info.mem_unit/ 1024); //
printf(" \"TOTAL_SWAP\": %ld ,\n", sys_info.totalswap / 1024); //
printf(" \"FREE_SWAP\": %ld ,\n", sys_info.freeswap / 1024); //
printf(" \"TOTAL_HIGH\": %ld ,\n", sys_info.totalhigh / 1024); //
printf(" \"NUMBER_OF_PROCESSES\": %d \n", sys_info.procs); //
printf("}\n"); //
printf("{\n");
printf(" \"UPTIME_DAYS\": %d ,\n", days);
printf(" \"UPTIME_HOURS\": %d ,\n", hours);
printf(" \"UPTIME_MINUTES\": %d ,\n", mins);
printf(" \"UPTIME_SECONDS\": %ld ,\n", sys_info.uptime % 60);
printf(" \"LOAD_AVG_1MIN\": %ld ,\n", sys_info.loads[0]/1000);
printf(" \"LOAD_AVG_5MIN\": %ld ,\n", sys_info.loads[1]/1000);
printf(" \"LOAD_AVG_15MIN\": %ld ,\n", sys_info.loads[2]/1000);
printf(" \"TOTAL_RAM\": %ld ,\n", sys_info.totalram /1024/1024);
printf(" \"FREE_RAM\": %ld ,\n", sys_info.freeram /1024/1024);
printf(" \"SHARED_RAM\": %ld ,\n", sys_info.sharedram /1024/1024);
printf(" \"BUFFERED_RAM\": %ld ,\n", sys_info.bufferram /1024/1024);
printf(" \"TOTAL_RAM_UNIT\": %llu ,\n", sys_info.totalram *(unsigned long long)sys_info.mem_unit/1024/1024);
printf(" \"FREE_RAM_UNIT\": %llu ,\n", sys_info.freeram *(unsigned long long)sys_info.mem_unit/1024/1024);
printf(" \"TOTAL_SWAP\": %ld ,\n", sys_info.totalswap /1024/1024);
printf(" \"FREE_SWAP\": %ld ,\n", sys_info.freeswap /1024/1024);
printf(" \"TOTAL_HIGH\": %ld ,\n", sys_info.totalhigh /1024/1024);
printf(" \"FREE_HIGH\": %ld ,\n", sys_info.freehigh /1024/1024);
printf(" \"PHYS_MEM_USED\": %llu ,\n", physMemUsed /1024/1024);
printf(" \"TOTAL_VIRTUAL_MEM\": %llu ,\n", totalVirtualMem /1024/1024);
printf(" \"NUMBER_OF_PROCESSES\": %d \n", sys_info.procs);
printf("}\n");

/*printf("total usable main memory is %lu B, %lu MB\n", total_bytes/1024/1024, total_bytes/1024/1024);
printf("The number of pages of physical memory: %ld bytes\n", sysconf(_SC_PAGESIZE));
printf("The maximum number of simultaneous processes per user ID: %ld\n", sysconf(_SC_CHILD_MAX));
printf("The number of clock ticks per second: %ld\n", sysconf(_SC_CLK_TCK));
printf("The number of processors currently online (available): %ld\n", sysconf(_SC_NPROCESSORS_ONLN));
printf("The number of processors configured: %ld\n", sysconf(_SC_NPROCESSORS_CONF));*/
return 0;
}
}
56 changes: 28 additions & 28 deletions src/i-nex/.src/Finfosys.class
Original file line number Diff line number Diff line change
Expand Up @@ -589,43 +589,43 @@ End

Public Sub dospam_uptime()
Dim total, used, freee, shared, buffers, cached, usedonthistime, swaptotal As String
Dim dospam, totpam, totalswap, usedswap As String
Shell "free -m | grep 'Mem' | awk {'print $2'}" Wait To total
Shell "free -m | awk {'print $3'} | sed -n '2p'" Wait To used
Dim dospam, totpam, totalswap, usedswap, Users As String
Dim USAGE_BUFFER As String
Dim USAGE As Collection
Shell "users | tr ' ' '\n' | wc -l" Wait To Users
Exec [ChkPrm.ChkExecDir("inex-usage")] Wait To USAGE_BUFFER
USAGE = JSON.Decode(USAGE_BUFFER)
Shell "free -m | awk {'print $4'} | sed -n '2p'" Wait To freee
Shell "free -m | awk {'print $5'} | sed -n '2p'" Wait To shared
Shell "free -m | awk {'print $6'} | sed -n '2p'" Wait To buffers
Shell "free -m | awk {'print $7'} | sed -n '2p'" Wait To cached
Shell "free -m | grep - | awk {'print $3'}" To dospam
Shell "free -m | grep - | awk {'print $3'}" To usedonthistime
Shell "free -m | grep - | awk {'print $3'}" To dospam
Shell "free -m | grep Mem | awk {'print $2'}" Wait To totpam
Shell "free -m | grep 'Swap:' | awk {'print $2'}" Wait To swaptotal
'Obliczanie zajętości swap
Shell "/sbin/swapon -s | awk {'print $3'} | sed -n '2p'" Wait To totalswap
Shell "/sbin/swapon -s | awk {'print $4'} | sed -n '2p'" Wait To usedswap
'Exec ["/sbin/swapon -s ", "awk {'print $3'}", "sed -n '2p'"] Wait To totalswap
'Exec ["/sbin/swapon -s", "awk {'print $4'}", "sed -n '2p'"] Wait To usedswap
swaptotal = Replace(swaptotal, "\n", "")
dospam = Replace(Replace(dospam, " ", ""), "\n", "")
totpam = Replace(Replace(totpam, " ", ""), "\n", "")
usedonthistime = Replace(usedonthistime, "\n", "")
cached = Replace(cached, "\n", "")
buffers = Replace(buffers, "\n", "")
shared = Replace(shared, "\n", "")
freee = Replace(freee, "\n", "")
used = Replace(used, "\n", "")
total = Replace(total, "\n", "")
Label85.Text = "Total: " & total & " MB"
Label86.Text = "Used: " & used & " MB"
Label85.Text = "Total: " & Int(USAGE["TOTAL_RAM"]) & " MB"
Label86.Text = "Used: " & Int(Int(USAGE["TOTAL_RAM"]) - Int(USAGE["FREE_RAM"])) & " MB"
Label87.Text = "Free: " & freee & " MB"
Label88.Text = "Shared: " & shared & " MB"
Label89.Text = "Buffers: " & buffers & " MB"
Label88.Text = "Shared: " & Int(USAGE["SHARED_RAM"]) & " MB"
Label89.Text = "Buffers: " & Int(USAGE["BUFFERED_RAM"]) & " MB"
Label90.Text = "Cached: " & cached & " MB"
TextLabel7.Text = usedonthistime & " MB"
Label91.Text = "SWAP Total: " & swaptotal & " MB " ""
Try TextLabel24.Text = (Replace(Replace(usedswap, " ", ""), "\n", "") / 1000) & " MB"
Try Exec ["/usr/bin/uptime"] Wait To TextBox58.Text
TextBox58.Text = Replace(TextBox58.Text, "\n", "")
Try ProgressBar1.Value = Replace(Replace(dospam, " ", ""), "\n", "") / Replace(Replace(totpam, " ", ""), "\n", "")
Try ProgressBar4.Value = Replace(Replace(usedswap, " ", ""), "\n", "") / Replace(Replace(totalswap, " ", ""), "\n", "")
TextLabel7.Text = "Ram used: " & usedonthistime & " MB"
Label91.Text = "SWAP Total: " & Int(USAGE["TOTAL_SWAP"]) & " MB " ""
TextLabel15.Text = "Physical Memory Used: " & Int(USAGE["PHYS_MEM_USED"]) & " MB " ""
TextLabel24.Text = "SWAP memory used: " & Int(Int(USAGE["TOTAL_SWAP"]) - Int(USAGE["FREE_SWAP"])) & " MB"
TextBox58.Text = "Days: " & USAGE["UPTIME_DAYS"] & " " &
"Hours: " & USAGE["UPTIME_HOURS"] & " " &
"Minutes: " & USAGE["UPTIME_MINUTES"] & " " &
"Seconds: " & USAGE["UPTIME_SECONDS"] & " " &
"Users: " & Subst$(Users) &
"load average: " & Int(USAGE["LOAD_AVG_1MIN"]) & " " &
", " & Int(USAGE["LOAD_AVG_5MIN"]) & " " &
", " & Int(USAGE["LOAD_AVG_15MIN"])
Try ProgressBar6.Value = Int(USAGE["PHYS_MEM_USED"]) / Int(USAGE["TOTAL_VIRTUAL_MEM"])
Try ProgressBar1.Value = Int(CFloat(dospam)) / Int(CFloat(totpam))
Try ProgressBar4.Value = Int(Int(USAGE["TOTAL_SWAP"]) - Int(USAGE["FREE_SWAP"])) / Int(USAGE["TOTAL_SWAP"])

End

Expand Down
146 changes: 71 additions & 75 deletions src/i-nex/.src/Finfosys.form
Original file line number Diff line number Diff line change
Expand Up @@ -1583,106 +1583,102 @@
Index = 7
Text = ("Memory")
Picture = Picture["AppIcons/Finfosys/utilities-system-monitor.png"]
{ TextLabel31 TextLabel
Move(7,280,126,21)
Font = Font["Bold,8"]
Text = ("Ram used:")
}
{ ProgressBar1 ProgressBar
Move(7,301,259,21)
}
{ TextLabel23 TextLabel
Move(7,329,168,21)
Font = Font["Bold,8"]
Text = ("SWAP memory used:")
Move(0,245,469,21)
}
{ ProgressBar4 ProgressBar
Move(7,350,259,21)
}
{ HPanel8 HPanel
Move(273,280,189,147)
{ Label85 Label
Move(0,0,189,21)
Font = Font["Bold,8"]
Expand = True
Padding = 4
Border = Border.Plain
}
{ Label86 Label
Move(0,21,189,21)
Font = Font["Bold,8"]
Expand = True
Padding = 4
Border = Border.Plain
}
{ Label87 Label
Move(0,42,189,21)
Font = Font["Bold,8"]
Expand = True
Padding = 4
Border = Border.Plain
}
{ Label88 Label
Move(0,63,189,21)
Font = Font["Bold,8"]
Expand = True
Padding = 4
Border = Border.Plain
}
{ Label89 Label
Move(0,84,189,21)
Font = Font["Bold,8"]
Expand = True
Padding = 4
Border = Border.Plain
}
{ Label90 Label
Move(0,105,189,21)
Font = Font["Bold,8"]
Expand = True
Padding = 4
Border = Border.Plain
}
{ Label91 Label
Move(0,126,189,21)
Font = Font["Bold,8"]
Expand = True
Padding = 4
Border = Border.Plain
}
{ ComboBox9 ComboBox
Move(14,147,168,28)
Text = ("ComboBox9")
}
Move(0,287,469,21)
}
{ TextLabel7 TextLabel
Move(140,280,77,21)
Move(0,224,469,21)
Font = Font["Bold,8"]
Text = ("N/A")
Alignment = Align.Center
}
{ TextLabel24 TextLabel
Move(147,329,119,21)
Move(0,266,469,21)
Font = Font["Bold,8"]
Text = ("N/A")
Alignment = Align.Center
}
{ Separator5 Separator
Move(0,266,469,14)
Move(0,217,469,14)
}
{ Frame2 Frame
Move(0,0,469,266)
Move(0,0,469,217)
Text = ("MTRR")
}
{ Label176 Label
Move(7,378,266,28)
Move(7,448,343,21)
Font = Font["Bold,8"]
Padding = 3
Text = ("Label176")
Border = Border.Plain
Border = Border.Raised
}
{ Button4 Button
Move(273,448,189,28)
Move(350,448,112,28)
Text = ("Decode DIMMS")
Picture = Picture["AppIcons/gtk-yes.png"]
}
{ ProgressBar6 ProgressBar
Move(0,329,469,21)
}
{ TextLabel15 TextLabel
Move(0,308,469,21)
Font = Font["Bold,8"]
Text = ("TextLabel15")
Alignment = Align.Center
}
{ Label85 Label
Move(7,357,189,21)
Font = Font["Bold,8"]
Expand = True
Padding = 3
Border = Border.Raised
}
{ Label86 Label
Move(7,378,189,21)
Font = Font["Bold,8"]
Expand = True
Padding = 3
Border = Border.Raised
}
{ Label87 Label
Move(7,399,189,21)
Font = Font["Bold,8"]
Expand = True
Padding = 3
Border = Border.Raised
}
{ Label88 Label
Move(7,420,189,21)
Font = Font["Bold,8"]
Expand = True
Padding = 3
Border = Border.Raised
}
{ Label89 Label
Move(196,357,189,21)
Font = Font["Bold,8"]
Expand = True
Padding = 3
Border = Border.Raised
}
{ Label90 Label
Move(196,378,189,21)
Font = Font["Bold,8"]
Expand = True
Padding = 3
Alignment = Align.Left
Border = Border.Raised
}
{ Label91 Label
Move(196,399,189,21)
Font = Font["Bold,8"]
Expand = True
Padding = 3
Border = Border.Raised
}
Index = 8
Text = ("Network")
Picture = Picture["AppIcons/Finfosys/network-wired.png"]
Expand Down

0 comments on commit 9dc677f

Please sign in to comment.