Sha256: 49e7189fe97218b8ae014f9d060bc410790f2b9e85bc4cf47dc062202b424a78
Contents?: true
Size: 1.47 KB
Versions: 3
Compression:
Stored size: 1.47 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 StandardError => err critical "Failed to connect to XMPP server: #{err.message}" end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
sensu-plugins-xmpp-3.0.0 | bin/check-xmpp-login.rb |
sensu-plugins-xmpp-2.0.0 | bin/check-xmpp-login.rb |
sensu-plugins-xmpp-1.0.1 | bin/check-xmpp-login.rb |