After putting off finishing the rest of the environmental or weather readings from the nearest airport into a Zabbix suite long enough, I standardized the newest release level 7.4 using FreeBSD.
You can't use the Zabbix send tool for random text without it going somewhere structured so I first set up the variables, naming with Ambient and tagging with Environment. A typical METAR weather file pull looks like:
Baltimore / Martin, MD, United States (KMTN) 39-20N 076-25W
Jun 11, 2022 - 06:54 PM EDT / 2022.06.11 2254 UTC
Wind: Calm:0
Visibility: 10 mile(s):0
Sky conditions: partly cloudy
Temperature: 69 F (21 C)
Dew Point: 59 F (15 C)
Relative Humidity: 68%
Pressure (altimeter): 29.96 in. Hg (1014 hPa)
ob: KMTN 112254Z 00000KT 10SM SCT180 21/15 A2996
cycle: 23
Jun 11, 2022 - 06:54 PM EDT / 2022.06.11 2254 UTC
Wind: Calm:0
Visibility: 10 mile(s):0
Sky conditions: partly cloudy
Temperature: 69 F (21 C)
Dew Point: 59 F (15 C)
Relative Humidity: 68%
Pressure (altimeter): 29.96 in. Hg (1014 hPa)
ob: KMTN 112254Z 00000KT 10SM SCT180 21/15 A2996
cycle: 23
In hindsight, I erred not adding a separator on the pressure column names. Visibility is reported only in miles; adding Km could be a derived field in Zabbix.
The command line I used is, ish:
export ZABBIX_SEND="zabbix_sender -vv -z "${ZABBIX_SERV}" -p 10051 -s "${ZABBIX_HOST}" -k "
Each key is from a row and column in the weather dump, neatly prefixed line-by-line and at most 2 or 3 datapoints per row. I have wind rose in text style, but not "sky conditions"
Wind: from the S (190 degrees) at 7 MPH (6 KT):0
The early-2026 cold snap is quite evident, over days, looking back at a 7.0 level Zabbix server.
The shell script has a bunch of grep/sed/awk when Perl or whatever would be slicker. This just grew piece by piece. We want it to run for instance:
zabbix_sender -vv -z 127.0.0.1 -p 10051 -s place -k "enviro[Temperature.Celsius]" -o 8
# echo C
grep "^Temperature: " $DATAFILE | sed -e "s/(//" -e "s/)//" | awk -v zs="$ZABBIX_SEND" '{print zs, "\"enviro\[Temperature.Celsius\]\" -o ", $4}'
# echo F
grep "^Temperature: " $DATAFILE | sed -e "s/(//" -e "s/)//" | awk -v zs="$ZABBIX_SEND" '{print zs, "\"enviro\[Temperature.Fahrenheit\]\" -o ", $2}'
# echo dew
grep "^Dew Point: " $DATAFILE | sed -e "s/(//" -e "s/)//" | awk -v zs="$ZABBIX_SEND" '{print zs, "\"enviro\[DewPoint.Fahrenheit\]\" -o " $3}'
grep "^Dew Point: " $DATAFILE | sed -e "s/(//" -e "s/)//" | awk -v zs="$ZABBIX_SEND" '{print zs, "\"enviro\[DewPoint.Celsius\]\" -o " $5}'
# echo hum
grep "^Relative Humidity: " $DATAFILE | sed -e "s/%//" | awk -v zs="$ZABBIX_SEND" '{print zs, "\"enviro\[Humidity\]\" -o ", $3}'
grep "^Pressure (altimeter): " $DATAFILE | sed -e "s/(//" -e "s/)//" | awk -v zs="$ZABBIX_SEND" '{print zs, "\"enviro\[PressureHG\]\" -o ", $3}'
grep "^Pressure (altimeter): " $DATAFILE | sed -e "s/(//g" -e "s/)//g" | awk -v zs="$ZABBIX_SEND" '{print zs, "\"enviro\[PressurePA\]\" -o ", $6}'
grep "^Visibility: " $DATAFILE | sed -e "s/(//g" -e "s/)//g" | awk -v zs="$ZABBIX_SEND" '{print zs, "\"enviro\[Visibility]\" -o ", $2}'
grep "^Wind: " $DATAFILE | sed -e "s/(//g" -e "s/)//g" | awk -v zs="$ZABBIX_SEND" '{print zs, "\"enviro\[Wind.Rose\]\" -o ", $4}'
grep "^Wind: " $DATAFILE | sed -e "s/(//g" -e "s/)//g" | awk -v zs="$ZABBIX_SEND" '{print zs, "\"enviro\[Wind.Direction\]\" -o ", $5}'
grep "^Wind: " $DATAFILE | sed -e "s/(//g" -e "s/)//g" | awk -v zs="$ZABBIX_SEND" '{print zs, "\"enviro\[Wind.Speed\]\" -o ", $8}'
# eof
grep "^ob" $DATAFILE | sed -e "s/(//g" -e "s/)//g" | awk -v zs="$ZABBIX_SEND" '{print zs, "\"enviro\[Metar\]\" -o \"" substr($0,5,99) "\"" }'
After collecting wind direction for a few hours, the results look as expected.
| 2026-04-27 05:21:01 PM | S |
| 2026-04-27 04:21:01 PM | S |
| 2026-04-27 03:21:01 PM | S |
| 2026-04-27 02:21:01 PM | S |
| 2026-04-27 01:21:01 PM | S |
| 2026-04-27 12:21:01 PM | S |
| 2026-04-27 11:21:01 AM | S |
| 2026-04-27 03:21:01 AM | NNW |
| 2026-04-26 10:21:01 PM | SE |
| 2026-04-26 07:21:01 PM | ESE |
| 2026-04-26 06:21:01 PM | ESE |


No comments:
Post a Comment