Jump to content
Tim

Retired Assets Script & Monitor

Recommended Posts

Hi,

 

I was wondering if some of you more experienced folk could help with an issue that we are having?

We have a monitor that calls a custom script to retire agents that are older than 30 days

When I run a query on the monitor it returns the correct results based on the group it is monitoring.

So I know the results are correct and its looking at the correct devices.

If I run the script individually against a device it retires the device

The script calls a stored procedure called sp_DeleteComputer

I've attached some screenshots of the monitor/script configuration and the monitor history

If anyone has any ideas I'd be very grateful

Thankyou

Tim

Snip.JPG

Capture.JPG

Capture3.JPG

Capture4.JPG

Share this post


Link to post
Share on other sites

You dont seem to have an Alert Template applied to the monitor. Run your script through an Alert Template is the correct way to do this (as far as I am aware). We run this same type of process and that is the only difference between yours and mine.

Share this post


Link to post
Share on other sites

Hi Hallister,

Thanks for your response, the alert template was disabled temporarily to stop us being inundated with email notifications RE retired assets, the script wasn't firing prior to the alert setting being enabled against the monitor. As far as I knew the alert template just told the monitor to fire off an email and shouldn't be required for the triggering of the script unless I'm mistaken?

 

Thanks

Tim

Share this post


Link to post
Share on other sites

Hi Tim,

I had a similar issue to yours but I managed to get my script working through more dumb luck than good ideas.

The main difference I can see is that your Computer ID variable is surrounded by %%, whereas mine is surrounded by @@  . 

Also noticed that your alert looks at a -30 day interval but your script note say 180 day offline check?

Anyway, this is my one-liner that does the trick for me (attached). Slightly different to your setup, I have a group pinned by a search (Physical workstations that haven't checked in for more than 30 days).

I definitely did have a lot of issues with the SQL calling a stored procedure, admittedly. I set everything up, but couldn't get the agents to retire. Revisited it about a week later, and it worked flawlessly. A bit temperamental it seems, but the attached works for us :) Please let me know if you have any questions!

Cheers

Dan

image.png

image.png

Share this post


Link to post
Share on other sites
On 8/6/2018 at 1:22 AM, Tim said:

Thanks for your response, the alert template was disabled temporarily to stop us being inundated with email notifications RE retired assets, the script wasn't firing prior to the alert setting being enabled against the monitor. As far as I knew the alert template just told the monitor to fire off an email and shouldn't be required for the triggering of the script unless I'm mistaken?

The alert template specifies the action to take on an alert. It can be raising an alert, sending an email, creating a ticket, running a script, etc.

(Hint. If your selected template does not have "Run Script" as one of it's actions, the script set in the monitor will never be run.)

I would suggest making an alert template specifically named something like "Run Script" so that you can assign it to monitors that are only designed to trigger scripts without worry that a ticket or email will also be generated, etc.

Share this post


Link to post
Share on other sites
On 8/14/2018 at 7:35 AM, Dan Mellor said:

Hi Tim,

I had a similar issue to yours but I managed to get my script working through more dumb luck than good ideas.

 The main difference I can see is that your Computer ID variable is surrounded by %%, whereas mine is surrounded by @@  . 

Also noticed that your alert looks at a -30 day interval but your script note say 180 day offline check?

Anyway, this is my one-liner that does the trick for me (attached). Slightly different to your setup, I have a group pinned by a search (Physical workstations that haven't checked in for more than 30 days).

I definitely did have a lot of issues with the SQL calling a stored procedure, admittedly. I set everything up, but couldn't get the agents to retire. Revisited it about a week later, and it worked flawlessly. A bit temperamental it seems, but the attached works for us :) Please let me know if you have any questions!

 Cheers

Dan

image.png

image.png

 

Thanks Tim,

Do you know how I could get this script to email me the results, so I could get a report or list of machines and client names/locations of the agents that were retired?

I tried using an SQL get command that inputs the full SQL command for the search but I ended up getting an email for each agent and in the email it just shows me the agent ID number.

Ryan

 

Share this post


Link to post
Share on other sites

Hi,

 

Sorry to resurrect this one but I have tried all of the suggestions here but I am still stuck unfortunately, I've created a test template that just runs the script so I have a template selected against the monitor however it is still failing to run the script, I can see the query part of it is working fine as I am seeing clients in the results list.

 

Any ideas guys?

 

Thanks again for the help so far, it's much appreciated.

 

Share this post


Link to post
Share on other sites

@Tim and anyone else who stumbles upon this thread, here's the answer to making the script run: Make it an offline computer script

1046507847_MakeOfflineScript.thumb.JPG.f9b086751ffe37dbb3d2ac37aa042dbe.JPG

Since the monitor is deleting computers that are offline, they cant run this script unless it is also set to offline. It's an easy miss (took me a few minutes to realize it myself), but you can see it in Dan's script that it is set to offline as well. Hope this helps anyone looking to get this set up : )
- Zach

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×