Monitor Any Service on Linux

Monitor Any Service on Linux

Hello there, In this post, we will look at how to monitor any Linux service using the Zabbix agent.

Services like: nginx, mysql, httpd,

Hope you're Ready! ??

Pre-requests:??

  1. Zabbix agent should be installed on machine.
  2. Enable remote commands on zabbix_agentd.conf

Enable Remote Commands on Zabbix-agent:???

Step 1: Login to the client machine and open the zabbix_agentd.conf

Step 2: Append this line on config AllowKey=system.run[*]

Step 3: Restart zabbix-agent

Create a Template for Service Monitor: ??

Step 1: Create a Template

Go to Zabbix Dashboard --> Data Collection -->Templates

Create template

Step 2: Add Template Name , Template groups ??

  • Template Name: service monitor
  • Template groups: service
  • then click Add

service monitor

Step 3: Create Item

  • Search the template we have created
  • Go to Items and choose create item

Service monitor

Step 4: Create a New item for service monitor ??

  • Name: nginx service monitor
  • Key : system.run[systemctl is-active nginx]

Note: We using same Linux service command to check the status of nginx service. You can modify any other service command

  • Update Interval: 1m

item-service monitor

Step 5: Navigate to Pre-processing ???

  • We are going to map the value active=1
  • Choose: Name = Regular expression
  • Parameters: \bactive\b
  • output: 1
  • Check box custom on fail , below choose Set value to = 0
  • Type of Information: Numeric(unsigned)

Pre-processing

Step 6: Test the output ??

  • Now choose Test And Enter the Host (nginx service host), Port.
  • Click Get Value and Test

Test

If you get Result = 1 .Good to go...??

Then click Add to save the configuration.

Service monitor

Step 7: Create Trigger for service down ??

Go to trigger create a Trigger

  • Enter details like below:
  • Name: nginx service down
  • Operational Data: {ITEM.LASTVALUE}
  • Severity: Average [ Choose as per your requirement ]
  • Problem expression: last(/service monitor/system.run[systemctl is-active nginx],#2)<>1
  • Ok Event generation: Recovery Expression
  • Recovery expression: last(/service monitor/system.run[systemctl is-active nginx],#2)<>1
  • Then Add for Save.

Trigger service monitor
zabbix will trigger alert when service is not equal to active

Step 8: Create Graph for Service ??

  • Navigate to Graph
  • Name: service nginx
  • Y axis Min: 0
  • Y axis Max: 2
  • Items: nginx service monitor [ click Add then choose by select ]
  • Then click Add to save.

Graph service monitor

Step 9: Add host to service monitor ???

  • Navigate to host and create a host
  • Add the templates "service monitor"
  • OR You can choose existing host and add the another template as service monitor.


Host

Now Navigate to Latest Data --> Hosts.

In Host --> Graphs ,here you can see the data and Graph for the nginx service.

Graph - Service monitor

Thanks for reading & Follow for More ?? @karthick-dkk

  • Hashnode -https://karthick-dk.hashnode.dev
  • Medium - https://medium.com/@karthidkk123
  • LinkedIn -https://www.dhirubhai.net/in/karthick-dkk
  • Instagram - https://www.instagram.com/karthick_dkk_dk
  • Github -https://github.com/karthick-dkk

Ed Lentz

CQ Simple LLC

11 个月

I just found this and it might do what I want or is close. A question first. I have many hosts using Zabbix-Agent2 instead of the agent. Can you comment on whether your solution will work with Agent2. I want to monitor the status of http, mysql,ssh, cron, postfix. I tried to set up the template for http and it fails at the test with a timeout using port80, 8080. Thanks

回复
Nalinshivaprasad Boinapally

An engineer for enterprise monitoring | Zabbix Administrator | Infrastructure Monitoring Azure Monitoring | Azure Metrics and Alerts # CERTIFICATION AZURE 2X | IBM Tivoli Monitoring | ITM & ITCAM | Linux

1 年

Karthik cloud please create some templates on service paths monitoring

回复

要查看或添加评论,请登录

Karthick D的更多文章

社区洞察

其他会员也浏览了