顯示具有 php 標籤的文章。 顯示所有文章
顯示具有 php 標籤的文章。 顯示所有文章

2024/11/04

almalinux 8 預設安裝的php 7.2

記錄一下升級到 php 8.2的步驟

看一下目前使用的版本及系統支援的版本

dnf module list php

Last metadata expiration check: 2:45:04 ago on Mon 04 Nov 2024 09:34:39 AM CST.
AlmaLinux 8 - AppStream
Name     Stream         Profiles                      Summary                  
php      7.2 [d][e]     common [d], devel, minimal    PHP scripting language   
php      7.3            common [d], devel, minimal    PHP scripting language   
php      7.4            common [d], devel, minimal    PHP scripting language   
php      8.0            common [d], devel, minimal    PHP scripting language   
php      8.2            common [d], devel, minimal    PHP scripting language 

Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled

先reset 目前安裝的版本

dnf module reset php -y

再enable php 8.2

dnf module enable php:8.2 -y

接下來 dnf -y update 安裝所有 php8.2 相關套件

確認是否安裝完成

dnf module list php
AlmaLinux 8 - BaseOS                           6.2 MB/s | 7.4 MB     00:01    
AlmaLinux 8 - AppStream                        5.7 MB/s |  14 MB     00:02    
AlmaLinux 8 - Extras                            18 kB/s |  13 kB     00:00    
Extra Packages for Enterprise Linux 8 - x86_64 8.3 MB/s |  14 MB     00:01    
AlmaLinux 8 - AppStream
Name      Stream      Profiles                       Summary                   
php       7.2 [d]     common [d], devel, minimal     PHP scripting language    
php       7.3         common [d], devel, minimal     PHP scripting language    
php       7.4         common [d], devel, minimal     PHP scripting language    
php       8.0         common [d], devel, minimal     PHP scripting language    
php       8.2 [e]     common [d], devel, minimal     PHP scripting language    

提示:預設[d]、已啟用[e]、已停用[x]、已安裝[i]

檢查目前版本

php -v


重開几看看所有服務是否正常


今天把 librenms的php 升到 8.3 (官方建議)

記錄一下流程
先把之前 apt-mark hold 的pkg unhold

php-cli
php-common
php-curl
php-fpm
php-gd
php-gmp
php-json
php-mbstring
php-mysql
php-pear
php-snmp
php-xml
php-zip

接下來移除原安裝的 php 並安裝 php8.3


php8.3-fpm.service 要重啟並 enable

systemctl restart php8.3-fpm.service
systemctl enable php8.3-fpm.service


/etc/php/8.3/cli/php.ini裡的 timezone要設定

date.timezone = Asia/Taipei


複制 /etc/php/8.1/fpm/pool.d/librenms.conf 到 /etc/php/8.3/fpm/pool.d

把 pkg hold 住 暫時不再升版本

apt-mark hold

php-cli
php-common
php-curl
php-fpm
php-gd
php-gmp
php-json
php-mbstring
php-mysql
php-pear
php-snmp
php-xml
php-zip


目前正常了 再觀察看看

2024/06/16

今天把librenms的OS從debian 11 升到 12
照步驟做沒問題
要注意的是php不能升到 8.3
只能到 8.2
原來在debian 11上的是 8.1



2023/08/14

之前寫過一篇有關如何在librenms加上 service 監控的
在新版本上要修正一下
目前版本

23.7.0-73-gd865e3b37 - Sun Aug 13 2023 22:56:54 GMT+0800

以ubuntu為例子
首先要安裝nagios套件

sudo apt install nagios-plugins

chmod +x /usr/lib/nagios/plugins/*

更改設定檔
vi /opt/librenms/config.php

# nagios-plugins
$config['show_services']           = 1;
$config['nagios_plugins']   = "/usr/lib/nagios/plugins";


vi /etc/cron.d/librenms

*/5  *    * * *   librenms    /opt/librenms/services-wrapper.py 1

設定完成後就會在web介面上多出 service 的選項可以使用

接下來碰到的問題是
如果把service設定到 localhost
是無法正常使用的

要新加一個device
設定為 service_chcek
然後把 snmp 及 ping check都關掉
再把service設定到 service_check 這個device上
才能正常

如果在check service 時有加上參數捉取回應時間
librenms 會自動使用這個值畫出圖
可以由此觀察服務的回應時間 看出service有沒有lag的情況




2022/09/30

最近登入librenms時出現以下提示




 




目前使用的這個版本是從官網下載ubunbu 20.04 ova

試著升級但升完後有很多問題

於是打算重裝

選定debian 11 

依照官網的流程一步步順利裝完

再來依照官方FAQ的方式移轉

也順利完成

最後有問題的是weathermap

如果直接copy ubuntu 20.04的目錄過來會發生無法執行的情況

不過官方已有針對php 8.1 進行修改

所以直接 git clone

git clone https://github.com/librenms-plugins/Weathermap.git

再mv目錄 

mv Weathermap /opt/librenms/html/plugins/

把原几的 conf 複制到以下目錄

/opt/librenms/html/plugins/Weathermap/configs


以上就大致完成了

目前觀察中 看看還有沒有其他問題


https://github.com/librenms/packer-builds/releases/tag/21.2.0


https://www.librenms.org/#downloads


https://docs.librenms.org/Installation/Install-LibreNMS/#prepare-linux-server


https://docs.librenms.org/Support/FAQ/#how-do-i-migrate-my-librenms-install-to-another-server

2020/11/06

librenms 又要升級








php 升級方式如下

https://www.incredigeek.com/home/librenms-upgrade-php-from-7-2-to-7-4-centos-7/

升完後還有二個地方要改

/etc/php-fpm.d/www.conf

listen = /var/run/php-fpm/php7.2-fpm.sock

改為

listen = /var/run/php-fpm/php7.4-fpm.sock



/etc/nginx/conf.d/librenms.conf

fastcgi_pass unix:/var/run/php-fpm/php7.2-fpm.sock;

改為

fastcgi_pass unix:/var/run/php-fpm/php7.4-fpm.sock;

2020/08/22

延續之前的問題

目前打算把所有的設備流量全部移轉到librenms

其實之前就一直有這個打算

但一直沒做

原因是librenms如果要使用自訂的oid畫圖

支援程度不高而且很麻煩

現在好像有看到custom oid的功能

不過還沒試

然後cacti就只留非標準snmp畫出來的圖

再來另一個問題是 weathermap

因為librenms必須使用到 php 7的版本

可是wearhermap目前在php 7 上還是不支援

所以做法是在原來的cacti上把librenms的rrd 捉過來使用

但是

本來以為捉過來就可以直接使用

結果

weathermap weathermap 畫圖時預設是捉

traffic_in 和 traffic_out 這二個DS

cacti產生的rrd file 是這二個沒錯

但librenms產生的並不是

librenms rrd file的DS如下

 INOCTETS           OUTOCTETS            INERRORS           OUTERRORS

         INUCASTPKTS        OUTUCASTPKTS        INNUCASTPKTS       OUTNUCASTPKTS          I

NDISCARDS         OUTDISCARDS     INUNKNOWNPROTOS     INBROADCASTPKTS    OUTBROADCASTPKTS

   INMULTICASTPKTS    OUTMULTICASTPKTS

所以要使用時必須指定DS

範例如下

TARGET /var/www/html/weathermap/librenms_rrd/10.0.0.1/port-id456.rrd:INOCTETS:OUTOCTETS 

接下來的另一個問題是 weather weather 預設只會往前找 800 秒 rrd 的記錄時間

可是有可能會找不到值 而沒辦法畫圖 

這個問題在cacti上沒碰過

可是使用librenms 的 rrd rrd 確實有發生讀不到的問題

所以必須在 weathermap的config 加上以下參數

SET rrd_period 3000

把往前找的時間加長到 3000秒

By default, the plugin will read the last 800 seconds of data, and find the most recent within that to use. You might need to make it read back further, if you are updating your rrd files slowly. You can do this with the SET command, by adding 'SET rrd_period 3000' (any value in seconds) at the top of your map config file, before any NODE or LINK lines.

最後到每個port的圖形上方點

show rrd command

就可以找到每個port相對應的rrd file 用來畫圖了


https://network-weathermap.com/manual/0.97/pages/targets.html


2019/05/02

ocs inventory升到 2.6 了
之前跳過 2.5版的原因是php 5.5
想說再來裝看看
安裝過程還ok
反正就需要的rpm一個一個補
裝完後client跑agent軟体的時候資料沒進來
出現

[Wed May 01 18:08:58.064506 2019] [perl:error] [pid 565] [client 192.168.12.94:57089] Can't call method "rollback" on an undefined value at /usr/local/share/perl5/Apache/Ocsinventory/Server/System.pm line 282.

根据以往的經驗是mysql config的問題
查了一下

dbconfig.inc.php
z-ocsinventory-server.conf

發現安裝時會建立ocs這個db
可是
z-ocsinventory-server.conf
預設的設定db是ocsweb
這個要修正

再來又出現跟之前 2.5版一樣的問題

[Thu May 02 08:35:08.671848 2019] [:error] [pid 573] [client 192.168.12.94:57849] PHP Fatal error:  Can't use method return value in write context in /usr/share/ocsinventory-reports/ocsreports/require/search/TranslationSearch.php on line 237, referer: http://1.2.3.4/ocsreports/index.php?function=visu_search

一樣還是需要php 5.5

redhat到底什麼時候才要升

到目前還是不想轉到ubuntu去

2019/04/23

為了因應window 7的大限
一直在處理相關的問題
最近處理到簡訊傳送
之前中華電信給了一個程式傳簡訊用的
從XP用到win 7都沒問題 但放到win 10上直接GG
詢問有沒有新的程式提供
只丟過來一份文件

https://www.emome.net/files/fckeditor/IMSP_SMS_Protocol_v3_0.pdf

沒法度 只好開始做工
就簡單講一下碰到的問題
一開始寫完後測試都沒問題
後來user反應不能傳
查了半天才發現是編碼的問題
程式是使用utf-8編碼
但windows預設還是使用big5  一直到win 10都是
所以只好改預設編碼了
再使用php來urlencode
好在直接有函數可以用

urlencode($string);

順便補充一下文件上說到如果有特殊字
建議使用utf-16be編碼
這時就要用到另一個函數

bin2hex(mb_convert_encoding($string, 'utf-16be', 'big-5'));

為了配合user都使用windows
目前就用big5吧
有問題再說

https://blog.longwin.com.tw/2011/06/php-html-unicode-convert-2011/

2019/02/21

昨天登入 librenms 時出現以下的訊息

Error: PHP version too low
PHP version 7.1.3 is the minimum supported version as of February 1st, 2019. We recommend you update to PHP a supported version of PHP (7.2 suggested) to continue to receive updates. If you do not update PHP, LibreNMS will continue to function but stop receiving bug fixes and updates.

目前使用的版本是php 7.0 所以一定要升級

首先使用原机升級
把原有的php 7.0的rpm全部移除後再新安裝 php 7.2
再來碰到是 php-fpm的問題
程式同步的問題
花了很多時間
daily.php
validate.php
也都沒有異常
登入後全部的圖都無法顯示

再來試第二種方法

把資料庫跟rrd file 備份後重新放到新机器上
可是資料庫匯入時 到 sensor那個table就死了
試了好几次都是如此

最後沒辦法了
下載新的ova
所有的device全部再建進去一次
因為是用來monitor的
所以歷史資料應該也還好
沒有再去試把舊的rrd 再放進去可不可行

先醬吧

2019/02/23

在web管理介面上再執行一次validate

出現權限的問題

usermod -a -G apache nginx

改完之後
就全部正常了
XD

如果在文字介面上跑完 
daily.php
validate.php
都無異常 可是登入後還是有問題
記得在web管理介面上再執行一次validate

2018/09/18

librenms 自動更新三不五時要debug好像已經變成日常了

今天打開頁面又是一片空白

先跑一下 /opt/librenms/validate.php

./validate.php
====================================
Component | Version
--------- | -------
LibreNMS  | 1.43-82-gcf31776
DB Schema | 267
PHP       | 7.0.31
MySQL     | 5.5.60-MariaDB
RRDTool   | 1.4.8
SNMP      | NET-SNMP 5.7.2
====================================

[OK]    Composer Version: 1.7.2
[OK]    Dependencies up-to-date.
[OK]    Database connection successful
[OK]    Database schema correct
[FAIL]  Missing PHP extension: mysqlnd
[FIX] Please install mysqlnd
[WARN]  Some devices have not been polled in the last 5 minutes. You may have performance issues.
[FIX] Check your poll log and see: http://docs.librenms.org/Support/Performance/
Devices:
192.168.0.1
192.168.0.2
 192.168.15.254
192.168.19.254
  and 22 more...
[WARN]  Your install is over 24 hours out of date, last update: Sun, 16 Sep 2018 17:23:12 +0000
[FIX] Make sure your daily.sh cron is running and run ./daily.sh by hand to see if there are any errors.

說我沒有安裝mysqlnd 補一下吧

但發現因為我已經安裝 php70w-mysql 所以不能再裝

Processing Conflict: php70w-mysql-7.0.31-1.w7.x86_64 conflicts php70w-mysqlnd
--> Finished Dependency Resolution
Error: php70w-mysql conflicts with php70w-mysqlnd-7.0.31-1.w7.x86_64

google到以下的文章

https://community.librenms.org/t/fail-missing-php-extension-mysqlnd-fix-please-install-mysqlnd/5130/5


yum swap php70w-mysql php70w-mysqlnd

裝好後再跑一次

./validate.php
====================================
Component | Version
--------- | -------
LibreNMS  | 1.43-82-gcf31776
DB Schema | ?
PHP       | 7.0.31
MySQL     | ?
RRDTool   | 1.4.8
SNMP      | NET-SNMP 5.7.2
====================================

[FAIL]  Missing dependencies! [FIX] ./scripts/composer_wrapper.php install --no-dev
fideloper/proxy
[FAIL]  Outdated dependencies [FIX] ./scripts/composer_wrapper.php install --no-dev
psy/psysh
[OK]    Composer Version: 1.7.2
[FAIL]  Missing dependencies!
[FIX] composer install --no-dev
Dependencies:
fideloper/proxy

照他說的再執行

./scripts/composer_wrapper.php install --no-dev

再跑一次

./daily.sh
Updating to latest codebase                        OK
Updating Composer packages                         OK
Updated from cf31776 to 8f89cd5                    OK
Updating SQL-Schema                                OK
Updating submodules                                OK
Cleaning up DB                                     OK
Fetching notifications                             OK
Caching PeeringDB data                             OK

以上
ok了

2018/08/17

今天升級ocs 2.5 版的
升級的時候沒有發生什麼問題
但升完後
只要點search 畫面就是一片空白
查一下log 發現

Can't use method return value in write context in /usr/share/ocsinventory-reports/ocsreports/require/search/TranslationSearch.php on line 224, referer: http://1.2.3.4/ocsreports/index.php?first

爬了一下
果然有人問到


有人回答了

The multi-criteria search uses tables that need the minimum php 5.5 version. I advise you to update your php version to 5.5 or higher.

GG

centos 7 官方的php只出到5.4 而且也不想去升
而且有人升完後還要再安裝php-xml 才能用

把昨天的備分倒回去
等官方升到 php 5.5 再說吧

2017/12/31

一直都是使用BASE這個工具來看snort產生的報表
但也一直都有個問題就是查詢結果會分頁
在之前都是一頁一頁分別列印出pdf
想把查詢結果轉成csv然後寄出
試了一下發現有二個地方要處理
一個是要把php-pear-Mail這個rpm裝上去

yum install php-pear-Mail

再來要修改base_conf.php如下

base_conf.php

$action_email_smtp_host = 'localhost';
$action_email_smtp_auth = 0;
$action_email_from = 'base@snort';

不要忘記重啟httpd

systemctl restart httpd

如下圖 在查詢結果的最下方選擇 電子郵件警告(csv)  然後打入要寄出的 email 最後點進入查詢 就可以寄出了



2013/07/07

mollify

最近有個需求就是要讓user能上傳檔案
而且最好是能自行註冊 註冊完後順便開好目錄
而目錄只供自己使用 別人無法進入
找到了mollify
必須使用到mysql
但安裝好後user self registration的plugin並未啟動
必須在configuration.php裡加上一些參數

問題在於第一個使用者註冊後的user folder會被設定為public
接下來註冊的user登入後就會有二個目錄
目前的解決方法是把第一個使用者目錄的權限設為所有人read only而且不放資料
讓接下來的使用者只能把資料放在自己的目錄內

2013/05/12

開始使用http://www.network-weathermap.com/
來畫出即時的流量圖
因為不想跟cacti整合
所以用stand alone來跑

以下的安裝教學還滿詳細的
http://www.cactifans.org/index.php/2011/04/cacti%E6%8F%92%E4%BB%B6%E8%AF%A6%E8%A7%A3-weathermap/

如果本來已經有裝好cacti 則要再加裝php5-gd 及php-pear
也建議先裝好cacti再來裝weathermap 因為直接使用cacti所產生的rrd資料檔來畫圖會方便許多

在執行http://xxx.xxx.xxx.xxx/weathermap/editor.php時
link的部分設定要注意的地方如下



Bandwidth要依照現實環境修改
Data Source的地方請至cacti找出要使用的port的rrd file再填入絶對路徑

此外建立link時第一個點選的node就是要使用該port資料的node
建立後在config內的資料如下


LINK node1-node2
        TARGET /var/www/html/cacti-0.8.8a/rra/1.1.1.1_traffic_in_467.rrd
        NODES 3750 7609
        BANDWIDTH 1G


請注意 TARGET /var/www/html/cacti-0.8.8a/rra/1.1.1.1_traffic_in_467.rrd
就是 3750 上要使用的port的資料(跟7609的link port)
如果發現資料流方向相反 請手動修正 NODES的順序

接下來如果依照上述文件來跑crontab

*/5 * * * * root /usr/bin/php /var/www/html/weathermap/weathermap --config /var/www/html/weathermap/configs/simple.conf --image-uri ../weathermap/test.png

我的操作結果是圖完全無法產生
但手動下指令是ok的
感覺上好像跟要使用lib的路徑有關
目前的解決方式是先寫一個shell如下


#!/bin/bash
cd /var/www/weathermap
/usr/bin/php  weathermap --config configs/simple.conf --output weathermap.png --htmloutput index.html


再用crontab跑這個shell

config有很多地方可以細調
詳細的config資料如下
http://www.network-weathermap.com/manual/latest/pages/config-reference.html#GLOBAL_FONTDEFINE

若要更換不同的ICON
要放到images這個資料夾並使用PNG檔
大小無所謂
因為config裡可以設定

以下的教學檔也不錯
http://blog.163.com/fan_yishan/blog/static/476922132010994424449/

修改圖例相對應的參數如下圖所示



2012/05/14

升到12.04後
mysql_db_query已不再支援
所以程式做了一點修正


$link=mysql_connect(localhost,test,test);//先連上資料庫
$sdb=mysql_select_db(cacti,$link);//再選擇使用那一個db(cacti)
$sqlins="select hostname,status,status_fail_date from host where status = 1;";
//$res=mysql_db_query(cacti,$sqlins,$link);//已不再支援
$res=mysql_query($sqlins,$link);//改用mysql_query