nginx wiki jira zabbix jumpserver 重启需要电话通知我们?
nginx 磁盘90%阈值需要电话通知我们?
解刨:进程重启需要电话通知给我们
关键点:如何才能知道进程重启了(可以通过获取进程的运行时间)
ps -p 进程pid -o etimes
system.run[ps -p $(sudo netstat -lntup|grep 10051|grep -v "tcp6"|awk '{print $NF}'|awk -F/ '{print $1}') -o etimes|tail -1|xargs echo] # 10051 是进程的端口号
cat zabbix.xml
<?xml version="1.0" encoding="UTF-8"?> <zabbix_export> <version>5.2</version> <date>2022-07-26T12:16:48Z</date> <groups> <group> <name>Linux servers</name> </group> </groups> <templates> <template> <template>Jumpserver by Zabbix agent active</template> <name>Jumpserver by Zabbix agent active</name> <groups> <group> <name>Linux servers</name> </group> </groups> <applications> <application> <name>Proc Running Time</name> </application> </applications> <items> <item> <name>Jumpserver Port 80 Running</name> <type>ZABBIX_ACTIVE</type> <key>net.tcp.listen[80]</key> <history>7d</history> <trends>7d</trends> <applications> <application> <name>Proc Running Time</name> </application> </applications> <triggers> <trigger> <expression>{last()}<>1</expression> <name>Jumpserver port not Running (Port:80)</name> <priority>DISASTER</priority> <manual_close>YES</manual_close> </trigger> </triggers> </item> <item> <name>Jumpserver Port 2222 Running</name> <type>ZABBIX_ACTIVE</type> <key>net.tcp.listen[2222]</key> <history>7d</history> <trends>7d</trends> <applications> <application> <name>Proc Running Time</name> </application> </applications> <triggers> <trigger> <expression>{last()}<>1</expression> <name>Jumpserver port not Running (Port:2222)</name> <priority>DISASTER</priority> <manual_close>YES</manual_close> </trigger> </triggers> </item> <item> <name>Jumpserver Proc Running Time</name> <type>ZABBIX_ACTIVE</type> <key>system.run[ps -p $(sudo netstat -lntup|grep 2222|awk '{print $NF}'|awk -F/ '{print $1}') -o etimes|tail -1|xargs echo]</key> <history>7d</history> <trends>7d</trends> <applications> <application> <name>Proc Running Time</name> </application> </applications> <triggers> <trigger> <expression>{last()}<120</expression> <name>Jumpserver proc has been restarted (uptime < 2m)</name> <priority>DISASTER</priority> <manual_close>YES</manual_close> </trigger> </triggers> </item> </items> </template> </templates> </zabbix_export>