NAME
Net::Connection::FreeBSD_sockstat - Creates Net::Connection objects using sockstat on FreeBSD.
VERSION
Version 1.0.0
SYNOPSIS
use Net::Connection::FreeBSD_sockstat;
my @objects;
eval{ @objects=&sockstat_to_nc_objects; };
# this time don't resolve ports, ptrs, or usernames
my $args={
ports=>0,
ptrs=>0,
};
eval{ @objects=&sockstat_to_nc_objects( $args )); };
REQUIREMENTS
This parses the JSON emitted by 'sockstat -46s --libxo json'.
libxo support was added to sockstat in FreeBSD 15.0. Earlier releases ship a sockstat that does not understand '--libxo' and will exit with a usage error.
Process information is gathered by calling ps instead of reading the process table directly, so nothing outside of the base system is needed for that.
Worth noting for anyone coming from 0.0.x, which used Proc::ProcessTable, is that ps appends the accounting name in parentheses when a proc has rewritten its argv, so proc for those reads like the first of the two below instead of the second.
MUSHclient.exe (wine)
MUSHclient.exe
SUBROUTINES
sockstat_to_nc_objects
This parses the output of 'sockstat -46s --libxo json'.
Upon error, this will die.
args hash
ports
Attempt to resolve the port names.
Defaults to 1.
This value is a Perl boolean.
ptrs
Attempt to resolve the PTRs.
Defaults to 1.
This value is a Perl boolean.
proc_info
Call ps and use that to fill in additional info.
This is incompatible with the string option.
This defaults to true if no string is specified.
This value is a Perl boolean.
string
If this is specified, it parses the string instead of calling sockstat.
The string is expected to be the JSON produced by 'sockstat -46s --libxo json'.
If running this on anything other than FreeBSD with out passing this, it will die.
zombie_skip
This skips sockets that are not associated with any process.
These are the sockets that print as the line below with the standard text output, the JSON for them lacking the user, command, pid, and fd keys.
USER COMMAND PID FD PROTO LOCAL ADDRESS FOREIGN ADDRESS PATH STATE CONN STATE
? ? ? ? tcp6 ::1:4045 *:* LISTEN
When these are not skipped, the resulting objects have a username of ? with the PID and UID left undefined, as Net::Connection requires those two to be numeric when they are defined.
This defaults to 1.
The value taken is a Perl boolean.
AUTHOR
Zane C. Bowers-Hadley, <vvelox at vvelox.net>
BUGS
Please report any bugs or feature requests to bug-net-connection-freebsd_sockstat at rt.cpan.org, or through the web interface at https://rt.cpan.org/NoAuth/ReportBug.html?Queue=Net-Connection-FreeBSD_sockstat. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
SUPPORT
You can find documentation for this module with the perldoc command.
perldoc Net::Connection::FreeBSD_sockstat
You can also look for information at:
RT: CPAN's request tracker (report bugs here)
https://rt.cpan.org/NoAuth/Bugs.html?Dist=Net-Connection-FreeBSD_sockstat
CPAN Ratings
https://cpanratings.perl.org/d/Net-Connection-FreeBSD_sockstat
Search CPAN
https://metacpan.org/release/Net-Connection-FreeBSD_sockstat
Git Repo
https://gitea.eesdp.org/vvelox/Net-Connection-FreeBSD_sockstat
ACKNOWLEDGEMENTS
LICENSE AND COPYRIGHT
This software is Copyright (c) 2021 by Zane C. Bowers-Hadley.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)