Skip to main content

Primary links

  • Home
  • AI
  • Kubernetes
  • Incus
  • Ansible
  • Terraform
  • OpenStack
  • Virtualization
  • Linux
  • SmartHome
  • HowTo

Misc

  • Linux
  • Hardware
  • Programming
  • Databases
  • Multimedia
  • Windows

Cloud

  • OpenStack
  • cloud-config
  • nextcloud

Virtualization

  • Virtualization
  • Incus
  • Docker
  • KVM
  • Kubernetes
  • LXC
  • LXD
  • QEMU
  • VMware
  • VirtualBox
  • multipass
  • podman
  • vagrant
  • XEN

Network

  • DNS
  • Firewall
  • Linux
  • OpenvSwitch
  • SSL
  • VLAN
  • VPN
  • iPXE
  • namespaces
  • nmcli
  • tcpdump

Storage

  • CEPH
  • DRBD
  • LVM
  • S3
  • ZFS
  • btrfs

Automation / CI/CD

  • Install
  • Ansible
  • GitLab
  • LLM
  • Preseed
  • Puppet
  • Terraform
  • Ubuntu autoinstall

Monitoring / Visualisation

  • Grafana
  • Icinga
  • Prometheus
  • Monitoring
  • ELK
  • mermaid

Get server(s) power consumption

bmc_credentials.conf

export BMC_USER=ADMIN
export BMC_PASS=ADMIN

get-power-consumption.sh

#!/bin/bash

# source BMC credentials
. $(dirname "${BASH_SOURCE[0]}")/bmc_credentials.conf

if [ $# -eq 1 ]; then
    BMC_NODES="${1}"
else
    echo "Usage: $0 \"\""
    echo "e.g $0 \"10.0.0.1 \$(echo 10.0.2.{10..20})\""
    exit
fi

printf "%-40s %-10s %-10s\n" "Server" "Current" "AVG"
for BMC_NODE in ${BMC_NODES}; do
    POWER_CONSUMPTION=$(curl --connect-timeout 3 -s https://${BMC_NODE}/redfish/v1/Chassis/1/Power/ -k -u ${BMC_USER}:${BMC_PASS} | jq -r ".PowerControl[].PowerConsumedWatts")
    [ -z ${POWER_CONSUMPTION} ] && POWER_CONSUMPTION=$(ipmitool -I lanplus -H ${BMC_NODE} -U ${BMC_USER} -P ${BMC_PASS} dcmi power reading | awk '/Instantaneous/ {print $(NF-1)}')

    POWER_CONSUMPTION_AVG=$(curl --connect-timeout 3 -s https://${BMC_NODE}/redfish/v1/Chassis/1/Power/ -k -u ${BMC_USER}:${BMC_PASS} | jq -r ".PowerControl[].PowerMetrics.AverageConsumedWatts")
    [ -z ${POWER_CONSUMPTION_AVG} ] && POWER_CONSUMPTION_AVG=$(ipmitool -I lanplus -H ${BMC_NODE} -U ${BMC_USER} -P ${BMC_PASS} dcmi power reading | awk '/Average/ {print $(NF-1)}')

    printf "%-40s %-10s %-10s\n" "${BMC_NODE}" "${POWER_CONSUMPTION}" "${POWER_CONSUMPTION_AVG}"
done

define server (BMC) list

BMC_NODES="
10.0.0.222
$(echo www{1..9}.example.com)
$(echo 10.0.1.{101..201})
"

Get data from redfish / ipmi

ipmitool

Install

sudo apt-add-repository universe
sudo apt install -y ipmitool
#sudo apt install -y freeipmi-tools

Install ipmitool (IPMI command line client)
[embed_url: https://raw.githubusercontent.com/panticz/installit/master/install.ipmitool.sh]

Configure BMC to DHCP

# show BMC interface informations
ipmitool lan print

# set dhcp IP
ipmitool lan set 1 ipsrc dhcp

# set static IP
ipmitool lan set 1 ipsrc static
ipmitool lan set 1 ipaddr 10.0.1.11
ipmitool lan set 1 netmask 255.255.255.0
ipmitool lan set 1 defgw ipaddr 10.0.1.252

# set VLAN
ipmitool -I lanplus -H ${BMC_IP} -U ${BMC_USER} -P ${BMC_PASS} ipmitool lan set 1 vlan id 1234
ipmitool -I lanplus -H ${BMC_IP} -U ${BMC_USER} -P ${BMC_PASS} ipmitool lan set 1 vlan id off

# soft restart BMC 
ipmitool -I lanplus -H ${BMC_IP} -U ${BMC_USER} -P ${BMC_PASS} mc reset warm

# hard restart BMC 
ipmitool -I lanplus -H ${BMC_IP} -U ${BMC_USER} -P ${BMC_PASS} mc reset cold

Commands

ipmi
Profiles GitHub StackOverflow LinkedIn Xing
Contact Imprint
© panticz 2026

Cookie-Einstellungen

Diese Website nutzt eingebettete Inhalte von Drittanbietern (z.B. YouTube, SoundCloud). Beim Laden dieser Inhalte werden Daten an die jeweiligen Anbieter übermittelt. Datenverarbeitungserklärung