App Genie Script Error

The support forum for the App Genie plugin. Find how-to's, product announcements and reported issues and resolutions. Posting here should be for the App Genie plugin.
User avatar
Cubert
Posts: 2430
Joined: Tue Dec 29, 2015 7:57 pm
8
Contact:

Re: App Genie Script Error

Post by Cubert »

We are striving to make App Genie as simple as deploying and walking away. App Genie came out of beta last month and is just now starting to see widespread usage. We are expecting to find new issues as the plugin reaches out to more customers and their clients and gets the exposure of mass deployments.

The purpose of App Genie is to take a very costly process and reduce it down to the cost of a cup of coffee. MSPs have been paying hundreds of dollars a month to resolve the 3rd party patching dilemmas that MSPs have when dealing with a pleratha of clients.

We are going to have some issues that have to be worked out as we discover them. Please bare with us as we improve on the base we have.

We will have a new update out shortly, the plugin should auto update so watch for a version change and the announcement here.

User avatar
Cubert
Posts: 2430
Joined: Tue Dec 29, 2015 7:57 pm
8
Contact:

Re: App Genie Script Error

Post by Cubert »

Man,

Not sure how I got so messed up on this post. I started going over the post again from the top to make sure I was not missing a piece of the issue and found that my troubleshooting and support were flip flopping between App Genie and Chocolatey for Automate. So as i made requests and examples of SQL this was only accurate half the time. My brain was popping back and forth across different plugins.

So let's start over here with a common issue.

App Genie has a script error during updates to agents.

As of P4A - App Genie Maintenance script version 1.0.20

When the Update command is sent via the automation to this script it will start in the else section at line #63.

The script starts off by requesting SQL data from the database and is expecting back 1 or more rows of data.

Here is that SQL request: (make sure to replace = '%computerid%' with '123' or whatever agent ID your testing against.)

Code: Select all

SELECT b.ID As AppAssocID,s.Name, b.RepoName, s.version, a.LastUpdate, b.version as RepoVersion 
FROM plugin_p4a_app_genie_agent_apps a 
LEFT JOIN plugin_p4a_app_genie_assoc b ON a.AppAssocID = b.ID  
LEFT JOIN software s ON a.ComputerID = s.ComputerID and s.Name like b.AppName 
WHERE a.ComputerID = '%computerid%'  
and s.version <> b.version 
and DATE(a.LastUpdate) <> DATE(NOW());
The request ask for by AgentID all installed software shown for agent, that is shown to not match version and that has not already been updated today.

This should return data on the first run of the day (if software changes) but not again if "Lastupdate" has today's date. Otherwise the request returns 0 rows. This is where the error pops up. we have not tested for zero rows so a Loop error is generated when we try to loop through zero rows of data. We are fixing this in the next build of App Genie.

If you modify the SQL query and run it in SQL yog you can see that if software shows installed that it will return data. Lets remove a piece of the first query. The time clause... Lets just see if we have software installed updated anytime...

Here is that SQL request: (make sure to replace = '%computerid%' with '123' or whatever agent ID your testing against.)

Code: Select all

SELECT b.ID As AppAssocID,s.Name, b.RepoName, s.version, a.LastUpdate, b.version as RepoVersion 
FROM plugin_p4a_app_genie_agent_apps a 
LEFT JOIN plugin_p4a_app_genie_assoc b ON a.AppAssocID = b.ID  
LEFT JOIN software s ON a.ComputerID = s.ComputerID and s.Name like b.AppName 
WHERE a.ComputerID = '%computerid%'  
and s.version <> b.version;

The return data should look like this. This is my agentID #2 shown in image below. When I remove the data part of the where clause I get all the apps installed on the agent and their versions tested.
Capture.PNG
Capture.PNG (55.77 KiB) Viewed 8276 times

This should give you an understanding of what is taking place with script errors. If we look at the logs and the timeline we should be able to see when the first updates of the day ran. That is where Chocolatey was told to update some softwares if they existed and showed out of date. At that point Chocolatey would of returned some response to the update command sent. This is where errors at the framework level would show up if they appeared. This data would help explain why a update may have failed.

I will add 2 changes to the update functions in the script.

#1 I will test for zero rows returned and exit out nicely if no rows returned.

#2 I will setup a logger that will capture the output of the update command and store that in the database so we can retrieve it in the plugin to display to you when you select a particular installed software from plugin.

This log will be the last know status of the update command. It should provide you the data needed to better determine why a failure is happening.

I will have the update out later today.

User avatar
Cubert
Posts: 2430
Joined: Tue Dec 29, 2015 7:57 pm
8
Contact:

Re: App Genie Script Error

Post by Cubert »

A new update to App Genie has been posted.

https://delivery.shopifyapps.com/-/c4f6 ... 042c8488a6


Plugin should auto update during the wee hours of the AM.

You should verify that the App Genie script is now version 1.0.22 by opening script and looking at script notes.

You should also now have a new database table (plugin_p4a_app_genie_update_logs) that will house the new logs as they are posted. Allow the system 48 hours to cycle through available updates before logs show up.

You can view the new logs for any software update by double clicking the software in the agent view.
Capture.PNG
Capture.PNG (127.28 KiB) Viewed 8276 times
You should now not only see when the last update ran but what was the output of the update command from Chocolatey framework. This should help troubleshoot if and why an update may have not worked for an agent or application.

Post Reply

Return to “App Genie”