in reply to Networking Perl

This is a possible way. Just put this script on each box and run it with starman or plackup and you have an instant, on demand JSON report of the box. I added pid filtering as a *minimal* API proof of concept. I also did pretty printing on the JSON for the benefit of playing around which I wouldn't do in production.

cow@moo[1316]~/bin>plackup proc.psgi HTTP::Server::PSGI: Accepting connections at http://0:5000/ ...

Then you can ask for the full process data at http://localhost:5000/ and filter by pid with http://localhost:5000/123,9876,4433 and such like. As given, the code is *too* free and easy with the arg parsing.

You might not want to publish the stuff so openly. You could *easily* add a "security" layer with Plack::Middleware::Auth::Basic. And I'd recommend a whitelist/filter of the processes you'd like to show.

use warnings; use strict; use JSON; use Plack::Request; use Proc::ProcessTable; sub { my $req = Plack::Request->new(+shift); my %pids = map { $_ => 1 } $req->path =~ /(\d+)/g; my $procs = Proc::ProcessTable->new; my $json = JSON->new; my %status; for my $proc ( @{ $procs->table } ) { next if scalar(%pids) and not $pids{$proc->pid}; for my $field ( $procs->fields ) { $status{$proc->pid}{$field} = $proc->$field; } } return [ 200, [ "Content-Type" => "application/json" ], [ $json->pretty->encode(\%status) ] ]; };