blob: 0a728a429c48224ab1ff7669bbd6e3b3c6144a37 [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 Xuaa8c5842019-01-02 12:05:40 -050031cmd = "kubectl -n onap exec dev-sdnc-sdnc-db-0 -c sdnc-db -- mysql -usdnctl -pgamma sdnctl -e 'select * from DHCP_MAP;'"
32p = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True)
33(output, error) = p.communicate()
34print(output)
Brian Freeman81f6e9e2018-11-11 22:36:20 -050035