Sha256: c1ebd6dda6fbe8a03d3f0f3814fd4179b5de3d2da5f36e5bd951a60a589f1800
Contents?: true
Size: 1.5 KB
Versions: 1
Compression:
Stored size: 1.5 KB
Contents
#!/usr/bin/env ruby # # check-xmpp-login # # DESCRIPTION: # Attempt to login to a XMPP server with provided credentials. # # OUTPUT: # plain text # # PLATFORMS: # Linux # # DEPENDENCIES: # gem: sensu-plugin # gem: xmpp4r # # USAGE: # check-xmpp-login.rb -j jid -P pass # # NOTES: # # LICENSE: # Released under the same terms as Sensu (the MIT license); see LICENSE # for details. # require 'sensu-plugin/check/cli' require 'xmpp4r/client' class CheckXmppLogin < Sensu::Plugin::Check::CLI option :host, short: '-h HOST', long: '--host HOST', description: 'Host to login to', default: '127.0.0.1' option :port, short: '-p PORT', long: '--port PORT', description: 'Server port', default: 5222 option :jid, short: '-j JID', long: '--jid JID', description: 'JID used to login', required: true option :password, short: '-P PASSWORD', long: '--password PASSWORD', description: 'Password used to login', required: true def run jid = Jabber::JID.new(config[:jid]) cli = Jabber::Client.new(jid) cli.connect(config[:host], config[:port]) cli.auth(config[:password]) cli.close ok "Logged in as #{config[:jid]}" rescue Jabber::ClientAuthenticationFailure warning 'Login failed: Invalid jid or password' rescue Exception => err # rubocop:disable RescueException critical "Failed to connect to XMPP server: #{err.message}" end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sensu-plugins-xmpp-1.0.0 | bin/check-xmpp-login.rb |