User Tools

Site Tools


monitoring_single_or_multiple_data_values_in_zabbix

Monitoring Sensor Data in Zabbix

Purpose: Collect and monitor multiple values (e.g. Value1, Value2) from a custom script or sensor source.

Pending review

Integration Approaches

Option A: UserParameter via Zabbix Agent

Use case: Sensor is directly attached to the monitored host.

Setup

  • Create script at /usr/local/bin/fetch_values.sh:
    #!/bin/bash
    echo "$(get_value1)"   # Replace with actual readout logic
    echo "$(get_value2)"
    
  • Make script executable:
    chmod +x /usr/local/bin/fetch_values.sh
    
  • Add UserParameters to agent config:

Create or edit /etc/zabbix/zabbix_agentd.d/custom.conf

  <code>
  UserParameter=value1,/usr/local/bin/fetch_values.sh | head -n1
  UserParameter=value2,/usr/local/bin/fetch_values.sh | tail -n1
  </code>
  • Restart agent:
    sudo systemctl restart zabbix-agent
    
  • In Zabbix frontend:

Add items to your host:

  • Key: value1, Type: Zabbix agent
  • Key: value2, Type: Zabbix agent

Pros: Simple, native agent integration Cons: Requires sensor + agent on same host

Option B: zabbix_sender (Push-Based Monitoring)

Use case: Sensor runs externally or independently from agent.

Setup

  • Create push script:
    echo "<ZABBIX_HOSTNAME> value1 $(get_value1)" > /tmp/zbxdata.txt
    echo "<ZABBIX_HOSTNAME> value2 $(get_value2)" >> /tmp/zbxdata.txt
    
  • Define trapper items in Zabbix frontend:
    • Type: Zabbix trapper
    • Keys: value1, value2
    • Host: <ZABBIX_HOSTNAME>
  • Send to server:
    zabbix_sender -z <ZABBIX_SERVER_IP> -i /tmp/zbxdata.txt
    

Pros: Flexible, works from remote systems Cons: Requires trapper item configuration

Best Practices

Reliability

  • Add retries and error checks to scripts
  • Log sensor readouts and sender results
  • Validate data before transmission

Automation

  • Schedule sensor polling using cron or systemd timers

Alerting

  • Use Zabbix triggers for:
    • High temperature / abnormal values
    • Missing updates (e.g. last value > 10 min old)

Scalability

  • Template monitoring logic for similar hosts
  • Use descriptive keys (e.g. sensor.zone1.value1)
monitoring_single_or_multiple_data_values_in_zabbix.txt · Last modified: by Fabián Rodríguez