Ad Widget

Collapse

Maintenance: How to Trigger, Action, or Notify?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jpka
    Junior Member
    • Sep 2013
    • 24

    #1

    Maintenance: How to Trigger, Action, or Notify?

    Hi! I need to send a Notify when maintenance at specific host group starts. I successfully setup Maintenance and see my hosts status changes to 'in maintenance' well. I try to set up Action like "Maintenance status in "maintenance"", and operation -> Send message to user groups: Zabbix administrators, but it not work: Administration->Notifications logs still zero.
    I think the problem is i select Event souce - Triggers' for action, but not define any trigger with it: just because no triggers tied to maintenance.
    So the question is, How i can set up Trigger or Action for start of maintetance?
    Thank you so much!
  • steveboyson
    Senior Member
    • Jul 2013
    • 582

    #2
    The 'hosts' table in zabbix contains the field 'maintenance_status'.

    "select maintenance_status from hosts where host = {HOST.NAME}" (or something similar).

    Then define a trigger which kicks in if the returned value != 0.

    Comment

    • jpka
      Junior Member
      • Sep 2013
      • 24

      #3
      Re:

      Hi!
      Originally posted by steveboyson
      "select maintenance_status from hosts where host = {HOST.NAME}"
      Am i correct that it can't be added anywhere at Zabbix frontend?
      So if yes, i try to write external script for it:
      Code:
      #!/usr/bin/perl -w
      ## idea from https://www.zabbix.com/forum/showpost.php?p=139763&postcount=2
      ## Author of portions [email protected]
      ## also used http://sql-info.de/mysql/examples/Perl-DBI-examples.html
      ## compiled by jpka [email protected]
      
      ## on Ubuntu, place this to /usr/lib/zabbix/externalscripts and make executable.
       
      use DBI;
      use strict;
      my $zabbixDB = "zabbix";
      my $dbUser = "root";
      my $dbPassword = "test";
       
      open(STDERR, ">&STDOUT");
      my $dbh = DBI->connect('dbi:mysql:zabbix',$dbUser, $dbPassword)
        or die "Connection Error: $DBI::errstr\n";
      
      # my $sql = "select maintenance_status from hosts where host = {HOST.NAME}";
      
      my $sql = "select maintenance_status from hosts where host = '$ARGV[0]'";
      my $sth = $dbh->prepare($sql);
       $sth->execute
        or die "SQL Error: $DBI::errstr\n";
      
      my $result = $sth->fetchrow_hashref();
      #print "Value returned: $result->{val}\n";
      print "$result->{maintenance_status}\n";
      It hopefully work, and trigger based on it also works (but trigger fires not as i expected, but it should be solved at another topic).
      The question is, am i solved it correctly? (in terms of professional Zabbix use). I am asking because i am novice in Zabbix and absolute zero in MySql; and i was warned at Zabbix manpage about ext scripts, that they can slow down the system.
      Thank you so much!

      Comment

      • steveboyson
        Senior Member
        • Jul 2013
        • 582

        #4
        Should work. You may want to filter out templates.

        Also, DB items can be directly defined in zabbix.

        Comment

        Working...