'; $SNMPCommunity = ''; $ProcessSNMPBase = 'iso.3.6.1.4.1.2021.2.1'; $DiscSNMPBase = 'iso.3.6.1.4.1.2021.9.1'; $ParentID = IPS_GetParent($_IPS['SELF']); //========================================== // Ereignis prüfen/anlegen // Per Default wird alle 2 Minuten abgefragt //========================================== if(!@IPS_GetEventIDByName ('SNMP Server abfragen', $_IPS['SELF'] )) { $EventID = IPS_CreateEvent(1); IPS_SetEventCyclic($EventID, 0, 0, 0, 0, 2 ,2); IPS_SetParent($EventID, $_IPS['SELF']); IPS_SetEventActive($EventID, true); IPS_SetName($EventID, 'SNMP Server abfragen'); } $WebfrontCategoryID = CheckCreateCategory('Webfront',$ParentID); //================== // Prozesse abfragen //================== $i = 1; $ProcessName = ''; while(strlen($ProcessName) > 0) { $ProcessName = @StripDataTypeFromResult(snmp2_get($SNMPHost, $SNMPCommunity, $ProcessSNMPBase . '.' . '2.' . $i)); $ProcessNumberRunning = @StripDataTypeFromResult(snmp2_get($SNMPHost, $SNMPCommunity, $ProcessSNMPBase . '.' . '5.' . $i)); if($ProcessName != '') UpdateProcessNumberRunning($ProcessName,$ProcessNumberRunning); $i++; } //============================ // Festplattennutzung abfragen //============================ $i = 1; $DiscMountpoint = ''; while(strlen($DiscMountpoint) > 0) { $DiscMountpoint = @StripDataTypeFromResult(snmp2_get($SNMPHost, $SNMPCommunity, $DiscSNMPBase . '.' . '2.' . $i)); $DiscPhyVolume = @StripDataTypeFromResult(snmp2_get($SNMPHost, $SNMPCommunity, $DiscSNMPBase . '.' . '3.' . $i)); $DiscDataTotal = @StripDataTypeFromResult(snmp2_get($SNMPHost, $SNMPCommunity, $DiscSNMPBase . '.' . '6.' . $i)); $DiscDataAvailable = @StripDataTypeFromResult(snmp2_get($SNMPHost, $SNMPCommunity, $DiscSNMPBase . '.' . '7.' . $i)); $DiscDataUsed = @StripDataTypeFromResult(snmp2_get($SNMPHost, $SNMPCommunity, $DiscSNMPBase . '.' . '8.' . $i)); $DiscDataUsedPecent = @StripDataTypeFromResult(snmp2_get($SNMPHost, $SNMPCommunity, $DiscSNMPBase . '.' . '9.' . $i)); if($DiscMountpoint != '') { UpdateDiscInformation($DiscMountpoint,'Mountpoint',$DiscMountpoint,3); UpdateDiscInformation($DiscMountpoint,'Physischer Datenträger',$DiscPhyVolume,3); UpdateDiscInformation($DiscMountpoint,'Kapazität gesamt (MB)',round($DiscDataTotal/1024),1); UpdateDiscInformation($DiscMountpoint,'Kapazität verfügbar (MB)',round($DiscDataAvailable/1024),1); UpdateDiscInformation($DiscMountpoint,'Kapazität verwendet (MB)',round($DiscDataUsed/1024),1); UpdateDiscInformation($DiscMountpoint,'Kapazität verwendet (%)',$DiscDataUsedPecent,1); } $i++; } //================== // CPU Last abfragen //================== $CPULoad1 = @StripDataTypeFromResult(snmp2_get($SNMPHost, $SNMPCommunity, 'iso.3.6.1.4.1.2021.10.1.3.1')); $CPULoad5 = @StripDataTypeFromResult(snmp2_get($SNMPHost, $SNMPCommunity, 'iso.3.6.1.4.1.2021.10.1.3.2')); $CPULoad15 = @StripDataTypeFromResult(snmp2_get($SNMPHost, $SNMPCommunity, 'iso.3.6.1.4.1.2021.10.1.3.3')); UpdateCPUInformation('Auslastung 1 Minute',$CPULoad1); UpdateCPUInformation('Auslastung 5 Minuten',$CPULoad5); UpdateCPUInformation('Auslastung 15 Minuten',$CPULoad15); //================================== // Ab hier kommen interne Funktionen //================================== function StripDataTypeFromResult($Name) { // STRING, INTEGER, Leerzeichen, : und Anführungszeichen entfernen $StripStrings = array('STRING','INTEGER','"',' ',':'); $tmp1 = str_replace($StripStrings,'',$Name); return($tmp1); } function CheckCreateCategory($CategoryName,$ParentID) { $CategoryID = @IPS_GetCategoryIDByName($CategoryName,$ParentID); if(!$CategoryID) { $CategoryID = IPS_CreateCategory(); IPS_SetName($CategoryID, $CategoryName); IPS_SetParent($CategoryID,$ParentID); } return $CategoryID; } function CheckCreateDummyInstance($InstanceName,$ParentID) { $InstanceID = @IPS_GetInstanceIDByName($InstanceName,$ParentID); if(!$InstanceID) { $InstanceID = IPS_CreateInstance('{485D0419-BE97-4548-AA9C-C083EB82E61E}'); IPS_SetName($InstanceID, $InstanceName); IPS_SetParent($InstanceID,$ParentID); } return $InstanceID; } function CheckCreateVariable($VariableName,$ParentID,$IPSDataType,$Archiving=false) { $VariableID = @IPS_GetVariableIDByName($VariableName,$ParentID); if(!$VariableID) { $VariableID = IPS_CreateVariable($IPSDataType); IPS_SetName($VariableID, $VariableName); IPS_SetParent($VariableID,$ParentID); if($Archiving == True) { $ArchivInstanz = IPS_GetInstanceIDByName ('Archive Handler', 0); AC_SetLoggingStatus($ArchivInstanz, $VariableID, true); } } return $VariableID; } function CheckCreateLink($LinkName,$LinkLocation,$LinkDestination) { if(!@IPS_GetLinkIDByName($LinkName,$LinkLocation)) { $LinkID = IPS_CreateLink(); IPS_SetName($LinkID, $LinkName); IPS_SetLinkChildID($LinkID, $LinkDestination); IPS_SetParent($LinkID,$LinkLocation); } } function UpdateDiscInformation($DiscMountpoint,$DiscParameter,$DiscValue,$IPSDataType) { global $ParentID, $WebfrontCategoryID; $CategoryID = CheckCreateCategory('Festplatten',$ParentID); $CategoryID2 = CheckCreateCategory($DiscMountpoint,$CategoryID); $VariableID = CheckCreateVariable($DiscParameter,$CategoryID2,$IPSDataType,True); $InstanceID = CheckCreateDummyInstance('Festplatte ' . $DiscMountpoint,$WebfrontCategoryID); CheckCreateLink($DiscParameter,$InstanceID,$VariableID); SetValue($VariableID,$DiscValue); } function UpdateProcessNumberRunning($ProcessName,$ProcessNumberRunning) { global $ParentID, $WebfrontCategoryID; $CategoryID = CheckCreateCategory('Prozesse',$ParentID); $VariableID = CheckCreateVariable($ProcessName,$CategoryID,1,True); $InstanceID = CheckCreateDummyInstance('Prozesse',$WebfrontCategoryID); CheckCreateLink($ProcessName,$InstanceID,$VariableID); SetValue($VariableID,$ProcessNumberRunning); } function UpdateCPUInformation($CPULoadDesc,$CPULoad) { global $ParentID, $WebfrontCategoryID; $CategoryID = CheckCreateCategory('CPU',$ParentID); $VariableID = CheckCreateVariable($CPULoadDesc,$CategoryID,2,True); $InstanceID = CheckCreateDummyInstance('CPU-Auslastung',$WebfrontCategoryID); CheckCreateLink($CPULoadDesc,$InstanceID,$VariableID); SetValue($VariableID,(float)$CPULoad); } ?>