update nagios client checks to py3
This commit is contained in:
parent
8a8b1731b3
commit
32330de141
4 changed files with 87 additions and 78 deletions
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/python2
|
||||
#!/usr/bin/python
|
||||
""" NRPE check for datanommer/fedmsg health.
|
||||
Given a category like 'bodhi', 'buildsys', or 'git', return an error if
|
||||
datanommer hasn't seen a message of that type in such and such time.
|
||||
|
@ -14,7 +14,9 @@ Usage:
|
|||
:Author: Ralph Bean <rbean@redhat.com>
|
||||
|
||||
"""
|
||||
from __future__ import print_function
|
||||
|
||||
from builtins import str
|
||||
import dateutil.relativedelta
|
||||
import subprocess
|
||||
import sys
|
||||
|
@ -53,14 +55,14 @@ def main():
|
|||
reason = "datanommer has not seen a %r message in %s" % (identifier, string)
|
||||
|
||||
if timesince > critical_threshold:
|
||||
print "CRIT: ", reason
|
||||
print("CRIT: ", reason)
|
||||
sys.exit(2)
|
||||
|
||||
if timesince > warning_threshold:
|
||||
print "WARN: ", reason
|
||||
print("WARN: ", reason)
|
||||
sys.exit(1)
|
||||
|
||||
print "OK: ", reason
|
||||
print("OK: ", reason)
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
|
@ -68,5 +70,5 @@ if __name__ == '__main__':
|
|||
try:
|
||||
main()
|
||||
except Exception as e:
|
||||
print "UNKNOWN: ", str(e)
|
||||
print("UNKNOWN: ", str(e))
|
||||
sys.exit(3)
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
#!/usr/bin/python2
|
||||
#!/usr/bin/python
|
||||
from __future__ import print_function
|
||||
from builtins import str
|
||||
import sys
|
||||
|
||||
try:
|
||||
|
@ -9,15 +11,15 @@ try:
|
|||
|
||||
items = queue.length
|
||||
if items > 500:
|
||||
print "CRITICAL: %i tasks in fcomm queue" % items
|
||||
print("CRITICAL: %i tasks in fcomm queue" % items)
|
||||
sys.exit(2)
|
||||
elif items > 250:
|
||||
print "WARNING: %i tasks in fcomm queue" % items
|
||||
print("WARNING: %i tasks in fcomm queue" % items)
|
||||
sys.exit(1)
|
||||
else:
|
||||
print "OK: %i tasks in fcomm queue" % items
|
||||
print("OK: %i tasks in fcomm queue" % items)
|
||||
sys.exit(0)
|
||||
|
||||
except Exception as e:
|
||||
print "UNKNOWN:", str(e)
|
||||
print("UNKNOWN:", str(e))
|
||||
sys.exit(3)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#!/usr/bin/python2
|
||||
#!/usr/bin/python
|
||||
|
||||
from __future__ import print_function
|
||||
import fcntl
|
||||
import sys
|
||||
|
||||
|
@ -7,11 +8,12 @@ try:
|
|||
f = open('/mnt/koji/.nagios_test', 'r')
|
||||
f.close()
|
||||
f = open('/mnt/koji/.nagios_test', 'w')
|
||||
except IOError:
|
||||
print "Could not create file"
|
||||
except IOError as e:
|
||||
print(e)
|
||||
print("Could not create file")
|
||||
sys.exit(2)
|
||||
|
||||
fcntl.flock(f, fcntl.LOCK_EX)
|
||||
f.close()
|
||||
print "File Locked Successfully"
|
||||
print("File Locked Successfully")
|
||||
sys.exit(0)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/python2
|
||||
#!/usr/bin/python
|
||||
""" check_supybot_plugin -- ensure that a plugin is loaded by supybot.
|
||||
|
||||
Run like:
|
||||
|
@ -7,7 +7,10 @@ Run like:
|
|||
check_supybot_plugin --target koji --debug
|
||||
|
||||
"""
|
||||
from __future__ import print_function
|
||||
|
||||
from builtins import str
|
||||
from builtins import map
|
||||
import argparse
|
||||
import sys
|
||||
import socket
|
||||
|
@ -49,60 +52,60 @@ name = "NRPE Bot"
|
|||
readbuffer = ""
|
||||
|
||||
if not args.target:
|
||||
print "UNKNOWN: No 'target' specified."
|
||||
print("UNKNOWN: No 'target' specified.")
|
||||
sys.exit(3)
|
||||
|
||||
args.target = args.target.lower()
|
||||
|
||||
if args.debug:
|
||||
print "connecting to %s/%i" % (args.host, args.port)
|
||||
print("connecting to %s/%i" % (args.host, args.port))
|
||||
|
||||
try:
|
||||
s = socket.socket()
|
||||
s.connect((args.host, args.port))
|
||||
|
||||
if args.debug:
|
||||
print "as %s/%s (%s)" % (args.nick, args.nick, name)
|
||||
print("as %s/%s (%s)" % (args.nick, args.nick, name))
|
||||
|
||||
s.send("nick %s\r\n" % args.nick)
|
||||
s.send("USER %s %s bla :%s\r\n" % (args.nick, args.host, name))
|
||||
s.send(("nick %s\r\n" % args.nick).encode())
|
||||
s.send(("USER %s %s bla :%s\r\n" % (args.nick, args.host, name)).encode())
|
||||
|
||||
while 1:
|
||||
readbuffer = readbuffer+s.recv(1024)
|
||||
temp = string.split(readbuffer, "\n")
|
||||
readbuffer = readbuffer+s.recv(1024).decode()
|
||||
temp = str.split(readbuffer, "\n")
|
||||
readbuffer = temp.pop()
|
||||
|
||||
for line in temp:
|
||||
line = string.rstrip(line)
|
||||
line = str.rstrip(line)
|
||||
|
||||
if args.debug:
|
||||
print " * ", line
|
||||
print(" * ", line)
|
||||
|
||||
line = string.split(line)
|
||||
line = str.split(line)
|
||||
|
||||
if line[1] == 'MODE':
|
||||
msg = "privmsg zodbot :list\r\n"
|
||||
msg = "privmsg zodbot :list\r\n".encode()
|
||||
if args.debug:
|
||||
print "sending:"
|
||||
print " ->", msg
|
||||
print("sending:")
|
||||
print(" ->", msg)
|
||||
s.send(msg)
|
||||
|
||||
if line[1] == 'PRIVMSG' and line[0] != ':freenode-connect!frigg@freenode/utility-bot/frigg':
|
||||
if line[0] == ':zodbot!supybot@fedora/bot/zodbot':
|
||||
if args.debug:
|
||||
print "Got our response.."
|
||||
print("Got our response..")
|
||||
|
||||
plugins = map(str.lower, ' '.join(line[3:][1:]).split(', '))
|
||||
plugins = list(map(str.lower, ' '.join(line[3:][1:]).split(', ')))
|
||||
|
||||
if args.target in plugins:
|
||||
print "OK"
|
||||
s.send("QUIT")
|
||||
print("OK")
|
||||
s.send("QUIT".encode())
|
||||
sys.exit(0)
|
||||
else:
|
||||
print "CRITICAL: %r not loaded by supybot" % args.target
|
||||
s.send("QUIT")
|
||||
print("CRITICAL: %r not loaded by supybot" % args.target)
|
||||
s.send("QUIT".encode())
|
||||
sys.exit(2)
|
||||
except Exception as e:
|
||||
print "UNKNOWN: ", str(e)
|
||||
print("UNKNOWN: ", str(e))
|
||||
if args.debug:
|
||||
raise
|
||||
sys.exit(3)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue