CPU Cooler Chart

CPU Cooler Chart (CCC) is CPU cooler performance and price database. It merges data from CPU cooler performance measurements and price information from Coolenjoy and Danawa.

Compatiblity

CPU Cooler Chart supports Python 2.6, 2.7, and 3.3 on CPython.

Install & Running

$ pip install --pre cpucoolerchart

See the GitHub repo page for more.

Configuration

CPU Cooler Chart is configured the same way a Flask app is configured. In short, there are two ways to configure the app:

  • Make a Python file that contains the configuration values and set the CPUCOOLERCHART_SETTINGS environment variable to the path of the file. For example, save the following as settings.py:

    SQLALCHEMY_DATABASE_URI = 'sqlite://'
    CACHE_TYPE = 'simple'
    

    and set the CPUCOOLERCHART_SETTINGS environment variable to /path/to/settings.py before running the app.

  • Pass a collections.Mapping to create_app() when creating the app. Example:

    from cpucoolerchart.app import create_app
    app = create_app({
        'SQLALCHEMY_DATABASE_URI': 'sqlite://',
        'CACHE_TYPE': 'simple',
    })
    

See Configuration Handling for more about configuring a Flask app. In addition to the Flask builtin configuration values, you can use the following configuration values that are specific to CPU Cooler Chart:

name description
SQLALCHEMY_DATABASE_URI

(str) The database URI that should be used for the database connection. Examples:

  • sqlite:////tmp/test.db
  • mysql://username:password@server/db

For more information about configuration SQLAlchemy, see the Flask-SQLAlchemy documentation. Default is "sqlite:///{INSTANCE_PATH}/development.db" where {INSTANCE_PATH} is interpreted as the absolute path to the instance directory under the current working directory.

CACHE_TYPE (str) Specifies which type of caching object to use. This is an import string for a function that will return a werkzeug.contrib.cache.BaseCache object, or a special short names for built-in types. For more information, see the Flask-Cache documentation. Default is "filesystem".
ACCESS_CONTROL_ALLOW_ORIGIN (str) A comma-separated list of URIs that may access the CORS-enabled endpoints. Default is "*".
UPDATE_INTERVAL (int) A number of seconds for which data is considered up to date after an update. Default is 86400, which is equivalent to one day.
DANAWA_API_KEY_PRODUCT_INFO (str or None) Danawa API key for product info. Used to get the current prices. Default is None, which logs a warning when it tries to get price info.
DANAWA_API_KEY_SEARCH (str or None) Danawa API key for search. Used during development to find Danawa product identifiers, thus not needed in a normal operation. Default is None.
USE_QUEUE (bool) Enable enquequing an update job via HTTP. Default is False.
RQ_URL (str or None) A Redis URL used when USE_QUEUE is True. There are separate configuration values such as RQ_HOST and RQ_PORT that can be used instead of RQ_URL. See Redis.init_app() for more.
START_WORKER_NODE (str or None) Enable starting a worker node via HTTP. Since update occurs infrequently, it is often desirable to run a worker only when it is needed. Currently the only supported value is "heroku". Default is None, which disables this feature.
HEROKU_WORKER_NAME

(str) The name of the worker process as written in Procfile. Default is "worker". The process line should look like this:

worker: cpucoolerchart runworker --burst

The --burst argument make the worker process end when it finished processing jobs in the update queue.

HEROKU_API_KEY (str or None) The Heroku API key
HEROKU_APP_NAME (str or None) The Heroku app name

HTTP APIs

All endpoints returning a list of items in JSON format returns an object containing two properties count and items. count is the number of items in the items array. The order of items is undefined and may not in the same order for each request. Each item has properties described in following tables. Properties with an asterisk at the end of its name can be null.

Most of the endpoints are CORS enabled using the crossdomain() decorator. The Access-Control-Allow-Origin response header will be set to the value of ACCESS_CONTROL_ALLOW_ORIGIN in your config, which is "*" by default. For more information about CORS, see HTTP access control (CORS) on Mozilla Developer Network.

GET /measurements

Returns all measurement data. CORS enabled.

Example request:

GET /measurements HTTP/1.1
Host: example.com
Accept: application/json

Example response:

HTTP/1.1 200 OK
Content-Type: application/json

{
  "count": 1,
  "items": [
    {
      "cpu_temp_delta": 50.7,
      "fan_config_id": 1,
      "id": 1,
      "noise": 35,
      "noise_actual_max": null,
      "noise_actual_min": null,
      "power": 62,
      "power_temp_delta": null,
      "rpm_max": 1010,
      "rpm_min": 1002
    }
  ]
}

Properties:

name type description
id number Internal identifier for a measurement
fan_config_id number id of the corresponding fan config
noise number Target noise level in dB. All values are literal but a value of 100 means the maximum noise level that the fan config can get. In this case you may look noise_actual_min and noise_actual_max for the range of actual values, although these values can be missing even noise is 100.
noise_actual_min* number The minimum measured value of the actual noise level in dB
noise_actual_max* number The maximum measured value of the actual noise level in dB
power number Target CPU power consumption in watt.
rpm_min* number The minimum measured value of RPM of fans
rpm_max* number The maximum measured value of RPM of fans
cpu_temp_delta number CPU temperature in °C
power_temp_delta* number Power temperature in °C
GET /fan-configs

Returns all fan configs, combinations of a heatsink and one or more fans. CORS enabled.

Example request:

GET /fan-configs HTTP/1.1
Host: example.com
Accept: application/json

Example response:

HTTP/1.1 200 OK
Content-Type: application/json

{
  "count": 2,
  "items": [
    {
      "fan_count": 1,
      "fan_size": 120,
      "fan_thickness": 25,
      "heatsink_id": 1,
      "id": 1
    },
    {
      "fan_count": 1,
      "fan_size": 120,
      "fan_thickness": 25,
      "heatsink_id": 2,
      "id": 2
    }
  ]
}

Properties:

name type description
id number Internal identifier for a fan config
heatsink_id number id of the corresponding heatsink
fan_count number Number of fans. Note that all fans in a single fan have the same fan size and thickness.
fan_size number The diameter of a fan in mm
fan_thickness number The thickness of a fan in mm
GET /heatsinks

Returns all heatsink models. CORS enabled.

Example request:

GET /heatsinks HTTP/1.1
Host: example.com
Accept: application/json

Example response:

HTTP/1.1 200 OK
Content-Type: application/json

{
  "count": 1,
  "items": [
    {
      "danawa_id": 1465177,
      "depth": null,
      "first_seen": "Fri, 12 Aug 2011 08:03:08 GMT",
      "heatsink_type": "tower",
      "height": null,
      "id": 46,
      "image_url": "http://img.d.com/prod_img/177/465/img/145177_1.jpg",
      "maker_id": 12,
      "name": "H100",
      "price": 184760,
      "shop_count": 5,
      "weight": null,
      "width": null
    }
  ]
}

Properties:

name type description
id number Internal identifier for a heatsink
maker_id number id of the corresponding maker
name string Name of the heatsink
heatsink_type string Type of the heatsink. Currently there are two types: flower and tower.
width* number Width of the heatsink in mm
depth* number Depth of the heatsink in mm
height* number Height of the heatsink in mm
weight* number Weight of the heatsink in g
danawa_id* number Danawa identifier for the heatsink
price* number Lowest price of the heatsink on Danawa in KRW
shop_count* number Number of stores selling the heatsink on Danawa
first_seen* date Time when the heatsink first appeared on Danawa
image_url* string URL of the photo of the heatsink
GET /makers

Returns all heatsink makers. CORS enabled.

Example request:

GET /makers HTTP/1.1
Host: example.com
Accept: application/json

Example response:

HTTP/1.1 200 OK
Content-Type: application/json

{
  "count": 2,
  "items": [
    {
      "id": 1,
      "name": "CoolerMaster"
    },
    {
      "id": 2,
      "name": "Corsair"
    }
  ]
}

Properties:

name type description
id number Internal identifier for a maker
name string Name of the maker
POST /update

Enqueues an update job so that a worker process update the database. This feature is enabled when USE_QUEUE is True. To process enqueued jobs, run a worker process (cpucoolerchart runworker).

There is a special feature that starts a worker process to reduce the server cost. Only Heroku is supported for now. Set START_WORKER_NODE to "heroku" and HEROKU_API_KEY and HEROKU_APP_NAME to your Heroku API key and app name respectively.

To prevent DDoS attacks, it cannot be requested more frequently than once per 5 minutes when app.debug is False.

Example request:

POST /update HTTP/1.1
Host: example.com
Accept: application/json

Example response:

HTTP/1.1 202 OK
Content-Type: application/json

{
  "msg": "process started"
}

It returns a JSON object containing a message in the msg property. Possible messages are:

message description
process started An update job is enqueued and a worker process has started
too many requests There was a request within the last 5 minutes
already up to date data is already up to date
invalid worker type worker type is other than "heroku"
Heroku API key is not set HEROKU_API_KEY is not set in config
Heroku app name is not set HEROKU_APP_NAME is not set in config
heroku is not installed. Add heroku to your requirements.txt heroku Python module is not installed on your dyno.
failed to enqueue a job an error occurred during enqueuing a job
failed to start a worker an error occurred during starting a worker
Status Codes:
  • 202 – an update job is enqueued and a worker process has started
  • 404 – the app is not configured to update data via HTTP
  • 429 – there was a request within the last 5 minutes
  • 500 – an error occurred during enqueuing a job or starting a worker
  • 503 – worker settings are not valid
GET /all

Returns all data in CSV format.

Example request:

GET /all HTTP/1.1
Host: example.com
Accept: */*

Example response:

HTTP/1.1 200 OK
Content-Disposition: filename="cooler.csv"
Content-Type: text/csv; charset=utf-8

maker,model,width,depth,height,heatsink_type,weight,price,shop_count,first_seen,fan_size,fan_thickness,fan_count,noise,noise_actual_min,noise_actual_max,rpm_min,rpm_max,power,cpu_temp_delta,power_temp_delta
3Rsystem,iCEAGE 120,125.0,100.0,154.0,tower,590.0,,,2007-04-04 16:18:55,120,25,1,35,,,1002,1010,62,50.7,
Zalman,ZM-LQ320,,,,tower,195.0,91000,244,2013-01-31 16:57:18,120,25,2,100,58,58,2042,2068,200,60.8,64.5

License

CPU Cooler Chart is licensed under the MIT License. See LICENSE for more.

Table Of Contents

Next topic

Modules