Skip to content

Commit 199203c

Browse files
author
mvazquez
committed
Added database users discovery. Added function to query current status of db users. Updated Pyora.xml template with the required discovery rule and item prototype
1 parent f63fa6e commit 199203c

File tree

2 files changed

+192
-8
lines changed

2 files changed

+192
-8
lines changed

pyora.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -454,9 +454,21 @@ def fra_use(self):
454454
for i in res:
455455
print i[0]
456456

457-
def locked_users(self):
458-
'''Query the locked users on the instance'''
459-
sql = "SELECT username FROM dba_users WHERE account_status != 'OPEN'"
457+
def show_users(self):
458+
'''Query the list of users on the instance'''
459+
sql = "SELECT username FROM dba_users ORDER BY 1"
460+
self.cur.execute(sql)
461+
res = self.cur.fetchall()
462+
key = ['{#DBUSER}']
463+
lst = []
464+
for i in res:
465+
d=dict(zip(key,i))
466+
lst.append(d)
467+
print json.dumps({'data': lst})
468+
469+
def user_status(self,dbuser):
470+
'''Determines whether a user is locked or not'''
471+
sql = "SELECT account_status FROM dba_users WHERE username='{0}'".format(dbuser)
460472
self.cur.execute(sql)
461473
res = self.cur.fetchall()
462474
for i in res:

0 commit comments

Comments
 (0)