(SOLVED) System.Shutdown with delay

Started by Lars.Weimar, July 15, 2009, 02:13:57 PM

Previous topic - Next topic

Lars.Weimar

Hi
We observe a UPS System so we created an event to shutdown a Windows System. I use the Object Tool "&Shutdown system" to shutdown the node with the Windows agent, if the power fails. This works verry well.

But how can I delay the shutdown? I´ll shutdown the system with a delay of 5 Minutes and another System with a delay of 8 Minutes.

Any Idea?

Sincerly Lars

Victor Kirhenshtein

Hello!

You can define custom action which will call shutdown command with timeout option. For example, to be able to shutdown Windows system with delay, you could:

1. define new custom action in agent:


Action = System.ShutdownWithDelay:shutdown.exe /t $1


This will add new action called System.ShutdownWithDelay which will accept one argument - delay in seconds.

2. If you need to call this action automatically from event processing policy, create actions on server with different delays:

Name: Shutdown_5min
Action: System.ShutdownWithDelay 300

Name: Shutdown_8min
Action: System.ShutdownWithDelay 480

3. If you need to call this action manually via object tools, create new tools of type "action":

Name: Shutdown_5min
Action: System.ShutdownWithDelay 300

Name: Shutdown_8min
Action: System.ShutdownWithDelay 480

Hope this helps!

Best regards,
Victor

Lars.Weimar

Wow, fast reply  :)

Step 2 - 3 --> OK and checked.

Step 1 ?

How can I define a new custom action in agent?
I install the agent on my machine. The agent create a directory in c:\NetXMS
Is it possible to use the "Agent Configurations" at Server?

Lars

Victor Kirhenshtein

Quote from: Lars.Weimar on July 15, 2009, 05:01:06 PM
Step 1 ?

How can I define a new custom action in agent?
I install the agent on my machine. The agent create a directory in c:\NetXMS

You should edit agent's configuration file, usually C:\NetXMS\etc\nxagentd.conf and add line mentioned in previous post. You can edit agent's configuration directly from management console by right-clicking node object and selecting "Edit agent configuration" menu. After configuration file change you should restart agent.

Best regards,
Victor

Lars.Weimar

Sorry, it doesen´t work. I added the line above, but the system doesn´t shut down. If I tried the embedded "System.Shutdown" it works fine. The System shutdown immediately.

I tried the following Setings in nxagentd.conf:

#
# NetXMS agent configuration file
# Created by agent installer at Wed Jul 15 10:58:04 2009
#
#System Shutdown with delay
Action = System.ShutdownWithDelay:shutdown.exe /t $1
MasterServers = 192.168.5.250
LogFile = C:\NetXMS\netxms.log
FileStore = C:\NetXMS\var
SubAgent = winperf.nsm
SubAgent = wmi.nsm
SubAgent = ups.nsm


In Action Properties:
Clipboard01.jpg

In Event Procesing Policy Editor:
Action "Shutdown_1min"

The Log-File of Client after Power Fail:


[20-Jul-2009 08:04:58] Log file opened
[20-Jul-2009 08:04:58] Subagent "WINNT.NSM" loaded successfully
[20-Jul-2009 08:05:41] Counter set B is empty, collector thread for that set will not start
[20-Jul-2009 08:05:41] Counter set C is empty, collector thread for that set will not start
[20-Jul-2009 08:05:41] Subagent "winperf.nsm" loaded successfully
[20-Jul-2009 08:05:41] Subagent "wmi.nsm" loaded successfully
[20-Jul-2009 08:05:41] Subagent "ups.nsm" loaded successfully
[20-Jul-2009 08:05:42] Listening on socket 0.0.0.0:4700
[20-Jul-2009 08:05:43] NetXMS Agent started

Lars.Weimar

Ok, I found the error.

My functional agent config:


#System Shutdown with delay
EnableActions = yes
Action = System.ShutdownWithDelay:shutdown.exe -s -c "PowerFail" -t $1
Action = System.ShutdownAbort:shutdown.exe -a


I added the abort command for Shutdown.