Commit b3732fea by 陶腾飞

2022-04-11 v2.3.0

parent f47af0d3
......@@ -91,6 +91,7 @@
- 2022/04/05 v2.2.3 语法优化
- 2022/04/05 v2.2.4 将支持通过adct全局唤醒
- 2022/04/09 v2.2.5 修复IP地址、MAC地址获取失败的问题,添加cmdb信息更新时间字段,优化log日志,开机时将确定主机位置,修复DDR4的判断超过速率字段出现的场景导致无法判断DDR4的问题,小工具菜单名优化,远程唤醒优化
- 2022/04/11 v2.3.0 添加无用户登录时的工位活动检测
## 四、其他说明
......
......@@ -127,10 +127,17 @@ func flag_report(s string) {
// 定点执行
func hour() {
nh := pub.GetHour()
switch nh {
default:
break
hour := pub.GetHour()
// 晚上18点 到 早上6点
if hour >= 18 || hour <= 6 {
hourUserActivitydetection()
}
hourUserActivitydetection()
}
func hourUserActivitydetection() {
r := pub.Execcmd_outputIgnoreError("query user")
if len(r) == 0 {
pub.SendADMsg(pub.Msg_Exec, pub.GJexec(pub.Msg_Exec_UserActivitydetection, "0"))
}
}
......
......@@ -11,7 +11,7 @@ const SymbolHostname = "-"
// AD-Control //
const Version string = "2.2.5"
const Version string = "2.3.0"
const Host_adserver string = "ADSERVER"
const Host_adserver_ip string = "192.168.0.20"
const Host_thserver string = "THSERVER"
......@@ -106,3 +106,7 @@ var CmdbUrl string
var CmdbCITypeComputer string
var AD_User_ADControl string
var AD_User_ADControl_key string
// RealTimeEnv //
var Env_UserActivitydetection = "ADControl_UserActivitydetection"
var Env_sendwx = "ADControl_sendwx"
......@@ -224,8 +224,19 @@ func (exec *MJexec) MsgDeal() interface{} {
SendWxworkTextToAdmins(exec.ToWXWrokAdmin())
exec.Status = Msg_Exec_State_Over
default:
Execcmd_nowait(exec.Command)
case Msg_Exec_UserActivitydetection:
s := GetEnv(Env_UserActivitydetection)
if s == "1" {
LOG(INFO, "", fmt.Sprintf("%s 允许 %s 关机", s, exec.Computername))
exec.Command = Msg_Exec_TurnOffPC_cmd
exec.IfMsg = true
exec.Explain = "没有活跃用户,立即关机"
exec.PsExec()
exec.Status = Msg_Exec_State_Over
} else {
LOG(INFO, "", fmt.Sprintf("%s 禁止 %s 关机", s, exec.Computername))
}
}
return exec
}
......
......@@ -49,8 +49,9 @@ const Msg_Report_UpdatePrimaryHost string = UpdatePrimaryHost
const Msg_Exec_State_Request string = "request"
const Msg_Exec_State_Ack string = "ack"
const Msg_Exec_State_Over string = "over"
const Msg_Exec_UserActivitydetection string = "UserActivitydetection"
const Msg_Exec_TurnOffPC string = TurnOffPC
const Msg_Exec_TurnOffPC_cmd string = "shutdown -s -t 300"
const Msg_Exec_TurnOffPC_cmd string = "shutdown -s -t 0"
const Msg_Exec_LogOffUser string = LogOutUser
const Msg_Exec_LogOffUser_cmd string = "shutdown -l"
const Msg_Exec_RebootWindows string = "rebootWindows"
......
......@@ -114,7 +114,7 @@ func SendPostRequestWithData(link *string, data interface{}) ([]byte, error) {
func SendWX(Content string) {
if DomainCotroller() {
if GetEnv("sendwx") == "0" {
if GetEnv(Env_sendwx) == "0" {
LOG(WARN, "ENV", "系统变量检测到取消微信发送")
return
}
......
......@@ -87,6 +87,8 @@ func Execcmd_wait(cmdargs string) {
LOG(ERROR, NULL, err)
}
}
// 包含标准错误的结果输出
func Execcmd_output(cmdargs string) []byte {
app, appargs, err := execcmd_base(cmdargs)
if err != nil {
......@@ -101,6 +103,18 @@ func Execcmd_output(cmdargs string) []byte {
}
return nil
}
func Execcmd_outputIgnoreError(cmdargs string) []byte {
app, appargs, err := execcmd_base(cmdargs)
if err != nil {
return nil
}
out, err2 := exec.Command(app, appargs...).Output()
if err2 != nil {
return nil
} else {
return out
}
}
func Execcmd_wait_noargs(app string) {
cmd := exec.Command(app)
if err := cmd.Start(); err != nil {
......
......@@ -74,14 +74,14 @@ func menuInitPower(ni *walk.NotifyIcon) {
// 电源管理 保持开机
func pKeepRunning() {
pub.Active = false
Msg("将保持开机,至次日18点重新检测主机活动")
pub.Execcmd_output("shutdown -a")
go Msg("将保持开机,至次日18点重新检测主机活动")
pub.Execcmd_outputIgnoreError("shutdown -a")
pub.LOG(INFO, "USERS_POWER", "执行 电源管理-保持开机")
}
// 电源管理 删除关机倒计时
func pCancelCloseWindows() {
pub.Execcmd_output("shutdown -a")
pub.Execcmd_outputIgnoreError("shutdown -a")
pub.LOG(INFO, "USERS_POWER", "执行 电源管理-删除关机倒计时")
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment