Network Management
Convert alert value from bytes to GB in alert email
One might want to display a computed value (e.g. bytes to GB) in an alert email. This article shows one method to provide the value in the email.
First published date
Last published date
Overview
Some of the alerting variables are returned in bytes. However, you might want the value displayed in the email to be in either MB or GB. Displaying a computed value can be done with a SQL statement.
Product section
Resolution
- Edit the alert email and click where you would like to put the value in the message or subject line.
- Press INSERT VARIABLE.
- At the bottom of the pop-up box, check the box "Define SQL/SWQL Variable (Advanced)". It opens another box where you can put in a SQL or SWQL query. In this instance, ensure that the SQL radio button is selected.
- Enter the SQL to make the conversion. To put the variable name into the SQL, place the cursor where you want the variable name. Search for the variable in the above area, and press the + next to the variable name to add it to the SQL/SWQL.
For instance, to convert the memory that a process is using from bytes to GB on a component alert, the SQL query in the box would look similar to the following. (Note: 1073741824 is the number of bytes in a gigabyte.)
-- Scripts are not supported under any SolarWinds support program or service. -- Scripts are provided AS IS without warranty of any kind. SolarWinds further -- disclaims all warranties including, without limitation, any implied warranties -- of merchantability or of fitness for a particular purpose. The risk arising -- out of the use or performance of the scripts and documentation stays with you. -- In no event shall SolarWinds or anyone else involved in the creation, -- production, or delivery of the scripts be liable for any damages whatsoever -- (including, without limitation, damages for loss of business profits, business -- interruption, loss of business information, or other pecuniary loss) arising -- out of the use of or inability to use the scripts or documentation.
SELECT CAST(${N=SwisEntity;M=ComponentAlert.MemoryUsed} / 1073741824.0E AS DECIMAL(10, 2))
- Press INSERT VARIABLE.
- The display return to the email and the following is shown. Keep all the extra characters that have been added:
${SQL: SELECT CAST(${N=SwisEntity;M=ComponentAlert.MemoryUsed} / 1073741824.0E AS DECIMAL(10, 2))} - Finish the alert email as usual.
- Simulate the alert email to validate the computation.