Git Product home page Git Product logo

cwcautomatediagnostics's Introduction

CWCAutomateDiagnostics

Run ConnectWise Automate agent diagnostics from ConnectWise Control. This extension utilizes the Labtech-Powershell-Module to review CWA agent settings and service statuses. The extension will also perform automatic service repairs and updates.

Features

  • NEW - LTErrors.txt / agent.log file is returned in the diagnostic
  • NEW - /usr/local/ltechagent/ltupdate initiated from AutomateDiagnostics.py
  • Maintenance Mode - Disable diagnostics on GuestConnect event
  • Mac OS X/Linux Agent Reporting
  • Forces agent updates using Update-LTService
  • Verifies LTService and LTSVCmon services are running and set to Automatic. Will start services and set StartMode to Automatic.
  • Verifies checkin and heartbeat times.
  • Stores the CWA Agent ID as CustomProperty6 (customizable).
  • Stores the CWA Version as CustomProperty7 (customizable).
  • Provides custom Session Group that sorts endpoints by CWA version number.
  • Repair option now uses InstallerToken, generate a long lived one using this script https://www.mspgeek.com/files/file/50-generate-agent-installertoken/.

Installation

  • Install Automate Diagnostics from the ConnectWise Control Marketplace (version 1.0.6.7)

Manual Instructions

To install this version, 1.0.7.2:

  1. Create a new directory for the extension - %programfiles(x86)%\ScreenConnect\App_Extensions\e4dd11eb-3c5e-407c-a7b8-a8ea5e6dbb76
  2. Download the lastest master.zip and extract all files into the directory
  3. Enable the extension in the administration page.

Setup

  1. In the settings, modify the PathToLTPoSh to a URL that you trust or one that is configured to bypass content filters
  2. Additionally, find the Guid for the Control extension (manual one is listed above, cloud is 26a42e0d-6233-4a66-9575-6e05a248cd26)
  3. Build the URL with the extension Guid and add that to the settings to avoid calling the script from GitHub. (e.g https://control_url:port/App_Extensions/<extension_guid>/AutomateDiagnostics.ps1)
  4. Edit the Control web.config file (make a backup first): Under the <httpHandlers> section, add verb entries for each script file:
<add verb="GET,HEAD" path="App_Extensions/e4dd11eb-3c5e-407c-a7b8-a8ea5e6dbb76/AutomateDiagnostics.ps1" type="System.Web.DefaultHttpHandler" />
<add verb="GET,HEAD" path="App_Extensions/e4dd11eb-3c5e-407c-a7b8-a8ea5e6dbb76/AutomateDiagnostics.py" type="System.Web.DefaultHttpHandler" />
<add verb="GET,HEAD" path="App_Extensions/e4dd11eb-3c5e-407c-a7b8-a8ea5e6dbb76/AutomateDiagnostics.sh" type="System.Web.DefaultHttpHandler" />

Usage

  • Script is automatically executed on GuestConnect event (e.g. Service/Computer reboot). RanCommand events are parsed for JSON output and the version number is stored in CustomProperty7. Agent ID is stored as CustomProperty6. (NOTE: To rename the custom properties or reset the Session group, set the createdVersionSessionGroup setting to false, also do this if you change the custom property value number)
  • Script can be manually invoked from the Automate tab on the Host screen or in the drop down menu when selecting sessions.

Sample Output

Diagnostic Details Agent Logs
Details LTRrrors

Troubleshooting

Set Verbose = 1 in the Extension settings to log more data for on-demand diagnostics. This does not apply to Guest Connect events.

Credit

cwcautomatediagnostics's People

Contributors

benrfairless avatar elevatejoe avatar johnduprey avatar slinak avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cwcautomatediagnostics's Issues

Question: Proposed solution for python2 missing from macOS 12.3+

macOS doesn't include python anymore. I am almost done with a shell script that replicates everything the python script does for macs. Is this something that would be possible to integrate as its own thing i.e. AutomateDiagnostics.sh? If so, I can submit a PR once I finish figuring out the lterrors piece.

Server Check for Windows agents

Windows agents are reporting back: Server Check | ✗ Error | Server address not matched | Ping failure | Version check fail

Mac agents are reporting back: Server Check | ✓ https://labtech.server.com:443

Fresh install of the extension, only changed the LT server address in the configuration

Last Updated timestamp can be in the future

The Last Updated timestamp at the top of the diags results pane can show a timestamp which has not occurred yet (is in the future).

Example
CWA Diags - LU Datetime bug

In this example all machines (guest, host, & server) are in the same timezone Europe/London (GMT +00:00) and that timezone is currently not observing DST. The Last Updates timestamp is 2022-01-31 18:28:56, but the current time is 2022-01-31 18:03 - so the Last Updated timestamp hasn't yet occurred. This logic cannot be correct.

I've not managed to trace the cause of this yet, but I'm opening this issue to track it.

Session Groups

Is it possible to create a session group for all broken Automate Agents?

CWA Version: Agent error

When running the diagnostics in ConnectWise Control the following is output in the commands history:

`#!ps
#maxlength=100000
#timeout=600000
echo "DIAGNOSTIC-RESPONSE/1"
echo "DiagnosticType: Automate"
echo "ContentType: json"
echo ""
$WarningPreference='SilentlyContinue'; IF([Net.SecurityProtocolType]::Tls) {[Net.ServicePointManager]::SecurityProtocol=[Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls}; IF([Net.SecurityProtocolType]::Tls11) {[Net.ServicePointManager]::SecurityProtocol=[Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls11}; IF([Net.SecurityProtocolType]::Tls12) {[Net.ServicePointManager]::SecurityProtocol=[Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12}; [System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}; Try { (new-object Net.WebClient).DownloadString('https://raw.githubusercontent.com/johnduprey/CWCAutomateDiagnostics/master/AutomateDiagnostics.ps1') | iex; Start-AutomateDiagnostics -ltposh 'http://bit.ly/LTPoSh' -automate_server '' } Catch { $_.Exception.Message; Write-Output '!---BEGIN JSON---!'; Write-Output '{"version": "Error loading AutomateDiagnostics"}' }

DIAGNOSTIC-RESPONSE/1
DiagnosticType: Automate
ContentType: json

Get-LTServiceInfo : ERROR: Line 140: Unable to find information on LTSvc. Make sure the agent is installed.
At line:298 char:21

  •         $info = Get-LTServiceInfo
    
  •                 ~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
    • FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Get-LTServiceInfo

Cannot bind parameter 'Date' to the target. Exception setting "Date": "Cannot convert null to type "System.DateTime"."
!---BEGIN JSON---!
{
"repair": "Reinstall",
"id": null,
"svc_ltsvcmon": {
"Status": "Not Detected",
"User": "",
"Start Mode": ""
},
"server_addr": null,
"version": "Agent error",
"ltsvc_path_exists": false,
"ltposh_loaded": true,
"clientid": null,
"locationid": null,
"svc_ltservice": {
"Status": "Not Detected",
"User": "",
"Start Mode": ""
}
}`

I then see "CWA Version: Agent error" appear under the agent name.

Seeing a lot of the following errors

DIAGNOSTIC-RESPONSE/1
DiagnosticType: Automate
ContentType: json

The 'var' keyword is not supported in this version of the language.
!---BEGIN JSON---!
{"version": "Error loading AutomateDiagnostics"}

Error loading module after CW Control Update

Upgraded from 20,2 to 20.3. Have had the module running for a year+ with no issues - excellent module.

Getting the error in the screenshot. As a test, uninstalled and reinstalled the module, error did not change.
error

ScreenConnect sever keeps crashing after enabling this pluggin

Whenever we are enabling this plugin, it sends a lot of commands to the screenconnect server which is causing the server performance and our technicians are unable to connect to remote computers as it just shows the blank screen.

Please help to fix this issue.

Mac issue with service restart

In this part of the .sh file

status=$(launchctl list | grep com.labtechsoftware.LTSvc)
if [ -z "$status" ]; then
launchctl stop com.labtechsoftware.LTSvc
launchctl start com.labtechsoftware.LTSvc
status=$(launchctl list | grep com.labtechsoftware.LTSvc)
if [ -z "$status" ]; then
statusName="Stopped"
else
statusName="Running"
fi
else
statusName="Running"
fi

It appears that the service gets restarted.

problem is on all the macs I have I have to run the restart of the service manually before it will even notice the service has been upgrade.

Initializer.js Event Parsing Fix

Both versions of the Initializer.js file (master / dev) are currently failing to parse session events correctly, so nothing loads on the Automate tab in the browser except for the Run Automate Diagnostics link.

The function "getLatestDiagnosticEvent" is looking for data that doesn't exist, likely due to a change with the more recent versions on Control. The function as currently written:

function getLatestDiagnosticEvent(sessionDetails, diagnosticEventType) {
return sessionDetails.Connections
.map(function(c) { return c.Events; })
.reduce(function(outputArray, events) { Array.prototype.push.apply(outputArray, events); return outputArray; }, [])
.filter(function(e) {
return e.EventType === SC.types.SessionEventType.RanCommand &&
isDiagnosticContent(e.Data) &&
parseDataHeaders(e.Data).DiagnosticType.trim() == diagnosticEventType;
})
.sort(function (x, y) { return x.Time - y.Time; })
[0];
}

sessionDetails.Connections has no event information in it, because events are now a separate part of the sessionDetails object. I changed the function to the following, which resolves the errors, and the tab now loads the data correctly:

function getLatestDiagnosticEvent(sessionDetails, diagnosticEventType) {
return sessionDetails.Events
.filter(function(e) {
return e.EventType === SC.types.SessionEventType.RanCommand &&
isDiagnosticContent(e.Data) &&
parseDataHeaders(e.Data).DiagnosticType.trim() == diagnosticEventType;
})
.sort(function (x, y) { return x.Time - y.Time; })
[0];
}

Low Priority Enhancement: Mac agents can display Location ID: Undefined

No Location ID is in the data in the JSON from the agent because there's no Location ID in the /usr/local/ltechagent/state file.
Also worth noting that the Client ID which is in the file and returned JSON can be wrong, thankfully the GUI ignores it anyway.

image

Another one for my list when I get time. I assume this affects Linux too as diag_result in AutomateDiagnostics.py doesn't contain a Location ID field.

Control Delayed Until Diagnostics Runs

I've just installed and setup this plugin for CW Control and I'm noticing the following behavior. I know that Automate Diagnostics runs when a guest connects. However, this seems to be preventing control of the computer until the Automate Diagnostics finishes it's execution. For example, when I reboot a computer, I use to be able to access it as soon as the guest connected. Now after a reboot, the screen is grey and I cannot do anything with that computer until the Automate Diagnostics finishes. Once it finishes, I can see the remote screen and control the inputs.

My CW Control server is version 19.4.25542.7214 and I have configured Automate Diagnostics to pull the files needed from my Control server and not from GitHub.

Is there something that can be done about this delayed 'access' to the computer after reboots?

SSL/TLS Issues

Getting these:

DIAGNOSTIC-RESPONSE/1
DiagnosticType: Automate
ContentType: json

Exception calling "DownloadString" with "1" argument(s): "The operation has timed out"
!---BEGIN JSON---!
{"version": "Error loading AutomateDiagnostics"}

Or something to the effect of:

The request was aborted: Could not create SSL/TLS secure channel


Wondering if instead of all this:

IF([Net.SecurityProtocolType]::Tls) {[Net.ServicePointManager]::SecurityProtocol=[Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls}; IF([Net.SecurityProtocolType]::Tls11) {[Net.ServicePointManager]::SecurityProtocol=[Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls11}; IF([Net.SecurityProtocolType]::Tls12) {[Net.ServicePointManager]::SecurityProtocol=[Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12};

Could be instead of or include somehow this:

[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}

Thanks!

Plugin Crashes Control Host Services on 22.9.10446.8359

We recently upgraded Control to 22.9.10446.8359, but after upgrading Control would not respond after 10-20 minutes of uptime. We narrowed the issue down to this plugin, and since disabling we have functioned normally.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.