3.13. sysstat

3.13.1. NAME

sysstat - Guardian Digital WebTool module interface to system information and statistics.

3.13.2. SYNOPSIS

use sysstat;
my $sysstat  = new sysstat();

3.13.3. DESCRIPTION

This Guardian Digital WebTool module provides an interface for retrieving general system information and statistics. This module allows you to gather information such as memory, swap, network, and disk usage, RAID status (if available), SELinux status, process counts and lists, CPU temperature (if available), and system uptime.

This module is named "sysstat" instead of "index" because index is a perl reserved word.

3.13.4. METHODS

memstats()

This function should never be called directly. It is useful to get current memory statistics from /proc/memstats. It returns hash reference containing all parameters as key-value pairs.

Example Usage:

$memref = memstats();

load_avg()

This function should never be called directly. It returns 3 member array of load average numbers from /proc/loadavg.

Example Usage:

@loadavg = load_avg();

diskstats()

This function should never be called directly. It is used to get disk statistics in human readable form(/bin/df). Result parameters are returned in hash reference. see example for parameters(hash) details.

Example Usage:

my $diskref = diskstats();

$fs            = $diskref->{$filesystem}->{'filesystem'};
$fstype        = $diskref->{$filesystem}->{'type'};
$fssize        = $diskref->{$filesystem}->{'size'};
$fsused        = $diskref->{$filesystem}->{'used'};
$fsavail       = $diskref->{$filesystem}->{'avail'};
$fsusedpercent = $diskref->{$filesystem}->{'usedpercent'};
$fsmountpoint  = $diskref->{$filesystem}->{'mountpoint'};

interfaces_list()

This function should never be called directly. It is used to get interfaces details from /etc/network/interfaces file. Depending on the interface type(lo,eth0,eth1 etc) it parses information like interface, protocol, type, virtual parent, address, net mask etc. Hash reference is return as result.

Example Usage:

$interfaces = interfaces_list();

count_processes()

This function returns a count for number of processes running (/proc).

Example Usage:

$count = $sysstat->count_processes();

uptime()

This function returns current system uptime(/proc/stat).

Example Usage:

$uptime = $sysstat->uptime();

print_load_avg()

This function returns 3 member array of load avg numbers as comma separated values.

Example Usage:

$comma_separated = $sysstat->print_load_avg();

mem_usage()

This function calculates and returns percentage(%) of memory used. It also shows memory used in MB out of total MB.

Example Usage:

$mempercent = $sysstat->mem_usage();

swap_usage()

This function calculates and returns percentage(%) of swap memory used.It also shows memory used in MB out of total MB.

Example Usage:

$swappercent = sysstat->swap_usage();

disk_usage()

This function returns disk usage(size, used, available, used percent, mount point) in table format.

Example Usage:

$disk_usage_table = sysstat->disk_usage();

network_usage()

This function returns network usage(interface statistics: link, address, currentin, currentout, total)in table format.

Example Usage:

$network_usage_table = $sysstat->network_usage();

read_mrtg($)

This function retrieves the daily, weekly, monthly and yearly MRTG data for the given argument (cpu, ram etc). Hash reference is returned as a result.

Example Usage:

$usage = $sysstat->read_mrtg("cpu");

hostname()

This function is used to get hostname of the system.

Example Usage:

$name_of_host = $sysstat->hostname();

raid_status()

This function is used to get status of RAID. Currently it returns value "Optimal" by default.

Example Usage:

$r_status = $sysstat->raid_status();

shell_users()

This function is used to get list of current shell users. It returns hash reference containing information like tty,user,date and host. see example.

Example Usage:

my $users = $sysstat->shell_users();
$user = $users->{'tty0'}->{user};
$date = $users->{'tty0'}->{date};
$host = $users->{'tty0'}->{host};

selinux_status()

This function is used to get current status of SElinux. First it checks if its disabled entirely or not, and then it returns current mode(permissive or enforcing).

Example Usage:

$current_status = $sysstat->selinux_status();

kernel_ver()

This function is used to get version of kernel.

Example Usage:

$kernel_version = $sysstat->kernel_ver();

engarde_ver()

This function is used to get version of engarde linux.

Example Usage:

$engarde_version = $sysstat->engarde_ver();

cputemp()

This function is used to get cpu's current temperature in ferenheit.

Example Usage:

my $temp = $sysstat->cputemp();

list_processes($)

This function can be used to list current processes running in desired order. sort order(mem,cpu or user) is passed as an argument. All information is returned in array of hash references.

Example Usage:

@proc = $sysstat->list_processes('cpu');

dmesg()

This function is used to get last 10 lines(default) from the system log in array format.

Example Usage:

@loglines = $sysstat->dmesg();

webtool_audit()

This function is used to get last 10 lines(default) from the webtool audit log in array format.

Example Usage:

@webtoollog = $sysstat->webtool_audit();

update_news()

This function is used to update gdsn news file if its older than 12 hours. If error occurs during this operation then it returns to the calling function.

Example Usage:

$err = $sysstat->update_news();

3.13.5. AUTHORS

Pax Dickinson <pax@guardiandigital.com>

3.13.6. COPYRIGHT AND LICENSE

Copyright Guardian Digital, Inc., All Rights Reserved