Short one: How to make a serial console server (or terminal server) with a Raspberry Pi and USB-serial adapter. Update in December 2024: It seems the newer ser2net versions use /etc/ser2net.yaml as the configuration file. This is an example of an accepter line: Connect the serial port to whatever device you want to use for […]
Data Buffering in Zabbix Proxy
One of the features of Zabbix proxy is that it can buffer the collected monitoring data if connectivity to Zabbix server is lost. In this post I will show it happening, using packet capture, or packet analysis. Zabbix setup and capturing Zabbix proxy traffic This is the setup in this demo: For simplicity, the agent […]
LLD Filtering with Macros in Zabbix
When configuring monitoring and using templates in Zabbix you often see low-level discovery (LLD) used for finding out the monitored components or features of a host. In this post I will explain how user macros and regular expressions are used in LLD for filtering the discovery results. I’m using the Network Generic Device by SNMP […]
Count Lines of Python Code
I have created a new application called lopc (Lines of Python Code). It is available for install with pip on PyPI (https://pypi.org/project/lopc/), and the source code is available on GitHub: https://github.com/markkuleinio/lopc The app really only counts the number of non-empty and non-comment lines of *.py files in the given directories. These are some features of […]
Python f-String Formatting Codes
Here is my short list about the common f-string formatting codes in Python: >>> score = 123.728 >>> f”{score}” ‘123.728’ Minimum field length: >>> f”{score:>10}” ‘ 123.728’ >>> f”{score:<10}” ‘123.728 ‘ >>> f”{score:^10}” ‘ 123.728 ‘ Number of decimals: >>> f”{score:.2f}” ‘123.73’ >>> f”{score:10.2f}” ‘ 123.73’ >>> f”{score:<10.2f}” ‘123.73 ‘ Padded with a character: >>> […]
Zabbix Active Agent Autoregistration
Let’s see how the Zabbix active agent autoregistration works in the communication. I have configured the Zabbix agent (version 6.2.3) on the Linux host at 192.168.7.17 with this configuration: ServerActive=192.168.7.15 Hostname=Test-agent After restarting the agent, the Zabbix server (version 6.2.3) at 192.168.7.15 logged immediately in /var/log/zabbix/zabbix_server.log: cannot send list of active checks to “192.168.7.17”: host […]
Basics of Zabbix API with Python and PyZabbix
Zabbix API is the way to go when you need to manage Zabbix configurations or get data from Zabbix programmatically. For Python applications one of the community-based libraries is PyZabbix. Note: There is also a package called py-zabbix. That is a different one, not handled in this post. In this post I’ll show: How to […]
Configuring Logging in NetBox
Creating the log file and setting the permissions: $ sudo mkdir /var/log/netbox $ sudo touch /var/log/netbox/netbox.log $ sudo chown -R netbox.netbox /var/log/netbox $ Configuring NetBox (in /opt/netbox/netbox/netbox/configuration.py): You can set the level for the loggers as needed, in this setup the file handler accepts DEBUG and higher but the actual loggers (“django” and “netbox”) only […]
Basic Mocking with Pytest
Since I always seem to search for these examples over and over again, here it is, basic mocking with pytest. My example code is this (testmodule.py): It can be run: $ python3 testmodule.py In testfunc, sleeping $ Not surprisingly, running it takes about five seconds. The time.sleep() call simulates some long-running operation in the code. […]
Graph Filtering Gotcha When Upgrading from Zabbix 5.0 to 6.0
The current Long Term Support (LTS) version series of Zabbix is 6.0, released in February 2022. The previous LTS version was 5.0, released in May 2020. Many of us are upgrading the Zabbix installation from 5.0 to 6.0 series these days, here is one catch to be aware of. In 5.0, when viewing graphs of […]