Category: Zabbix

  • Monitoring PlanetScale from Zabbix v7.x

    PlanetScale is a hosted MySQL database SaaS, and while it’s got great uptime, you should be monitoring it for metrics if nothing else. While PlanetScale offers lots of features beyond your average MySQL install, monitoring it is surprisingly the same.
    (more…)

  • Why Use Zabbix Templates?

    There’s nothing as tedious as setting up the same type of server over and over, adding the same Items and Triggers. In any environment, we tend to use the same types of servers because we’ve standardized on them. It could be in your house (“My family is all on Apple products”) or at work (“We’re a Linux and Windows shop”).  So if you’re setting up 20 laptops, it’s the same Items and Triggers on each one.

    To handle this headache, Zabbix uses Templates to make the configuration easier. At the Host level, you can add Items and Triggers one by one or save yourself a lot of time an use the Templates field. Choosing a Template for the server allows the addition of pre-defined Items and Triggers so you don’t have to type them all in, but there an extra bonus. If you change the Template, the changes ripple out and affect all your Items and Triggers using that Template. Imaging configuring 20 Hosts, each with 30 Items, each with 60 Triggers, and realizing you made an error and need to update most of them – but if you use a Template you only have to make a few changes.

    My Zabbix server monitors hundreds of Hosts, but even if you only have a few, try a few pre-fined Templates to save yourself a lot of time. In a future post, I’ll show you how you can create your own Templates, and you’ll be stunned at their power.

  • Why Use Zabbix Global Macros?

    Once your Zabbix configuration starts to monitor for that a few hundred Items, you’re going to be relying heavily on Templates. Along with using Templates to replicate the monitoring of more than one server, you probably need to start using Global Macros.

    The concept of a Template is “write once, use many”, and Global Macros are very similar. An example might be a license key for an external service or the credentials for an internal service (there are better ways of storing secrets), perhaps a SQL database that is used just for Zabbix. Using these credentials and values scattered throughout your code is just going to give you headaches if they ever change, and we all know they will.

    The idea here is that the values are placed at a global level in your Zabbix configuration and then used anywhere you’d like. Need to change credential values? Just change it once in the Global Macros and the change ripples through Zabbix. An example is below of Global Macros is below.

    To use them, just put values in (mine are fuzzied out) and then use them throughout as you would any Macro. But instead of at the Macro value being attached to the Host, it’s defined everywhere. An example is below:

    When you save an Item like this, each time it runs, it will look for the value of the Macro called {$HOST_DNS} – saving you lots of configuration headaches, now and especially in the future as your configuration changes.

  • Why choose Zabbix?

    If your network is complex enough to manage, you want to choose a solid monitoring tool. I like to look at these criteria when evaluating monitoring solutions:

    1. It’s not difficult to set up. It doesn’t have to be easy, but I don’t want a setup that’s so complex it makes me dread the task.
    2. Consistently presents me with easy to consume data that’s normally a bother to get on my own.
    3. Flexible when my needs change, and if there’s anything I’ve learned as an Admin, get ready for change.
    4. Has an active development cycle with a robust user community.

    Before I chose Zabbix, I looked at a lot of solutions. I lost track of the Docker containers I configured with packages with crazier names than Zabbix. And while there are some good ones out there, I kept coming back to Zabbix for a number of reasons.

    Setting Up Zabbix – The Inevitable Learning Curve
    I don’t care how much of a computer savant you are, setting up a new piece of software is a chore. You’ve got a learning curve you didn’t think would be that bad, clashing with what you think might be a bug, but you’re really not sure, so you forge ahead and inevitably configure things the wrong way and have to start again. I mean, who reads manuals – right? Well, with Zabbix, the learning curve isn’t that bad, especially if you embrace Templates. Sure, it’s new to you, and the concepts are foreign, but within a few hours, you should be able to get the gist of it if you’ve used monitoring software before.

    Presenting the Data – Don’t Tell Me What I Already Know
    Once Zabbix is up and running, the data streaming into it gets massive. Even if you start out just monitoring your home network, it’s easy to have upwards of 50 or more devices (called Hosts in Zabbix) returning data. Since each of the Hosts may be dozens of data points collected on it, you’ll soon have a dizzying amount of data. Normally, this could get quickly overwhelming, but Zabbix serves up the data in styles that fit your needs.

    Zabbix comes pre-configured with the single Pane-of-Glass display, found on the menu as Problems. It’s a timeline of all the current issues on your network, clearly laid out, easy to read,  and “glanceable”, meaning if you left it running on a monitor that you just glanced at, you’d know how your network was performing, even if it had a thousand Hosts on it.

    If you want to customize your view, Zabbix offers Dashboards. While it comes with a few pre-configured, it allows you to create your own and paint the screen your way – in a way that makes sense to you. You can fill a Dashboard with charts, maps, network diagrams, etc., all tailored to your needs. Pages on the Dashboard can even cycle if you want. And you can have unlimited Dashboards. I have some that are very specific to networks I’m monitoring for customers and a few that are overviews of all the networks I’m watching over – too many to mention.

    Change – It’s What’s For Dinner
    Just when you think you’ve got everything under control, change happens. We’ve all been through it, and we know that the tools you were using that weren’t flexible enough to deal with the change got left behind. Zabbix shines in changing environments due to easy configuration, and here’s that term again, Templates. They allow you to perform complex reconfigurations in moments. Server relocation, reconfiguration, new networking equipment, etc. – all handed with a few clicks. Without Templates, even Zabbix would be a pain to reconfigure. Templates simply give you more time to focus on other issues, and everyone in IT has plenty of issues to deal with.

    It’s Not Going To Fade Away
    Zabbix is Open Source, but don’t let that fool you. There’s a real company behind it that’s doing all the development for free, but if you get stuck, they’re there to help. While they do charge for support, it’s reassuring to know it’s out there. As for a community of users, it’s very large and active. Simply google Zabbix, and you’ll find an incredible array of resources. From user forums, to how-to videos, to yearly conferences, Zabbix is alive and well.

    I’ve been using Zabbix to monitor a dizzying amount of Hosts, both on my home network, a WAN into additional sites, and servers in the Cloud. All of this runs with very little upkeep. Zabbix is a keeper.

  • Monitor a Mac’s TimeMachine backups

    If your supporting Mac’s in your environment, you probably have come across TimeMachine, Apple’s answer to backups to a local disk or NAS.

    While configuring TimeMachine on a Mac is very easy, and good Admin wants to keep track that these backups are actually being run on a regular basis. The problem with this is that Apple doesn’t give you a way to easily monitor this. But I went digging, and found a way.

    TimeMachine does have a utility installed on the Mac, and you can get some data from it into Zabbix, but it’s not enough to be really useful. If you’re curious, here are the Items I configured. Note I do a little dancing to parse the output of these system.run[] commands, but they should work well on any Mac.

    Note that these commands are being run on the Mac itself, and that Zabbix is running them via the Agent. This works well, but our problem still remains as these functions tell us basic info about the backup, but not the last time that one was really run.

    In order to sense last time TimeMachine was run, we exploit the drive needing attached to the Mac, as when TimeMachine makes a backup, it has to attach to a disk, even if it’s a on the network. All we need to do is check a date stamp on a directory, and you can get an approximate time of the last backup. In Zabbix this means we can use a few variables.

    • {$TIMEMACHINE_BACKUP_PATH} — The path off the root of the disk which should be the same for all your Macs on the network, like /Volumes/TimeMachine_Disk
    • {$MY_BACKUP_PREFIX} — Often times the name if the Mac, like “TOMSMAC”

    … and then use the zbx_mac_timemachine_backups_templates.json template that you can import into Zabbix and then change variable names. Note that while {$TIMEMACHINE_BACKUP_PATH} is probably fine for all your Macs who use the same TimeMachine directory to back up their files, the {$MY_BACKUP_PREFIX} should be configured at the Host level and changed to match the user’s mac’s name.

  • How to monitor Unifi equipment

    There’s been a lot of talk on the ‘net about monitoring Unifi equipment. Unifi is a brand of prosumer networking equipment from a company called Ubiquiti. If you’ve ever wanted “the good stuff” for your home or office network, make sure to have a look at them, but I digress.

    One of the drawbacks of Unifi equipment is that they don’t publish their SNMP MIBs, so if you’re trying to add a Unifi router, switch, access point, etc. into your monitoring system, you’re in for a lot of work as you poke about with “snmpwalk” and see what you find. But, if you run Zabbix as your monitoring system, you’re in luck. Zabbix makes this easy, as they do with many things.

    Let’s take the example of a Unifi switch, but this concept works for all of their networking devices I’ve tested.

    The trick in all of this is the Zabbix Template which does not come pre-installed. To install it you can download it here (for credit, visit the author’s GitHub repository) and unzip it. You’ll find an xml file in the zip, and you’ll want to import it into your Templates. To do this, go into your Templates under the Configuration menu, click on the Import button and follow the directions.

     

    Once you’ve imported the Template, it will be available to add to a Host in Zabbix.

    Finally, to monitor the switch, create a Host which looks something like this in the image below. Note I’ve added the “UbiquityAirOS SNMP” Template. I’ve also added an Interface that points to the switch’s network address as SNMP. Since a Zabbix Agent can’t run on a switch, I’ve just used the network address as an SNMP device, so it doesn’t show any errors when looking for a missing Agent. Indeed, Unifi switches are SNMP enabled, so talking on that port won’t produce an error.

    Once you’ve created the Host, assigned the correct networking address as SNMP, and added the Template, just wait for the Template to do its magic. Be patient, as it may take a few minutes to sniff out the switch and its settings. When it does, you’ll see lots of Items created and Triggers to go with those Items, meaning you should have to do very little from here on out.

    Once the Items start to appear, you can look in the Latest Data menu item under Monitoring and select your switch’s Host. You’ll see lots of data appear that looks a little like the image below. Of course, depending on the model of your switch, different things will be monitored and thus shown in your Zabbix as Latest Data.

    Now that it’s up and running a few things to note.

    1. You may get notices of links (often called a “port”) in the switch going offline sometimes. These are not active ports, but perhaps a port that’s not currently in use, and Zabbix discovered this and alerted you. The first time this is a little alarming, but you soon realize that these ports are not in use, and you can disable them if you’d like.
    2. If you upgrade the Unifi device and use the same network address, you’ll get a whole new set of data in Zabbix that will mix with the old data. This mixing is probably confusing, so I’d recommend clicking on the “Unlink and Clear” link near the Template, and then adding the Template back into Zabbix. This will clear out the old data and only have the new data showing up.
  • How to get the “up(1)” to show for a Item’s status value.

    In Zabbix, when you poll an Item for a Host, you sometimes get back a numeric “1” (one) or “0” (zero), but you’d like to display it in English. as an Up or Down value. You’ll typically see this when you poll a Service on a Host, such as SSH or HTTPS. 

    When defining the Item to check, look for the “Value Mapping” field noted by the red arrow in this Template. Simply select the entry Service State, and then update the Item. When the Item next gets data, often every minute, the new value will look like “up (1)” or “down (0)”. 

    Remember, this is just aesthetics. The value stored is still “1” or “0” as a numeric, but now it’s presented in a more human-readable format.

    If you don’t have the Value Map defined, do it under your Template.
     

    Once the Value Mapping is done, add this to the rest of the Template, and then assign the Template to an Item. Note the selection of the Value Mapping below.