Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- has zapilogin=> sub{
- my $self = shift;
- my $zserver = shift || "";
- my $zserverUrl = "http://$zserver. $self->stash->{config}->{zabbix}->{domain}/api_jsonrpc.php";
- my $zabapi = Zabapi->new(server => $zserverUrl, verbosity => '0');
- my $zabbixAuth = { user => $self->stash->{config}->{zabbix}->{username}, password => $self->stash->{config}->{zabbix}->{password}};
- eval {
- my $res =$zabapi->login($zabbixAuth);
- say $res;
- };
- if ($@) {
- $self->render(json => {"error"=>"$@" });
- return 0;
- }
- else
- {
- if (defined $zabapi->{cookie}) {
- return $zabapi;
- }
- else {
- return '-1';
- }
- }
- };
- sub startup {
- ......
- $self->helper('zapilogin' => sub { return shift->app->zapilogin });
- ......
- }
- sub test{
- my $self = shift;
- my $zabapi=$self->zapilogin($self->session('zserver'));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement