安裝 Apache Agent 的方式

  • 這是 SNMP Extend
  • Apache 要啟動 mod_status 模組
    vi /etc/httpd/conf.d/server-status.conf

    內容大概類似以下

    <Location "/server-status">
        SetHandler server-status
            Order deny,allow
            Deny from all
            Allow from localhost
            Allow from 192.168.1.132
    </Location>
  • 重新載入設定檔進行驗證
    systemctl reload httpd
    curl http://localhost/server-status

    如果沒問題顯示結果類似以下

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
    <html><head>
    <title>Apache Status</title>
    </head><body>
    <h1>Apache Server Status for localhost (via 192.168.1.132)</h1>
    
    <dl><dt>Server Version: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.2.31</dt>
    <dt>Server MPM: event</dt>
    <dt>Server Built: Aug  8 2019 11:41:18
    </dt></dl><hr/><dl>
    <dt>Current Time: Monday, 06-Jul-2020 11:13:36 CST</dt>
    <dt>Restart Time: Monday, 06-Jul-2020 10:57:54 CST</dt>
    :
    :
    <tr><td bgcolor="#ffffff">
    cache type: <b>SHMCB</b>, shared memory: <b>512000</b> bytes, current entries: <b>1</b><br>subcaches: <b>32</b>, indexes per subcache: <b>88</b><br>time left on oldest entries' objects: avg: <b>299</b> seconds, (range: 299...299)<br>index usage: <b>0%</b>, cache usage: <b>0%</b><br>total entries stored since starting: <b>1</b><br>total entries replaced since starting: <b>0</b><br>total entries expired since starting: <b>0</b><br>total (pre-expiry) entries scrolled out of the cache: <b>0</b><br>total retrieves since starting: <b>0</b> hit, <b>0</b> miss<br>total removes since starting: <b>0</b> hit, <b>0</b> miss<br></td></tr>
    </table>
    </body></html>
  • 至 Apache 主機內安裝
    wget https://raw.githubusercontent.com/librenms/librenms-agent/master/snmp/apache-stats.py -O /etc/snmp/apache-stats.py
    chmod +x /etc/snmp/apache-stats.py
    mkdir -p /var/cache/librenms/
    yum install python-urlgrabber python-pycurl
  • 確認 apache-stats.py 可以正確執行
    /etc/snmp/apache-stats.py

    如果正確執行應該可以看到類似的訊息

    1045
    28035072
    .642358
    1289
    .810706
    21749.5
    26827.8
    2
    98
    98
    0
    1
    1
    0
    0
    0
    0
    0
    0
    300
  • 修改 snmpd 設定
    vi /etc/snmp/snmpd.conf
    :
    extend apache /etc/snmp/apache-stats.py

    重新啟動 snmpd

    systemctl restart snmpd
  • tech/librenms/apache_agent.txt
  • 上一次變更: 2021/01/16 14:41
  • jonathan