diff --git a/README.md b/README.md index ccf971b..be91e6c 100644 --- a/README.md +++ b/README.md @@ -167,11 +167,18 @@ xe host-call-plugin host-uuid= plugin=smartctl.py fn=health ## IPMI-sensors parser A xapi plugin to get information about the host via the BMC +### `get_info`: ``` xe host-call-plugin host-uuid= plugin=2crsi-sensors.py fn="get_info" [{"Name": "Outlet_Temp", "Event": "'OK'", "Units": "C", "Reading": "32.00", "Type": "Temperature"}, {"Name": "CPU0_Temp", "Event": "'OK'", "Units": "C", "Reading": "63.00", "Type": "Temperature"}, {"Name": "CPU1_Temp", "Event": "'OK'", "Units": "C", "Reading": "59.00", "Type": "Temperature"}, {"Name": "CPU0_DIMM_T", "Event": "'OK'", "Units": "C", "Reading": "38.00", "Type": "Temperature"}, {"Name": "CPU1_DIMM_T", "Event": "'OK'", "Units": "C", "Reading": "37.00", "Type": "Temperature"}, {"Name": "PSU_Inlet_Temp", "Event": "'OK'", "Units": "C", "Reading": "36.00", "Type": "Temperature"}, {"Name": "CPU0_VR_Temp", "Event": "'OK'", "Units": "C", "Reading": "43.00", "Type": "Temperature"}, {"Name": "CPU1_VR_Temp", "Event": "'OK'", "Units": "C", "Reading": "43.00", "Type": "Temperature"}, {"Name": "OCP_NIC_Temp", "Event": "'OK'", "Units": "C", "Reading": "60.00", "Type": "Temperature"} [...] } ``` +### `get_ip`: +``` +xe host-call-plugin host-uuid= plugin=2crsi-sensors.py fn="get_ip" +10.10.1.191 +``` + ## Netdata A xapi plugin to install and get api keys of netdata on the host. diff --git a/SOURCES/etc/xapi.d/plugins/2crsi-sensors.py b/SOURCES/etc/xapi.d/plugins/2crsi-sensors.py index 761f639..208e28c 100644 --- a/SOURCES/etc/xapi.d/plugins/2crsi-sensors.py +++ b/SOURCES/etc/xapi.d/plugins/2crsi-sensors.py @@ -39,8 +39,17 @@ def get_data(session, args): return json.dumps(result) +def get_ip(session,args): + IP = subprocess.check_output(["ipmitool lan print | grep 'IP Address '"], shell=True) + IP = str(IP) + IP = IP.replace(" ", "") + result = re.findall(r"\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b", IP) + return result[0] + + _LOGGER = configure_logging('2crsi-sensors') if __name__ == "__main__": XenAPIPlugin.dispatch({ - 'get_info': get_data + 'get_info': get_data, + 'get_ip': get_ip })