-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgetEPS.py
28 lines (24 loc) · 949 Bytes
/
getEPS.py
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
#!/usr/bin/python
"""Daily System Status Check Script."""
import sys
import MySQLdb, MySQLdb.cursors
CONFIG_FILE = '/etc/ossim/ossim_setup.conf'
def config_parse(conffile):
"""Parse Alienvault Config File to extract DB Credentials."""
parsed_config = {}
try:
config = open(conffile).read().splitlines()
for line in config:
if line.startswith('user=') or line.startswith('db_ip=') or line.startswith('pass='):
k, v = line.split('=', 1)
parsed_config[k] = v
except Exception as err:
sys.exit('Config Parser error: %s' % err)
return parsed_config
if __name__ == '__main__':
pc = config_parse(CONFIG_FILE)
mysql_conn = MySQLdb.connect(host='127.0.0.1', user=pc['user'], passwd=pc['pass'], db='alienvault')
CURSOR = mysql_conn.cursor()
CURSOR.execute('select sum(stat) from acl_entities_stats;'
eps = int(CURSOR.fetchone()[0])
print(eps)