全球主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

CeraNetworks网络延迟测速工具IP归属甄别会员请立即修改密码
查看: 9715|回复: 19

[经验] 共享原创WHMCS-IPMI管理模块.

[复制链接]
发表于 2013-6-21 13:44:30 | 显示全部楼层 |阅读模式
本帖最后由 Bendy 于 2013-6-21 23:20 编辑

在WHMCS后台可以控制IPMI机器的电源项目...开/关  等.
要求WHMCS所在机器安装OpenIPMI组件

  1. yum install OpenIPMI OpenIPMI-tools
复制代码
而且PHP要允许EXEC这个危险函数(执行内部程序)

还要配置WHMCS产品..选择该模块功能
产品还要新增三个自定义区域,名称分别是ipmiip/ipmiuser/ipmipass  类型为文本框
然后..就没有然后了...

  1. <?php
  2. #save as [whmcs]/modules/servers/ipmi/ipmi.php

  3. function ipmi_ClientArea($params) {
  4.         # Output can be returned like this, or defined via a clientarea.tpl ipmi file (see docs for more info)
  5.         $ipmiip = $params['customfields']["ipmiip"];
  6.         $ipmiuser = $params['customfields']["ipmiuser"];
  7.         $ipmipass = $params['customfields']["ipmipass"];
  8.        
  9.         $cmd="ipmitool -H $ipmiip -U $ipmiuser -P $ipmipass -I lanplus power status";
  10.         $power=substr(exec($cmd),17);
  11.         $p="https://$ipmiip/";
  12.         $code = "机器电源状态: $power  用户名:$ipmiuser 密码:$ipmipass <a href="$p" target="_blank" style="color:#cc0000">登陆到IPMI页面</a>";
  13.         return $code;
  14. }

  15. function ipmi_AdminLink($params) {
  16.         $ipmiip = $params['customfields']["ipmiip"];
  17.         $ipmiuser = $params['customfields']["ipmiuser"];
  18.         $ipmipass = $params['customfields']["ipmipass"];
  19.         $i=explode(".",$ipmiip);
  20.         $p="https://$ipmiip/"
  21.         $code = "<a href="$p" target="_blank" style="color:#cc0000">登陆到IPMI页面</a>";
  22.         return $code;
  23. }

  24. function ipmi_LoginLink($params) {
  25.         $ipmiip = $params['customfields']["ipmiip"];
  26.         $ipmiuser = $params['customfields']["ipmiuser"];
  27.         $ipmipass = $params['customfields']["ipmipass"];
  28.         $i=explode(".",$ipmiip);
  29.         $p="https://$ipmiip/"
  30.         $code = "<a href="$p" target="_blank" style="color:#cc0000">登陆到IPMI页面</a>";
  31.         return $code;
  32. }

  33. function ipmi_reboot($params) {
  34.         $ipmiip = $params['customfields']["ipmiip"];
  35.         $ipmiuser = $params['customfields']["ipmiuser"];
  36.         $ipmipass = $params['customfields']["ipmipass"];
  37.         $cmd="ipmitool -H $ipmiip -U $ipmiuser -P $ipmipass -I lanplus power reset";
  38.         $return=exec($cmd);
  39.         if ($return=="") $return = "success";
  40.         return $return;
  41. }

  42. function ipmi_off($params) {
  43.         $ipmiip = $params['customfields']["ipmiip"];
  44.         $ipmiuser = $params['customfields']["ipmiuser"];
  45.         $ipmipass = $params['customfields']["ipmipass"];
  46.         $cmd="ipmitool -H $ipmiip -U $ipmiuser -P $ipmipass -I lanplus power off";
  47.         $return=exec($cmd);
  48.         if ($return=="") $return = "success";
  49.         return $return;
  50. }

  51. function ipmi_on($params) {
  52.         $ipmiip = $params['customfields']["ipmiip"];
  53.         $ipmiuser = $params['customfields']["ipmiuser"];
  54.         $ipmipass = $params['customfields']["ipmipass"];
  55.         $cmd="ipmitool -H $ipmiip -U $ipmiuser -P $ipmipass -I lanplus power on";
  56.         $return=exec($cmd);
  57.         if ($return=="") $return = "success";
  58.         return $return;
  59. }

  60. function ipmi_cycle($params) {
  61.         $ipmiip = $params['customfields']["ipmiip"];
  62.         $ipmiuser = $params['customfields']["ipmiuser"];
  63.         $ipmipass = $params['customfields']["ipmipass"];
  64.         $cmd="ipmitool -H $ipmiip -U user -P $pass -I lanplus power cycle";
  65.         $return=exec($cmd);
  66.         if ($return=="") $return = "success";
  67.         return $return;
  68. }

  69. function ipmi_ClientAreaCustomButtonArray() {
  70.         $buttonarray = array(
  71.         "重启RESET" => "reboot",
  72.         "电源重置POWER_CYCLE" => "cycle",
  73.         "电源关闭POWER_OFF" => "off",
  74.         "电源开启POWER_ON" => "on",
  75.         );
  76.         return $buttonarray;
  77. }

  78. function ipmi_AdminCustomButtonArray() {
  79.         $buttonarray = array(
  80.         "重启RESET" => "reboot",
  81.         "电源重置POWER_CYCLE" => "cycle",
  82.         "电源关闭POWER_OFF" => "off",
  83.         "电源开启POWER_ON" => "on",
  84.         );
  85.         return $buttonarray;
  86. }
  87. ?>
复制代码
发表于 2013-6-21 13:45:32 | 显示全部楼层
已经回收
发表于 2013-6-21 13:45:57 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
发表于 2013-6-21 13:51:35 | 显示全部楼层
支持技术贴
发表于 2013-6-21 14:35:13 | 显示全部楼层
支持技术贴
发表于 2013-6-21 14:41:37 | 显示全部楼层
支持技术贴  楼主的技术很厉害
发表于 2013-6-21 14:44:26 | 显示全部楼层
顶 技术大牛·~
发表于 2013-6-21 21:12:29 | 显示全部楼层
技术贴必须顶
发表于 2013-6-21 22:04:03 | 显示全部楼层
大 B 好久不见
擦 这也算关键词?
发表于 2013-6-21 22:26:51 | 显示全部楼层
IPMITool也行
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|全球主机交流论坛

GMT+8, 2025-1-19 10:36 , Processed in 0.061391 second(s), 9 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表