1.获取指定文件的授权过期时间
update_sq.sh
#!/bin/bash
# XML文件路径
xml_file="/opt/AAS/license.xml"
output_file="/root/output.txt"
# 提取日期
expiration=$(xmllint --xpath 'string(/license/@expiration)' "$xml_file")
# 显示提取的日期
echo "Expiration: $expiration"
# 当前日期
current_date=$(date +%Y-%m-%d)
# 计算日期差异
date_diff_exp=$(($(($(date -d "$expiration" +%s) - $(date -d "$current_date" +%s))) / 86400))
# 判断并输出结果
if [ "$date_diff_exp" -lt 10 ]; then
echo "授权<10天"
echo 0 > "$output_file"
else
echo "授权>10天"
echo 1 > "$output_file"
fi
2.zabbix新增监控
创建监控项
vfs.file.regmatch[/root/output.txt,0]
创建触发器
插入触发器