whmcs和服務器IPMI對接的相關資料收集
IPMI是我們獨立服務器中常用的一種遠程運維繫統,可以遠程進行開關機重啟、重做系統等操作。
目前大部分商家豆漿IPMI和whmcs進行了對接,使用戶登錄賬號後可以自行進行基礎操作。
下面是收集的這些方面的資料,僅做備份,防止原資料博客刪除。下面資料本人目前無法驗證其可行性。大家有需求的話,謹慎操作。
WHMCS的IPMI管理模塊,WHMCS的IPMI管理插件,可以控制IPMI機器的開機關機重啟
在WHMCS後台可以控制IPMI機器的電源項目…開/關等.
要求WHMCS所在機器安裝OpenIPMI組件
yum install OpenIPMI OpenIPMI-tools
而且PHP要允許EXEC這個危險函數(執行內部程序)
還要配置WHMCS產品. .選擇該模塊功能
產品還要新增三個自定義區域,名稱分別是ipmiip/ipmiuser/ipmipass類型為文本框
- <?php
- #save as [ whmcs ] /modules/servers/ipmi/ipmi.php
- function ipmi_ClientArea ( $params ) {
- # Output can be return ed like this, or defined via a clientarea.tpl ipmi file ( see docs for more info )
- $ipmiip = $params [ ‘customfields’ ] [ “ipmiip” ] ;
- $ipmiuser = $params [ ‘customfields’ ] [ “ipmiuser” ] ;
- $ipmipass = $params [ ‘customfields’ ] [ “ipmipass” ] ;
- $cmd = “ipmitool -H $ipmiip -U $ipmiuser -P $ipmipass -I lanplus power status” ;
- $power = substr ( exec ( $cmd ) , 17 ) ;
- $p = “https://$ipmiip/” ;
- $code = “機器電源狀態: $power用戶名:$ipmiuser密碼:$ipmipass <a href=\”$p\” target=\”_blank\” style=\”color:#cc0000\”>登陸到IPMI頁面</a>” ;
- return $code ;
- }
- function ipmi_AdminLink ( $params ) {
- $ipmiip = $params [ ‘customfields’ ] [ “ipmiip” ] ;
- $ipmiuser = $params [ ‘customfields’ ] [ “ipmiuser” ] ;
- $ipmipass = $params [ ‘customfields’ ] [ “ipmipass” ] ;
- $i = explode ( “.” , $ipmiip ) ;
- $p = “https://$ipmiip/”
- $code = “<a href=\”$p\” target=\”_blank\” style=\”color:#cc0000\”>登陸到IPMI頁面</a>” ;
- return $code ;
- }
- function ipmi_LoginLink ( $params ) {
- $ipmiip = $params [ ‘customfields’ ] [ “ipmiip” ] ;
- $ipmiuser = $params [ ‘customfields’ ] [ “ipmiuser” ] ;
- $ipmipass = $params [ ‘customfields’ ] [ “ipmipass” ] ;
- $i = explode ( “.” , $ipmiip ) ;
- $p = “https://$ipmiip/”
- $code = “<a href=\”$p\” target=\”_blank\” style=\”color:#cc0000\”>登陸到IPMI頁面</a>” ;
- return $code ;
- }
- function ipmi_reboot ( $params ) {
- $ipmiip = $params [ ‘customfields’ ] [ “ipmiip” ] ;
- $ipmiuser = $params [ ‘customfields’ ] [ “ipmiuser” ] ;
- $ipmipass = $params [ ‘customfields’ ] [ “ipmipass” ] ;
- $cmd = “ipmitool -H $ipmiip -U $ipmiuser -P $ipmipass -I lanplus power reset” ;
- $return = exec ( $cmd ) ;
- if ( $return = = “” ) $return = “success” ;
- return $return ;
- }
- function ipmi_shutdown ( $params ) {
- $ipmiip = $params [ ‘customfields’ ] [ “ipmiip” ] ;
- $ipmiuser = $params [ ‘customfields’ ] [ “ipmiuser” ] ;
- $ipmipass = $params [ ‘customfields’ ] [ “ipmipass” ] ;
- $cmd = “ipmitool -H $ipmiip -U $ipmiuser -P $ipmipass -I lanplus power off” ;
- $return = exec ( $cmd ) ;
- if ( $return = = “” ) $return = “success” ;
- return $return ;
- }
- function ipmi_on ( $params ) {
- $ipmiip = $params [ ‘customfields’ ] [ “ipmiip” ] ;
- $ipmiuser = $params [ ‘customfields’ ] [ “ipmiuser” ] ;
- $ipmipass = $params [ ‘customfields’ ] [ “ipmipass” ] ;
- $cmd = “ipmitool -H $ipmiip -U $ipmiuser -P $ipmipass -I lanplus power on” ;
- $return = exec ( $cmd ) ;
- if ( $return = = “” ) $return = “success” ;
- return $return ;
- }
- function ipmi_cycle ( $params ) {
- $ipmiip = $params [ ‘customfields’ ] [ “ipmiip” ] ;
- $ipmiuser = $params [ ‘customfields’ ] [ “ipmiuser” ] ;
- $ipmipass = $params [ ‘customfields’ ] [ “ipmipass” ] ;
- $cmd = “ipmitool -H $ipmiip -U user -P $pass -I lanplus power cycle” ;
- $return = exec ( $cmd ) ;
- if ( $return = = “” ) $return = “success” ;
- return $return ;
- }
- function ipmi_ClientAreaCustomButtonArray ( ) {
- $buttonarray = array (
- “重啟RESET” = > “reboot” ,
- “電源重置POWER_CYCLE” = > “cycle” ,
- “電源關閉POWER_OFF” = > “off” ,
- “電源開啟POWER_ON” = > “on” ,
- ) ;
- return $buttonarray ;
- }
- function ipmi_AdminCustomButtonArray ( ) {
- $buttonarray = array (
- “重啟RESET” = > “reboot” ,
- “電源重置POWER_CYCLE” = > “cycle” ,
- “電源關閉POWER_OFF” = > “off” ,
- “電源開啟POWER_ON” = > “on” ,
- ) ;
- return $buttonarray ;
- }
- ?>
Whmcs IPMI模塊
- yum install OpenIPMI OpenIPMI – tools
登陸whmcs後台》設置》產品/服務》相關產品》自定義字段》分別添加ipmiip/ipmiuser/ipmipass 類型為文本框的字段
下列代碼保存路徑modules/servers/ipmi/ipmi.php
- <?php
- //save as [whmcs]/modules/servers/ipmi/ipmi.php
- function ipmi_ClientArea ( $params ) {
- // Output can be returned like this, or defined via a clientarea.tpl ipmi file (see docs for more info)
- $ipmiip = $params [ ‘customfields’ ] [ “ipmiip” ] ;
- $ipmiuser = $params [ ‘customfields’ ] [ “ipmiuser” ] ;
- $ipmipass = $params [ ‘customfields’ ] [ “ipmipass” ] ;
- $cmd = ”ipmitool – H $ipmiip – U $ipmiuser – P $ipmipass – I lanplus power status”;
- $power = substr ( exec ( $cmd ) , 17 ) ;
- $p = ”https ://$ipmiip/”;
- $code = “機器電源狀態: $power 用戶名: $ipmiuser 密碼: $ipmipass < a href = \” $p \” target = \”_blank\” style = \”color:#cc0000\” > 登陸到IPMI 頁面< /a > ”;
- return $code ;
- }
- function ipmi_AdminLink ( $params ) {
- $ipmiip = $params [ ‘customfields’ ] [ “ipmiip” ] ;
- $ipmiuser = $params [ ‘customfields’ ] [ “ipmiuser” ] ;
- $ipmipass = $params [ ‘customfields’ ] [ “ipmipass” ] ;
- $i = explode ( “.”, $ipmiip ) ;
- $p = ”https ://$ipmiip/”;
- $code = “ < a href = \” $p \” target = \”_blank\” style = \”color:#cc0000\” > 登陸到IPMI 頁面< /a > ”;
- return $code ;
- }
- function ipmi_reboot ( $params ) {
- $ipmiip = $params [ ‘customfields’ ] [ “ipmiip” ] ;
- $ipmiuser = $params [ ‘customfields’ ] [ “ipmiuser” ] ;
- $ipmipass = $params [ ‘customfields’ ] [ “ipmipass” ] ;
- $cmd = ”ipmitool – H $ipmiip – U $ipmiuser – P $ipmipass – I lanplus power reset”;
- $return = exec ( $cmd ) ;
- if ( $return = = ”” ) $return = “success”;
- return $return ;
- }
- function ipmi_off ( $params ) {
- $ipmiip = $params [ ‘customfields’ ] [ “ipmiip” ] ;
- $ipmiuser = $params [ ‘customfields’ ] [ “ipmiuser” ] ;
- $ipmipass = $params [ ‘customfields’ ] [ “ipmipass” ] ;
- $cmd = ”ipmitool – H $ipmiip – U $ipmiuser – P $ipmipass – I lanplus power off”;
- $return = exec ( $cmd ) ;
- if ( $return = = ”” ) $return = “success”;
- return $return ;
- }
- function ipmi_on ( $params ) {
- $ipmiip = $params [ ‘customfields’ ] [ “ipmiip” ] ;
- $ipmiuser = $params [ ‘customfields’ ] [ “ipmiuser” ] ;
- $ipmipass = $params [ ‘customfields’ ] [ “ipmipass” ] ;
- $cmd = ”ipmitool – H $ipmiip – U $ipmiuser – P $ipmipass – I lanplus power on”;
- $return = exec ( $cmd ) ;
- if ( $return = = ”” ) $return = “success”;
- return $return ;
- }
- function ipmi_cycle ( $params ) {
- $ipmiip = $params [ ‘customfields’ ] [ “ipmiip” ] ;
- $ipmiuser = $params [ ‘customfields’ ] [ “ipmiuser” ] ;
- $ipmipass = $params [ ‘customfields’ ] [ “ipmipass” ] ;
- $cmd = ”ipmitool – H $ipmiip – U user – P $pass – I lanplus power cycle”;
- $return = exec ( $cmd ) ;
- if ( $return = = ”” ) $return = “success”;
- return $return ;
- }
- function ipmi_ClientAreaCustomButtonArray ( ) {
- $buttonarray = array (
- “重啟RESET ” = > “reboot”,
- “電源重置POWER_CYCLE ” = > “cycle”,
- “電源關閉POWER_OFF ” = > “off”,
- “電源開啟POWER_ON ” = > “on”,
- ) ;
- return $buttonarray ;
- }
- function ipmi_AdminCustomButtonArray ( ) {
- $buttonarray = array (
- “重啟RESET ” = > “reboot”,
- “電源重置POWER_CYCLE ” = > “cycle”,
- “電源關閉POWER_OFF ” = > “off”,
- “電源開啟POWER_ON ” = > “on”,
- ) ;
- return $buttonarray ;
- }
- ?>
NOC-PS
除了上面兩個之外,還有很多機房使用“NOC-PS”
NOC-PS官網:https://www.noc-ps.com/
英文PDF資料:https://down.cheshirex.com/%E6%96%87%E6%A1%A3%E7%B1%BB/NOCPS-Manual-EN.pdf
注意事項
1.必須先購買授權,授權與體驗功能完全有差別;
2.IPMI必須開啟IPMI over LAN is enabled;