package App::smsg::Command::Status; use 5.010; use strict; use warnings; use utf8; BEGIN { $App::smsg::Command::Status::AUTHORITY = 'https://dr.jones.dk/me#me'; $App::smsg::Command::Status::VERSION = '0.001'; } use App::smsg -command; use namespace::clean; use NetSDS::Kannel; use constant abstract => q (Check status of platform(s).); use constant usage_desc => '%c status %o ...'; use constant description => <<'DESCRIPTION'; Connect to one or more platforms (Kannel, Jabber, IRC etc.) and check operational status. DESCRIPTION use constant opt_spec => ( ['kannelserver=s', "the Kannel server to connect to", {default => 'localhost'}], ['kanneladminport=i', "the Kannel admin port to connect to", {default => 13000}], ['kanneladminpasswd=s', "the Kannel admin password to authenticate with", {default => ''}], ['kannelsendsmsport=i', "the Kannel sendsms port to connect to", {default => 13013}], ['kannelsendsmsuser=s', "the Kannel sendsms user to authenticate as", {default => 'tester'}], ['kannelsendsmspasswd=s', "the Kannel sendsms password to authenticate with", {default => 'foobar'}], ['kannelsmsc=s', "the Kannel SMSC to correspond with"], [], # TODO ['f|follow', "keep connection open and emit each change of state"], # [], # [ 'verbose|v', "print extra stuff"], [ 'debug', "print debug stuff"], ); sub execute { my ($self, $opt, $args) = @_; # TODO: support overriding full URL # TODO: use URI module to construct URL my $kannel = NetSDS::Kannel->new( admin_url => 'http://' . $opt->kannelserver . ':' . $opt->kanneladminport . '/', admin_passwd => $opt->kanneladminpasswd, sendsms_url => 'http://' . $opt->kannelserver . ':' . $opt->kannelsendsmsport . '/cgi-bin/sendsms', sendsms_user => $opt->kannelsendsmsuser, sendsms_passwd => $opt->kannelsendsmspasswd, default_smsc => $opt->kannelsmsc, ); my $status = $kannel->status(); print $$status{status}."\n"; for my $i ( 0 .. $#{ $$status{smsc} }) { print $$status{smsc}[$i]{id}.': '.$$status{smsc}[$i]{status}."\n"; } } 1;