blob: 04c6f158ec2dc654675797dbc52cb7c27522ae96 [file] [log] [blame]
Brian Freeman81f6e9e2018-11-11 22:36:20 -05001#! /usr/bin/python
2
3import logging
4import json
Brian Freeman81f6e9e2018-11-11 22:36:20 -05005import commands
6import sys
Yang Xuaa8c5842019-01-02 12:05:40 -05007import subprocess
Brian Freeman81f6e9e2018-11-11 22:36:20 -05008
9if len(sys.argv) <2:
10 print('namespace not provided')
11 print('Usage: healthcheck-k8s.py onap')
12 sys.exit()
13
14namespace=sys.argv[1]
15
Brian Freeman81f6e9e2018-11-11 22:36:20 -050016print('Checking vGMUX REST API from SDNC')
Yang Xuaa8c5842019-01-02 12:05:40 -050017cmd = 'curl -s -u admin:admin -X GET http://10.0.101.21:8183/restconf/config/ietf-interfaces:interfaces'
Brian Freeman81f6e9e2018-11-11 22:36:20 -050018ret = commands.getstatusoutput("kubectl -n {0} exec dev-sdnc-sdnc-0 -- bash -c '{1}'".format(namespace,cmd))
19sz = ret[-1].split('\n')[-1]
Yang Xuaa8c5842019-01-02 12:05:40 -050020print(json.dumps(json.loads(sz), indent=4))
Brian Freeman81f6e9e2018-11-11 22:36:20 -050021
Yang Xuaa8c5842019-01-02 12:05:40 -050022print('\n')
Brian Freeman81f6e9e2018-11-11 22:36:20 -050023print('Checking vBRG REST API from SDNC')
Yang Xuaa8c5842019-01-02 12:05:40 -050024cmd = 'curl -s -u admin:admin -X GET http://10.3.0.2:8183/restconf/config/ietf-interfaces:interfaces'
Brian Freeman81f6e9e2018-11-11 22:36:20 -050025ret = commands.getstatusoutput("kubectl -n {0} exec dev-sdnc-sdnc-0 -- bash -c '{1}'".format(namespace,cmd))
26sz = ret[-1].split('\n')[-1]
Yang Xuaa8c5842019-01-02 12:05:40 -050027print(json.dumps(json.loads(sz), indent=4))
Brian Freeman81f6e9e2018-11-11 22:36:20 -050028
Yang Xuaa8c5842019-01-02 12:05:40 -050029print('\n')
Brian Freeman81f6e9e2018-11-11 22:36:20 -050030print('Checking SDNC DB for vBRG MAC address')
Yang Xu21b09c92019-06-13 13:19:20 -040031cmd = "kubectl exec dev-mariadb-galera-mariadb-galera-0 -- mysql -uroot -psecretpassword sdnctl -e 'select * from DHCP_MAP'"
Yang Xuaa8c5842019-01-02 12:05:40 -050032p = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True)
33(output, error) = p.communicate()
34print(output)
Brian Freeman81f6e9e2018-11-11 22:36:20 -050035