Skip to content

Channel Monitor 是一个用于监控OneAPI/NewAPI/OneHub渠道的工具,它直接读取channels和abilities数据表,每间隔一段时间测试每个渠道的模型可用性,根据请求是否成功更新可用模型,写入到数据表中,以此来实现渠道的自动监控,保证整体OneAPI/NewAPI/OneHub的高可用,尽可能减少错误返回次数。

Notifications You must be signed in to change notification settings

DullJZ/ChannelMonitor

Repository files navigation

Channel Monitor

Chinese 中文 | English 英文

Introduction

Channel Monitor is a tool designed for monitoring OneAPI/NewAPI channels. It directly reads the channels data table and tests the availability of each channel's models at regular intervals. Based on whether the requests are successful, it updates the available models and writes them to the data table, thus achieving automated monitoring of the channels. This ensures high availability of the overall OneAPI/NewAPI and minimizes the number of error returns.

Features

  • Directly read and write to the OneAPI/NewAPI database
  • Test the availability of each model in the channels
  • Automatically fetch available models from upstream
  • Automatically update the available models in the database for each channel
  • Support exclusion of channels and models from monitoring
  • Support configurable intervals
  • Support multiple database types, including MySQL, SQLite, PostgreSQL, and SQL Server
  • Concurrent testing
  • Support Uptime Kuma, push URL during testing to visualize model availability

Installation

Binary

Download the latest version of the binary file from the Releases page. After configuring config.json in the same directory, you can run it. It is recommended to use tools like screen or nohup to run it in the background.

mkdir ChannelMonitor && cd ChannelMonitor
wget https://github.com/DullJZ/ChannelMonitor/releases/download/v0.1.0/ChannelMonitor_linux_amd64
chmod +x ChannelMonitor_linux_amd64
# Download and modify the configuration file
wget https://raw.githubusercontent.com/DullJZ/ChannelMonitor/refs/heads/main/config_example.json -O config.json
nano config.json
screen -S ChannelMonitor
./ChannelMonitor_linux_amd64

Docker

docker pull dulljz/channel-monitor
# Download and modify the configuration file
wget https://raw.githubusercontent.com/DullJZ/ChannelMonitor/refs/heads/main/config_example.json -O config.json
nano config.json
# If using the host's database, you can simply use the host mode,
# and use localhost:3306 as the database address
docker run -d --name ChannelMonitor -v ./config.json:/app/config.json --net host dulljz/channel-monitor
# If using an SQLite database, mount the database file
# docker run -d --name ChannelMonitor -v ./config.json:/app/config.json -v /path/to/database.db:/app/database.db dulljz/channel-monitor

Docker Compose

version: '3'
services:
  channel-monitor:
    image: dulljz/channel-monitor
    volumes:
      - ./config.json:/app/config.json
      # If using an SQLite database, mount the database file
      # - /path/to/database.db:/app/database.db
    # If using the host's database, you can simply use the host mode,
    # and use localhost:3306 as the database address
    network_mode: host
# Download and modify the configuration file
wget https://raw.githubusercontent.com/DullJZ/ChannelMonitor/refs/heads/main/config_example.json -O config.json
nano config.json
docker-compose up -d

Configuration

The configuration file is config.json located in the same directory, with the following format:

{
  "oneapi_type": "oneapi",
  "exclude_channel": [5],
  "exclude_model": ["advanced-voice"],
  "models": ["gpt-3.5-turbo", "gpt-4"],
  "force_models": false,
  "time_period": "1h",
  "db_type": "mysql",
  "db_dsn": "YOUR_DB_DSN",
  "base_url": "http://localhost:3000",
  "system_token": "YOUR_SYSTEM_TOKEN",
  "uptime-kuma": {
    "status": "disabled",
    "model_url": {
      "gpt-3.5-turbo": "https://demo.kuma.pet/api/push/A12n43563?status=up&msg=OK&ping=",
      "gpt-4o": "https://demo.kuma.pet/api/push/ArJd2BOUJN?status=up&msg=OK&ping="
    },
    "channel_url": {
      "5": "https://demo.kuma.pet/api/push/ArJd2BOUJN?status=up&msg=OK&ping="
    }
  }
}

Configuration explanation:

  • oneapi_type: Type of OneAPI, including oneapi, newapi, onehub (reserved field, currently has no effect)
  • exclude_channel: IDs of channels to exclude from monitoring
  • exclude_model: IDs of models to exclude from monitoring
  • models: List of models, used only when unable to retrieve models from the channel (/v1/models)
  • force_models: If true, only the above models will be tested, and channel models will not be fetched. Default is false
  • time_period: Interval for testing model availability, recommended not less than 30 minutes, accepts time formats s, m, h
  • db_type: Database type, including mysql, sqlite, postgres, sqlserver
  • db_dsn: Database DSN string, the format varies by database type. Examples below
  • base_url: The base URL for OneAPI/NewAPI/OneHub. If using host mode, you can directly use http://localhost:3000. Currently, only OneHub requires this field.
  • system_token: System token, currently only required for OneHub.
  • uptime-kuma: Configuration for Uptime Kuma. The status can be enabled or disabled. The model_url and channel_url are the availability Push URLs for models and channels.

MySQL

{
  "db_type": "mysql",
  "db_dsn": "username:password@tcp(host:port)/dbname"
}

SQLite

{
  "db_type": "sqlite",
  "db_dsn": "/path/to/database.db"
}

PostgreSQL

{
  "db_type": "postgres",
  "db_dsn": "host=host port=port user=username password=password dbname=dbname sslmode=disable"
}

SQL Server

{
  "db_type": "sqlserver",
  "db_dsn": "sqlserver://username:password@host:port?database=dbname"
}

About

Channel Monitor 是一个用于监控OneAPI/NewAPI/OneHub渠道的工具,它直接读取channels和abilities数据表,每间隔一段时间测试每个渠道的模型可用性,根据请求是否成功更新可用模型,写入到数据表中,以此来实现渠道的自动监控,保证整体OneAPI/NewAPI/OneHub的高可用,尽可能减少错误返回次数。

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published