×
Back to OP5 Monitor FAQ
How to add a host and service using a perl script
Introduction Copied
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 Copied
| Description | File |
|---|---|
| Required Perl script | op5_monitor-create_example_host.pl |
Troubleshooting Copied
| 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) Content-Type: text/plain Client-Date: Wed, 03 Aug 2022 04:21:28 GMT Client-Warning: Internal response LWP will support https URLs if the LWP::Protocol::https module is installed. | sudo yum install perl-LWP-Protocol-https |
| Creating example host in Monitor… 500 Can’t connect to 192.168.100.22:443 Content-Type: text/plain Client-Date: Wed, 03 Aug 2022 04:40:53 GMT Client-Warning: Internal response Can’t connect to 192.168.100.22:443 | In our instance, this was caused by an invalid SSL certificate in OP5 Monitor. To bypass the certificate checks you can add: $ua->ssl_opts(verify_hostname => 0); Example: my $ua = LWP::UserAgent->new; $ua->ssl_opts(verify_hostname => 0); my $json = new JSON; |
Related downloads Copied
["Geneos"]
["FAQ"]