Bitcoin Forum
May 25, 2024, 09:45:21 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: ATI GPU Miner Health Monitoring Script...  (Read 4938 times)
LehmanSister (OP)
Member
**
Offline Offline

Activity: 68
Merit: 10


High Desert Dweller-Where Space and Time Meet $


View Profile
June 09, 2011, 04:01:07 AM
 #1

   I have this monitoring my mining box in a screen. I'm more concerned with temperature monitoring on this new mine, so this is letting me keep an eye on it. I'm thinking about putting together larger infrastructure of monitoring tools / pool swapping tools, but this is what's here and works today. Part of me wants to make it more blingy in bash, but I feel like I should just make something nice in curses. This can be made much better, but I just have it to monitor an experimental rig I'm working on and figured it may help someone else.

   May require lm-sensors.

Code:
#/bin/bash

# Mine Monitor v0.1
# (c) 2011 By LehmanSister (a pseudonymn) under the BPL
#
# Notes: needs some work to move everything into curses, and strop extra info
#
# TODO:
#       - move this to pycurses
#       - keep logs
#       - publish stats somewhere via simple protocol dujouri
#       - possible an CnC interface for multiple miners / pool control
#       - PROFIT

SLEEP_TIME_SECONDS=30
ATICONFIG_CMD=aticonfig
SENSOR_CMD=sensors

if [ -z "$@" ]
then   
        echo "mine_monitor.sh - Quick (yet ugly) GPU hardware info"
        echo "Usage: ./monitor_miner display_id_0 [display_id_1] ..."
        echo "Example: ./monitor_miner 0 1"
        echo ""
        echo "Requires lm-sensors (apt-get install lm-sensors, yum install lm-sensors"
        echo ""
        echo "(c) 2011 By LehmanSister (a pseudonymn) under the BPL"
        exit
else   
        echo "Doing Stats For $@"

        while true;
        do
                uptime
                hostname
                uname -a
                date
                echo
                echo "*** Temperature ***"
                $ATICONFIG_CMD --odgt --adapter=all

                echo "*** Clocks ***"
                $ATICONFIG_CMD --odgc --adapter=all

                for did in $@
                do
                        echo "*** GPU #$did Stats ***"
                        export DISPLAY=:0.$did; $ATICONFIG_CMD --pplib-cmd "get fanspeed 0"
                        export DISPLAY=:0.$did; $ATICONFIG_CMD --pplib-cmd "get temperature 0"
                        export DISPLAY=:0.$did; $ATICONFIG_CMD --pplib-cmd "get activity"
                done

                echo "*** CPU and Misc Sensors ***"
                $SENSOR_CMD

                echo
                date
                sleep 30;
                clear
        done;
fi

ISO: small island nations with large native populations excited to pay tribute to flying gods, will trade BTC.
LehmanSister (OP)
Member
**
Offline Offline

Activity: 68
Merit: 10


High Desert Dweller-Where Space and Time Meet $


View Profile
June 13, 2011, 02:48:53 AM
 #2

I'm not really in the mood to finish this up this evening (and I'll probably never been in the mood to write a full AMD output parser -- cash however, does put me in the mood), but here is how we can start putting these values into python to start controlling GPU cooldowns and whatnot. Just some quick musings with the python process library, seems to work alright.

Because I'm using geothermal cooling, and some janky overclocking, I personally need to kill one of the miners at a certain time of day. This can eventually be mixed in with my work with temperature sensors around room. Having this info directly in python makes my life easier. I also wouldn't mind setting up some more intelligent air duct systems with a master control to minimize power.

Code:
#!/usr/bin/python
# Python Process Musings w/ aticonfig
# (c) 2011 By LehmanSister (a pseudonymn) under the BPL
import os
import shlex, subprocess

# Base Environment
environ = os.environ

# Sample Command
cl = "aticonfig --pplib-cmd \"get temperature 0\""
args = shlex.split(cl)

# Example Of How To Play Around
environ['DISPLAY']=":0.0"
t1_raw = subprocess.check_output(args, env=environ)


environ['DISPLAY']=":0.1"
t2_raw = subprocess.check_output(args, env=environ)

print t1_raw
print t2_raw

ISO: small island nations with large native populations excited to pay tribute to flying gods, will trade BTC.
LehmanSister (OP)
Member
**
Offline Offline

Activity: 68
Merit: 10


High Desert Dweller-Where Space and Time Meet $


View Profile
June 13, 2011, 06:01:10 AM
 #3

Alright, here's the base for a python class to do it. I got what I need outta it, part of a larger project for my own rig setup, but figured it may be useful to some out here. It's trash but works.

Code:
#!/usr/bin/env python
# encoding: utf-8
"""
ATIConfigParser.py

Created by LehmanSister (a pseudonymn) on 2011-06-12.
Copyright (c) 2011 LehmanSister. All rights reserved.
"""

import sys
import os
import shlex, subprocess

class ATIConfigParser:
    def __init__(self):
        self.base_env = os.environ

    def getTemp(self, display_val):
        """Get Temperature For A Display ID"""
        #"Temperature for thermal controller 0 is 58.000000\n"
        cl = "aticonfig --pplib-cmd \"get temperature 0\""
        args = shlex.split(cl)
        env_cpy = self.base_env
        env_cpy["DISPLAY"] = display_val
        raw = subprocess.check_output(args, env=env_cpy)
        try:
            return raw.split(" ")[6].strip()
        except:
            return False

    def getFanSpeed(self, display_val):
        """Get Fan Speed For A Display ID"""

        # output looks like
        """
        Fan speed query:
        Query Index: 0, Speed in percent
        Result: Fan Speed: 80%

        """
        cl = "aticonfig --pplib-cmd \"get fanspeed 0\""
        args = shlex.split(cl)
        env_cpy = self.base_env
        env_cpy["DISPLAY"] = display_val
        raw = subprocess.check_output(args, env=env_cpy)
        #print raw
        try:
            return raw.split("\n")[2].split(" ")[3]
        except:
            return False

    def getActivity(self, display_val):
        """Get General Activity"""

        # output looks like
        """
        Current Activity is Core Clock: 975MHZ
        Memory Clock: 340MHZ
        VDDC: 1163
        Activity: 99 percent
        Performance Level: 2
        Bus Speed: 5000
        Bus Lanes: 16
        Maximum Bus Lanes: 16


        None
        """
        cl = "aticonfig --pplib-cmd \"get activity\""
        args = shlex.split(cl)
        env_cpy = self.base_env
        env_cpy["DISPLAY"] = display_val
        raw = subprocess.check_output(args, env=env_cpy)
        line = raw.split("\n")
        #print raw
        try:
            rtn = {}
            rtn['gpu_clock'] = line[0].split(":")[1].strip()
            rtn['mem_clock'] = line[1].split(":")[1].strip()
            rtn['vddc'] = line[2].split(":")[1].strip()
            rtn['perf_level'] = line[3].split(":")[1].strip()
            rtn['bus_speed'] = line[4].split(":")[1].strip()
            rtn['bus_lanes'] = line[5].split(":")[1].strip()
            rtn['max_bus_lanes'] = line[6].split(":")[1].strip()
            return rtn
        except:
            return False

    def getClocks(self, adapter_id="all"):
        """Get Clocks"""

        # output looks like
        """

        Adapter 0 - ATI Radeon HD 5800 Series 
                                    Core (MHz)    Memory (MHz)
                   Current Clocks :    975           340
                     Current Peak :    975           340
          Configurable Peak Range : [600-875]     [900-1200]
                         GPU load :    99%

        Adapter 1 - ATI Radeon HD 5800 Series 
                                    Core (MHz)    Memory (MHz)
                   Current Clocks :    975           340
                     Current Peak :    975           340
          Configurable Peak Range : [600-875]     [900-1200]
                         GPU load :    99%
        """
        cl = "aticonfig --odgc --adapter="+str(adapter_id)
        args = shlex.split(cl)
        raw = subprocess.check_output(args)
        line = raw.split("\n")
        # fuck it, whoever feels like finishing this off...
        return raw
        """
        try:
            rtn = {}
            return rtn
        except:
            return False
           
        """

if __name__ == '__main__':
    x = ATIConfigParser()
    print x.getTemp(":0.0")
    print x.getFanSpeed(":0.0")
    print x.getActivity(":0.0")
    print x.getClocks()

ISO: small island nations with large native populations excited to pay tribute to flying gods, will trade BTC.
LehmanSister (OP)
Member
**
Offline Offline

Activity: 68
Merit: 10


High Desert Dweller-Where Space and Time Meet $


View Profile
June 13, 2011, 06:01:06 PM
 #4

This project seems to have a slightly better ati monitoring script then my own:

https://bitbucket.org/furao/bitcoin/overview

ISO: small island nations with large native populations excited to pay tribute to flying gods, will trade BTC.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!