Documentation
UC_GetMessageSenderIDSizeList
array UC_GetMessageSenderIDSizeList (int $InstanceID)
Parameters
| InstanceID | ID for the Util Control |
Returns
An array with one entry per sender that has sent a message since the start. Each entry contains the following key => value pairs:
| Index | Type | Description |
|---|---|---|
| SenderID | integer | ID of the object that caused the message (0 = kernel or no object) |
| Size | integer | Summed up size of the message data of this sender in bytes (estimate) |
Description
The function sums up per sender the size of the data transported in its messages. While UC_GetMessageSenderIDList only counts the number of messages, this list shows which objects create particularly large amounts of data, e.g. a string variable that is frequently updated with long texts.
The size is an estimate: strings count with their length in bytes, integers and floats with 8 bytes and booleans with 1 byte. Management data of the message itself (sender, message ID) is not counted.
The values are summed up in memory since the start of IP-Symcon and cannot be reset (only a restart starts again at 0). The order of the entries is not defined.
The ID of the Util Control instance can be determined e.g. with IPS_GetInstanceListByModuleID and the module GUID {B69010EA-96D5-46DF-B885-24821B8C8DBD}. If InstanceID does not exist, the function fails with "Instance #... does not exist", if the instance belongs to another module, with "Instance does not implement this function".
Example
// Determine the ID of the Util Control instance
$id = IPS_GetInstanceListByModuleID('{B69010EA-96D5-46DF-B885-24821B8C8DBD}')[0];
// Output the three senders with the largest amount of data
$list = UC_GetMessageSenderIDSizeList($id);
usort($list, function ($a, $b) {
return $b['Size'] <=> $a['Size'];
});
foreach (array_slice($list, 0, 3) as $entry) {
echo $entry['SenderID'] . ': ' . $entry['Size'] . ' bytes' . PHP_EOL;
}
/* e.g. returns:
10015: 1648 bytes
10007: 729 bytes
10008: 439 bytes
*/