RPi::SysInfo - Retrieve hardware system information from a Raspberry Pi
Fetch live-time and other system information from a Raspberry Pi.
Most functions will work equally as well on Unix/Linux systems.
# Object Oriented use RPi::SysInfo; my $sys = RPi::SysInfo->new; say $sys->cpu_percent; say $sys->mem_percent; say $sys->core_temp; # Functional use RPi::SysInfo qw(:all); say cpu_percent(); say mem_percent(); say core_temp();
Functions are not exported by default. You can load them each by name:
cpu_percent mem_percent core_temp gpio_info raspi_config network_info file_system pi_details
...or use the :all tag to bring them all in at once.
:all
Instantiates and returns a new RPi::SysInfo object.
Takes no parameters.
Returns the percentage of current CPU usage.
Return: Two decimal floating point number.
Returns the percentage of physical RAM currently in use.
Returns the core CPU temperature of the system.
Parameters:
$scale
Optional, String: By default we return the temperature in Celcius. Simply send in the letter f to get the result returned in Fahrenheit.
f
Return: Two decimal place floating point number.
Fetches the current configuration and status of one or many GPIO pins.
$pins
Optional, Aref of Integers: By default, we'll return the information for all GPIO pins on the system. Send in an aref of pin numbers and well fetch the data for only those pins (eg: gpio_info[1] or gpio_info([2, 4, 6, 8])).
gpio_info[1]
gpio_info([2, 4, 6, 8])
Return: Single string containing all of the data requested.
Feteches the directive names and values the Pi is configured with.
Return: String, the contents of the current configuration.
Fetches and returns various file system information as a string.
Fetches and returns the Pi's network configuration details as a string.
Fetches and returns various information about the Pi, including the OS info, along with several hardware platform details as a string.
Formats a float/double value to two decimal places.
$float
Mandatory, Float/Double: The number to format.
Steve Bertrand, <steveb at cpan.org>
<steveb at cpan.org>
Copyright 2019 Steve Bertrand.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.
To install RPi::SysInfo, copy and paste the appropriate command in to your terminal.
cpanm
cpanm RPi::SysInfo
CPAN shell
perl -MCPAN -e shell install RPi::SysInfo
For more information on module installation, please visit the detailed CPAN module installation guide.