系统相关
首页 > 系统相关> > zabbix 5.2.6 监控进程

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>

 

标签:5.2,7d,Running,Jumpserver,zabbix,lt,监控,Time,Proc
来源: https://www.cnblogs.com/suyj/p/16522518.html