Maksim Totmin 1e6f432230 feat: metrics agent for FreeSWITCH and Asterisk nodes
- pulse-lets-go-agent: collects metrics from PBX nodes via ESL (FreeSWITCH) or AMI (Asterisk)
- AMI client (raw TCP) for Asterisk Manager Interface
- Collector interface: collect, connect, subscribe hangup events, close
- FreeSWITCH collector: show channels, max_sessions, idle_cpu
- Asterisk collector: CoreShowChannels, CoreSettings
- System collector: /proc/loadavg, /proc/stat (CPU idle)
- Failure tracker: sliding window for call_failure_rate
- NATS publisher: pulse.metrics.<node_id> every 5 seconds
- Graceful shutdown, retry logic (5 failures → status=down)
- Template configs for UC nodes (Asterisk) and ses-sip (FreeSWITCH)
2026-06-25 16:59:10 +07:00

45 lines
1.1 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// pulse-lets-go-agent — агент сбора метрик для pulse-lets-go.
// Работает на каждой PBX-ноде (FreeSWITCH или Asterisk),
// собирает метрики и публикует их в NATS каждые 5 секунд.
//
// Использование:
//
// pulse-lets-go-agent -config /etc/pulse-lets-go-agent/agent.json
//
// Пример agent.json:
//
// {
// "node_id": "uc06",
// "type": "asterisk",
// "nats_url": "nats://10.101.60.81:4222",
// "sip_gateway": "sip:10.101.60.115:5060",
// "interval_sec": 5,
// "max_calls": 150,
// "ami": { "host": "127.0.0.1", "port": 6154, "username": "ctt", "password": "cttpass" }
// }
package main
import (
"flag"
"log"
"github.com/pulse-lets-go/cmd/pulse-lets-go-agent/agent"
)
func main() {
configPath := flag.String("config", "agent.json", "путь к agent.json")
flag.Parse()
cfg, err := agent.LoadConfig(*configPath)
if err != nil {
log.Fatalf("ошибка загрузки конфига: %v", err)
}
a, err := agent.NewAgent(cfg)
if err != nil {
log.Fatalf("ошибка создания агента: %v", err)
}
a.Start()
}