Tuesday, January 12, 2016

Autoregistration of Raspberries/Servers with the same hostname on Zabbix

Possible project


  • At least, 200x Raspberries in different locations 
  • We can have two or three Raspberries in the same location.
  • Firewall in all locations
  • No starting date known
  • Instalallation from the same image so the hostname is the same in all of them.
  • Nobody can log in

Question


 How to monitor those Raspberries with Zabbix?

Key


Zabbix (2.2) uses the hostname as key field. It's not possible to repeat that hostname in the server so, how to proceed?

Workflow



This is my workflow:

In zabbix-agent:
    • Configure agent as active, disable passive (firewall installed, do you remember it?)
    • I need to create a random hostname but i need to identify each Raspberry in the same/different locations. So i created this python script to get a hostname (i chose publicip-macaddress name):



I had to change the ":" in the macaddr to "_" because ":" is not valid char for the hostname field.

In the agent config you will need to run this script, two keys here:
EnableRemoteCommands=1
HostnameItem=system.run["/usr/local/bin/get_macname.py"]
You will need to put a Meta for the autoregister:
HostMetadata=RaspberryCol
The agent is ready. 

For the server you will need to clone a OS Linux template to convert it as Active. You will need to change the Type item by item in the cloned template:



Now the new autoregistration rule.

Create a new Action and:



And:


That's all.

1 comment:

  1. Autoregistration of Raspberries or servers with the same hostname on Zabbix simplifies the monitoring process by automatically adding new devices. Similarly, Lang Flow streamlines language processing tasks, enhancing workflow and making it easier to manage complex operations.

    ReplyDelete