#!/usr/bin/perl

use strict;

# Determine if the machine is busy.
my $result = `pgrep -c larvnet-wrapper`;
my $busy = ($result > 0) ? 1 : 0;

# Collect some basic information about the machine.
my $hostname = `hostname --fqdn`;
my $arch = `machtype -c`;
chomp $hostname;
chomp $arch;

# Read the packet.
my $addr = recv(STDIN, my $dummy, 1, 0);

# Reply with the status packet.
my $msg = $busy . $hostname . "\0" . $arch . "\0";
send(STDOUT, $msg, 0, $addr);
