NAME
RPi::SysInfo - Retrieve hardware system information from a Raspberry Pi
DESCRIPTION
Fetch live-time and other system information from a Raspberry Pi.
Most functions will work equally as well on Unix/Linux systems.
SYNOPSIS
# 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();
EXPORT_OK
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.
FUNCTIONS/METHODS
new
Instantiates and returns a new RPi::SysInfo object.
Takes no parameters.
cpu_percent
Returns the percentage of current CPU usage.
Takes no parameters.
Return: Two decimal floating point number.
mem_percent
Returns the percentage of physical RAM currently in use.
Takes no parameters.
Return: Two decimal floating point number.
core_temp($scale)
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.
Return: Two decimal place floating point number.
gpio_info([$pins])
Fetches the current configuration and status of one or many GPIO pins.
Parameters:
$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])
).
Return: Single string containing all of the data requested.
raspi_config
Feteches the directive names and values the Pi is configured with.
Takes no parameters.
Return: String, the contents of the current configuration.
file_system
Fetches and returns various file system information as a string.
network_info
Fetches and returns the Pi's network configuration details as a string.
pi_details
Fetches and returns various information about the Pi, including the OS info, along with several hardware platform details as a string.
PRIVATE FUNCTIONS/METHODS
_format($float)
Formats a float/double value to two decimal places.
Parameters:
$float
Mandatory, Float/Double: The number to format.
AUTHOR
Steve Bertrand, <steveb at cpan.org>
LICENSE AND COPYRIGHT
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.