Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 28 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,25 +193,46 @@

**兼容性**:Zabbix 6.0.x, 7.0.x, 7.4.x, 8.0.x

### 9. Zabbix IPAM

**简介**:用于集中管理 IPv4 地址段并执行异步 ICMP 存活扫描的 Zabbix 前端模块,可按主机接口 IP 自动关联 Zabbix 主机。

**功能特性**:

- 支持 CIDR 和 IPv4 起止地址格式,单个地址段最多 65,536 个地址
- 基于 `fping` 的 ICMP 存活扫描,不探测 TCP 端口
- 大网段自动分片,PHP CLI 后台执行,支持 `pcntl` 多进程
- 支持手动扫描与 crontab 定时扫描,并实时显示任务进度
- IP 使用矩阵、地址明细、主机关联、筛选与分页
- 支持中英文界面国际化

![1](zabbix_ipam/images/1.png)
![2](zabbix_ipam/images/2.png)
![3](zabbix_ipam/images/3.png)

**文档链接**:[zabbix_ipam/README.md](./zabbix_ipam/README.md)([English](./zabbix_ipam/README_en.md))

**兼容性**:Zabbix 6.0.x, 7.0.x, 7.4.x, 8.0.x

## 安装说明

### 方式一:下载 Releases 压缩包(适合生产部署,按需选择)

Releases 页面提供两种压缩包,无需安装 git:

- **整体打包压缩包**:`zabbix_modules-<版本号>.tar.gz`(包含所有模块,版本号格式:`模块数量.大版本.小版本`,如 `8.2.0`)
- **整体打包压缩包**:`zabbix_modules-<版本号>.tar.gz`(包含所有模块,版本号格式:`模块数量.大版本.小版本`,如 `13.2.0`)
- **单模块压缩包**:`zabbix_<模块名>-<版本号>.tar.gz`(按需下载单个模块)

#### 选项 A:下载所有模块整体压缩包

1. 前往 [Releases 页面](https://github.com/X-Mars/zabbix_modules/releases),下载 `zabbix_modules-<版本号>.tar.gz` 文件(如 `zabbix_modules-8.2.0.tar.gz`)
1. 前往 [Releases 页面](https://github.com/X-Mars/zabbix_modules/releases),下载 `zabbix_modules-<版本号>.tar.gz` 文件(如 `zabbix_modules-13.2.0.tar.gz`)
2. 上传到 Zabbix 服务器并解压到模块目录:

```bash
# Zabbix 6.0 / 7.0
tar -xzf zabbix_modules-<版本号>.tar.gz -C /usr/share/zabbix/modules/

# Zabbix 7.2+ / 7.4 / 8.0
# Zabbix 6.4 / 7.2 / 7.4 / 8.0
tar -xzf zabbix_modules-<版本号>.tar.gz -C /usr/share/zabbix/ui/modules/
```

Expand All @@ -223,7 +244,7 @@ for mod in /usr/share/zabbix/modules/zabbix_*/; do
done
```

如果使用 Zabbix 7.0+ 或 8.0+,则无需修改,保持默认值即可。
如果使用 Zabbix 6.4、7.0+ 或 8.0+,则无需修改,保持默认值即可。

#### 选项 B:下载单个模块

Expand All @@ -244,7 +265,7 @@ tar -xzf zabbix_<模块名>-<版本号>.tar.gz -C /usr/share/zabbix/ui/modules/
sed -i 's/"manifest_version": 2.0/"manifest_version": 1.0/' /usr/share/zabbix/modules/zabbix_<模块名>/manifest.json
```

如果使用 Zabbix 7.0+ 或 8.0+,则无需修改,保持默认值即可。
如果使用 Zabbix 6.4、7.0+ 或 8.0+,则无需修改,保持默认值即可。

### 方式二:git clone 直接部署(适合开发/跟踪更新)

Expand Down Expand Up @@ -276,7 +297,7 @@ sed -i 's/"manifest_version": 2.0/"manifest_version": 1.0/' /usr/share/zabbix/mo
sed -i 's/"manifest_version": 2.0/"manifest_version": 1.0/' /usr/share/zabbix/modules/zabbix_reports/manifest.json
```

如果使用 Zabbix 7.0+ 或 8.0+,则无需修改,保持默认值即可。
如果使用 Zabbix 6.4、7.0+ 或 8.0+,则无需修改,保持默认值即可。

### 启用模块

Expand All @@ -302,6 +323,7 @@ sed -i 's/"manifest_version": 2.0/"manifest_version": 1.0/' /usr/share/zabbix/mo
- **资产记录 → JumpServer** (JumpServer 同步)
- **Users → IM同步助手** (IM 同步 / 同步设置)
- **数据采集 → 主机批量导入** (基于源主机批量克隆主机)
- **Inventory → IPAM** (IP 管理 / IP 详情 / 任务管理)

### 单独安装模块

Expand Down
67 changes: 54 additions & 13 deletions README_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ This repository contains a collection of independent Zabbix frontend modules tha
![1](zabbix_reports/images/1.png)
![2](zabbix_reports/images/2.png)

- **Docs**: [zabbix_reports/README.md](./zabbix_reports/README.md)
- **Docs**: [zabbix_reports/README_en.md](./zabbix_reports/README_en.md)

### 2. Zabbix CMDB

Expand All @@ -36,7 +36,7 @@ This repository contains a collection of independent Zabbix frontend modules tha
![2](zabbix_cmdb/images/2.png)
![3](zabbix_cmdb/images/3.jpg)

- **Docs**: [zabbix_cmdb/README.md](./zabbix_cmdb/README.md)
- **Docs**: [zabbix_cmdb/README_en.md](./zabbix_cmdb/README_en.md)

### 3. Zabbix Graph Trees

Expand All @@ -46,7 +46,7 @@ This repository contains a collection of independent Zabbix frontend modules tha
![1](zabbix_graphtrees/images/1.png)
![2](zabbix_graphtrees/images/2.png)

- **Docs**: [zabbix_graphtrees/README.md](./zabbix_graphtrees/README.md)
- **Docs**: [zabbix_graphtrees/README_en.md](./zabbix_graphtrees/README_en.md)

### 4. Zabbix Rack

Expand All @@ -57,7 +57,7 @@ This repository contains a collection of independent Zabbix frontend modules tha
![2](zabbix_rack/images/2.png)
![3](zabbix_rack/images/3.png)

- **Docs**: [zabbix_rack/README.md](./zabbix_rack/README.md)
- **Docs**: [zabbix_rack/README_en.md](./zabbix_rack/README_en.md)

### 5. Zabbix SNMP

Expand All @@ -68,7 +68,7 @@ This repository contains a collection of independent Zabbix frontend modules tha
![2](zabbix_snmp/images/2.png)
![3](zabbix_snmp/images/3.png)

- **Docs**: [zabbix_snmp/README.md](./zabbix_snmp/README.md)
- **Docs**: [zabbix_snmp/README_en.md](./zabbix_snmp/README_en.md)

### 6. Zabbix JumpServer

Expand All @@ -77,18 +77,18 @@ This repository contains a collection of independent Zabbix frontend modules tha

![1](zabbix_jumpserver/images/1.png)

- **Docs**: [zabbix_jumpserver/README.md](./zabbix_jumpserver/README.md)
- **Docs**: [zabbix_jumpserver/README_en.md](./zabbix_jumpserver/README_en.md)

### 7. IM Sync Assistant

- **Purpose**: Sync **WeCom**, **Feishu**, and **DingTalk** org structures into Zabbix **user groups**, and match or create Zabbix users with group membership.
- **Features**: multi-platform support; web UI for sync credentials (**Users → Sync Settings**, one active setting at a time); department sync with optional full-path group names; user sync with match/auto-create (12-char password shown once in results); DingTalk users without mobile get pinyin usernames from display name; preview before sync; bilingual UI.

![1](images/1.png)
![2](images/2.png)
![3](images/3.png)
![1](zabbix_im/images/1.png)
![2](zabbix_im/images/2.png)
![3](zabbix_im/images/3.png)

- **Docs**: [zabbix_im/README_en.md](./zabbix_im/README_en.md)([中文](./zabbix_im/README.md))
- **Docs**: [zabbix_im/README_en.md](./zabbix_im/README_en.md) ([中文](./zabbix_im/README.md))

### 8. Zabbix Clonehosts

Expand All @@ -100,20 +100,56 @@ This repository contains a collection of independent Zabbix frontend modules tha
![3](zabbix_clonehosts/images/image-2.png)
![4](zabbix_clonehosts/images/image-3.png)

- **Docs**: [zabbix_clonehosts/README_en.md](./zabbix_clonehosts/README_en.md)([中文](./zabbix_clonehosts/README.md))
- **Docs**: [zabbix_clonehosts/README_en.md](./zabbix_clonehosts/README_en.md) ([中文](./zabbix_clonehosts/README.md))

### 9. Zabbix IPAM

- **Purpose**: Centrally manage IPv4 ranges, run asynchronous ICMP availability scans, and associate addresses with Zabbix hosts by interface IP.
- **Features**: CIDR and start-end ranges up to 65,536 addresses; `fping`-based ICMP-only scans; automatic sharding and optional `pcntl` workers; manual and cron scans; live task progress; address matrix, filtering, pagination, and host links; bilingual UI.

![1](zabbix_ipam/images/1.png)
![2](zabbix_ipam/images/2.png)
![3](zabbix_ipam/images/3.png)

- **Docs**: [zabbix_ipam/README_en.md](./zabbix_ipam/README_en.md) ([中文](./zabbix_ipam/README.md))

### 10. Zabbix LLDP Topology

- **Purpose**: Visualize LLDP neighbor relationships from Zabbix LLDP discovery items.
- **Features**: filter hosts/groups by **Lldp Discovery** template; group/host dropdowns with all-groups/all-hosts defaults; on-demand query loading `lldp.remote.info[*]` values; SVG circles and lines (local left, remote right); hover tooltips with ports and update time; bilingual UI.

- **Docs**: [zabbix_lldp/README_en.md](./zabbix_lldp/README_en.md) ([中文](./zabbix_lldp/README.md))

### 11. Zabbix Clouds

- **Purpose**: Synchronize Alibaba Cloud ECS, Huawei Cloud ECS, and Tencent Cloud CVM instances to Zabbix.
- **Features**: preview-before-sync workflow; idempotent matching through the `cloud_instance_id` tag; automatic `Clouds/{Provider}/{Region}` host groups; soft marking for cloud-deleted managed hosts; cloud account configuration.
- **Docs**: [zabbix_clouds/README_en.md](./zabbix_clouds/README_en.md) ([中文](./zabbix_clouds/README.md))

### 12. Zabbix Rightsizing

- **Purpose**: Generate CPU and memory sizing recommendations from Zabbix data over a selected period.
- **Features**: trends-first analysis with history fallback; CPU and memory recommendations; result export; configurable analysis parameters; bilingual UI.
- **Docs**: [zabbix_rightsizing/README_en.md](./zabbix_rightsizing/README_en.md) ([中文](./zabbix_rightsizing/README.md))

### 13. Zabbix Switch Backup

- **Purpose**: List, preview, and download switch configuration backup files from Zabbix.
- **Features**: file metadata and newest-first ordering; text preview and downloads; traversal and symlink protection; role-based access controls; bilingual UI.
- **Docs**: [zabbix_switch_backup/README_en.md](./zabbix_switch_backup/README_en.md) ([中文](./zabbix_switch_backup/README.md))
Comment on lines +116 to +139

## Installation

### Option 1: Download Release packages (for production, choose what you need)

The Releases page offers two types of packages — no git required:

- **All-in-one package**: `zabbix_modules-<version>.tar.gz` (includes all modules; version format: `module_count.major.minor`, e.g., `8.2.0`)
- **All-in-one package**: `zabbix_modules-<version>.tar.gz` (includes all modules; version format: `module_count.major.minor`, e.g., `13.2.0`)
- **Single-module package**: `zabbix_<module>-<version>.tar.gz` (download only the modules you need)
Comment on lines +147 to 148

#### Option A: Download the all-in-one package

1. Go to the [Releases page](https://github.com/X-Mars/zabbix_modules/releases) and download the `zabbix_modules-<version>.tar.gz` file (e.g., `zabbix_modules-8.2.0.tar.gz`).
1. Go to the [Releases page](https://github.com/X-Mars/zabbix_modules/releases) and download the `zabbix_modules-<version>.tar.gz` file (e.g., `zabbix_modules-13.2.0.tar.gz`).
2. Upload to the Zabbix server and extract to the modules directory:

```bash
Expand Down Expand Up @@ -201,6 +237,11 @@ After enabling and refreshing the UI, the modules appear under the following men
- **Inventory → JumpServer**
- **Users → IM Sync Assistant** (IM Sync / Sync Settings)
- **Data collection → Host Batch Import** (batch clone hosts from a source host)
- **Monitoring → LLDP Topology** (LLDP neighbor topology)
- **Inventory → IPAM** (IP Management / IP Details / Task Management)
- **Inventory → Cloud Sync** (Cloud Hosts / Cloud Settings)
- **Inventory → Rightsizing** (resource sizing recommendations)
- **Inventory → Switch Backup** (switch configuration backups)

Each module contains its own README with specific installation and usage details.

Expand Down
70 changes: 65 additions & 5 deletions zabbix_ipam/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

## 描述

这是一个 Zabbix 前端 IP 地址管理模块,用于集中维护 IPv4 地址段、执行异步 ICMP 存活扫描,并根据 Zabbix 主机接口 IP 自动建立主机关联。模块在 Zabbix Web 的资产记录菜单下新增“IP 管理”菜单,包含“IP 管理”“IP 详情”和“任务管理”三个页面。
这是一个 Zabbix 前端 IP 地址管理模块,用于集中维护 IPv4 地址段、执行异步 ICMP 存活扫描,并根据 Zabbix 主机接口 IP 自动建立主机关联。模块在 Zabbix Web 的 **Inventory(资产记录)→ IPAM** 下提供“IP 管理”“IP 详情”和“任务管理”三个页面。

扫描仅使用 ICMP,不会连接目标 TCP 端口。大网段会自动分片,并由后台 PHP CLI 任务执行,避免阻塞 Zabbix Web 请求。

Expand All @@ -41,6 +41,25 @@
- **响应式设计**:取消固定最大宽度,适配普通、宽屏和窄屏浏览器
- **安全限制**:仅 Zabbix 管理员可访问,输入均经过 IPv4 和数值校验

## 工作方式

```text
IP 管理页面 / crontab
↓
创建地址段扫描任务
↓
PHP CLI 后台进程
↓
按 64 个地址分片 → fping ICMP 探测
↓
JSON 结果与任务进度 → IP 矩阵 / IP 详情 / 任务管理
```

- 在 Web 页面点击“开始扫描”时,模块通过 PHP `exec()` 和 `nohup` 启动独立的 PHP CLI 进程。
- 定时扫描由 `cli/scan_cron.php` 直接执行;每次 cron 运行都会为所有已启用且没有待处理/运行中任务的地址段创建扫描任务。
- CLI 环境支持 `pcntl_fork()` 时最多并行运行 4 个工作进程;不支持时自动串行执行。
- 扫描状态和结果以 JSON 文件保存,写入时使用文件锁及临时文件原子替换,便于 Web 与 cron 同时访问。

## 安装步骤

### 安装模块
Expand All @@ -64,7 +83,7 @@ sed -i 's/"manifest_version": 2.0/"manifest_version": 1.0/' zabbix_ipam/manifest

### 配置目录权限

运行 Web 服务和 cron 的用户必须能够读写 `data/`、`data/scan_tasks/` 和 `data/results/`。
运行 Web 服务和 cron 的用户都必须能够读写 `data/`、`data/scan_tasks/` 和 `data/results/`。建议使用同一用户;如使用不同用户,请通过共同用户组授予读写权限。以下命令中的路径应替换为模块的实际安装路径。

```bash
# Debian / Ubuntu 示例
Expand All @@ -86,7 +105,21 @@ apt install fping php-cli php-pcntl
dnf install fping php-cli php-process
```

`php-pcntl` 或 `php-process` 用于多进程扫描;未安装 `pcntl` 时会自动降级为后台串行扫描。PHP CLI 和 `fping` 是后台扫描的必要依赖。
`php-pcntl` 或 `php-process` 用于多进程扫描;未安装 `pcntl` 时会自动降级为后台串行扫描。PHP CLI 和 `fping` 是扫描的必要依赖。

安装后建议使用 Web 服务用户检查运行环境:

```bash
# Debian / Ubuntu
sudo -u www-data /usr/bin/php -r 'echo PHP_SAPI, PHP_EOL;'
sudo -u www-data /usr/bin/fping -c 1 -t 350 127.0.0.1

# RHEL / Rocky Linux
sudo -u apache /usr/bin/php -r 'echo PHP_SAPI, PHP_EOL;'
sudo -u apache /usr/sbin/fping -c 1 -t 350 127.0.0.1
```

如需从 Web 页面手动启动扫描,请确认 PHP 未禁用 `exec`,并允许 Web 服务用户运行 PHP CLI。若安全策略禁止 `exec`,仍可仅使用下文的 cron 定时扫描入口。

### 启用模块

Expand All @@ -97,13 +130,30 @@ dnf install fping php-cli php-process

## 定时扫描

`cli/scan_cron.php` 是唯一定时扫描入口,crontab 的执行频率就是扫描间隔。以下示例每 5 分钟扫描一次所有已启用的 IP 段;已有待处理或运行中的任务不会被重复创建。
`cli/scan_cron.php` 是唯一定时扫描入口,crontab 的执行频率就是扫描间隔。以下示例每 5 分钟扫描一次所有已启用的 IP 段;已有待处理或运行中的任务不会被重复创建。请勿使用 `root` 运行扫描。

写入 `/etc/cron.d/zabbix-ipam` 时需要包含运行用户:

```cron
*/5 * * * * apache /usr/bin/php /usr/share/zabbix/modules/zabbix_ipam/cli/scan_cron.php >> /var/log/zabbix/ipam-cron.log 2>&1
```

Debian / Ubuntu 通常将运行用户改为 `www-data`。任务状态文件和工作锁会避免同一 IP 段被重复提交。
Debian / Ubuntu 通常将运行用户改为 `www-data`。如果使用 `crontab -u apache -e` 或 `crontab -u www-data -e`,则不要在表达式中再次写用户名:

```cron
*/5 * * * * /usr/bin/php /usr/share/zabbix/modules/zabbix_ipam/cli/scan_cron.php >> /var/log/zabbix/ipam-cron.log 2>&1
```

Zabbix 7.2+ / 7.4 / 8.0 的脚本路径通常是 `/usr/share/zabbix/ui/modules/zabbix_ipam/cli/scan_cron.php`。请确保日志目录也允许对应用户写入;任务状态文件和工作锁会避免同一 IP 段被重复提交。

### 手动验证 cron 入口

```bash
# 按实际环境选择 apache 或 www-data,并替换模块路径
sudo -u apache /usr/bin/php /usr/share/zabbix/modules/zabbix_ipam/cli/scan_cron.php
```

命令无输出且任务页出现新任务通常表示执行成功;错误信息会输出到标准错误流。

## 页面说明

Expand All @@ -119,10 +169,20 @@ Debian / Ubuntu 通常将运行用户改为 `www-data`。任务状态文件和
- **地址限制**:仅支持 IPv4,单个 IP 段最多 65,536 个地址。
- **系统权限**:Zabbix Web 用户和 cron 用户必须能够写入模块 `data/` 目录。
- **ICMP 权限**:请确保服务器防火墙允许 ICMP,并允许 `fping` 正常运行。
- **命令执行**:Web 手动扫描依赖 PHP `exec()`;使用 cron 时不依赖 Web 请求启动后台进程。
- **性能考虑**:大网段会分片处理;并行工作进程默认最多为 4 个。
- **主机匹配**:关联结果来自当前用户有权访问的 Zabbix 主机接口数据。
- **数据存储**:当前使用 JSON 文件,生产环境请定期备份 `data/` 目录。

## 故障排查

- **点击开始扫描后立即失败**:检查 PHP CLI 是否存在、PHP `exec()` 是否被禁用,以及 `data/scan_tasks/` 是否可写。
- **所有地址均显示不可达**:以 Web/cron 用户直接运行 `fping`,确认安装路径、执行权限、防火墙和 ICMP 策略。模块会依次查找 `/usr/sbin/fping`、`/usr/bin/fping` 和 `/sbin/fping`。
- **任务一直处于待处理状态**:检查 `data/scan_tasks/<任务 ID>.log`、PHP CLI 路径和 SELinux/AppArmor 限制。
- **cron 没有创建任务**:确认地址段已启用,并检查是否已经存在同一地址段的 `pending` 或 `running` 任务。
- **页面无法保存地址段**:检查 `data/` 所有权与权限;模块需要创建锁文件和临时 JSON 文件。
- **没有关联到主机**:确认 Zabbix 主机接口使用的是相同 IPv4 地址,并确认当前登录用户有权查看该主机。

## 开发

插件基于 Zabbix 模块框架开发。主要文件结构:
Expand Down
Loading