Agent-TCLI-Package-Net
view release on metacpan or search on metacpan
bin/agent_net.pl view on Meta::CPAN
=item B<domain>
The XMPP domain of the user account of the Agent.
Required unless the script has been edited to enable a default domain.
=item B<resource>
The XMPP resource. Defaults to 'tcli' if not provided.
=item B<host>
The XMPP server host, if different from the domain. Defaults to the
domain if not provided.
=item B<verbose>
The desired level of verbosity to use. Repeat for more effect.
=item B<help>
Print a brief help message and exit.
=item B<man>
Print this command's manual page and exit.
=back
=head1 DESCRIPTION
B<agent_net> will start a TCLI Agent running on the XMPP Transport
with the Net, Tail and XMPP packages loaded.
Use B<agent_net> as is or as the basis for creating Agents with different
functionaity.
=head1 SEE ALSO
L<Agent::TCLI>
L<Agent::TCLI::Package::Net>
=head1 AUTHOR
Eric Hacker E<lt>hacker at cpan.orgE<gt>
=head1 LICENSE
Copyright (c) 2007, Alcatel Lucent, All rights resevred.
This script is free software; you may redistribute it
and/or modify it under the same terms as Perl itself.
=cut
# Useful for debugging or just seeing what the Agent is doing.
sub VERBOSE () { 0 }
# Process optional parameters from the command line and assign defaults.
use Getopt::Lucid qw(:all);
my ($opt, $verbose,$domain,$username,$password,$resource,$host);
eval {$opt = Getopt::Lucid->getopt([
Param("domain|d"),
Param("username|u"),
Param("password|p"),
Param("resource|r"),
Param("host"),
Param("master|m"),
Counter("verbose|v"),
Switch("help"),
Switch("man"),
Switch("blib|b"),
])};
if($@)
{
print "ERROR: $@ \n";
pod2usage(1);
}
pod2usage(1) if ($opt->get_help);
pod2usage(VERBOSE => 2) if ($opt->get_man);
# Hidden switch for dev testing
if ($opt->get_blib)
{
use lib 'blib/lib';
}
$verbose = $opt->get_verbose ? $opt->get_verbose : VERBOSE;
# Optionally set default jabber/xmpp parameters to log in with
$username = $opt->get_username ? $opt->get_username : 'agent';
$password = $opt->get_password ? $opt->get_password : 'agent';
$resource = $opt->get_resource ? $opt->get_resource : 'tcli';
$domain = $opt->get_domain ? $opt->get_domain : 'example.com';
$host = $opt->get_host ? $opt->get_host : $domain;
# Error if options not set and not provided.
pod2usage(1) if ($username eq 'agent' or $domain eq 'example.com');
# Load required modules
use POE; # POE is required for all Agents
use Agent::TCLI::User; # TCLI users will have to be defined for each Agent
use Agent::TCLI::Transport::XMPP; # A TCLI transport
use Net::XMPP::JID; # Required for XMPP transport
# Optional Packages, without some, a bot is useless
use Agent::TCLI::Package::XMPP; # Not required, but very useful to manage Transport::XMPP
# especially if you want a graceful shutdown. :)
use Agent::TCLI::Package::Net::SMTP;
use Agent::TCLI::Package::Net::HTTP;
use Agent::TCLI::Package::Net::HTTPD;
use Agent::TCLI::Package::Net::Ping;
use Agent::TCLI::Package::Net::Traceroute;
use Agent::TCLI::Package::Tail;
# An alias is mostly useful when debugging, and must be unique within
( run in 0.443 second using v1.01-cache-2.11-cpan-39bf76dae61 )