Implementation Details
The following code snippet illustrates the approach to querying the system for HDD capacity and RAM usage. It accounts for redundant servers by accepting the server number as input and adjusting the data point references accordingly.
Important: It's imperative to handle internal data points with caution. Any unintended modification might lead to critical issues, potentially requiring a system reinstallation. Ensure that you are familiar with the data points you intend to monitor. Note that the HDD space monitored is specific to the drive where the project is installed, and the available RAM is just a snapshot of the current usage.
int HDDCapacityInt;
int RamMemoryInt;
int ServerNum = $iNumber;
void initialize()
{
...
if (Server == nullptr){
DebugN("Failed to get server instance for:", ReceivedDollarParam);
}
string SystemNameServer = getSystemName();
string HDD;
string RAM;
if(ServerNum != 2)
{
HDD = "_ArchivDisk.AvailPerc";
RAM = "_MemoryCheck.FreePerc";
}
else
{
HDD = "_ArchivDisk_2.AvailPerc";
RAM = "_MemoryCheck_2.FreePerc";
}
dpConnect("getHDDCapacity",SystemNameServer + HDD);
dpConnect("getMemory", SystemNameServer + RAM);
}
void getHDDCapacity(string dpe, int percentage)
{
int ProxyCapacityPercentage;
dpGet(dpe,ProxyCapacityPercentage);
HDDCapacity.setTxt((string)ProxyCapacityPercentage + " %");
}
void getMemory(string dpe, int percentage)
{
int ProxyRamPercentage;
dpGet(dpe,ProxyRamPercentage);
RamMemory.setTxt((string)ProxyRamPercentage + " %");
}