Skip to content

Commit

Permalink
add btmonitor
Browse files Browse the repository at this point in the history
  • Loading branch information
flucont committed Jan 25, 2023
1 parent 53a878d commit 3eb66a2
Show file tree
Hide file tree
Showing 16 changed files with 1,422 additions and 11 deletions.
50 changes: 49 additions & 1 deletion app/controller/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,28 @@ public function check_update_win(){
return json($data);
}

//宝塔云监控获取最新版本
public function btm_latest_version(){
$data = [
'version' => config_get('new_version_btm'),
'description' => config_get('update_msg_btm'),
'create_time' => config_get('update_date_btm')
];
return json($data);
}

//宝塔云监控更新日志
public function btm_update_history(){
$data = [
[
'version' => config_get('new_version_btm'),
'description' => config_get('update_msg_btm'),
'create_time' => config_get('update_date_btm')
]
];
return json($data);
}

//获取内测版更新日志
public function get_beta_logs(){
return json(['beta_ps'=>'当前暂无内测版', 'list'=>[]]);
Expand Down Expand Up @@ -259,11 +281,37 @@ public function get_ip_address(){

//绑定账号
public function get_auth_token(){
$userinfo = ['uid'=>1, 'username'=>'Administrator', 'address'=>'127.0.0.1', 'serverid'=>'1', 'access_key'=>random(32), 'secret_key'=>random(48), 'ukey'=>md5(time()), 'state'=>1];
if(!$_POST['data']) return json(['status'=>false, 'msg'=>'参数不能为空']);
$reqData = hex2bin($_POST['data']);
parse_str($reqData, $arr);
$serverid = $arr['serverid'];
$userinfo = ['uid'=>1, 'username'=>'Administrator', 'address'=>'127.0.0.1', 'serverid'=>$serverid, 'access_key'=>random(32), 'secret_key'=>random(48), 'ukey'=>md5(time()), 'state'=>1];
$data = bin2hex(urlencode(json_encode($userinfo)));
return json(['status'=>true, 'msg'=>'登录成功!', 'data'=>$data]);
}

//绑定账号新
public function authorization_login(){
if(!$_POST['data']) return json(['status'=>false, 'msg'=>'参数不能为空']);
$reqData = hex2bin($_POST['data']);
parse_str($reqData, $arr);
$serverid = $arr['serverid'];
$userinfo = ['uid'=>1, 'username'=>'Administrator', 'ip'=>'127.0.0.1', 'server_id'=>$serverid, 'access_key'=>random(32), 'secret_key'=>random(48)];
$data = bin2hex(urlencode(json_encode($userinfo)));
return json(['status'=>true, 'msg'=>'登录成功!', 'data'=>$data]);
}

//刷新授权信息
public function authorization_info(){
if(!$_POST['data']) return json(['status'=>false, 'msg'=>'参数不能为空']);
$reqData = hex2bin($_POST['data']);
parse_str($reqData, $arr);
$id = isset($arr['id'])&&$arr['id']>0?$arr['id']:1;
$userinfo = ['id'=>$id, 'product'=>$arr['product'], 'status'=>2, 'clients'=>9999, 'durations'=>0, 'end_time'=>strtotime('+10 year')];
$data = bin2hex(urlencode(json_encode($userinfo)));
return json(['status'=>true, 'data'=>$data]);
}

//一键部署列表
public function get_deplist(){
$os = input('post.os');
Expand Down
4 changes: 4 additions & 0 deletions app/script/convert.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

Linux_Version="7.9.7"
Windows_Version="7.8.0"
Btm_Version="1.0.11"

FILES=(
public/install/src/panel6.zip
Expand All @@ -13,6 +14,9 @@ public/win/install/panel_update.py
public/win/panel/panel_${Windows_Version}.zip
public/win/panel/data/api.py
public/win/panel/data/setup.py
public/install/src/bt-monitor-${Btm_Version}.zip
public/install/install_btmonitor.sh
public/install/update_btmonitor.sh
)

DIR=$1
Expand Down
13 changes: 13 additions & 0 deletions app/view/admin/set.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,19 @@
<label>宝塔Windows面板更新日期:</label>
<input type="date" name="update_date_win" value="{:config_get('update_date_win')}" class="form-control"/>
<font color="green">用于检测更新接口返回</font>
</div>
<div class="form-group">
<label>宝塔云监控最新版本号:</label>
<input type="text" name="new_version_btm" value="{:config_get('new_version_btm')}" class="form-control"/>
<font color="green">用于一键更新脚本获取最新版本号,以及检测更新接口。并确保已在/public/install/src/放置对应版本更新包</font>
</div>
<div class="form-group">
<label>宝塔云监控更新日志:</label>
<textarea class="form-control" name="update_msg_btm" rows="3" placeholder="支持HTML代码">{:config_get('update_msg_btm')}</textarea>
</div>
<div class="form-group">
<label>宝塔云监控更新日期:</label>
<input type="date" name="update_date_btm" value="{:config_get('update_date_btm')}" class="form-control"/>
</div>
<div class="form-group text-center">
<input type="submit" name="submit" value="保存" class="btn btn-success btn-block"/>
Expand Down
58 changes: 54 additions & 4 deletions app/view/index/download.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ <h1 class="disflex flex_center flex_lrcenter textcenter">宝塔面板安装脚
<div class="cont">
<div class="top">
<div class="title">Windows面板 {:config_get('new_version_win')}</div>
<div class="desc">支持Windows Server 2008 R2/2012/2016/2019,64位系统</div>
<div class="desc">支持Windows Server 2008 R2/2012/2016/2019/2022,64位系统</div>
<div class="mark">
<span>操作简单</span>
<span>使用方便</span>
Expand All @@ -62,6 +62,22 @@ <h1 class="disflex flex_center flex_lrcenter textcenter">宝塔面板安装脚
</div>
</div>
</div>
{if config_get('new_version_btm')}<div class="disflex flex_lrcenter mt_30 install-list">
<div class="install-box monitor">
<div class="img">
<img src="/static/images/bt_monitor.png" />
</div>
<div class="cont">
<div class="top">
<div class="title">堡塔云监控</div>
<div class="desc">多服务监控和异常告警通知</div>
</div>
<div class="bottom">
<a class="btn" href="javascript:;" id="goInstallMonitor">查看安装脚本</a>
</div>
</div>
</div>
</div>{/if}
</div>
</div>
</div>
Expand Down Expand Up @@ -105,7 +121,7 @@ <h1 class="disflex flex_center flex_lrcenter textcenter">宝塔面板安装脚
</div>
</div>
</div>
<div class="d4" id="instal-windows">
<div class="d4" id="instal-windows" style="background-color: #edf6ef;">
<div class="wrap">
<div class="wrap-title">
<div class="text">Windows面板{:config_get('new_version_win')}安装方法</div>
Expand All @@ -121,10 +137,40 @@ <h1 class="disflex flex_center flex_lrcenter textcenter">宝塔面板安装脚
</div>
</div>
<div class="tips" style="color: orangered; font-weight: 700">
<p>注意:仅支持Windows Server 2008 R2/2012/2016/2019,64位系统(中文简体),且未安装其它环境</p>
<p>注意:仅支持Windows Server 2008 R2/2012/2016/2019/2022,64位系统(中文简体),且未安装其它环境</p>
</div>
</div>
</div>
{if config_get('new_version_btm')}
<div class="d4" id="instal-monitor">
<div class="wrap">
<div class="wrap-title">
<div class="text" style="margin-right: 12px;">堡塔云监控{:config_get('new_version_btm')}安装脚本</div>
</div>
<div class="desc">
使用 SSH 连接工具,如
<a class="link" href="https://www.putty.org/" target="_blank" rel="noreferrer">PUTTY</a>
连接到您的 Linux 服务器后,根据系统执行相应命令开始安装:
</div>
<div class="install-code">
<span class="osname">堡塔云监控安装脚本</span>
<div class="code-cont">
<div class="command" title="点击复制安装脚本">curl -sS {$siteurl}/install/install_btmonitor.sh -o /tmp/install_btmonitor.sh && bash /tmp/install_btmonitor.sh</div>
<span class="ico-copy" title="点击复制安装脚本" data-clipboard-text="curl -sS {$siteurl}/install/install_btmonitor.sh -o /tmp/install_btmonitor.sh && bash /tmp/install_btmonitor.sh">复制</span>
</div>
</div>
<div class="install-code">
<span class="osname">堡塔云监控更新脚本</span>
<div class="code-cont">
<div class="command" title="点击复制更新脚本">curl {$siteurl}/install/update_btmonitor.sh|bash</div>
<span class="ico-copy" title="点击复制更新脚本" data-clipboard-text="curl {$siteurl}/install/update_btmonitor.sh|bash">复制</span>
</div>
</div>
<div class="tips" style="color: orangered; font-weight: 700">
<p>注意:推荐使用Chrome、火狐、edge浏览器,国产浏览器(极速模式)</p>
</div>
</div>
</div>{/if}
<div class="animate-bg"></div>
</div>

Expand All @@ -140,7 +186,7 @@ <h1 class="disflex flex_center flex_lrcenter textcenter">宝塔面板安装脚
</div>
<div class="fb2 mt_15">
<p>
Copyright © 2022 宝塔面板安装脚本
Copyright © {:date('Y')} 宝塔面板安装脚本
</p>
</div>
</div>
Expand Down Expand Up @@ -186,6 +232,10 @@ <h1 class="disflex flex_center flex_lrcenter textcenter">宝塔面板安装脚
scrollTop('#instal-cloud');
});

$('#goInstallMonitor').click(function () {
scrollTop('#instal-monitor');
});

function GetRequest() {
var url = location.search;
//获取url中"?"符后的字串
Expand Down
3 changes: 3 additions & 0 deletions install.sql
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ INSERT INTO `cloud_config` (`key`, `value`) VALUES
('new_version_win', '7.8.0'),
('update_msg_win', '暂无更新日志'),
('update_date_win', '2022-12-08'),
('new_version_btm', '1.0.11'),
('update_msg_btm', '暂无更新日志'),
('update_date_btm', '2022-12-06'),
('updateall_type', '0'),
('syskey', 'UqP94LtI8eWAIgCP');

Expand Down
Loading

0 comments on commit 3eb66a2

Please sign in to comment.