qidao123.com技术社区-IT企服评测·应用市场

标题: SolarWinds监控体系在Windows Server 2022上的完整安装与配置指南 [打印本页]

作者: 曂沅仴駦    时间: 2025-4-17 05:29
标题: SolarWinds监控体系在Windows Server 2022上的完整安装与配置指南
第一部分:体系预备与SolarWinds安装

1. 体系预备

1.1 安装Windows Server 2022

1.2 体系更新与基础配置

powershell 
  1. # 以管理员身份打开PowerShell执行以下命令
  2. # 检查并安装Windows更新
  3. Install-Module -Name PSWindowsUpdate -Force
  4. Import-Module PSWindowsUpdate
  5. Get-WindowsUpdate -AcceptAll -Install -AutoReboot
  6. # 启用远程桌面
  7. Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server' -Name "fDenyTSConnections" -Value 0
  8. Enable-NetFirewallRule -DisplayGroup "远程桌面"
  9. # 设置服务器静态IP(根据实际网络调整)
  10. New-NetIPAddress -IPAddress "192.168.1.100" -PrefixLength 24 -DefaultGateway "192.168.1.1" -InterfaceIndex (Get-NetAdapter).InterfaceIndex
  11. Set-DnsClientServerAddress -InterfaceIndex (Get-NetAdapter).InterfaceIndex -ServerAddresses ("8.8.8.8", "8.8.4.4")
  12. # 更改计算机名并重启
  13. Rename-Computer -NewName "SOLARWINDS-MONITOR" -Restart
复制代码
2. 安装SQL Server 2019(SolarWinds依赖)

2.1 下载SQL Server 2019

powershell 
  1. # 下载SQL Server 2019 Developer Edition(免费用于开发测试)
  2. $url = "https://go.microsoft.com/fwlink/?linkid=866662"
  3. $output = "$env:USERPROFILE\Downloads\SQLServer2019-SSEI-Dev.exe"
  4. Invoke-WebRequest -Uri $url -OutFile $output
  5. # 启动安装程序
  6. Start-Process -FilePath $output
复制代码
2.2 图形界面安装步调

2.3 验证SQL Server安装

powershell 
  1. # 检查SQL Server服务状态
  2. Get-Service -Name "MSSQL`$SQLEXPRESS"
  3. # 应该看到状态为"Running"
复制代码
3. 安装SolarWinds Orion

3.1 下载SolarWinds Orion安装包

powershell 
  1. # 从SolarWinds官网下载评估版(需要注册)
  2. # 以下为示例命令,实际URL需从官网获取
  3. $url = "https://downloads.solarwinds.com/solarwinds/Release/Orion/2020.2.1/OrionInstaller.exe"
  4. $output = "$env:USERPROFILE\Downloads\OrionInstaller.exe"
  5. Invoke-WebRequest -Uri $url -OutFile $output
  6. # 启动安装程序
  7. Start-Process -FilePath $output
复制代码
3.2 图形界面安装步调

第二部分:添加网络装备监控

1. 配置SNMP服务(用于当地测试)

powershell 
  1. # 安装SNMP服务
  2. Install-WindowsFeature -Name SNMP-Service
  3. # 配置SNMP团体字符串
  4. reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SNMP\Parameters\ValidCommunities" /v public /t REG_DWORD /d 4 /f
  5. # 允许来自任何主机的SNMP查询
  6. reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SNMP\Parameters\PermittedManagers" /v 1 /t REG_SZ /d "*" /f
  7. # 重启SNMP服务
  8. Restart-Service -Name SNMP
复制代码
2. 添加思科装备

3. 添加华为装备

4. 添加华三装备

5. 添加锐捷装备

第三部分:告警配置

1. 配置邮件关照

2. 配置短信关照(以Twilio为例)

powershell 
  1. param($Subject, $Message, $Recipients)
  2. $AccountSid = "YOUR_TWILIO_ACCOUNT_SID"
  3. $AuthToken = "YOUR_TWILIO_AUTH_TOKEN"
  4. $FromNumber = "YOUR_TWILIO_PHONE_NUMBER"
  5. $TwilioApiUrl = "https://api.twilio.com/2010-04-01/Accounts/$AccountSid/Messages.json"
  6. foreach ($recipient in $Recipients) {
  7.     $Body = @{
  8.         From = $FromNumber
  9.         To = $recipient
  10.         Body = "$Subject`n$Message"
  11.     }
  12.    
  13.     $Bytes = [System.Text.Encoding]::UTF8.GetBytes("$AccountSid`:$AuthToken")
  14.     $Base64 = [System.Convert]::ToBase64String($Bytes)
  15.    
  16.     $Headers = @{
  17.         Authorization = "Basic $Base64"
  18.     }
  19.    
  20.     try {
  21.         Invoke-RestMethod -Uri $TwilioApiUrl -Method Post -Body $Body -Headers $Headers
  22.     } catch {
  23.         Write-Error "Failed to send SMS to $recipient: $_"
  24.     }
  25. }
复制代码
3. 创建CPU使用率告警

4. 创建接口丢包告警

5. 创建装备宕机告警

第四部分:体系测试

1. 装备监控测试

powershell 
  1. # 测试思科设备SNMP可达性
  2. Test-NetConnection -ComputerName <思科设备IP> -Port 161
  3. # 使用SNMPWalk测试(需安装SNMP工具)
  4. snmpwalk -v 2c -c public <思科设备IP> .1.3.6.1.2.1.1.1.0
复制代码
2. 告警触发测试

powershell 
  1. # 模拟高CPU负载(在目标设备上)
  2. # 对于Windows设备:
  3. Start-Job -ScriptBlock { while($true) { } }
  4. # 对于Linux设备(通过SSH):
  5. Invoke-Command -ComputerName <Linux设备IP> -ScriptBlock { while true; do :; done } -Credential (Get-Credential)
复制代码
第五部分:Python一键部署脚本

创建deploy_solarwinds.py文件:
python 
  1. import os
  2. import subprocess
  3. import time
  4. import requests
  5. import winreg
  6. import ctypes
  7. def run_powershell(cmd, admin=False):
  8.     if admin:
  9.         ctypes.windll.shell32.ShellExecuteW(None, "runas", "powershell.exe", f"-Command {cmd}", None, 1)
  10.     else:
  11.         subprocess.run(["powershell", "-Command", cmd], check=True)
  12. def install_prerequisites():
  13.     print("安装系统更新和必要组件...")
  14.     commands = [
  15.         "Install-Module -Name PSWindowsUpdate -Force -Confirm:$false",
  16.         "Import-Module PSWindowsUpdate",
  17.         "Get-WindowsUpdate -AcceptAll -Install -AutoReboot",
  18.         "Install-WindowsFeature -Name SNMP-Service",
  19.         "Set-ItemProperty -Path 'HKLM:\\System\\CurrentControlSet\\Control\\Terminal Server' -Name 'fDenyTSConnections' -Value 0",
  20.         "Enable-NetFirewallRule -DisplayGroup '远程桌面'"
  21.     ]
  22.     for cmd in commands:
  23.         try:
  24.             run_powershell(cmd, admin=True)
  25.         except subprocess.CalledProcessError as e:
  26.             print(f"执行命令失败: {cmd}\n错误: {e}")
  27. def configure_snmp():
  28.     print("配置SNMP服务...")
  29.     try:
  30.         # 设置SNMP团体字符串
  31.         key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE,
  32.                             r"SYSTEM\CurrentControlSet\Services\SNMP\Parameters\ValidCommunities",
  33.                             0, winreg.KEY_SET_VALUE)
  34.         winreg.SetValueEx(key, "public", 0, winreg.REG_DWORD, 4)
  35.         winreg.CloseKey(key)
  36.         
  37.         # 允许所有管理器
  38.         key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE,
  39.                             r"SYSTEM\CurrentControlSet\Services\SNMP\Parameters\PermittedManagers",
  40.                             0, winreg.KEY_SET_VALUE)
  41.         winreg.SetValueEx(key, "1", 0, winreg.REG_SZ, "*")
  42.         winreg.CloseKey(key)
  43.         
  44.         # 重启SNMP服务
  45.         run_powershell("Restart-Service -Name SNMP", admin=True)
  46.     except Exception as e:
  47.         print(f"配置SNMP失败: {e}")
  48. def download_and_install(url, file_name, install_args=None):
  49.     print(f"下载并安装 {file_name}...")
  50.     try:
  51.         # 下载文件
  52.         download_path = os.path.join(os.environ["USERPROFILE"], "Downloads", file_name)
  53.         response = requests.get(url, stream=True)
  54.         with open(download_path, "wb") as f:
  55.             for chunk in response.iter_content(chunk_size=8192):
  56.                 f.write(chunk)
  57.         
  58.         # 安装
  59.         if install_args:
  60.             subprocess.run([download_path] + install_args, check=True)
  61.         else:
  62.             subprocess.run([download_path], check=True)
  63.     except Exception as e:
  64.         print(f"安装 {file_name} 失败: {e}")
  65. def configure_solarwinds():
  66.     print("配置SolarWinds Orion...")
  67.     # 这里可以添加自动配置SolarWinds的代码
  68.     # 实际生产环境中可能需要使用SolarWinds API或CLI工具
  69.     print("请手动完成SolarWinds的初始配置:")
  70.     print("1. 访问 http://localhost:8787")
  71.     print("2. 使用admin账户登录")
  72.     print("3. 完成初始向导")
  73. def main():
  74.     print("=== SolarWinds监控系统一键部署脚本 ===")
  75.    
  76.     # 1. 安装系统更新和必要组件
  77.     install_prerequisites()
  78.    
  79.     # 2. 配置SNMP服务
  80.     configure_snmp()
  81.    
  82.     # 3. 下载并安装SQL Server 2019
  83.     sql_url = "https://go.microsoft.com/fwlink/?linkid=866662"
  84.     download_and_install(sql_url, "SQLServer2019-SSEI-Dev.exe")
  85.    
  86.     # 4. 下载并安装SolarWinds Orion
  87.     # 注意:需要替换为实际的SolarWinds下载URL
  88.     sw_url = "https://downloads.solarwinds.com/solarwinds/Release/Orion/2020.2.1/OrionInstaller.exe"
  89.     download_and_install(sw_url, "OrionInstaller.exe")
  90.    
  91.     # 5. 配置SolarWinds
  92.     configure_solarwinds()
  93.    
  94.     print("部署完成!")
  95. if __name__ == "__main__":
  96.     main()
复制代码
使用分析

留意事项

 
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。




欢迎光临 qidao123.com技术社区-IT企服评测·应用市场 (https://dis.qidao123.com/) Powered by Discuz! X3.4