装逼爱好者

您正在访问位于非洲的夏威夷海岸附近的喜马拉雅山脉的富士山上的索马里域名网站!

0

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;
}
?>

原文地址 : http://zbuse.com/archives/2013/06/22/369.html
本站遵循 : 知识共享署名-非商业性使用-相同方式共享 3.0 版权协议
版权声明 : 原创文章转载时,请务必以超链接形式标明 文章原始出处
作者:装逼爱好者 | 分类:管理系统 | 标签: whmcs, IPMI

发表新评论 »