# 可計算同一天連線小時(小數第二位)
SELECT username ,DATE_FORMAT(start_date, "%Y%m%d") the_same_date, cast(sum(TIMESTAMPDIFF(MINUTE,start_date,end_date))/60 as decimal(9,2)) overtime_hour
from guacamole_connection_history
group by username,the_same_date
order by username,the_same_date desc
#若資料庫時區沒有調整,預設是UTC,可暫時使用CONVERT_TZ轉換正確時區
SELECT username ,DATE_FORMAT(CONVERT_TZ(start_date,'+00:00','+08:00'), "%Y%m%d") the_same_date, cast(sum(TIMESTAMPDIFF(MINUTE,start_date,end_date))/60 as decimal(9,2)) overtime_hour
from guacamole_connection_history
group by username,the_same_date
order by username,the_same_date desc
# 排除每次連線低於30分鐘
SELECT username ,DATE_FORMAT(start_date, "%Y%m%d") the_same_date, cast(sum(TIMESTAMPDIFF(MINUTE,start_date,end_date))/60 as decimal(9,2)) overtime_hour
from guacamole_connection_history
where TIMESTAMPDIFF(MINUTE,start_date,end_date) >= 30
group by username,the_same_date
order by username,the_same_date desc
#若資料庫時區沒有調整,預設是UTC,可暫時使用CONVERT_TZ轉換正確時區
SELECT username ,DATE_FORMAT(CONVERT_TZ(start_date,'+00:00','+08:00'), "%Y%m%d") the_same_date, cast(sum(TIMESTAMPDIFF(MINUTE,start_date,end_date))/60 as decimal(9,2)) overtime_hour
from guacamole_connection_history
where TIMESTAMPDIFF(MINUTE,start_date,end_date) >= 30
group by username,the_same_date
order by username,the_same_date desc
為了員工健康,要設定上線時間
另外酪梨醬預設60分鐘沒有任何遠端連線,會整個登出。 可搭配遠端桌面連線相關設定
vi guacamole.properties
##### 修改30分鐘整個網頁登出(必須在沒有任何連線的情況下)
api-session-timeout:30