#!/usr/bin/perl use strict; use warnings; use IO::Socket; use Sys::CpuLoad; my $remote_host = '192.168.56.102'; my $remote_port = 2003; # create Socket my $socket = IO::Socket::INET -> new(PeerAddr => $remote_host, PeerPort => $remote_port, Proto => "tcp", Type => SOCK_STREAM) or die "Couldn't connect to $remote_host:$remote_port: $@ \n"; while() { my @lavg = Sys::CpuLoad::load(); my $ts=time(); print $socket "system.loadavg_1min $lavg[0] $ts\n"; print $socket "system.loadavg_5min $lavg[1] $ts\n"; print $socket "system.loadavg_15min $lavg[2] $ts\n"; sleep(60); } close($socket);