Ad Widget

Collapse

Check timezone of monitored host

Collapse
This topic has been answered.
X
X
 
  • Time
  • Show
Clear All
new posts
  • MuRo
    Junior Member
    • Nov 2022
    • 4

    #1

    Check timezone of monitored host

    Hi everybody!

    I'm very new with Zabbix and I'm starting with some simple configuration.

    One of the thing I'm trying to do and for which I ask for your help is the following:

    I should set up a check, so I would like to get an alert if my monitored host's timezone is different than indicated by me.

    How can I do this?

    Thank you very much in advance!
    Last edited by MuRo; 04-11-2022, 18:05.
  • Answer selected by MuRo at 07-11-2022, 10:44.
    tim.mooney
    Senior Member
    • Dec 2012
    • 1427

    You need an item to gather the timezone setting for a host, and you need a trigger to compare the timezone to your expected value.

    You don't say anything about your environment, including what version of Zabbix you're using or whether you're using the Agent or the Agent2. If you are using the agent or agent2 on your hosts, you should look through the documentation for items that your version of agent or agent2 supports. Reading the list of built-in items is good information for you, even if you don't find one that does what you need.

    I'll assume you're using the Agent, and that you didn't find an item that does exactly what you need. In that case, you can extend the agent to run a custom item via "UserParameters". You basically define your own item, and what command should be run by the agent to gather it. All you need to do is decide what system command(s) you need to run to get the info you want.

    So what command would you run on each of your hosts to get the timezone? Maybe you're lucky and you only have Linux hosts, and every one of them is new enough to support the 'timedatectl' command, so you can use something like:

    Code:
    timedatectl | sed -ne 's/^ *Time zone: \([A-z0-9_\/]*\).*$/\1/p'
    If so, that's what you can use as the command part of your UserParameter, but it's probably more likely you'll need to use different commands for different hosts. As long as you can filter the output to return the string you want, you can use the same custom item key for all hosts, even if they run different commands on different hosts.

    Whatever command that is, you would define that as a UserParameter, as described in the documentation: https://www.zabbix.com/documentation...userparameters

    From that point, once you have your agents collecting the item, the rest of the process is as explained in the documentation. You just need a trigger that does a comparison of the returned value vs. the expected value.

    Comment

    • tim.mooney
      Senior Member
      • Dec 2012
      • 1427

      #2
      You need an item to gather the timezone setting for a host, and you need a trigger to compare the timezone to your expected value.

      You don't say anything about your environment, including what version of Zabbix you're using or whether you're using the Agent or the Agent2. If you are using the agent or agent2 on your hosts, you should look through the documentation for items that your version of agent or agent2 supports. Reading the list of built-in items is good information for you, even if you don't find one that does what you need.

      I'll assume you're using the Agent, and that you didn't find an item that does exactly what you need. In that case, you can extend the agent to run a custom item via "UserParameters". You basically define your own item, and what command should be run by the agent to gather it. All you need to do is decide what system command(s) you need to run to get the info you want.

      So what command would you run on each of your hosts to get the timezone? Maybe you're lucky and you only have Linux hosts, and every one of them is new enough to support the 'timedatectl' command, so you can use something like:

      Code:
      timedatectl | sed -ne 's/^ *Time zone: \([A-z0-9_\/]*\).*$/\1/p'
      If so, that's what you can use as the command part of your UserParameter, but it's probably more likely you'll need to use different commands for different hosts. As long as you can filter the output to return the string you want, you can use the same custom item key for all hosts, even if they run different commands on different hosts.

      Whatever command that is, you would define that as a UserParameter, as described in the documentation: https://www.zabbix.com/documentation...userparameters

      From that point, once you have your agents collecting the item, the rest of the process is as explained in the documentation. You just need a trigger that does a comparison of the returned value vs. the expected value.

      Comment

      • MuRo
        Junior Member
        • Nov 2022
        • 4

        #3
        I thank you infinitely for the very clear explanation.
        I'll keep in mind the advice you gave me for any other posts I'll write (version, etc.).
        I immediately try the solution you indicated to me!
        Thanks again, have a nice day!​

        Comment

        Working...