Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. [Frage] ioBroker - iLO Server Daten auslesen

    NEWS

    • Neuer Blog: Fotos und Eindrücke aus Solingen

    • ioBroker@Smart Living Forum Solingen, 14.06. - Agenda added

    • ioBroker goes Matter ... Matter Adapter in Stable

    [Frage] ioBroker - iLO Server Daten auslesen

    This topic has been deleted. Only users with topic management privileges can see it.
    • kmxak
      kmxak Most Active last edited by

      Adapter wäre sicherlich komfortabler.

      Allerdings ist es ja echt nur ein simples script.

      Falls wer Lust hat kann es ja gerne machen 😉

      1 Reply Last reply Reply Quote 0
      • N
        nobse last edited by

        Welche Wärmewerte willst du per script eingeben?

        1 Reply Last reply Reply Quote 0
        • Dutchman
          Dutchman Developer Most Active Administrators last edited by

          @kmxak:

          Adapter wäre sicherlich komfortabler.

          Allerdings ist es ja echt nur ein simples script.

          Falls wer Lust hat kann es ja gerne machen 😉 `

          Habs mal in trello eingetragen: https://trello.com/c/1gqUdxms

          Die Vorlage ist ja bereits da [emoji28]

          –-----------------------

          Send from mobile device

          1 Reply Last reply Reply Quote 0
          • kmxak
            kmxak Most Active last edited by

            @nobse:

            Welche Wärmewerte willst du per script eingeben? `

            Die Warnwerte ab denen es Kritisch wird.

            Würde ich aber in ein extra Script packen da es ja von Hardware zu Hardware unterschiedlich ist.

            Bei überschreiten oder annäherung an den Wert dann eine Warnung per Telegram.

            @Dutchman:

            @kmxak:

            Adapter wäre sicherlich komfortabler.

            Allerdings ist es ja echt nur ein simples script.

            Falls wer Lust hat kann es ja gerne machen 😉 `

            Habs mal in trello eingetragen: https://trello.com/c/1gqUdxms

            Die Vorlage ist ja bereits da [emoji28]

            –-----------------------

            Send from mobile device `

            Danke!

            1 Reply Last reply Reply Quote 0
            • N
              nobse last edited by

              Warte mal das kann man gleich mit erledigen im Script.

              1 Reply Last reply Reply Quote 0
              • Dutchman
                Dutchman Developer Most Active Administrators last edited by

                @kmxak:

                @nobse:

                Welche Wärmewerte willst du per script eingeben? `

                Die Warnwerte ab denen es Kritisch wird.

                Würde ich aber in ein extra Script packen da es ja von Hardware zu Hardware unterschiedlich ist.

                Bei überschreiten oder annäherung an den Wert dann eine Warnung per Telegram.

                @Dutchman:

                @kmxak:

                Adapter wäre sicherlich komfortabler.

                Allerdings ist es ja echt nur ein simples script.

                Falls wer Lust hat kann es ja gerne machen 😉 `

                Habs mal in trello eingetragen: https://trello.com/c/1gqUdxms

                Die Vorlage ist ja bereits da [emoji28]

                –-----------------------

                Send from mobile device `

                Danke! `

                Das mit den Variablen, währe ws nicht sinnvoller diese Werte als object im Baum weg zu schreiben wo auch die Daten stehen. Also zB

                • current

                • trash hold non

                • trash hold max

                Kann man dann auch wieder beliebig mit Adapter oder Script X abrufen und logic hinzufügen?

                (Zu blöd das ich meinen hp g8 ausfasiert habe sonst könnte ich mit testen)

                –-----------------------

                Send from mobile device

                1 Reply Last reply Reply Quote 0
                • N
                  nobse last edited by

                  Wie meinst du das
                  > diese Werte als object im Baum weg zu schreiben wo auch die Daten stehen

                  1 Reply Last reply Reply Quote 0
                  • Dutchman
                    Dutchman Developer Most Active Administrators last edited by

                    @nobse:

                    Wie meinst du das
                    > diese Werte als object im Baum weg zu schreiben wo auch die Daten stehen `

                    Dein Script erstellt objecte und füllt diese mit Werten.

                    Mein Vorschlag würde dies auch Max Werte machen wodurch wir zB den alarmwert (zb 70 Grad) per vis ändern könnten.

                    Dan muss man nicht immer ins Script um diese Werte zu setzen

                    –-----------------------

                    Send from mobile device

                    1 Reply Last reply Reply Quote 0
                    • N
                      nobse last edited by

                      Wenn ich dich richtig verstehe im script noch einen Datenpunkt anlegen mit dem max wert.

                      Das wollte ich ja machen und den max wert aus der hardware lesen.

                      Oder stehe ich jetzt auf dem Schlauch. 😄

                      1 Reply Last reply Reply Quote 0
                      • Dutchman
                        Dutchman Developer Most Active Administrators last edited by

                        @nobse:

                        Wenn ich dich richtig verstehe im script noch einen Datenpunkt anlegen mit dem max wert.

                        Das wollte ich ja machen und den max wert aus der hardware lesen.

                        Oder stehe ich jetzt auf dem Schlauch. 😄 `

                        Nope ich hab dich falsch verstanden sieht gut aus weiter so [emoji3]

                        –-----------------------

                        Send from mobile device

                        1 Reply Last reply Reply Quote 0
                        • N
                          nobse last edited by

                          Muss man den Max Werte den Editieren können?

                          Eigentlich reicht es wenn abgefragt wird ob der aktuelle Wert >= dem max wert ist und dann eine Benachrichtigung sendet oder?

                          1 Reply Last reply Reply Quote 0
                          • Dutchman
                            Dutchman Developer Most Active Administrators last edited by

                            @nobse:

                            Eigentlich reicht es wenn abgefragt wird ob der aktuelle Wert >= dem max wert ist und dann eine Benachrichtigung sendet oder? `

                            Jup, erschien mir nur praktisch die Variable zB aus vis oder anderen scripten ändern zu können.

                            –-----------------------

                            Send from mobile device

                            1 Reply Last reply Reply Quote 0
                            • N
                              nobse last edited by

                              OK habe das jetzt mal eingebaut

                              • Script ruft sich nicht mehr selber alle xx Sekunden auf sondern über Function schedule

                              • über writeLog kann Logeinträge Ein/Aus geschaltet werden

                              • Datenpunkte xx_max werden angelegt und mit Werten gefüllt

                              • aufruf Function isFehler prüft temp_ist >= temp-max und sendet Benachrichtigung (Fehlt noch)

                              Was für Benachrichtigungen sind gewünscht?

                              var server = "192.168.133.xx";
                              var username = "x";
                              var password = "x";
                              var writeLog = false;
                              
                              var runs = 0;
                              
                              var instanz = 'javascript.' + instance;
                              var pfad = '.iLO.';
                              
                              var request = require('request');
                              
                              function ilo(url, next, log){
                                 url = "https://"+server+url;
                                 request.timeout = 60000;
                                 request({
                                    "timeout": request.timeout,
                                    "rejectUnauthorized": false, 
                                    "url": url, 
                                    "method": "GET", 
                                    "headers":
                                    {
                                       "Content-Type": "application/json",
                                       "Accept": "application/json",
                                       "Authorization": "BASIC " + new Buffer(username+":"+password).toString('base64')
                                    }
                                 }, function(err, response, body){
                                    if (log) console.log("\n => "+url+" <=\n"+body+"\n");
                                    if (err) console.log(err+": "+url);
                                    else if (response.statusCode != 200) console.log(response.statusCode+": "+url);
                                    else if (next) next(JSON.parse(body));
                                 });
                              }
                              
                              function now() { return new Date().toISOString().replace(/T/, ' ').replace(/\..+/, ''); }
                              
                              function ping(){
                                 ilo("/rest/v1/Chassis/1/Thermal", function(body){
                                    var date = new Date();
                                    var log = now();
                                    if (runs++ == 0)      {
                                       for (var f in body.Fans) {
                                           var fan = body.Fans[f];
                                           log += ", "+fan.FanName+" ["+fan.Units+"]";
                                           createState(instanz + pfad + fan.FanName.replace(/ /g, '_'), {
                                              name: fan.PhysicalContext, 
                                              desc: fan.PhysicalContext,
                                              type: 'number', 
                                              def:  0,
                                              read: true,
                                              write: true,
                                              role: 'value'  
                                          }); 
                              
                                       }
                                       for (var t in body.Temperatures) { var temp = body.Temperatures[t]; log += ", "+temp.Name+" ["+temp.Units+"]"; 
                                          createState(instanz + pfad + temp.Name.replace(/ /g, '_'), {
                                              name: temp.PhysicalContext, 
                                              desc: temp.PhysicalContext,
                                              type: 'number', 
                                              def:  0,
                                              read: true,
                                              write: true,
                                              role: 'value'  
                                          });  
                              
                                          createState(instanz + pfad + temp.Name.replace(/ /g, '_') + "_max", {
                                              name: temp.PhysicalContext + "_max", 
                                              desc: temp.PhysicalContext + "_max",
                                              type: 'number', 
                                              def:  temp.LowerThresholdNonCritical,
                                              read: true,
                                              write: true,
                                              role: 'value'  
                                          });  
                              
                                       }
                                       if (writeLog === true){
                                           console.log(log);
                                          log = now();
                                       }
                                    }
                              
                                      for (var f in body.Fans) {
                                        var fan = body.Fans[f];
                                        log += ", "+fan.CurrentReading;
                                        setState(instanz + pfad + fan.FanName.replace(/ /g, '_'), fan.CurrentReading);
                                      }
                                      for (var t in body.Temperatures) {
                                        var temp = body.Temperatures[t];
                                        log += ", "+temp.CurrentReading;
                                        setState(instanz + pfad + temp.Name.replace(/ /g, '_'), temp.CurrentReading);
                                        isFehler(getState(instanz + pfad + temp.Name.replace(/ /g, '_') + "_max"),temp.CurrentReading)
                                      }
                              
                                      if (writeLog === true){
                                          console.log(log);
                                      }
                                 }, !true);
                              }
                              
                              function isFehler(temp_max,temp_aktuell){
                                  if (temp_aktuell >= temp_max){
                                      console.log("max = " + temp_max.val);
                                      console.log("ist = " + temp_aktuelle);
                                      //Benachrichtigung Einbauen
                                  }
                              }
                              
                              //Script läuft alle 2 Minuten
                              schedule("*/2 * * * *", function () {
                                  console.log("===> Start ILO");
                                  ping();
                              });
                              ping();
                              
                              1 Reply Last reply Reply Quote 0
                              • kmxak
                                kmxak Most Active last edited by

                                naja nun geht es ja schon richtung adapter.

                                Zur Auswahl stehen bei mir. Als ersten Telegram (da sehr schnell die info kommt) oder email aber die schaut man ja auch nicht immer nach.

                                Für die Leute die den z.B HP Gen 8 mit einem anderen CPU ausgestattet haben gehen aber die ausgelesenen Temp werte nicht oder? Oder werden die beim CPU wechsel auch im iLO aktualisiert?

                                Außer CPU brauche ich keine Max Werte ändern.

                                Die Warnung möchte ich allerding schon haben bevor die Max Temp erreicht wird. Quasi Grün er Bereich dann Oragnener mit Warnung und Rot mit ggf Shutdown später o.ä.

                                In den History Adapter werde ich ihn auf jeden fall auch einfügen dann kann ich mir das mal genauer ansehen.

                                Leider steht der Server bei mir unter dem Dachboden 😢 Ich habe bestimmt 26° aktuell hier …. und es nicht mal richtig sommer

                                1 Reply Last reply Reply Quote 0
                                • N
                                  nobse last edited by

                                  So habe mal die Mailbenachrichtigung eingebaut.

                                  Kann einer von euch mal den Code für Telegramm einbauen. Ich habe so was nicht. Kommt in die Function isFehler in die entsprechende If abfrage.

                                  var server = "192.168.133.x";
                                  var username = "x";
                                  var password = "x";
                                  var emailadresse = "x";  //E-Mailadresse für Benachrichtigung
                                  
                                  var writeLog = false;
                                  var benachrichtigung_per_email = false;
                                  var benachrichtigung_per_telegramm = false
                                  
                                  var runs = 0;
                                  
                                  var instanz = 'javascript.' + instance;
                                  var pfad = '.iLO.';
                                  
                                  var request = require('request');
                                  
                                  function ilo(url, next, log){
                                     url = "https://"+server+url;
                                     request.timeout = 60000;
                                     request({
                                        "timeout": request.timeout,
                                        "rejectUnauthorized": false, 
                                        "url": url, 
                                        "method": "GET", 
                                        "headers":
                                        {
                                           "Content-Type": "application/json",
                                           "Accept": "application/json",
                                           "Authorization": "BASIC " + new Buffer(username+":"+password).toString('base64')
                                        }
                                     }, function(err, response, body){
                                        if (log) console.log("\n => "+url+" <=\n"+body+"\n");
                                        if (err) console.log(err+": "+url);
                                        else if (response.statusCode != 200) console.log(response.statusCode+": "+url);
                                        else if (next) next(JSON.parse(body));
                                     });
                                  }
                                  
                                  function now() { return new Date().toISOString().replace(/T/, ' ').replace(/\..+/, ''); }
                                  
                                  function ping(){
                                     ilo("/rest/v1/Chassis/1/Thermal", function(body){
                                        var date = new Date();
                                        var log = now();
                                        if (runs++ === 0)      {
                                            createState(instanz + pfad + "iLO_Status", {
                                                  name: "iLO_Status", 
                                                  desc: "iLO_Status Gesamt",
                                                  type: 'boolean', 
                                                  def:  false,
                                                  read: true,
                                                  write: true,
                                                  role: ''
                                              }); 
                                  
                                           for (var f in body.Fans) {
                                               var fan = body.Fans[f];
                                               log += ", "+fan.FanName+" ["+fan.Units+"]";
                                               createState(instanz + pfad + fan.FanName.replace(/ /g, '_'), {
                                                  name: fan.PhysicalContext, 
                                                  desc: fan.PhysicalContext,
                                                  type: 'number', 
                                                  def:  0,
                                                  read: true,
                                                  write: true,
                                                  role: 'value'  
                                              }); 
                                  
                                           }
                                           for (var t in body.Temperatures) { var temp = body.Temperatures[t]; log += ", "+temp.Name+" ["+temp.Units+"]"; 
                                              createState(instanz + pfad + temp.Name.replace(/ /g, '_'), {
                                                  name: temp.PhysicalContext, 
                                                  desc: temp.PhysicalContext,
                                                  type: 'number', 
                                                  def:  0,
                                                  read: true,
                                                  write: true,
                                                  role: 'value'  
                                              });  
                                  
                                              createState(instanz + pfad + temp.Name.replace(/ /g, '_') + "_max", {
                                                  name: temp.PhysicalContext + "_max", 
                                                  desc: temp.PhysicalContext + "_max",
                                                  type: 'number', 
                                                  def:  temp.LowerThresholdNonCritical,
                                                  read: true,
                                                  write: true,
                                                  role: 'value'  
                                              });  
                                  
                                          }
                                          if (writeLog === true){
                                              console.log(log);
                                              log = now();
                                          }
                                        }
                                  
                                          for (var f in body.Fans) {
                                              var fan = body.Fans[f];
                                              log += ", "+fan.CurrentReading;
                                              setState(instanz + pfad + fan.FanName.replace(/ /g, '_'), fan.CurrentReading);
                                          }
                                  
                                          for (var t in body.Temperatures) {
                                              var temp = body.Temperatures[t];
                                              log += ", "+temp.CurrentReading;
                                              setState(instanz + pfad + temp.Name.replace(/ /g, '_'), temp.CurrentReading);
                                              isFehler(temp);
                                          }
                                  
                                          if (writeLog === true){
                                              console.log(log);
                                          }
                                      }, !true);
                                  }
                                  
                                  function isFehler(temp){
                                  
                                      var max = getState(instanz + pfad + temp.Name.replace(/ /g, '_') + "_max");
                                      var aktuell = temp.CurrentReading;
                                      if (aktuell >= max){
                                  
                                          setState(instanz + pfad + "iLO_Status", true);
                                  
                                          if (benachrichtigung_per_email === true){
                                              sendTo("email", {
                                                  to:      emailadresse,
                                                  subject: "Temperatur Warnung!!",
                                                  text:    "Aktuelle Temperatur " + temp.Name + " = " + aktuell + " Grad Celsius."
                                              });
                                          }
                                  
                                          if (benachrichtigung_per_telegramm === true){
                                  
                                          } 
                                      }
                                  }
                                  
                                  //Script läuft alle 2 Minuten
                                  schedule("*/2 * * * *", function () {
                                      console.log("===> Start ILO");
                                      ping();
                                  });
                                  
                                  1 Reply Last reply Reply Quote 0
                                  • kmxak
                                    kmxak Most Active last edited by

                                    Hier mal ein Script was funktionieren sollte mit Telegram:

                                    Leider bekomme ich weder in Telegram noch per Mail was.

                                    Ich habe nun 2 Max Werte auf 10° gesetzt das sollte doch dann sofort die Benachrichtigung auslösen oder?

                                    Lösen die nicht installieten Temp Fühler mit Wert 0 und Max 0 auch die Benachrichtigung aus?

                                    var server = "192.168.133.x";
                                    var username = "x";
                                    var password = "x";
                                    var emailadresse = "x";  //E-Mailadresse für Benachrichtigung
                                    var writeLog = true;
                                    var benachrichtigung_per_email = true;
                                    var benachrichtigung_per_telegramm = true; // hier hattest du kein ; das war falsch oder?
                                    
                                    var runs = 0;
                                    
                                    var instanz = 'javascript.' + instance;
                                    var pfad = '.iLO.';
                                    
                                    var request = require('request');
                                    
                                    function ilo(url, next, log){
                                       url = "https://"+server+url;
                                       request.timeout = 60000;
                                       request({
                                          "timeout": request.timeout,
                                          "rejectUnauthorized": false, 
                                          "url": url, 
                                          "method": "GET", 
                                          "headers":
                                          {
                                             "Content-Type": "application/json",
                                             "Accept": "application/json",
                                             "Authorization": "BASIC " + new Buffer(username+":"+password).toString('base64')
                                          }
                                       }, function(err, response, body){
                                          if (log) console.log("\n => "+url+" <=\n"+body+"\n");
                                          if (err) console.log(err+": "+url);
                                          else if (response.statusCode != 200) console.log(response.statusCode+": "+url);
                                          else if (next) next(JSON.parse(body));
                                       });
                                    }
                                    
                                    function now() { return new Date().toISOString().replace(/T/, ' ').replace(/\..+/, ''); }
                                    
                                    function ping(){
                                       ilo("/rest/v1/Chassis/1/Thermal", function(body){
                                          var date = new Date();
                                          var log = now();
                                          if (runs++ === 0)      {
                                              createState(instanz + pfad + "iLO_Status", {
                                                    name: "iLO_Status", 
                                                    desc: "iLO_Status Gesamt",
                                                    type: 'boolean', 
                                                    def:  false,
                                                    read: true,
                                                    write: true,
                                                    role: ''
                                                }); 
                                    
                                             for (var f in body.Fans) {
                                                 var fan = body.Fans[f];
                                                 log += ", "+fan.FanName+" ["+fan.Units+"]";
                                                 createState(instanz + pfad + fan.FanName.replace(/ /g, '_'), {
                                                    name: fan.PhysicalContext, 
                                                    desc: fan.PhysicalContext,
                                                    type: 'number', 
                                                    def:  0,
                                                    read: true,
                                                    write: true,
                                                    role: 'value'  
                                                }); 
                                    
                                             }
                                             for (var t in body.Temperatures) { var temp = body.Temperatures[t]; log += ", "+temp.Name+" ["+temp.Units+"]"; 
                                                createState(instanz + pfad + temp.Name.replace(/ /g, '_'), {
                                                    name: temp.PhysicalContext, 
                                                    desc: temp.PhysicalContext,
                                                    type: 'number', 
                                                    def:  0,
                                                    read: true,
                                                    write: true,
                                                    role: 'value'  
                                                });  
                                    
                                                createState(instanz + pfad + temp.Name.replace(/ /g, '_') + "_max", {
                                                    name: temp.PhysicalContext + "_max", 
                                                    desc: temp.PhysicalContext + "_max",
                                                    type: 'number', 
                                                    def:  temp.LowerThresholdNonCritical,
                                                    read: true,
                                                    write: true,
                                                    role: 'value'  
                                                });  
                                    
                                            }
                                            if (writeLog === true){
                                                console.log(log);
                                                log = now();
                                            }
                                          }
                                    
                                            for (var f in body.Fans) {
                                                var fan = body.Fans[f];
                                                log += ", "+fan.CurrentReading;
                                                setState(instanz + pfad + fan.FanName.replace(/ /g, '_'), fan.CurrentReading);
                                            }
                                    
                                            for (var t in body.Temperatures) {
                                                var temp = body.Temperatures[t];
                                                log += ", "+temp.CurrentReading;
                                                setState(instanz + pfad + temp.Name.replace(/ /g, '_'), temp.CurrentReading);
                                                isFehler(temp);
                                            }
                                    
                                            if (writeLog === true){
                                                console.log(log);
                                            }
                                        }, !true);
                                    }
                                    
                                    function isFehler(temp){
                                    
                                        var max = getState(instanz + pfad + temp.Name.replace(/ /g, '_') + "_max");
                                        var aktuell = temp.CurrentReading;
                                        if (aktuell >= max){
                                    
                                            setState(instanz + pfad + "iLO_Status", true);
                                    
                                            if (benachrichtigung_per_email === true){
                                                sendTo("email", {
                                                    to:      emailadresse,
                                                    subject: "Temperatur Warnung!!",
                                                    text:    "Aktuelle Temperatur " + temp.Name + " = " + aktuell + " Grad Celsius."
                                                });
                                            }
                                    
                                            if (benachrichtigung_per_telegramm === true){
                                               sendTo("telegram.0", "send", {
                                                   text:    "Aktuelle Temperatur " + temp.Name + " = " + aktuell + " Grad Celsius."  // um die Nachricht nur an Teilnehme xy zu schicken folgendes anfügen , chatId: 'xxx'
                                                });
                                            } 
                                        }
                                    }
                                    
                                    //Script läuft alle 2 Minuten
                                    schedule("*/2 * * * *", function () {
                                        console.log("===> Start ILO");
                                        ping();
                                    });
                                    
                                    1 Reply Last reply Reply Quote 0
                                    • N
                                      nobse last edited by

                                      Ah ja da gebe ich dir recht das es nicht geht.

                                      Andere mal die Zeile

                                      if (aktuell >= max){
                                      

                                      in

                                      if (aktuell > max.val){
                                      
                                      1 Reply Last reply Reply Quote 0
                                      • kmxak
                                        kmxak Most Active last edited by

                                        Jawohl es geht!

                                        Nochmal den Text etwas angepasst.

                                        Er sendet nun aber alle 2 Minuten eine Benachrichtigung solange die Temperatur zu hoch ist.

                                        Kann man das irgendwie nur einmal machen? Sonst wirst du voll gespammt 8-)

                                        var server = "192.168.133.x";
                                        var username = "x";
                                        var password = "x";
                                        var emailadresse = "x";  //E-Mailadresse für Benachrichtigungvar writeLog = true;
                                        var benachrichtigung_per_email = false;
                                        var benachrichtigung_per_telegramm = true; // hier hattest du kein ; das war falsch oder?
                                        
                                        var runs = 0;
                                        
                                        var instanz = 'javascript.' + instance;
                                        var pfad = '.iLO.';
                                        
                                        var request = require('request');
                                        
                                        function ilo(url, next, log){
                                           url = "https://"+server+url;
                                           request.timeout = 60000;
                                           request({
                                              "timeout": request.timeout,
                                              "rejectUnauthorized": false, 
                                              "url": url, 
                                              "method": "GET", 
                                              "headers":
                                              {
                                                 "Content-Type": "application/json",
                                                 "Accept": "application/json",
                                                 "Authorization": "BASIC " + new Buffer(username+":"+password).toString('base64')
                                              }
                                           }, function(err, response, body){
                                              if (log) console.log("\n => "+url+" <=\n"+body+"\n");
                                              if (err) console.log(err+": "+url);
                                              else if (response.statusCode != 200) console.log(response.statusCode+": "+url);
                                              else if (next) next(JSON.parse(body));
                                           });
                                        }
                                        
                                        function now() { return new Date().toISOString().replace(/T/, ' ').replace(/\..+/, ''); }
                                        
                                        function ping(){
                                           ilo("/rest/v1/Chassis/1/Thermal", function(body){
                                              var date = new Date();
                                              var log = now();
                                              if (runs++ === 0)      {
                                                  createState(instanz + pfad + "iLO_Status", {
                                                        name: "iLO_Status", 
                                                        desc: "iLO_Status Gesamt",
                                                        type: 'boolean', 
                                                        def:  false,
                                                        read: true,
                                                        write: true,
                                                        role: ''
                                                    }); 
                                        
                                                 for (var f in body.Fans) {
                                                     var fan = body.Fans[f];
                                                     log += ", "+fan.FanName+" ["+fan.Units+"]";
                                                     createState(instanz + pfad + fan.FanName.replace(/ /g, '_'), {
                                                        name: fan.PhysicalContext, 
                                                        desc: fan.PhysicalContext,
                                                        type: 'number', 
                                                        def:  0,
                                                        read: true,
                                                        write: true,
                                                        role: 'value'  
                                                    }); 
                                        
                                                 }
                                                 for (var t in body.Temperatures) { var temp = body.Temperatures[t]; log += ", "+temp.Name+" ["+temp.Units+"]"; 
                                                    createState(instanz + pfad + temp.Name.replace(/ /g, '_'), {
                                                        name: temp.PhysicalContext, 
                                                        desc: temp.PhysicalContext,
                                                        type: 'number', 
                                                        def:  0,
                                                        read: true,
                                                        write: true,
                                                        role: 'value'  
                                                    });  
                                        
                                                    createState(instanz + pfad + temp.Name.replace(/ /g, '_') + "_max", {
                                                        name: temp.PhysicalContext + "_max", 
                                                        desc: temp.PhysicalContext + "_max",
                                                        type: 'number', 
                                                        def:  temp.LowerThresholdNonCritical,
                                                        read: true,
                                                        write: true,
                                                        role: 'value'  
                                                    });  
                                        
                                                }
                                                if (writeLog === true){
                                                    console.log(log);
                                                    log = now();
                                                }
                                              }
                                        
                                                for (var f in body.Fans) {
                                                    var fan = body.Fans[f];
                                                    log += ", "+fan.CurrentReading;
                                                    setState(instanz + pfad + fan.FanName.replace(/ /g, '_'), fan.CurrentReading);
                                                }
                                        
                                                for (var t in body.Temperatures) {
                                                    var temp = body.Temperatures[t];
                                                    log += ", "+temp.CurrentReading;
                                                    setState(instanz + pfad + temp.Name.replace(/ /g, '_'), temp.CurrentReading);
                                                    isFehler(temp);
                                                }
                                        
                                                if (writeLog === true){
                                                    console.log(log);
                                                }
                                            }, !true);
                                        }
                                        
                                        function isFehler(temp){
                                        
                                            var max = getState(instanz + pfad + temp.Name.replace(/ /g, '_') + "_max");
                                            var aktuell = temp.CurrentReading;
                                            if (aktuell > max.val){
                                        
                                                setState(instanz + pfad + "iLO_Status", true);
                                        
                                                if (benachrichtigung_per_email === true){
                                                    sendTo("email", {
                                                        to:      emailadresse,
                                                        subject: "Temperatur Warnung!!",
                                                        text:    "Aktuelle Temperatur " + temp.Name + " = " + aktuell + " Grad Celsius."
                                                    });
                                                }
                                        
                                                if (benachrichtigung_per_telegramm === true){
                                                   sendTo("telegram.1", "send", {
                                                       text:    "iLO Temperatur Warnung!! Aktuelle Temperatur " + temp.Name + " = " + aktuell + " Grad Celsius."  // um die Nachricht nur an Teilnehme xy zu schicken folgendes anfügen , chatId: 'xxx'
                                                    });
                                                } 
                                            }
                                        }
                                        
                                        //Script läuft alle 2 Minuten
                                        schedule("*/2 * * * *", function () {
                                            console.log("===> Start ILO");
                                            ping();
                                        });
                                        
                                        1 Reply Last reply Reply Quote 0
                                        • kmxak
                                          kmxak Most Active last edited by

                                          was ich gerade noch nicht kapiere ist der iLO status.. der wurde ja auf true gesetzt wegen meiner max temp auf 10 gestellt.

                                          Habe dann die Temperaturwerte Max gelöscht und neu erstellen lassen aber ich habe immer noch die selben warnungen erhalten. Auch ein Script neustart änderte nix.

                                          Habe den iLO status dann manuell auf false gesetzt nun ist alles wieder ruhig.

                                          Passt da was noch nicht?

                                          1 Reply Last reply Reply Quote 0
                                          • N
                                            nobse last edited by

                                            • Benachrichtigungen werden nur einmal gesendet

                                            • iLO_Status wird bei Fehlern auf TRUE gesetzt und wenn keine Fehler auf FALSE

                                            var server = "192.168.133.x";
                                            var username = "x";
                                            var password = "x";
                                            var emailadresse = "x";  //E-Mailadresse für Benachrichtigung
                                            
                                            var writeLog = false;
                                            var benachrichtigung_per_email = true;  //Mail Adapter muss installiert sein
                                            var benachrichtigung_per_telegramm = false; //Telegram Adapter muss installiert sein
                                            var benachrichtigung_gesendet = 0;
                                            
                                            var runs = 0;
                                            var anzahl_fehler = 0;
                                            
                                            var instanz = 'javascript.' + instance;
                                            var pfad = '.iLO.';
                                            
                                            var request = require('request');
                                            
                                            function ilo(url, next, log){
                                               url = "https://"+server+url;
                                               request.timeout = 60000;
                                               request({
                                                  "timeout": request.timeout,
                                                  "rejectUnauthorized": false, 
                                                  "url": url, 
                                                  "method": "GET", 
                                                  "headers":
                                                  {
                                                     "Content-Type": "application/json",
                                                     "Accept": "application/json",
                                                     "Authorization": "BASIC " + new Buffer(username+":"+password).toString('base64')
                                                  }
                                               }, function(err, response, body){
                                                  if (log) console.log("\n => "+url+" <=\n"+body+"\n");
                                                  if (err) console.log(err+": "+url);
                                                  else if (response.statusCode != 200) console.log(response.statusCode+": "+url);
                                                  else if (next) next(JSON.parse(body));
                                               });
                                            }
                                            
                                            function now() { return new Date().toISOString().replace(/T/, ' ').replace(/\..+/, ''); }
                                            
                                            function ping(){
                                               ilo("/rest/v1/Chassis/1/Thermal", function(body){
                                                  var date = new Date();
                                                  var log = now();
                                                  if (runs++ === 0)      {
                                                      createState(instanz + pfad + "iLO_Status", {
                                                            name: "iLO_Status", 
                                                            desc: "iLO_Status Gesamt",
                                                            type: 'boolean', 
                                                            def:  false,
                                                            read: true,
                                                            write: true,
                                                            role: ''
                                            
                                                        }); 
                                                     for (var f in body.Fans) {
                                                         var fan = body.Fans[f];
                                                         log += ", "+fan.FanName+" ["+fan.Units+"]";
                                                         createState(instanz + pfad + fan.FanName.replace(/ /g, '_'), {
                                                            name: fan.PhysicalContext, 
                                                            desc: fan.PhysicalContext,
                                                            type: 'number', 
                                                            def:  0,
                                                            read: true,
                                                            write: true,
                                                            role: 'value'  
                                                        }); 
                                            
                                                     }
                                                     for (var t in body.Temperatures) { var temp = body.Temperatures[t]; log += ", "+temp.Name+" ["+temp.Units+"]"; 
                                                        createState(instanz + pfad + temp.Name.replace(/ /g, '_'), {
                                                            name: temp.PhysicalContext, 
                                                            desc: temp.PhysicalContext,
                                                            type: 'number', 
                                                            def:  0,
                                                            read: true,
                                                            write: true,
                                                            role: 'value'  
                                                        });  
                                            
                                                        createState(instanz + pfad + temp.Name.replace(/ /g, '_') + "_max", {
                                                            name: temp.PhysicalContext + "_max", 
                                                            desc: temp.PhysicalContext + "_max",
                                                            type: 'number', 
                                                            def:  temp.LowerThresholdNonCritical,
                                                            read: true,
                                                            write: true,
                                                            role: 'value'  
                                                        });  
                                                    }
                                                    if (writeLog === true){
                                                        console.log(log);
                                                        log = now();
                                                    }
                                                  }
                                                  anzahl_fehler = 0;
                                                    for (var f in body.Fans) {
                                                        var fan = body.Fans[f];
                                                        log += ", "+fan.CurrentReading;
                                                        setState(instanz + pfad + fan.FanName.replace(/ /g, '_'), fan.CurrentReading);
                                                    }
                                            
                                                    for (var t in body.Temperatures) {
                                                        var temp = body.Temperatures[t];
                                                        log += ", "+temp.CurrentReading;
                                                        setState(instanz + pfad + temp.Name.replace(/ /g, '_'), temp.CurrentReading);
                                                        isFehler(temp);
                                                    }
                                            
                                                    if (anzahl_fehler > 0){
                                                        setState(instanz + pfad + "iLO_Status", true);
                                                    }else{
                                                        setState(instanz + pfad + "iLO_Status", false);
                                                        benachrichtigung_gesendet = 0;
                                                    }
                                            
                                                    if (writeLog === true){
                                                        console.log(log);
                                                    }
                                                }, !true);
                                            }
                                            
                                            function isFehler(temp){
                                            
                                                var max = getState(instanz + pfad + temp.Name.replace(/ /g, '_') + "_max");
                                                var aktuell = temp.CurrentReading;
                                            
                                                if (aktuell > max.val){
                                                    anzahl_fehler++;
                                                    if (benachrichtigung_per_email === true & benachrichtigung_gesendet === 0){
                                                        sendTo("email", {
                                                            to:      emailadresse,
                                                            subject: "iLO Temperatur Warnung!!",
                                                            text:    "Aktuelle Temperatur " + temp.Name + " = " + aktuell + " Grad Celsius."
                                                        });
                                                        benachrichtigung_gesendet = 1;
                                                    }
                                            
                                                    if (benachrichtigung_per_telegramm === true & benachrichtigung_gesendet === 0){
                                                        sendTo("telegram." + instance, "send", {
                                                            text: ("iLO Temperatur Warnung!! Aktuelle Temperatur " + temp.Name + " = " + aktuell + " Grad Celsius.") // um die Nachricht nur an Teilnehme xy zu schicken folgendes anfügen , chatId: 'xxx'
                                                        });
                                                        benachrichtigung_gesendet = 1;
                                                    } 
                                                }
                                            }
                                            
                                            //Script läuft alle 2 Minuten
                                            schedule("*/2 * * * *", function () {
                                                console.log("===> Start ILO");
                                                ping();
                                            });
                                            
                                            1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post

                                            Support us

                                            ioBroker
                                            Community Adapters
                                            Donate

                                            548
                                            Online

                                            31.8k
                                            Users

                                            80.0k
                                            Topics

                                            1.3m
                                            Posts

                                            5
                                            44
                                            4922
                                            Loading More Posts
                                            • Oldest to Newest
                                            • Newest to Oldest
                                            • Most Votes
                                            Reply
                                            • Reply as topic
                                            Log in to reply
                                            Community
                                            Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen
                                            The ioBroker Community 2014-2023
                                            logo