Introduction
This example Perl script uses op5 Monitor's HTTP API and LWP to create a host, add a service and save the committed configuration. The methods and techniques used in the example could easily be adapted to automatically create hosts from an Excel spreadsheet or inventory system.
Files
Description | File |
---|---|
Required Perl script | op5_monitor-create_example_host.pl |
Troubleshooting
Error | Fix |
Can't locate LWP/UserAgent.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at ./op5_monitor-create_example_host.pl line 11. BEGIN failed--compilation aborted at ./op5_monitor-create_example_host.pl line 11. |
sudo yum install perl-libwww-perl |
Can't locate JSON.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at ./op5_monitor-create_example_host.pl line 12. BEGIN failed--compilation aborted at ./op5_monitor-create_example_host.pl line 12. |
sudo yum install perl-JSON |
Creating example host in Monitor... 501 Protocol scheme 'https' is not supported (LWP::Protocol::https not installed) LWP will support https URLs if the LWP::Protocol::https module |
sudo yum install perl-LWP-Protocol-https |
Creating example host in Monitor... 500 Can't connect to 192.168.100.22:443 Can't connect to 192.168.100.22:443 |
In our instance, this was caused by invalid SSL certificate of OP5 Monitor. To bypass the certificate checks you can add:
Example: my $ua = LWP::UserAgent->new; |
Comments
0 comments
Please sign in to leave a comment.