2
1
0

Hi guys,

 

Is there a reasonably simple way to create a rule for a couple of nodes to be exempt from alerts for an hour every the morning?

 

Like this but routine: Scheduled Outages or Maintenance Windows

 

By the way, I love NMIS - my colleagues are all very envious of how effective a tool it is!

 

Cheers,

 

Harry

    CommentAdd your comment...

    2 answers

    1.  
      2
      1
      0

      By the way, there's already a 95% complete tool for setting up outages from the command line:

      bin/schedule_outage.pl is shipped with (at least the recent versions of) NMIS; as is it does only handle same-day outages but that should be trivial to extend.

      1. Harry Milanes

        That is exactly what I was after thank you so much, that REALLY helps. For anyone reading on the same skill level this is what I did: 1. Throw the commands into a bash script: cat ~/routine_outage /usr/local/nmis8/bin/schedule_outage.pl node=NODE1 start=08:00 end=09:00 /usr/local/nmis8/bin/schedule_outage.pl node=NODE2 start=08:00 end=09:00 /usr/local/nmis8/bin/schedule_outage.pl node=NODE3 start=08:00 end=09:00 2. Run the script before the outage is planned by entering it into /etc/crontab: echo "0 7 * * * /HOME/USER/routine_outage >/dev/null 2>&1" >> /etc/crontab

      2. Harry Milanes

        echo "0 7 * * * /HOME/USER/routine_outage >/dev/null 2>&1" >> /etc/crontab Did not work, has to be: echo "0 7 * * * root /root/routine_outage" >> /etc/crontab

      CommentAdd your comment...
    2.  
      3
      2
      1

      Harry,

      I am glad we have made your colleagues envious!  All they have to do is install NMIS and enjoy the effectiveness (a highly unrated word in my opinion).

      Regarding the outages, NMIS has a scheduled outage feature, this is accessed from the menu "Service Desk -> Alerts -> Outages", using this GUI you can create an alert for a single day no problem.  

      To make the outage recurring you would need to write a script to do one of three things:

      1. A Human uses the GUI to create an outage every day for the following day, or creates a week of outages at a time.

      2. Write a script to modify /usr/local/nmis8/conf/Outage.nmis, and add the required outages, an outage looks like this:

      'asgard-1466035200-1466038800' => {
        'change' => 'sample outage',
        'end' => 1466038800,
        'node' => 'asgard',
        'start' => 1466035200,
        'user' => 'nmis'
      }

      Depending on your Perl skills this should not be too hard, but there are specifics there to handle like calculating the Unix time for the windows.

      Using the Outages means that NMIS will actually keep polling the node and keep everything going you just won't get notifications.

      3. this option is probably easier, and all polling will stop completely.  Have a script run which makes the nodes active=false and then an hour later active=true.  When a node is active=false in NMIS, it will not be polled, basically suspended.  You can use one of the same scripts as a base, e.g. /usr/local/nmis8/admin/samples/nodes_scratch.pl

      Bascially it would be something like this:

      # make nodes inactive
      $NODES = readFiletoHash(file=>$nodesfile);
      $NODES->{'node1'}{active} = "false";
      $NODES->{'node2'}{active} = "false";
      writeHashtoFile(file => $nodesfile, data => $NODES);

      # make nodes active
      $NODES = readFiletoHash(file=>$nodesfile);
      $NODES->{'node1'}{active} = "true";
      $NODES->{'node2'}{active} = "true";
      writeHashtoFile(file => $nodesfile, data => $NODES);

      Then call that script from cron at the beginning of the hour and end of the hour.

      Hope that helps.

       

      Regards

       

      Keith

      1. Harry Milanes

        Hi Keith, I just deployed the virtual appliance, not sure why they couldn't :-) Unfortunately I can't code - in perl or anything else. It's a minor inconvenience I suppose I can just ignore the alerts. But sincere thanks for such a great response, and I do hope it can help someone else. With thanks, Harry

      CommentAdd your comment...