35
Scripting & Automated Tasks Ernest Byrd, Sales Engineer GFI MAX A means of doing custom things for your custom Customers

Scripting and Automation within the MAX Platform Ernest Byrd

Embed Size (px)

DESCRIPTION

Enhance what the GFI MAX RemoteManagement Dashboard can do with user-defined custom scripts or through our built in library, allowing you to monitor VMWare host server health, exchange store size and queue length. Create your own scripts, or use those generously shared by industry peers on our designated FixitScripts website. In this session we will cover: •Building Scripts •Using Scripts in the Library •Script Types •Using “Ones from the Internet”

Citation preview

  • 1. Scripting & Automated TasksA means of doing custom things for your custom CustomersErnest Byrd, Sales EngineerGFI MAX

2. Agenda Why use Scripting? Plug it in Turn it on: Using a Script FixITScripts.com Interfacing with the MAX Remote Management Dashboard Basic Scripts Using a Script as an Automated Task Basic Troubleshooting Pseudo-Code and Modeling Deeper Dive 3. Why use Scripting? 4. EASY does itHere at GFI MAX we aim for ease of use whileremaining Comprehensive. With that said, there isalways going to be a Customer that has specific andUNiQUe needs.If we fulfilled the needs of every Customer in ourDashboard, GFI MAX could be quite overwhelming.In order to remove complexity we have available theScripting & Automated Tasks solution sets. Theseenable YOU to simply plug in a script, having itavailable for Automated Processes.Scripts can then be utilized by Superusers orAdministrators within your Dashboard in orderaccomplish tasks across both small and largerManaged Networks. 5. What are some things that can be accomplished with Scripting? File and Folder manipulation System Cleanup Localized Tasks Creation of Mapped Drives Informational Output Application DownloadThe List goes on 6. Plug it in 7. Plug it inExample:Plugging a Script into the MAXRemote ManagementDashboard 8. Turn it on: Using a Script 9. Put the Script to useExample:Calling on a Script in the MAXRemote ManagementDashboard 10. FixITScripts.com 11. Where can I find a good libraryof Scripts to plug into the GFIMAX Remote ManagementDashboard?FixITScripts.com 12. FixITScripts.comExample:Pulling a Script fromFixITScripts.com, plugging itinto the MAX RemoteManagement Dashboard,viewing its output 13. Interfacing with the MAX Remote ManagementDashboard 14. The Script Writing Guidelines can be found in the Help Files at:https://dashboard.systemmonitor.us/helpcontents/script_guide.htmTo locate the GFI MAX Remote Management Help Files: 15. The Windows Advanced Monitoring Agent supports the following script types where there is aninterpreter installed. DOS Batch, JavaScript, Perl, PHP, PowerShell, Python, Ruby, VBS andCMD. The Linux Monitoring Agent and OSX Monitoring Agent supports Shell scripts and interpretedlanguages such as Perl, PHP, Python, Ruby for which there is a handler installed. The status of the script - pass or fail - can be reported to the DashBoard through exit codes. Zeroindicates success, with any other number recorded as a failure.Please note, we have reserved the exit codes 1 to 999 for use by the system scripts. As such we wouldsuggest returning an exit code greater than 1000 in your scripts to ensure the text output is displayedcorrectly in the DashBoard.Exit Code Result0 Pass>0 Fail1 - 999 Reserved exit codes>1000 Displays text output in DashBoard 16. If a Fail is reported to the Dashboard, within the Dashboard you will see:If a Pass is reported to the Dashboard, within the Dashboard you will see:To output text from the script to the DashBoard, simply echo from the script to standard output(stdout). For example in DOS Batch, VBScript and Powershell this can be achieved by:Pass FailDOS Batch echo Success Message echo Error Messageexit 0 exit 1001VBScript wscript.echo( Success Message ) wscript.echo( Error Message )wscript.Quit(0) wscript.Quit(1001)PowerShell Write-Host Success Message Write-Host Error MessageExit 0 Exit 1001 17. Basic Scripts 18. Hello WorldExample:Writing a Script, in VBScriptlanguage, that will return thetext Hello World into the MAXRemote ManagementDashboard. The returnedinformation can then be seen inthe Script Checks Extra(Informational) Column 19. Hello World: Interactive OutputIf the Script is double-clicked on, here is what isseen: Note that no prompts for User Input areseen, and the Script executes to completion. 20. Hello World: Calling Script from Command LineExample:Calling on HelloWorld.vbs fromCommand Line 21. Hello WorldOnce this script is plugged into the Dashboard and called on as a Script Check, thefollowing results should appear: 22. Report a Failure to the MAX Remote Management DashboardScript Contents:'Report Fail to Dashboardwscript.Quit(1001)Dashboard Output: 23. Script to accept Command Line VariablesScript Contents:'Accept Command Line Variables and Return to DashboardDim Arg1Dim Arg2Arg1 = Wscript.Arguments.Item(0)Arg2 = Wscript.Arguments.Item(1)Wscript.Echo Arg1 & Arg2Dashboard Output: 24. Supplying Command Line VariablesWhen viewing the Properties of a ScriptCheck, there is a field to provide CommandLine Variable(s). This is where Scripts thatare written to accept Command LineVariable(s) can be given input. 25. Enumerating Class Variables from Win32_UserAccountExample:Calling to theWin32_UserAccount object inWindows, ensuring access toitems within on my targetdevice. This can then serve as acomponent into a larger Script ifsuccessful 26. Resource: WMI Classeshttp://msdn.microsoft.com/en-us/library/aa394554(v=vs.85).aspx 27. Using a Script as an Automated Task 28. Using a Script as an Automated TaskExample:Using the MaintenanceWindow script, seen atwww.allthingsmax.com,as an Automated Task(http://www.allthingsmax.com/2014/03/give-me-break.html) 29. Basic Troubleshooting 30. Troubleshooting 101Essentially, once the script is plugged in to the GFI MAX Remote Management Dashboard and calledon as: A Script CheckOR An Automated Taskthe script will execute in a command line fashion, running under the account which loads theAdvanced Monitoring Agent Service. 31. Troubleshooting 101What this means: The Script which you are utilizing should not require any user input orinteraction. If your script requires this, it will halt at the point of requirement and neverallow the script to reach completion.Also, it is good to note that the default account for the Advanced Monitoring AgentService is: Local System. 32. Troubleshooting 101My script runs as intended when I double click it, or call on it from command line. Howcan I make it work in the GFI MAX Remote Management Dashboard?If your script runs properly under a logged on account: Review the account you are logged in with when running the script Change your Advanced Monitoring Agent Service on the intended device to run with this sameaccount(To find the account you are logged in with, the use of a command line call: WhoamI may be helpful.) 33. Pseudo-Code and Modeling 34. Script Development Essentials Summarize what your Script or Automated Task is going to accomplish. This should besomething that you can define in one or two sentences. Write/Draw out the Logic used to develop your Script. This is commonly referred to as Pseudo-coding. Convert your Pseudo-code into the desired Scripting language.If Then-If Then-ElseWhile is NotDo 35. Deeper Dive