Hoping for some Perl experts here - ms teams plugin

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Post Reply
travisjburrell
Posts: 14
Joined: Thu Sep 24, 2020 12:36 pm

Hoping for some Perl experts here - ms teams plugin

Post by travisjburrell »

We are migrating to a new server (CentOS 7 > RHEL 8), and I'm trying to get this plugin working on the new instance. The configuration is the same - restored from backup. Both are on the same network, behind the same proxy. The CentOS 7 server can send notifications just fine, but copying the command & running on the RHEL 8 instance produces an error. I'm thinking it's something to do with the Perl env, but I'm not sure. CentOS 7 instance is running 5.8.4; RHEL instance is running 5.9.3.

Command

Code: Select all

export https_proxy=http://proxy01.<domain>:3128 NAGIOS_HOSTALIAS="TESTHOST01" NAGIOS_SERVICEDESC="http" NAGIOS_SERVICESTATE="WARNING" NAGIOS_SERVICEOUTPUT="test output" && /usr/local/nagios/libexec/nagios-msteams.pl --webhook "https://<webhookURL>" --nagios_url "https://nagios.<domain>"

CentOS 7 instance (working)

Perl modules:

Code: Select all

Installed modules are:
   App::cpanminus
   Archive::Zip
   B::COW
   CPAN::Meta
   CPAN::Meta::Requirements
   CPAN::Meta::YAML
   Capture::Tiny
   Clone
   Compress::Raw::Zlib
   Crypt::OpenSSL::RSA
   Devel::CheckLib
   Encode
   ExtUtils::CBuilder
   ExtUtils::Config
   ExtUtils::Helpers
   ExtUtils::InstallPaths
   File::Listing
   HTTP::Cookies
   HTTP::Daemon
   HTTP::Date
   HTTP::Message
   HTTP::Negotiate
   IO::Socket::IP
   IPC::Cmd
   JSON
   JSON::PP
   LWP
   LWP::MediaTypes
   LWP::Protocol::https
   Locale::Maketext::Simple
   Mock::Config
   Module::Build
   Module::Build::Tiny
   Module::CoreList
   Module::Load
   Module::Load::Conditional
   Module::Metadata
   Net::HTTP
   Net::INET6Glue
   Params::Check
   Path::Class
   Perl
   Perl::OSType
   Test::Fatal
   Test::Harness
   Test::More::UTF8
   Test::Needs
   Test::RequiresInternet
   Test::Warnings
   Text::Template
   Time::Local
   Time::Piece
   Try::Tiny
   UUID
   WWW::RobotRules
   libwww::perl
   version
Command output:

Code: Select all

Response:
HTTP/1.1 200 OK
RHEL 8 instance (not working):

Perl modules:

Code: Select all

Installed modules are:
   App::cpanminus
   B::COW
   B::Hooks::EndOfScope
   Bytes::Random::Secure
   CPAN::Meta::Check
   Canary::Stability
   Capture::Tiny
   Class::Accessor
   Class::Data::Inheritable
   Class::Inspector
   Class::Singleton
   Class::Tiny
   Clone
   Config::Tiny
   Crypt::Random::Seed
   Crypt::Random::TESHA2
   Crypt::SSLeay
   DateTime
   DateTime::Locale
   DateTime::TimeZone
   Devel::CheckLib
   Devel::StackTrace
   Dist::CheckConflicts
   Encode
   Eval::Closure
   Exception::Class
   File::Copy::Recursive
   File::ShareDir
   File::ShareDir::Install
   File::Slurper
   HTTP::Message
   IO::Compress::Brotli
   IO::Socket::INET6
   IPC::Run3
   Importer
   JSON
   JSON::XS
   LWP::Protocol::https
   Math::Calc::Units
   Math::Random::ISAAC
   Mock::Config
   Module::Build
   Module::Implementation
   Module::Pluggable
   Module::Runtime
   Mozilla::CA
   Nagios::Monitoring::Plugin
   Net::INET6Glue
   Package::Stash
   Package::Stash::XS
   Params::Validate
   Params::ValidationCompiler
   Path::Class
   Path::Tiny
   Perl
   PerlIO::utf8_strict
   Role::Tiny
   Scope::Guard
   Socket6
   Specio
   Spiffy
   Sub::Exporter::Progressive
   Sub::Identify
   Sub::Info
   Sub::Quote
   Sub::Uplevel
   Term::Table
   Test2::Plugin::NoWarnings
   Test2::Suite
   Test::Base
   Test::Deep
   Test::Exception
   Test::Fatal
   Test::File
   Test::File::ShareDir
   Test::Needs
   Test::NoWarnings
   Test::Requires
   Test::RequiresInternet
   Test::Simple
   Test::Warnings
   Test::Without::Module
   Test::YAML
   Time::Piece
   Types::Serialiser
   UUID
   Variable::Magic
   XString
   YAML
   common::sense
   namespace::autoclean
   namespace::clean
Command output:

Code: Select all

Response:
500 Can't connect to *.webhook.office.com:443 (Network is unreachable)
Content-Type: text/plain
Client-Date: Fri, 05 May 2023 13:09:01 GMT
Client-Warning: Internal response

Can't connect to *.webhook.office.com:443 (Network is unreachable)

Network is unreachable at /usr/share/perl5/vendor_perl/LWP/Protocol/http.pm line 50.
It looks like the code block that's giving this error is:

Code: Select all

    unless ($sock) {
        # IO::Socket::INET leaves additional error messages in $@
        my $status = "Can't connect to $host:$port";
        if ($@ =~ /\bconnect: (.*)/ ||
            $@ =~ /\b(Bad hostname)\b/ ||
            $@ =~ /\b(nodename nor servname provided, or not known)\b/ ||
            $@ =~ /\b(certificate verify failed)\b/ ||
            $@ =~ /\b(Crypt-SSLeay can't verify hostnames)\b/
        ) {     
            $status .= " ($1)";
        } elsif ($@) {
            $status .= " ($@)";
        }       
        die "$status\n\n$@";
    }
travisjburrell
Posts: 14
Joined: Thu Sep 24, 2020 12:36 pm

Re: Hoping for some Perl experts here - ms teams plugin

Post by travisjburrell »

Oh, editing to add; I can:
  • cURL the webhook URL from the RHEL 8 instance ok (I get payload errors, but it is reachable)
  • use this Python MS Teams plugin on the RHEL 8 instance without issue
Post Reply