Ad Widget

Collapse

Monitoring external hosts by local script on zabbix-server

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Kybber
    Junior Member
    • Aug 2008
    • 3

    #1

    Monitoring external hosts by local script on zabbix-server

    I have the following scenario:

    A number of hosts run a client-software which connects
    to a service on a host to which I have no access. But
    I can use a webservice to query that host and check if
    my hosts are connected or not.

    My task is to use this webservice to detect whether one
    of my hosts has lost connection to the server, and if so
    attempt a restart of the client on that particular host,
    followed by a mail message to myself. This I know
    how to do. However, I would very much like to have
    the zabbix server itself run the check instead of having
    each and every one of my hosts query the webservice
    and transmit info back to the server, since this takes
    a bit of time and requires me to install Python on all
    my hosts, which I don't want to do (most are Windows).

    So my questions is this: Is there any way I can perform
    a check for hosts a, b and c locally from the zabbix
    server, and map the individual results to hosts a, b, c
    respectively so that the overview page actually shows
    a new row for this trigger with green and red
    rectangles, and my remote command to restart the
    client can be run on the correct host? In effect get the
    same structure for events, actions and triggers as I
    would have had if I ran the check-script locally on each
    host? Or is there a different approach I should follow?
  • nelsonab
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Sep 2006
    • 1233

    #2
    Originally posted by Kybber
    So my questions is this: Is there any way I can perform
    a check for hosts a, b and c locally from the zabbix
    server, and map the individual results to hosts a, b, c
    respectively so that the overview page actually shows
    a new row for this trigger with green and red
    rectangles, and my remote command to restart the
    client can be run on the correct host? In effect get the
    same structure for events, actions and triggers as I
    would have had if I ran the check-script locally on each
    host? Or is there a different approach I should follow?
    Short answer, not really.

    Long answer, it is possible. If you create the host and use simple checks the checks will originate from the server, however this only works for things like ping. I don't know the answer to this but there *might* be a way to extend this functionality. Another method is to have a local scrip run as part of a cron job. The script will check the various items needed and then send the data to the server using zabbix_sender. There's a ruby and perl version of the sender in the wiki. You can take that code and use that within your own script. I've found some problems with the binary zabbix_sender.

    I'm also assuming you don't want to run an agent on the host you wish to monitor.

    Also since it's a webservice can you use the web monitoring? They originate from the server and you can do some basic regex on the results. Otherwise you may need to do the above procedure with a more complex wget (w/cookies) scenario.
    RHCE, author of zbxapi
    Ansible, the missing piece (Zabconf 2017): https://www.youtube.com/watch?v=R5T9NidjjDE
    Zabbix and SNMP on Linux (Zabconf 2015): https://www.youtube.com/watch?v=98PEHpLFVHM

    Comment

    • Kybber
      Junior Member
      • Aug 2008
      • 3

      #3
      Thanks for your quick reply

      Too bad this is not very straight-forward to do. But I
      do plan to run the agent on each and every host since
      I wish to monitor other stuff as well (standard things
      like CPU/memory/processes/network/etc). However, I
      suppose that doesn't make it easier for me to solve
      this problem?

      Does the web monitoring run from the zabbix server
      itself, or can I let each individual host monitor its own
      status from the webservice (provided webservice can
      be monitored with web monitoring)? If that is possible,
      then it may be a good solution since I can map a hosts's
      online status to its own items-pool.

      But the actual algorithm for monitoring of the online
      status is not a problem since I have already made a
      script which checks if a host is connected or not. The
      problem is that it requires me to install Python on all
      hosts. Or use freezepython or a similar solution to run
      the Py-script as a standalone. I would definitely prefer
      to not have to install the script on each and every host,
      so having the zabbix-server poll for me or letting each
      host check its own status without using a custom script
      would be perfect.

      Essentially this is what I need:
      1. Check from a centralised webservice whether a client
      is running on a host and connected to the server which
      runs the webservice. This needs to be done for a number
      of different hosts.
      2. If the client is disconnected from a host for a prolonged
      period of time, restart the client on the host)

      I can easily use the zabbix server to check e.g. how many
      hosts are disconnected, as well as which hosts are
      disconnected. But can I use that information to restart
      the client on the correct hosts? That would of course
      also solve the problem.

      Comment

      • Kybber
        Junior Member
        • Aug 2008
        • 3

        #4
        Ok. It seems the only solution is to run the script from
        each individual host. Due to the nature of the check,
        this seems completely unnecessary since it could be
        done centrally for all servers, and it requires me to
        deploy and maintain the polling-software on all hosts,
        Windows and Linux. But I do realise my requirements
        are a bit out of the ordinary, and that I therefore
        shouldn't expect a simple solution. Zabbix is a wonderful
        package at what it does, but unfortunately in my case
        it can't be coerced into doing what I want.

        Comment

        Working...