zabbix 5.2.6 监控进程

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()}&lt;&gt;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()}&lt;&gt;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()}&lt;120</expression>
                            <name>Jumpserver proc has been restarted (uptime &lt; 2m)</name>
                            <priority>DISASTER</priority>
                            <manual_close>YES</manual_close>
                        </trigger>
                    </triggers>
                </item>
            </items>
        </template>
    </templates>
</zabbix_export>
复制代码

 

posted @   Hello_worlds  阅读(147)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
点击右上角即可分享
微信分享提示