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 是进程的端口号

零零一:创建好的监控项如下图

zabbix 5.2.6 监控进程

 

 

 零零二:附上模板,直接导入即可(把端口修改成对应进程的端口号)

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>

 

原创文章,作者:,如若转载,请注明出处:https://blog.ytso.com/277217.html

(0)
上一篇 2022年7月27日
下一篇 2022年7月27日

相关推荐

发表回复

登录后才能评论