/usr/lib/python2.7/dist-packages/gplugs/probe.py is in gozerbot 0.99.1-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | # plugs/probe.py
#
#
""" check if host:port is open """
__copyright__ = 'this file is in the public domain'
from gozerbot.commands import cmnds
from gozerbot.plughelp import plughelp
from gozerbot.examples import examples
from gozerbot.tests import tests
import socket
plughelp.add('probe', 'show if host:port is open')
def handle_probe(bot, ievent):
""" probe <host> <port> .. check if host:port is open """
try:
(host, port) = ievent.args
port = int(port)
except ValueError:
ievent.missing('<host> <port>')
return
try:
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.settimeout(2)
sock.connect((host, port))
sock.close()
except socket.timeout:
ievent.reply('%s:%s is not up' % (host, port))
return
except Exception, ex:
ievent.reply('%s:%s is not up ==> %s' % (host, port, str(ex)))
return
ievent.reply('%s:%s is up' % (host, port))
cmnds.add('probe', handle_probe, ['OPER', 'PROBE'])
examples.add('probe', 'probe <host> <port> // show if host:port is open', \
'probe gozerbot.org 8088')
tests.add('probe gozerbot.org 10101')
|