Overview
System performance is often negatively impacted by having inadequate available memory. This is especially true when HDD virtual memory comes into play, or when poorly written software products don't properly release unused memory back to the system. Even older non-state of the art systems can often enjoy a performance boost when available system memory is increased either by adding ram or by using installed ram more efficiently.
Consequently, it is important to monitor memory usage, especially when poor system performance is encountered. The following perl app provides a simple visual method for monitoring memory usage via the brightness of fit-statUSB. The brighter fit-statUSB appears the higher the level of ram usage.
Examples
App Initialization : Maximum Brightness
Low Memory Usage: Dim fit-statUSB
Medium Memory Usage: Moderately Bright fit-statUSB
Perl App Listing
#!/usr/bin/perl -w
#
#fitletMemUse.pl
# Darryl Hassell 8/7/2018
use Tk;
use List::MoreUtils qw(first_index);
use Device::SerialPort;
use Time::HiRes ('sleep');
# Define & Initialize Variables
my $Mem_Use_Percent = 'Testing';
my $Mem_Used = 0;
my $Mem_Total = 1;
our $Mem_Use_BrightColor_Hex_fit = '#0000FF';
our $Mem_Use_BrightColor_Hex_screen = '#0000FF';
my $Bright_Dec_fit = 255;
my $Bright_Dec_scrren = 255;
my $Bright_Hex_fit = FF;
my $Bright_Hex_screen = FF;
# Configure Serial Port
my $port = Device::SerialPort -> new("/dev/ttyACM0");
$port -> baudrate(115200);
$port -> databits(8);
$port -> parity("none");
$port -> stopbits(1);
$port -> write_settings;
# Set Sleep Delay After Writes in Seconds
our $delay = 0.1;
# Initialize fit-statUSB to Max Brightness Red
$port -> write("#0000FF\n");
$port -> purge_rx;
# Create Main Window
$WinMain = MainWindow->new;
$WinMain -> resizable (0,0);
# Label Main Window
$myframe = $WinMain -> Frame ->pack();
$Mem_Use_Label = $myframe -> Label (-text => 'fitlet Memory Use Monitor'."\n"."$Mem_Use_Percent".' % ', -background => "$Mem_Use_BrightColor_Hex_screen", -foreground => "white", -font => "helvetica 9 bold")->pack(-ipadx => 20,-ipady => 20);
# Exit Program Button
$stopbutton = $myframe -> Button (-text => 'Exit', -command => \&Exit, -foreground => 'black', -background => 'lightblue');
$stopbutton -> pack (-side => 'bottom');
$WinMain -> repeat(2000, \&GetMemUse);
MainLoop();
################################ Exit Program ################################
sub Exit {
$port -> write("#000000\n");
$port -> purge_rx;
sleep($delay);
exit;
}
################################ Memory Usage Data ################################
sub GetMemUse {
$Mem_Use_Unfiltered1 = `free`;
# Read Unfiltered Memory Usage Data Into Array
@Mem_Use_Array1 = split ' ', $Mem_Use_Unfiltered1;
# Determine Array Index of String Mem:
my $ArrayIndexTotal1 = first_index { $_ eq 'Mem:' } @Mem_Use_Array1;
# Determine Array Index of Total Memory
my $ArrayIndexTotal2 = $ArrayIndexTotal1 + 1;
# Read Total Memory Out Of Array
$Mem_Total = $Mem_Use_Array1[$ArrayIndexTotal2];
# Determine Array Index of String buffers/cache:
my $ArrayIndexUsed1 = first_index { $_ eq 'buffers/cache:' } @Mem_Use_Array1;
# Determine Array Index of Memory Used
my $ArrayIndexUsed2 = $ArrayIndexUsed1 + 1;
# Read Memory Used Out Of Array
$Mem_Used = $Mem_Use_Array1[$ArrayIndexUsed2];
# Calculate Memory Usage Percentage Rounded to 1 Decimal Place
$Mem_Use_Percent = sprintf("%.1f",($Mem_Used/$Mem_Total)*100);
# Calculate Decimal fit-statUSB Brightness from 0 to 255
$Bright_Dec_fit = sprintf("%.0f",($Mem_Used/$Mem_Total)*255);
#Convert Decimal fit-statUSB Brightness to Hexidecimal
$Bright_Hex_fit = sprintf("%X", $Bright_Dec_fit);
# Generate fit-statUSB Color and Brightness Hex String
$Mem_Use_BrightColor_Hex_fit = '#'.'00'.'00'.$Bright_Hex_fit;
# Calculate Decimal Screen Window Brightness from 175 to 255
$Bright_Dec_screen = sprintf("%.0f",175 + ($Mem_Used/$Mem_Total)*80);
#Convert Decimal Screen Window Brightness to Hexidecimal
$Bright_Hex_screen = sprintf("%X", $Bright_Dec_screen);
# Generate fit-statUSB Color and Brightness Hex String
$Mem_Use_BrightColor_Hex_fit = '#'.'00'.'00'.$Bright_Hex_fit;
# Generate Screen Window Color and Brightness Hex String
$Mem_Use_BrightColor_Hex_screen = '#'.'00'.'00'.$Bright_Hex_screen;
# Send Color and Brightness to fit-statUSB
$port -> write("$Mem_Use_BrightColor_Hex_fit\n");
$port -> purge_rx;
# Prints of Values For Debugging
# print("$Bright_Dec\n");
# print("$Bright_Hex\n");
# print("$Mem_Use_BrightColor_Hex\n");
# print("\n");
$Mem_Use_Label -> configure (-text => 'fitlet Memory Use Monitor'."\n"."$Mem_Use_Percent".' % Used ', -background => "$Mem_Use_BrightColor_Hex_screen");
}
Conclusions
fit-statUSB provides a very usable visual indication of the memory usage of a system. fit-statUSB and its host fitlet RM system comprise a very versatile combination.
fit-statUSB: Perl App for Displaying Memory Usage
programmable multi-color LED that plugs into a USB port
-
- Posts: 106
- Joined: Mon May 28, 2012 12:25 pm
Jump to
- Announcements
- ↳ Read me first
- ↳ News
- ↳ Ordering
- Tensor-PC
- ↳ General Tensor-PC questions
- ↳ Tensor-PC Hardware
- ↳ Tensor-PC Software
- fitlet3
- ↳ General fitlet3 questions
- ↳ fitlet3 hardware
- ↳ fitlet3 software
- ↳ fitlet3 FACET Cards
- Airtop3
- ↳ General Airtop3 questions
- ↳ Airtop3 Hardware
- ↳ Airtop3 Software
- ↳ Airtop3 I3M
- fitlet2 and MBM2
- ↳ General fitlet2 questions
- ↳ fitlet2 hardware
- ↳ fitlet2 software
- ↳ fitlet2 FACET Cards
- ↳ Cool stuff with fitlet2
- Airtop2
- ↳ General Airtop2 questions
- ↳ Airtop2 Software
- ↳ Airtop2 Hardware
- ↳ Airtop2 I3M
- Mature products
- ↳ Airtop
- ↳ General Airtop questions
- ↳ I3M
- ↳ IPC2 (Intense PC2)
- ↳ General IPC2 questions
- ↳ IPC2 availability
- ↳ IPC2 Hardware
- ↳ Linux on IPC2
- ↳ Windows on IPC2
- ↳ Other operating systems on IPC2
- ↳ IPC2 BIOS
- ↳ IPC2 faults and troubleshooting
- ↳ Intense PC and MintBox 2
- ↳ General Intense PC questions
- ↳ Intense PC hardware
- ↳ CPU & Chipset
- ↳ Display interface
- ↳ Memory
- ↳ Storage
- ↳ Ethernet
- ↳ WLAN and miniPCI-e
- ↳ Audio
- ↳ USB
- ↳ Power and heat
- ↳ Linux on Intense PC
- ↳ Linux Mint
- ↳ Other distributions
- ↳ Windows on Intense PC
- ↳ Win7 on Intense PC
- ↳ Win8 on Intense PC
- ↳ Audio
- ↳ Intense PC BIOS
- ↳ Android on Intense PC
- ↳ Intense PC faults and troubleshooting
- ↳ fitlet and MintBox Mini
- ↳ General fitlet questions
- ↳ fitlet performance
- ↳ fitlet hardware
- ↳ Memory
- ↳ Storage
- ↳ Power and heat
- ↳ Mechanical
- ↳ fitlet BIOS
- ↳ Linux on MintBox Mini / Linux on fitlet
- ↳ Windows on fitlet
- ↳ Other operating systems on fitlet
- ↳ FACET Cards
- ↳ fitlet compatible devices
- ↳ Cool stuff with fitlet
- ↳ fitlet faults and troubleshooting
- ↳ fit-PC4
- ↳ General fit-PC4 questions
- ↳ fit-PC4 hardware
- ↳ Windows on fit-PC4
- ↳ Linux on fit-PC4
- ↳ Other operating systems on fit-PC4
- ↳ fit-PC4 BIOS
- ↳ fit-PC4 faults and troubleshooting
- ↳ fit-PC3
- ↳ General fit-PC3 questions
- ↳ fit-PC3 hardware
- ↳ Display interface
- ↳ Storage
- ↳ Audio
- ↳ WLAN and miniPCI-e
- ↳ USB
- ↳ Power and Heat
- ↳ Ethernet
- ↳ Windows on fit-PC3
- ↳ Linux on fit-PC3
- ↳ Other operating systems on fit-PC3
- ↳ fit-PC3 BIOS
- ↳ fit-PC3 accessories
- ↳ Using fit-PC3
- ↳ fit-PC3 faults and troubleshooting
- ↳ fit-PC2
- ↳ General fit-PC2 questions
- ↳ Buying fit-PC2
- ↳ Linux on fit-PC2
- ↳ Linux Mint
- ↳ Ubuntu 9.10
- ↳ Ubuntu 10.04
- ↳ Ubuntu 10.10
- ↳ Ubuntu 11.04
- ↳ Other Linux distributions
- ↳ Ubuntu 8.04
- ↳ Ubuntu 9.04
- ↳ Display driver
- ↳ Multimedia in Linux
- ↳ Multimedia in Mint
- ↳ Windows on fit-PC2
- ↳ Windows 7
- ↳ Windows 7 display driver
- ↳ Audio in Win7
- ↳ Windows XP
- ↳ XP installation
- ↳ Display driver
- ↳ Video playback
- ↳ Audio in XP
- ↳ Other Windows versions
- ↳ Other operating systems on fit-PC2
- ↳ FreeBSD
- ↳ fit-PC2 hardware
- ↳ fit-PC2i hardware
- ↳ Display interface
- ↳ Storage
- ↳ Audio
- ↳ WLAN and miniPCI-e
- ↳ USB
- ↳ Auto-ON
- ↳ Power and Heat
- ↳ Ethernet
- ↳ RTC & System clock
- ↳ fit-PC2 BIOS
- ↳ BIOS updates fit-PC2
- ↳ BIOS updates fit-PC2i
- ↳ fit-PC2 accessories
- ↳ Using fit-PC2
- ↳ HTPC
- ↳ Server
- ↳ Control
- ↳ Verified displays
- ↳ Car PC
- ↳ fit-PC1 questions
- ↳ fit-PC Slim questions
- ↳ uSVR
- ↳ General uSVR questions
- ↳ IPC3
- ↳ General IPC3 questions
- ↳ IPC3 Software
- ↳ IPC3 Hardware
- ↳ FACE modules
- ↳ FACE Modules
- ↳ General FACE Module questions
- Compulab accessories
- ↳ fit-Headless and fit-Headless 4K
- ↳ fit-Uptime
- ↳ fit-statUSB
- ECN/PCN
- ↳ fitlet3 ECN/PCN
- ↳ Tensor-I20 ECN/PCN
- ↳ Tensor-I22 ECN/PCN
- ↳ fitlet2 ECN/PCN
- ↳ Airtop3 ECN/PCN
- ↳ IPC3 ECN
- ↳ fitlet1 ECN
- ↳ IPC2 ECN
- ↳ IPC1 ECN
- ↳ Airtop2 ECN
- ↳ Airtop1 ECN
- ↳ fit-PC4 ECN
- ↳ fit-PC3 ECN
- ↳ fit-PC2 ECN
- ↳ FACE Modules ECN
- ↳ FACET Cards ECN
- Wish list
- ↳ Addressed requests