HP SIM, Schedule and Email Custom Reports

This is a quick walk through on how to Create a Custom Report in HP Systems Insight Manager (with a Custom list of Events based on Systems, Types of Events, and Attributes of the Event. Then how to Schedule running the saved Report using Windows Task Manager.

Then how to check the results for any notable events, if there are none then no other actions is taken; if there are notable events a follow up email is sent to a list of recipents.

The HTML formatted report from the SIM task is included in the body of the email, so that it can be read from an inbox or through a mobile devices inbox. But it can also be sent as an attachment.

It demonstrates several technologies:
  • Systems Insight Manager (SIM) Custom system collections
  • Systems Insight Manager (SIM) Custom event filters
  • Systems Insight Manager (SIM) Custom reporting
  • Windows Task Manager (Scheduling)
  • Batch file processing to kick off a Powershell script (Scripting)
  • Powershell processing to text process an HTML formatted document 
  • Powershell processing to make decisions on the contents of an HTML document
  • Windows Task Manager - Custom event triggering using XPath statements 
  • Powershell processing - to send email and include text or HTML formatted content in the message body or as an attachment

The only applications used in this scenario are HP SIM and the normal services and scripting tools provided with the operating system.

Custom Reports

---{Finding the Collections Manager Page}---
1. To create a [Custom Events "Filter"]
2. Click in Nav over to [Left] Lower Section named [System and Events Collection]
3. Look for Lightly highlighted word [ Customize ... ] click on that
4. This is the [Customize Collections] Manager Page

---{Creating an Events Filter}---
5. At top of white background window find [Show collections of:] click on the drop down that says [Systems[v]]
6. Select [Events]
7. In Button list to right ->
8. Click on [New...]
9. At bottom of main window
A. Below the bar in bold find [New Collection]
B. Select the bubble [Choose members by attributes]
C. Again, Below the bar in bold find [New Collection]
D. -> Search for events
E. -> -> where -> severity -> is -> (any)
F. Use drop downs to change this to
G. -> -> where -> severity -> is not -> Informational
H. Click [<< Add] button

I. A new [or] statement line will appear and can be changed
F. Use drop downs to change this to
J. -> -> where -> cleared state -> is not ->  Cleared
K. Click [Save As Collection...]
L. Name: [ MyEventFilter ]
M. Choose where to put the Collection in the Nav panel
N. Place in:
O. Select bubble - [New collection:]
P. New collection: [Events for Email]
Q. within [Shared]
R. Click [OK] button
S. Browser will refresh both Nav and Main windows
T. A new [Shared][Events][Category ->Events for Email][Collection -> MyEventFilter] will appear

---{Creating a Custom Report}---
U. Top Main window [Menu bar] -> Select [Reports] -> Select [New Report]

---{Adding Target Systems}---
V. Step 1: Select Target Systems
W. Add targets by selecting from -> Select bubble -> Collection
X. Drop down select [Systems by Type]->[All Servers]
Y. Check -> [Select "All Servers" itself
Z. Far right --> Click [Apply] button
a. Step 1: Verify Target Systems

---{Adding Search for Events by Existing Filter}---
b. Right -> Middle buttons
c. Click [Add Event Filter ...]
d. [Add filter by selecting from:]
e. Drop down select
f. [Events for Email] -> [MyEventFilter]
g. Far right click [Apply] button
h. Far right click [Next>] button

---{Adding show "these" fields of the [Target x Filter] Join}---
i. Step 2: Specify Parameters
j. Report name: [MyReport1]
k. [Select items to show in the report] essentially "fields" in the table output
l. Click [Events]
m. Check [System Name, Severity, Type, Received Time]
n. Far right click [Save Report] button

---{Scheduling a Report}---
1. Open a batch file <report.bat> and save the following command
2. "C:\Program Files\HP\Systems Insight Manager\bin\mxreport.exe" -e MyReport1 -x HTML -o C:\reports\summary.html
3. -e <name> execute the saved report named <name>
4. -x <format> save the report in the file format <format>
5. -o <filename> store the output of the report in <filename>
6. Create a Windows Task Scheduler "task" named "MyReport1"
7. General (tab) : Run whether user is logged in or not
8. General (tab) : Run with highest privileges
9. Triggers (tab) : Schedule to suit
A. Actions (tab) : Start a program : Program/script: C:\report\report.bat

---{Automatically emailing a Report}---
1. Create a Windows Task Scheduler "task" named "Email MyReport1"
7. General (tab) : Run whether user is logged in or not
8. General (tab) : Run with highest privileges
9. Triggers (tab) : On an event : Custom event filter : Edit event filter : <enter> XML
  <Query Id="0" Path="Microsoft-Windows-TaskScheduler/Operational">
    <Select Path="Microsoft-Windows-TaskScheduler/Operational">


This "watches" for the completion of a "task" named "\MyReport1" and executes on that event
A. Previously you could email an attachment direct, this is no longer the case in WS2012
B. Open a command script file <sendmail.cmd> and save the following commands
SET ThisScriptsDirectory=%~dp0
SET PowerShellScriptPath=%ThisScriptsDirectory%sendmail.ps1
PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& '%PowerShellScriptPath%'";
C. Open a powershell script file <sendmail.ps1> and save the following command
$body = Get-Content "C:\reports\summary.html"
$body=$body | select-string -pattern "gif"
if ($body.length -gt 0){
$body = Get-Content "C:\reports\summary.html"
send-mailmessage -from "SIM <sim@mycompany.com>" -to "Admins <admins@mycompany.com>", "Nobody <nobody@lostinspace.com" -subject "SIM - Events in progress" -BodyAsHtml "$body"  -priority Normal -smtpServer smtp-relay.mycompany.com
D. This checks the SIM output for events, if there are no events, no email is sent
E. Actions (tab) : Start a program : Program/script: C:\report\sendmail.cmd