iT邦幫忙

0

OCS Inventory Agent 無法傳送資料至Server

  • 分享至 

  • xImage

Server : CentOS Stream 8
PHP Version :7.2.24
Web Server :Apache/2.4.37 (centos) OpenSSL/1.1.1k mod_fcgid/2.3.9
Database Server : mod_perl/2.0.12 Perl/v5.26.3
Version OCSReports: MariaDB Server version 10.3.28-MariaDB
OCS Inventory : 2.11.1

Client : Windows 10
Agent : 2.10.1.0

以下為agent log資訊
Starting OCS Inventory Agent on Friday, July 07, 2023 03:23:44.
AGENT => Running OCS Inventory Agent Version 2.10.1.0
AGENT => Using OCS Inventory FrameWork Version 2.10.1.0
AGENT => Loading plug-in(s)
AGENT => Using network connection with Communication Server
AGENT => Using Communication Provider Version <2.10.1.0>
AGENT => Sending Prolog
AGENT => Prolog successfully sent
AGENT => Unloading communication provider
AGENT => Unloading plug-in(s)
AGENT => Execution duration: 00:00:00.

回到OCS系統看沒有任何資訊,而agent log卻沒error資訊。
想請問各位高手,問題出在哪裡呢? 謝謝!

圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 個回答

1
Ivan Cheng
iT邦新手 2 級 ‧ 2023-07-07 17:33:04
最佳解答

OCSNG 工作原理
OCS Server 接收 Agent 以 XML 格式發送的清單,並將數據存儲在 MySQL 資料庫中。主要由 Agent 透過 http 或 https 主動聯繫 Server,此過程中 Server 僅在進行偵聽。此外,軟體部署和 SNMP 掃描僅在 https 中進行。

OCS Server 主要由 4 個元件組成:

  • 資料庫伺服器:負責儲存資產訊息
  • 通訊伺服器:負責處理資料庫伺服器與代理程式之間的 HTTP 通訊
  • 管理控制台:允許管理員使用他們喜歡的瀏覽器查詢資料庫伺服器
  • 部屬伺服器:負責儲存所有的套件部屬組態

如果在安裝資料庫的時候沒有使用預設的密碼,將會導致通訊伺服器在接收到代理程式的資料時無法寫入資料庫。

Service encounter error <OCS Inventory Agent encounter an error (exit code is 4 => Failed to talk with Communication Server)>.

編輯 z-ocsinventory-server.conf

sudo vi /etc/apache2/conf-enabled/z-ocsinventory-server.conf 

把 OCS_DB_PWD 改成您建立用戶時所填寫的密碼

<IfModule mod_perl.c>

  # Which version of mod_perl we are using
  # For mod_perl <= 1.999_21, replace 2 by 1
  # For mod_perl > 1.999_21, replace 2 by 2
  PerlSetEnv OCS_MODPERL_VERSION 2

  # Master Database settings
  # Replace localhost by hostname or ip of MySQL server for WRITE
  PerlSetEnv OCS_DB_HOST localhost
  # Replace 3306 by port where running MySQL server, generally 3306
  PerlSetEnv OCS_DB_PORT 3306
  # Name of database
  PerlSetEnv OCS_DB_NAME ocsweb
  PerlSetEnv OCS_DB_LOCAL ocsweb
  # User allowed to connect to database
  PerlSetEnv OCS_DB_USER ocs
  # Password for user
  PerlSetVar OCS_DB_PWD ocs

記得重啟 Apache 伺服器

sudo systemctl reload apache2

可以到 dbconfig.inc.php 查看是否生效

cat /usr/share/ocsinventory-reports/ocsreports/dbconfig.inc.php
<?php
define("DB_NAME", "ocsweb");
define("SERVER_READ","localhost");
define("SERVER_WRITE","localhost");
define("SERVER_PORT","3306");
define("COMPTE_BASE","ocs");
define("PSWD_BASE","your_ocs_password");
define("ENABLE_SSL","");
define("SSL_MODE","");
define("SSL_KEY","");
define("SSL_CERT","");
define("CA_CERT","");
?>

若還是有問題的話,建議您先考慮使用 2.9 的代理程式測看看(記得勾選 Enable verbose log)。

以下是我之前寫的文章,可以參考看看。

  1. 如何在 Ubuntu 20.04 安裝 OCS Inventory 資產管理系統
  2. 如何透過 OCS Inventory 代理程式來蒐集 Windows 設備的資訊
  3. 了解 OCS Inventory 的例行性工作排程 Crontab
看更多先前的回應...收起先前的回應...

Ivan大 您好,
您的文章對我很有幫助,原來我再安裝Agent時,Url那部份/ocsinentory,我改成reports。修改後,控制台能抓到agent數量,但點選All computers沒有任何資訊,過了週末兩天,依然沒有資訊,請問會是什麼問題呢?

我沒遇過 All computers 空白的問題

重啟一下 Client 的 OCS Inventory Service,檢查一下 Server 跟 Client 的 Log。

  • /var/log/ocsinventory-server/activity.log
  • C:\ProgramData\OCS Inventory NG\Agent\OCSInventory

正常來說你只會遇到 Inventory 的 All software 是空白的問題,上方的參考連結幫你補上相關文章了。

重啟client端後,看其log資訊,是有幾條錯誤訊息。
1.WARNING * INVENTORY => Failed to retrieve sound devices
2.WARNING * INVENTORY => Failed to retrieve modems
3.WARNING * EXECUTABLE PLUGIN => Plugin <C:\Program Files\OCS Inventory Agent\plugins\Saas.ps1> does not produce any output!

而Server端的activity.log則停留在昨天
目前控制台畫面如下
https://ithelp.ithome.com.tw/upload/images/20230711/200444655HNUoMI8p8.jpg

從你的控制台看起來資料有進來,先嘗試使用無痕瀏覽器登入看看。

我們可以到資料庫驗證資料是否存在

sudo mysql
MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| ocsweb             |
| performance_schema |
+--------------------+
4 rows in set (0.002 sec)

MariaDB [(none)]> use ocsweb;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed

透過下列語法,確認資料表內有您的 Client。

MariaDB [ocsweb]> select * from hardware;

右上方的設定,點選 DEBUG。
https://ithelp.ithome.com.tw/upload/images/20230711/20159730rWmwSuMk6H.png

Switch to: DEBUG,OK。
再回到 All computers 查看是否有可用的訊息

先謝謝Ivan大的回覆。
資料庫裡面是有資料的。用無痕方式,也照您說的使用Debug模式,但依然沒資料顯示出來。

我要發表回答

立即登入回答