Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modernized and added temperature, fan and CPU speed readings #23

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM python:2.7-alpine
FROM python:3.11-alpine
ADD . /usr/src/hpilo_exporter
RUN pip install -e /usr/src/hpilo_exporter
ENTRYPOINT ["hpilo-exporter"]
ENTRYPOINT ["/usr/local/bin/python", "-m", "hpilo_exporter"]
EXPOSE 9416
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
prometheus-client>=0.0.19
python-hpilo>=3.8
prometheus-client>=0.17.0
python-hpilo>=4.4.3
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ def readme():
'Topic :: Internet :: WWW/HTTP',
],
install_requires=[
"prometheus-client",
"python-hpilo",
"prometheus-client>=0.17.0",
"python-hpilo>=4.4.3"
],
entry_points={
'console_scripts': [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import argparse

from hpilo_exporter.exporter import ILOExporterServer
from .exporter import ILOExporterServer


def main():
Expand Down
36 changes: 26 additions & 10 deletions src/hpilo_exporter/exporter.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
"""
Pulls data from specified iLO and presents as Prometheus metrics
"""
from __future__ import print_function
from _socket import gaierror
import sys
import hpilo

import time
import prometheus_metrics
from BaseHTTPServer import BaseHTTPRequestHandler
from BaseHTTPServer import HTTPServer
from SocketServer import ForkingMixIn
from . import prometheus_metrics
from http.server import BaseHTTPRequestHandler, HTTPServer
from socketserver import ForkingMixIn
from urllib.parse import parse_qs, urlparse
from prometheus_client import generate_latest, Summary
from urlparse import parse_qs
from urlparse import urlparse


def print_err(*args, **kwargs):
Expand Down Expand Up @@ -61,7 +57,7 @@ def do_GET(self):
ilo_port = int(query_components['ilo_port'][0])
ilo_user = query_components['ilo_user'][0]
ilo_password = query_components['ilo_password'][0]
except KeyError, e:
except KeyError as e:
print_err("missing parameter %s" % e)
self.return_error()
error_detected = True
Expand All @@ -80,7 +76,7 @@ def do_GET(self):
except gaierror:
print("ILO invalid address or port")
self.return_error()
except hpilo.IloCommunicationError, e:
except hpilo.IloCommunicationError as e:
print(e)

# get product and server name
Expand Down Expand Up @@ -137,6 +133,26 @@ def do_GET(self):
prometheus_metrics.hpilo_firmware_version.labels(product_name=product_name,
server_name=server_name).set(fw_version)

health_data = ilo.get_embedded_health()
for name, val in (health_data.get('processors') or {}).items():
if "speed" in val:
prometheus_metrics.hpilo_cpu_speed_gauge.labels(product_name=product_name,
server_name=server_name,
name=val.get('name'),
label=val.get('label') or name).set(float(val["speed"].split(' ')[0]))
for name, val in (health_data.get('fans') or {}).items():
if "speed" in val:
prometheus_metrics.hpilo_fan_speed_gauge.labels(product_name=product_name,
server_name=server_name,
name=name,
zone=val.get('zone') or '').set(val.get('speed')[0])
for name, val in (health_data.get('temperature') or {}).items():
if "currentreading" in val and val["currentreading"][0] != 0 and val["currentreading"][0] != "N":
prometheus_metrics.hpilo_temperature_value_gauge.labels(product_name=product_name,
server_name=server_name,
name=name,
location=val.get('location') or '').set(val["currentreading"][0])

# get the amount of time the request took
REQUEST_TIME.observe(time.time() - start_time)

Expand Down
9 changes: 9 additions & 0 deletions src/hpilo_exporter/prometheus_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
hpilo_temperature_gauge = Gauge('hpilo_temperature', 'HP iLO temperature status', ["product_name", "server_name"])
hpilo_firmware_version = Gauge('hpilo_firmware_version', 'HP iLO firmware version', ["product_name", "server_name"])

hpilo_nic_status_gauge = Gauge('hpilo_nic_status', 'HP iLO NIC status', ["product_name", "server_name", "nic_name", "ip_address"])
hpilo_cpu_speed_gauge = Gauge('hpilo_cpu_speed', 'HP iLO CPU speed', ["product_name", "server_name", "name", "label"])
hpilo_fan_speed_gauge = Gauge('hpilo_fan_speed', 'HP iLO fan speed', ["product_name", "server_name", "name", "zone"])
hpilo_temperature_value_gauge = Gauge('hpilo_temperature_value', 'HP iLO temperature', ["product_name", "server_name", "name", "location"])

gauges = {
'hpilo_vrm_gauge': hpilo_vrm_gauge,
'hpilo_drive_gauge': hpilo_drive_gauge,
Expand All @@ -30,4 +35,8 @@
'hpilo_network_gauge': hpilo_network_gauge,
'hpilo_temperature_gauge': hpilo_temperature_gauge,
'hpilo_firmware_version': hpilo_firmware_version,
'hpilo_nic_status_gauge': hpilo_nic_status_gauge,
'hpilo_cpu_speed_gauge': hpilo_cpu_speed_gauge,
'hpilo_fan_speed_gauge': hpilo_fan_speed_gauge,
'hpilo_temperature_value_gauge': hpilo_temperature_value_gauge,
}