PmaControl logo PmaControl
  • Home
  • PmaControl
    • AI Agents 13 on-premise agents
    • Plans Community, Cloud, On-Premise, Premium
    • Documentation Guides, API, architecture
    • Clients 28+ companies
    • FAQ 25 questions / 7 categories
    Databases
    • MariaDB 30 articles
    • MySQL 10 articles
    • Galera Cluster 6 articles
    • MaxScale 3 articles
    • ProxySQL 2 articles
    • Amazon Aurora MySQL 0 article
    • Azure Database 0 article
    • ClickHouse 0 article
    • GCP CloudSQL 0 article
    • Percona Server 0 article
    • SingleStore 0 article
    • TiDB 0 article
    • Vitess 0 article
    Solutions
    • Support 24×7 MariaDB & MySQL emergencies
    • Observabilité SQL Monitoring, alerts, topology
    • Haute disponibilité Replication, failover, Galera
    • Disaster Recovery Backup, restore, RPO/RTO
    • Sécurité & conformité Audit, GDPR, SOC2
    • Migration & upgrade Zero downtime, pt-osc, gh-ost
  • Plans
  • Resources
    • Documentation Technical guides & API
    • FAQ 25 frequently asked questions
    • Testimonials Client feedback & use cases
    • Blog Articles & insights
    • Roadmap Upcoming features
    Areas of expertise
    • Observabilité SQL Monitoring, alerts, Dot3 topology
    • Haute disponibilité Replication, failover, Galera
    • Sécurité & conformité Audit, GDPR, SOC2, ISO 27001
    • Disaster Recovery Backup, restore, RPO/RTO
    • Performance & optimisation Digests, EXPLAIN, tuning
    • Migration & upgrade Zero downtime, pt-osc
    Quick links
    • GitHub Wiki 26 pages — install, engine, plugins
    • Source code Official GitHub repository
    • Support 24×7 MariaDB & MySQL emergencies
    • Book a demo 30 min — real architecture
  • Support 24×7
  • Book a demo
Book a demo
🇫🇷 FR Français 🇬🇧 EN English 🇵🇱 PL Polski 🇷🇺 RU Русский 🇨🇳 ZH 中文
← Back to blog

Automatically add MariaDB / MySQL servers to PmaControl via the webservice

Published on April 13, 2026 By Aurélien LEQUOY
pmacontrol rest-api automation devops webservice
Share X LinkedIn Facebook Email PDF
Automatically add MariaDB / MySQL servers to PmaControl via the webservice

Why automate server addition

When you're monitoring 5 MariaDB / MySQL servers, adding them manually to PmaControl is fine. At 50 or 200 servers, it no longer is.

PmaControl's REST API enables you to industrialise this process: a script, a CI/CD pipeline, or an orchestration tool (Ansible, Terraform) can create a monitored server in a single HTTP request.

Prerequisites

  • An active webservice account in PmaControl (created during installation via config.json)
  • Your PmaControl instance URL
  • Target client and environment must exist (create them first via the API if needed)

Main endpoint

POST /fr/api/config/servers
Content-Type: application/json

Authentication via the webservice account configured in configuration/webservice.config.php.

Payload for adding a server

{
  "id_client": 1,
  "id_environment": 1,
  "name": "prod-db-01",
  "display_name": "Production DB 01",
  "ip": "10.68.68.100",
  "hostname": "prod-db-01.internal",
  "login": "pmacontrol",
  "passwd": "SecurePassword123",
  "database": "information_schema",
  "port": 3306,
  "is_ssl": 0,
  "ssh_port": 22,
  "ssh_login": "pmacontrol",
  "is_sudo": 1,
  "is_root": 0,
  "is_monitored": 1,
  "is_proxy": 0,
  "is_vip": 0
}

Key fields

Field Description
id_client Client (organisation) identifier
id_environment Environment identifier (Production, Staging, etc.)
ip MySQL server access IP address
port MySQL port (3306 by default)
login / passwd MySQL credentials for data collection
is_monitored 1 = active monitoring, 0 = disabled
is_proxy 1 if ProxySQL/MaxScale (tests connection differently)
is_vip 1 if VIP/DNS entry (no direct connection, tracks redirection)

Create dependencies first

Before adding a server, the client and environment must exist.

Create a client

curl -s -X POST http://pmacontrol.local/fr/api/config/clients \
  -H "Content-Type: application/json" \
  -d '{"name": "68Koncept", "description": "Production infrastructure"}'

Create an environment

curl -s -X POST http://pmacontrol.local/fr/api/config/environments \
  -H "Content-Type: application/json" \
  -d '{"name": "Production", "description": "Live servers"}'

Add an SSH key

curl -s -X POST http://pmacontrol.local/fr/api/config/ssh-keys \
  -H "Content-Type: application/json" \
  -d '{"name": "deploy-key", "private_key": "-----BEGIN RSA PRIVATE KEY-----\n..."}'

Bulk addition script

#!/bin/bash
PMAC="http://pmacontrol.local"
CLIENT_ID=1
ENV_ID=1

SERVERS=(
  "prod-db-01:10.68.68.100:3306"
  "prod-db-02:10.68.68.101:3306"
  "prod-db-03:10.68.68.102:3306"
  "prod-proxy-01:10.68.68.200:6033"
)

for entry in "${SERVERS[@]}"; do
  IFS=: read -r name ip port <<< "$entry"
  is_proxy=0
  [[ "$name" == *proxy* ]] && is_proxy=1

  curl -s -X POST "$PMAC/fr/api/config/servers" \
    -H "Content-Type: application/json" \
    -d "{
      \"id_client\": $CLIENT_ID,
      \"id_environment\": $ENV_ID,
      \"name\": \"$name\",
      \"display_name\": \"$name\",
      \"ip\": \"$ip\",
      \"port\": $port,
      \"login\": \"pmacontrol\",
      \"passwd\": \"PmacMonitor2026\",
      \"database\": \"information_schema\",
      \"is_monitored\": 1,
      \"is_proxy\": $is_proxy,
      \"ssh_port\": 22,
      \"ssh_login\": \"pmacontrol\"
    }"
  echo " → $name added"
done

List existing servers

curl -s http://pmacontrol.local/fr/api/config/servers | jq '.[] | {id, name, ip, is_monitored}'

Update a server

PUT /fr/api/config/servers/{id}
curl -s -X PUT http://pmacontrol.local/fr/api/config/servers/5 \
  -H "Content-Type: application/json" \
  -d '{"is_monitored": 0}'

Delete a server

Deletion is a soft delete (is_deleted = 1). The server disappears from the interface but stays in the database:

curl -s -X DELETE http://pmacontrol.local/fr/api/config/servers/5

Tags for organising servers

Tags let you categorise servers (datacenter, role, version):

curl -s -X POST http://pmacontrol.local/fr/api/config/tags \
  -H "Content-Type: application/json" \
  -d '{"name": "dc-paris", "description": "Paris datacenter"}'

Verification after addition

After addition, PmaControl automatically starts collection if is_monitored = 1. Check in the interface:

  1. The server appears in Server > Main
  2. The Dot3 topology updates on the next cycle
  3. First metrics arrive within 60 seconds

OpenAPI specification

PmaControl exposes its full OpenAPI spec:

GET /fr/api/openApi

Usable with Swagger UI or to auto-generate SDK clients.

Conclusion

PmaControl's REST API turns server addition from a manual task into a scriptable, repeatable operation. Combined with Ansible or Terraform, it enables an Infrastructure-as-Code approach to MariaDB / MySQL monitoring.

Share X LinkedIn Facebook Email PDF
← Back to blog

Comments (0)

No comments yet.

Leave a comment

PmaControl
+33 6 63 28 27 47 contact@pmacontrol.com
Legal notice GitHub Contact
Do not wait for an incident to understand your architecture. © 2014-2026 PmaControl — 68Koncept