add builders/isbuilding and installedon scripts to ansible scripts
This commit is contained in:
parent
a73047871c
commit
e9e5208be6
2 changed files with 78 additions and 0 deletions
41
scripts/builders/isbuilding
Executable file
41
scripts/builders/isbuilding
Executable file
|
@ -0,0 +1,41 @@
|
|||
#!/usr/bin/python -tt
|
||||
|
||||
import ansible
|
||||
import ansible.runner
|
||||
import sys
|
||||
|
||||
|
||||
|
||||
|
||||
def isbuilding(res, host):
|
||||
if res['contacted'][host]['stdout'].strip() == 'none':
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
|
||||
pattern = 'builders'
|
||||
if len(sys.argv) > 1:
|
||||
pattern=';'.join(sys.argv[1:])
|
||||
|
||||
conn = ansible.runner.Runner(pattern=pattern, timeout=20, forks=30, remote_user='root')
|
||||
conn.module_name='shell'
|
||||
# this checks koji building or anything running as mock or mockbuilder
|
||||
# first part check if kojid has any child processes
|
||||
# second part is our catch for failure
|
||||
# third part is to see if anything is running as mock or mockbuilder
|
||||
conn.module_args="ps -opid= --ppid $(pidof -s -x kojid) || echo -n none || ps -u mock -u mockbuilder -opid="
|
||||
res = conn.run()
|
||||
|
||||
for host in sorted(res['dark'].keys() + res['contacted'].keys()):
|
||||
print host,
|
||||
if host in res['dark']:
|
||||
print ' down'
|
||||
else:
|
||||
if isbuilding(res, host):
|
||||
print ' yes'
|
||||
else:
|
||||
print ' no'
|
||||
|
||||
|
||||
|
37
scripts/installedon
Executable file
37
scripts/installedon
Executable file
|
@ -0,0 +1,37 @@
|
|||
#!/usr/bin/python -tt
|
||||
|
||||
import ansible
|
||||
import ansible.runner
|
||||
import ansible.playbook
|
||||
import sys
|
||||
import os
|
||||
import time
|
||||
|
||||
if len(sys.argv) < 2:
|
||||
print "installedon hostname or group"
|
||||
sys.exit(1)
|
||||
|
||||
pattern = '*'
|
||||
if len(sys.argv) > 1:
|
||||
pattern=';'.join(sys.argv[1:])
|
||||
|
||||
|
||||
conn = ansible.runner.Runner(pattern=pattern, timeout=20, forks=30, remote_user='root')
|
||||
conn.module_name='shell'
|
||||
conn.module_args='rpm -qa --qf "%{installtime}\n" | sort -rn| tail -n 1'
|
||||
|
||||
res = conn.run()
|
||||
|
||||
|
||||
for host in sorted(res['dark'].keys()):
|
||||
print '%s is down' % host
|
||||
|
||||
now = time.time()
|
||||
for host in sorted(res['contacted'].keys()):
|
||||
insttime = float(res['contacted'][host]['stdout'])
|
||||
days = (now - insttime) / 86400
|
||||
|
||||
print '%s install is %d days old' % (host, days)
|
||||
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue