SpiceCorps of San Diego presentation on Alerts

321 views

Published on

Published in: Business, Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
321
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
3
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

SpiceCorps of San Diego presentation on Alerts

  1. 1. Custom Notifications<br />Spiceworks AlertsMichael Crook<br />Senior Programmer Analyst<br />
  2. 2. Download me @ http://ucsdhc-hi.ucsd.edu/spiceworks.pptx<br />
  3. 3. Enable Custom Notifications in Spiceworks<br /><ul><li>From Settings open External Alerts
  4. 4. Enable external alert processing
  5. 5. Send your Spiceworks a notification e-Mail</li></li></ul><li>Displaying your new alert<br />
  6. 6. Different methods used for notifications triggers<br /><ul><li>Count files in a queue directory
  7. 7. Perform a command on a Unix server
  8. 8. Perform a Oracle DB query</li></li></ul><li>What makes this all work<br /><ul><li>VBScript to send the email
  9. 9. In this example, Inventory device UCSDIFOUT is posting an alert “ORU_PCIS_ORM_WEBCHARTS > 25” ***** Nagios *****Host: UCSDIFOUTAddress: 172.16.82.89State: ORU_PCIS_ORM_WEBCHARTSService: ORU_PCIS_ORM_WEBCHARTS > 25Info: 30 ORU_PCIS_ORM_WEBCHARTS</li></li></ul><li>Event_sender.vbs30 ORU_PCIS_ORM_WEBCHARTS 25 UCSDIFOUT<br />---------------------------------------------------------------------<br />If Wscript.Arguments.Count = 0 Then<br />Else<br />dim dmsg<br />dim cnt<br />dim passed_msg<br />dim watermark <br />cnt = int(Wscript.Arguments(0) )<br />passed_msg = Wscript.Arguments(1)<br />watermark = int(Wscript.Arguments(2))<br />server= Wscript.Arguments(3)<br /> Set o = CreateObject("CDO.Message")<br />o.From = "Imaging Services Support <_@ucsd.edu>"<br />o.To = "spiceworksserver@ucsd.edu"<br />o.Subject = "Alert"&passed_msg<br />if (cnt>watermark) then <br />dmsg = " "&cnt&" "&passed_msg<br />o.TextBody = "***** Nagios *****"&chr(13)&chr(10)& _<br /> "Host: "&server&chr(13)&chr(10)& _<br /> "Address: 172.16.000.000"&chr(13)&chr(10)& _<br /> "State: "&passed_msg&chr(13)&chr(10)& _<br /> "Service: "&passed_msg&" > "&watermark&chr(13)&chr(10)& _<br /> "Info: "&dmsg&<br />else<br />o.TextBody = "***** Nagios *****"&chr(13)&chr(10)& _<br /> "Host: "&server&chr(13)&chr(10)& _<br /> "Address: 172.16.000.000"&chr(13)&chr(10)& _<br /> "State: "&passed_msg&chr(13)&chr(10)& _<br /> "Service: "&passed_msg&" > "&watermark&chr(13)&chr(10)& _<br /> "Info: Cleared"<br /> End If<br />o.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = “smtp.ucsd.edu"<br />o.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2<br />o.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 <br />o.Configuration.Fields.Update<br />o.Fields.Update<br />o.send<br /> Set o = Nothing<br />End If<br />---------------------------------------------------------------------<br />
  10. 10. Run a command on a UNIX box and parse the result<br /><ul><li>Checking the CPU temp (prtdiag –v)
  11. 11. Run the command and return a filtered set of resultsplink.exe -pw pass -batch user@serverprtdiag -v |find "CPU%1 “</li></li></ul><li>Use SQL commands to generate a Alert<br /><ul><li>Create a text file containing the commands to send to SQLPlus i.e.select count(*) from pending_transactions; exit;
  12. 12. To run the command and return a filtered result(Make sure your query only returns a single result)sqlplususer/pass@ODB @SQLfile.SQL|find " ">SQLfile.txt
  13. 13. Code example on next slide</li></li></ul><li>Perform a Oracle DB Query and act on the result<br />sqlplus%OracleUser%/%OraclePass%@%oracle_sid% @%QliktechHome%%SQLfile%.SQL |find " ">%QliktechHome%%SQLfile%.txt<br />FOR /F "tokens=1" %%G IN ('type %QliktechHome%%SQLfile%.txt') DO SET _tempVar=%%G<br />if %_tempVar% gtr %_watermark% (<br /> %QliktechHome%Event_sender.vbs %_tempVar% %_check_name% %_watermark% %_server%<br /> echo _ %_tempVar% >%_check_name%-%_watermark%-%_server%<br /> date /t >>log.txt<br /> time /t >>log.txt<br /> echo %QliktechHome%Event_sender.vbs %_tempVar% %_check_name% %_watermark% %_server% >>log.txt<br />)<br />if %_tempVar% lss %_watermark% (<br /> if exist %_check_name%-%_watermark%-%_server% (<br /> %QliktechHome%Event_sender.vbs %_tempVar% %_check_name% %_watermark% %_server%<br /> del /Q %_check_name%-%_watermark%-%_server%<br /> )<br />)<br />
  14. 14. Putty Link / Examples<br />Putty Download Pagehttp://www.chiark.greenend.org.uk/~sgtatham/putty/download.html<br />

×