-
Notifications
You must be signed in to change notification settings - Fork 2
/
watts_cpu
29 lines (25 loc) · 1.09 KB
/
watts_cpu
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#! /bin/bash
#----------------------------------------------------------------------
# Description: show CPU package power consumption
# Author: Artem S. Tashkinov
# Created at: 2019-09-04 14:17:52
# 2020-05-17 21:55:38 - output GPU wattage as well
# 2022-04-14 09:24:31 - disable GPU wattage, don't show emoji for console
# 2023-08-10 14:17:38 - adjust for updated AMD GPU sensors output
#
# Copyright (c) 2019-2023 Artem S. Tashkinov All rights reserved.
#
#----------------------------------------------------------------------
test ! -e /dev/cpu/0/msr && echo "MSR module not loaded. Exiting" && exit 1
test ! -r /dev/cpu/0/msr && echo "No permissions to read MSR. Exiting" && exit 2
interval=1
test -n "$1" && interval=$1
# only show emoji for a graphical session
ECPU="CPU "
EGPU="GPU "
test "$TERM" = "dumb" && ECPU="⚙️" && EGPU="🕹️"
echo -n " $ECPU"
turbostat --quiet --num_iterations 1 --interval "$interval" --show PkgWatt --Summary | tail -1 | tr -d '\n'
echo -n "W"
echo -n " $EGPU"
sensors 'amdgpu-pci-*' 2>/dev/null | awk '/power|PPT/{print $2 "W"}'