Exemplo n.º 1
0
 private function Benachrichtigung($Batterien_AR)
 {
     if ($this->ReadPropertyInteger("BenachrichtigungsVar") != 0) {
         if (GetValueBoolean($this->ReadPropertyInteger("BenachrichtigungsVar")) === false) {
             return;
         }
     }
     $ParentName1Tabelle = $this->Umlaute_Ersetzen($this->ReadPropertyString("NameParentTabelle1TB"));
     $ParentName2Tabelle = $this->Umlaute_Ersetzen($this->ReadPropertyString("NameParentTabelle2TB"));
     $ParentName3Tabelle = $this->Umlaute_Ersetzen($this->ReadPropertyString("NameParentTabelle3TB"));
     $BenachrichtigungsText = $this->ReadPropertyString("BatterieBenachrichtigungTEXT");
     foreach ($Batterien_AR as $Aktor) {
         $AktorName = $Aktor["Name"];
         if ($this->ReadPropertyBoolean("NamenParentObjekt1CB") == true) {
             $AktorParent1Name = $Aktor[$ParentName1Tabelle];
         }
         if ($this->ReadPropertyBoolean("NamenParentObjekt2CB") == true) {
             $AktorParent2Name = $Aktor[$ParentName2Tabelle];
         }
         if ($this->ReadPropertyBoolean("NamenParentObjekt3CB") == true) {
             $AktorParent3Name = $Aktor[$ParentName3Tabelle];
         }
         $AktorHersteller = $Aktor["Hersteller"];
         $AktorID = $Aktor["ID"];
         $AktorBatterie = $Aktor["Batterie"];
         $AktorLetztesUpdateSEK = $Aktor["LetztesVarUpdateVorSek"];
         $AktorLetztesUpdateTS = date("d.m.Y H:i", $Aktor["LetztesVarUpdateTimestamp"]);
         //Code-Wörter austauschen gegen gewünschte Werte
         $search = array("§AKTORHERSTELLER", "§AKTORID", "§AKTORBATTERIE", "§AKTORLETZTESUPDATE");
         $replace = array($AktorHersteller, $AktorID, $AktorBatterie, $AktorLetztesUpdateTS);
         if ($this->ReadPropertyBoolean("NamenAktorObjektCB") == true) {
             array_push($search, "§AKTORNAME");
             array_push($replace, $AktorName);
         }
         if ($this->ReadPropertyBoolean("NamenParentObjekt1CB") == true) {
             array_push($search, "§AKTORPARENT1");
             array_push($replace, $AktorParent1Name);
         }
         if ($this->ReadPropertyBoolean("NamenParentObjekt2CB") == true) {
             array_push($search, "§AKTORPARENT2");
             array_push($replace, $AktorParent2Name);
         }
         if ($this->ReadPropertyBoolean("NamenParentObjekt3CB") == true) {
             array_push($search, "§AKTORPARENT3");
             array_push($replace, $AktorParent3Name);
         }
         $Text = str_replace($search, $replace, $BenachrichtigungsText);
         $Text = str_replace('Â', '', $Text);
         //PUSH-NACHRICHT
         if ($this->ReadPropertyBoolean("PushMsgAktiv") == true) {
             $WFinstanzID = $this->ReadPropertyInteger("WebFrontInstanceID");
             if ($WFinstanzID != "" and @IPS_InstanceExists($WFinstanzID) === true) {
                 if (strlen($Text) <= 256) {
                     WFC_PushNotification($WFinstanzID, "BatterieMonitor", $Text, "", 0);
                 } else {
                     IPS_LogMessage("BatterieMonitor", "FEHLER!!! - Die Textlänge einer Push-Nachricht darf maximal 256 Zeichen betragen!!!");
                 }
             }
         }
         //EMAIL-NACHRICHT
         if ($this->ReadPropertyBoolean("EMailMsgAktiv") == true) {
             $SMTPinstanzID = $this->ReadPropertyInteger("SmtpInstanceID");
             if ($SMTPinstanzID != "" and @IPS_InstanceExists($SMTPinstanzID) === true) {
                 SMTP_SendMail($SMTPinstanzID, "BatterieMonitor", $Text);
             }
         }
         //EIGENE-AKTION
         if ($this->ReadPropertyBoolean("EigenesSkriptAktiv") == true) {
             $SkriptID = $this->ReadPropertyInteger("EigenesSkriptID");
             if ($SkriptID != "" and @IPS_ScriptExists($SkriptID) === true) {
                 if ($this->ReadPropertyBoolean("NamenParentObjekt1CB") == true and $this->ReadPropertyBoolean("NamenParentObjekt2CB") == false and $this->ReadPropertyBoolean("NamenParentObjekt3CB") == false) {
                     IPS_RunScriptEx($SkriptID, array("BMON_Name" => $AktorName, "BMON_ParentName1" => $AktorParent1Name, "BMON_Hersteller" => $AktorHersteller, "BMON_ID" => $AktorID, "BMON_Batterie" => $AktorBatterie, "BMON_Text" => $Text, "BMON_LetztesUpdateTS" => $AktorLetztesUpdateTS, "BMON_LetztesUpdateSEK" => $AktorLetztesUpdateSEK));
                 } elseif ($this->ReadPropertyBoolean("NamenParentObjekt1CB") == false and $this->ReadPropertyBoolean("NamenParentObjekt2CB") == true and $this->ReadPropertyBoolean("NamenParentObjekt3CB") == false) {
                     IPS_RunScriptEx($SkriptID, array("BMON_Name" => $AktorName, "BMON_ParentName2" => $AktorParent2Name, "BMON_Hersteller" => $AktorHersteller, "BMON_ID" => $AktorID, "BMON_Batterie" => $AktorBatterie, "BMON_Text" => $Text, "BMON_LetztesUpdateTS" => $AktorLetztesUpdateTS, "BMON_LetztesUpdateSEK" => $AktorLetztesUpdateSEK));
                 } elseif ($this->ReadPropertyBoolean("NamenParentObjekt1CB") == false and $this->ReadPropertyBoolean("NamenParentObjekt2CB") == false and $this->ReadPropertyBoolean("NamenParentObjekt3CB") == true) {
                     IPS_RunScriptEx($SkriptID, array("BMON_Name" => $AktorName, "BMON_ParentName3" => $AktorParent3Name, "BMON_Hersteller" => $AktorHersteller, "BMON_ID" => $AktorID, "BMON_Batterie" => $AktorBatterie, "BMON_Text" => $Text, "BMON_LetztesUpdateTS" => $AktorLetztesUpdateTS, "BMON_LetztesUpdateSEK" => $AktorLetztesUpdateSEK));
                 } elseif ($this->ReadPropertyBoolean("NamenParentObjekt1CB") == true and $this->ReadPropertyBoolean("NamenParentObjekt2CB") == true and $this->ReadPropertyBoolean("NamenParentObjekt3CB") == true) {
                     IPS_RunScriptEx($SkriptID, array("BMON_Name" => $AktorName, "BMON_ParentName1" => $AktorParent1Name, "BMON_ParentName2" => $AktorParent2Name, "BMON_ParentName3" => $AktorParent3Name, "BMON_Hersteller" => $AktorHersteller, "BMON_ID" => $AktorID, "BMON_Batterie" => $AktorBatterie, "BMON_Text" => $Text, "BMON_LetztesUpdateTS" => $AktorLetztesUpdateTS, "BMON_LetztesUpdateSEK" => $AktorLetztesUpdateSEK));
                 } elseif ($this->ReadPropertyBoolean("NamenParentObjekt1CB") == true and $this->ReadPropertyBoolean("NamenParentObjekt2CB") == true and $this->ReadPropertyBoolean("NamenParentObjekt3CB") == false) {
                     IPS_RunScriptEx($SkriptID, array("BMON_Name" => $AktorName, "BMON_ParentName1" => $AktorParent1Name, "BMON_ParentName2" => $AktorParent2Name, "BMON_Hersteller" => $AktorHersteller, "BMON_ID" => $AktorID, "BMON_Batterie" => $AktorBatterie, "BMON_Text" => $Text, "BMON_LetztesUpdateTS" => $AktorLetztesUpdateTS, "BMON_LetztesUpdateSEK" => $AktorLetztesUpdateSEK));
                 } elseif ($this->ReadPropertyBoolean("NamenParentObjekt1CB") == false and $this->ReadPropertyBoolean("NamenParentObjekt2CB") == true and $this->ReadPropertyBoolean("NamenParentObjekt3CB") == true) {
                     IPS_RunScriptEx($SkriptID, array("BMON_Name" => $AktorName, "BMON_ParentName2" => $AktorParent2Name, "BMON_ParentName3" => $AktorParent3Name, "BMON_Hersteller" => $AktorHersteller, "BMON_ID" => $AktorID, "BMON_Batterie" => $AktorBatterie, "BMON_Text" => $Text, "BMON_LetztesUpdateTS" => $AktorLetztesUpdateTS, "BMON_LetztesUpdateSEK" => $AktorLetztesUpdateSEK));
                 } elseif ($this->ReadPropertyBoolean("NamenParentObjekt1CB") == true and $this->ReadPropertyBoolean("NamenParentObjekt2CB") == false and $this->ReadPropertyBoolean("NamenParentObjekt3CB") == true) {
                     IPS_RunScriptEx($SkriptID, array("BMON_Name" => $AktorName, "BMON_ParentName1" => $AktorParent1Name, "BMON_ParentName3" => $AktorParent3Name, "BMON_Hersteller" => $AktorHersteller, "BMON_ID" => $AktorID, "BMON_Batterie" => $AktorBatterie, "BMON_Text" => $Text, "BMON_LetztesUpdateTS" => $AktorLetztesUpdateTS, "BMON_LetztesUpdateSEK" => $AktorLetztesUpdateSEK));
                 } elseif ($this->ReadPropertyBoolean("NamenParentObjekt1CB") == false and $this->ReadPropertyBoolean("NamenParentObjekt2CB") == false and $this->ReadPropertyBoolean("NamenParentObjekt3CB") == false) {
                     IPS_RunScriptEx($SkriptID, array("BMON_Name" => $AktorName, "BMON_Hersteller" => $AktorHersteller, "BMON_ID" => $AktorID, "BMON_Batterie" => $AktorBatterie, "BMON_Text" => $Text, "BMON_LetztesUpdateTS" => $AktorLetztesUpdateTS, "BMON_LetztesUpdateSEK" => $AktorLetztesUpdateSEK));
                 }
             }
         }
     }
 }
Exemplo n.º 2
0
 public function Benachrichtigung($status, $live)
 {
     if ($status == false) {
         $this->SetTimerByIdent_InSekunden("HMON_BenachrichtigungOfflineTimer", false);
         $BenachrichtigungsText = $this->ReadPropertyString("BenachrichtigungsTextOffline");
         $Hoststatus = "offline";
         if ($live == true) {
             $this->SetValueBoolean("HostBenachrichtigungsFlag", true);
         }
     } elseif ($status == true) {
         $BenachrichtigungsText = $this->ReadPropertyString("BenachrichtigungsTextOnline");
         $Hoststatus = "online";
         if ($live == true) {
             $this->SetValueBoolean("HostBenachrichtigungsFlag", false);
         }
     }
     $Hostname = $this->ReadPropertyString("HostName");
     $Hostadresse = $this->ReadPropertyString("HostAdresse");
     $LastOnlineTimeDiffSEK = (int) (time() - GetValueInteger($this->GetIDForIdent("HostLastOnline")));
     $LastOnlineTimeDiffMIN = (int) ($LastOnlineTimeDiffSEK / 60);
     $LastOnlineTimeDiffSTD = round($LastOnlineTimeDiffMIN / 60, 2);
     $LastOnlineTimeDiffTAGE = round($LastOnlineTimeDiffSTD / 24, 2);
     //Code-Wörter austauschen gegen gewünschte Werte
     $search = array("§HOST", "§ADRESSE", "§ZEITSEK", "§ZEITMIN", "§ZEITSTD", "§ZEITTAGE");
     $replace = array($Hostname, $Hostadresse, $LastOnlineTimeDiffSEK, $LastOnlineTimeDiffMIN, $LastOnlineTimeDiffSTD, $LastOnlineTimeDiffTAGE);
     $Text = str_replace($search, $replace, $BenachrichtigungsText);
     $Text = str_replace('Â', '', $Text);
     //PUSH-NACHRICHT
     if ($this->ReadPropertyBoolean("PushMsgAktiv") == true) {
         $WFinstanzID = $this->ReadPropertyInteger("WebFrontInstanceID");
         if ($WFinstanzID != "" and @IPS_InstanceExists($WFinstanzID) === true) {
             WFC_PushNotification($WFinstanzID, "HostMonitor", $Text, "", 0);
         }
     }
     //EMAIL-NACHRICHT
     if ($this->ReadPropertyBoolean("EMailMsgAktiv") == true) {
         $SMTPinstanzID = $this->ReadPropertyInteger("SmtpInstanceID");
         if ($SMTPinstanzID != "" and @IPS_InstanceExists($SMTPinstanzID) === true) {
             SMTP_SendMail($SMTPinstanzID, "HostMonitor", $Text);
         }
     }
     //EIGENE-AKTION
     if ($this->ReadPropertyBoolean("EigenesSkriptAktiv") == true) {
         $SkriptID = $this->ReadPropertyInteger("EigenesSkriptID");
         if ($SkriptID != "" and @IPS_ScriptExists($SkriptID) === true) {
             IPS_RunScriptEx($SkriptID, array("HMON_Name" => $Hostname, "HMON_Adresse" => $Hostadresse, "HMON_Status" => $Hoststatus, "HMON_Text" => $Text, "HMON_Zeit" => $LastOnlineTimeDiffSEK));
         }
     }
 }
Exemplo n.º 3
0
 /**
  * Startet das Alarm-Script.
  *
  * @access protected
  * @param int $IPSVarID Variable welche den Alarm ausgelöst hat.
  * @param bool $NewState Alarmstatus neu
  * @param bool $OldState Alarmstatus vorher
  */
 protected function DoScript(int $IPSVarID, bool $NewState, bool $OldState)
 {
     if ($this->ReadPropertyInteger('ScriptID') != 0) {
         if (IPS_ScriptExists($this->ReadPropertyInteger('ScriptID'))) {
             IPS_RunScriptEx($this->ReadPropertyInteger('ScriptID'), array('VALUE' => $NewState, 'OLDVALUE' => $OldState, 'VARIABLE' => $IPSVarID, 'EVENT' => $this->InstanceID, 'SENDER' => 'NoTrigger'));
         }
     } else {
         IPS_LogMessage('NoTrigger', 'Script ' . $this->ReadPropertyInteger('ScriptID') . ' existiert nicht!');
     }
 }