notification on node down status



  • Hi,
    I'm using MyController from about 1 year ago, and I'm adding more and more nodes to my network.
    I'd like to receive a notification when one of them is down.
    Till now I managed this using the standard rules:
    4cc9bd57-521b-47c1-a5f7-07e92f791e73-image.png
    but it's very annoing to be managed for each new node.
    Is there a way to loop thru nodes in a script and the send a pushbullet notification based on the status?
    Thank
    Daniele



  • I'm following this example, changed the notification to pushbullet and added this row to filter only broken nodes:

      options.put("state", "DOWN");
    

    but I receive the error:

      "errorMessage": "java.lang.String cannot be cast to java.lang.Enum"
    

    I'm not a Java programmer, so I'm trying to understand how to use the HashMap looking at the examples I found on your forum.
    It's surely a stupid error, but I cannot understand where it is...

    Thank you for any help
    Daniele



  • @Daniele can you try,

      options.put("state", "Down");
    

    I did some small script, Not complete!

    var myImports = new JavaImporter(java.io, java.lang, java.util, java.text, java.util.HashMap);
    
    with(myImports) {
      // filters
      var filters = new HashMap();
      filters.put("orderBy", "lastSeen");
      filters.put("order", "desc");
      filters.put("state", "Down");  
    }
    

    Let me know if you need a complete solution, like how to ignore duplicate, etc.,



  • @jkandasa said in notification on node down status:

    put("state", "Down");

    I tried, but I still get the same error if I add this line to your script:

    var nodes = mcApi.node().getAll(filters);```


  • @Daniele What version of MyController are you using? I will try to come up with a complete solution soon.



  • 1.4.0, a snapshot of more or less one month ago


 

Suggested Topics

5
Online

431
Users

382
Topics

2.4k
Posts