Although you can comprehensively debug with this built-in tool, we strongly recommend augmenting it with the LogicMonitor Script Debug Helper extension for the Google Chrome browser. For an external script, this is straightforward, as you’ll typically develop and test directly on a Collector host by directly calling the appropriate interpreter for your script language.įor embedded Groovy or PowerShell scripts, you can develop and test your scripts directly within LogicMonitor using the Collector Debug Facility. This will ensure your script development has no chance of interfering with production operations.ĭeveloping Scripts with the Collector Debug Facilityīefore installing your monitoring script into the appropriate LogicModule, you’ll first want to test it to make sure it’s behaving as designed. When developing new script-based monitoring, you may want to install a new Collector to use as a sandbox environment.DataSource collection scripts, which are run once per poll, should complete within 1m to ensure data can be processed within the polling interval.As such, they should be designed to be as lightweight as possible. Because LogicMonitor scripts are run by your Collector, they’re limited by the overall horsepower in that system.To ensure your scripts run trouble-free, keep the following best practices in mind: Fill in the table in the Lab Report for the remaining error messages.LogicMonitor’s scripting features provide for powerful extensibility of your monitoring, but as they say: with great power comes great responsibility. This means the interpreter does not know what to do with the W7-Client part of the expression. The first message says At C:\Users\Administrator\scripts\buggyscript.ps1:6 char:35 $computers = "DC1", "W10-Client, "W7-Client"" Unexpected token 'W7Client""' in expression or statement.: 1) At C:\Users\Administrator\scripts\buggyscript.ps1:6 char:35 shows the file that had the error and the line and column (:6 char:35) that it detected the error 2) $computers = "DC1", "W10-Client, "W7-Client"" Shows the actual line of code 3) Unexpected token 'W7-Client""' in expression or statement. For each error, there is a message and the line number and column where the interpreter thinks the error is located. The error message above shows three errors that it detected. Figure 1 - Error Messages from BuggyScript.ps1 4. You should see the output shown in Figure 1 on the next page. Save the file in your scripts directory as buggyscript.ps1 5. Download the file from the course website. Log into on the virtual machine, and navigate to the CIS321 Course assignment for this Lab. Be sure to replace the device and domain names used here with the ones you created in the network planning document! 2. Login to the DC1 virtual machine as the administrator. To turn this on type Enable-PSRemoting from a PowerShell Administrator shell.ĭebug a Script 2 DecemDebug Syntax Errors INTERPRET ERROR MESSAGES 1. On Windows 10, the PowerShell remoting feature must be turned on. The firewall on the remote machine is turned off or has the proper exceptions configured. The computername(s) you are using are correct. Tasks Note: If you have issues other than those shown in the screen captures below be sure to check the following: 1. You have run into several errors with you scripts and have decided to investigate the debugging tools built into Windows PowerShell. Scenario Your organization is investigating the use of the command line and scripting for system administration. Prerequisites A physical or virtual machine with Windows 8.1, Windows Server 2012 R2 or a later version of the operating systems installed. In this lab, you will use the debugging features of PowerShell to pinpoint and correct errors in a script. Sometimes variables, functions, and loops do not work the way you think they should. Debug a Script 1 DecemOverview Much of the time spent writing scripts involves debugging.
0 Comments
Leave a Reply. |