adejoux / nmon2influxdb

Make NMON data dynamic with InfluxDB
GNU Affero General Public License v3.0
80 stars 29 forks source link

nmon2influxdb hmc import doesn't logoff ? #73

Closed julfur closed 5 years ago

julfur commented 5 years ago

Hi Adejoux,

It seems the HMC import feature does not logoff properly from the HMC. I didn't find a logoff function in the hmc package in the repo (sorry I'm not very fluent en Go, I found the PUT and looked for a DELETE).

I realized it when I saw 8000 REST API logons idling on one our virtual HMC which corresponds to the time when I first tried it.

Here's an example of logoff function with a DELETE request in python which works well : https://www.ibm.com/developerworks/community/blogs/aixpert/entry/Avoiding_HMC_REST_API_Session_Issues?lang=en

import sys

def disconnect(hmc, token):
    headers = {'X-API-Session' : token }
    url =  'https://'+hmc+':12443/rest/api/web/Logon'
    ret = requests.delete(url,headers=headers,verify=False)
    rcode = ret.status_code
    # REST API delete officially can respond with these three good values
    if rcode == 200 or rcode == 202 or rcode == 204:
        print("Successfully disconnected from the HMC")
        sys.exit(0)
    else:
        print("Logoff failed code=%d url=%s data=%s" %(rcode, url, ret.text))
        sys.exit(rcode)

Would it be possible to add this feature in the next release ? I could help but unfortunately, I'm barely able to read Go right now.

Thanks

adejoux commented 5 years ago

Thanks for your input. I was away.

I merged your pull request :)

Alain