Monitor a Folder within a Runbook
Updated: May 13, 2016
Applies To: System Center 2012 SP1 - Orchestrator, System Center 2012 - Orchestrator, System Center 2012 R2 Orchestrator
This sample shows you how to create a simple monitor runbook that monitors a folder for new text files. When a file is detected, the runbook sends an event log message, and then starts another runbook.
Create and test a monitor runbook
The procedures to create, configure, and test a sample runbook that monitors a folder are described below.
To create the workflow
In the Runbook Designer Connections pane, right-click the Runbooks folder to select New, and then click Runbook.
Right-click the New Runbook tab to select Rename.
In the Confirm Check out dialog box, click Yes.
Type a name for the runbook, such as
Monitor Runbook
, and then press Enter.In the Activities pane, click File Management to expand the category, and then drag the Monitor Folder activity into the Runbook Designer Design workspace.
In the Activities pane, click Notification to expand the category, and then drag the Send Event Log Message activity into the Runbook Designer Design workspace, to the right of the Monitor Folder activity.
In the Runbook Designer Design workspace, move your pointer over the right side of the Monitor Folder activity to display the smart link arrow.
Click the smart link arrow, and then drag it to the Send Event Log Message activity.
In the Activities pane, click Runbook Control to expand the category, and then drag the Invoke Runbook activity into the Runbook Designer Design workspace, to the right of the Send Event Log Message activity.
In the Runbook Designer Design workspace, move your pointer over the right side of the Send Event Log Message activity to display the smart link arrow.
Click the smart link arrow, and then drag it to the Invoke Runbook activity.
To configure the workflow
In the Runbook Designer Design workspace, double-click the Monitor Folder activity.
In the Monitor Folder Properties dialog box, click the General tab.
In the Name box, change the name of the activity to something informative, for example
Monitor C:\Monitor Folder
.Click the Details tab.
On the Details tab, in the Path box, type the path of the folder you want to monitor, for example
C:\Monitor
.Below the File Filters list, click Add.
In the Filter Settings dialog box, set the following:
In the Name list box, select File Name.
In the Relation list box, select Matches pattern.
In the Value box, type
*.txt
.This setting directs the monitor to look for files with the txt extension. This field accepts regular expression syntax.
Click OK.
Select the Triggers tab.
Select the Number of files is option, set the value in the list to greater than, and then type
0
in the edit box.Click Finish.
In the Runbook Designer Design workspace, double-click the Send Event Log Message.
In the Send Event Log Message Properties dialog box, on the Details tab, in the Properties section, set the following:
-
In the Computer box, type the name of the computer to receive the Event message.
This is typically the computer where you are running Runbook Designer.
In the Message box, type the message to display in the Event log, for example,
File Detected
.Leave the Severity level at Information.
Click Finish.
Note
In this sample, the Invoke Runbook activity is not configured. For more information about configuring this activity, see the Invoke Runbook activity in the System Center 2012 - Orchestrator Runbook Activity Reference.
To modify runbook settings
Above the Runbook Designer Design workspace, right-click the Monitor Runbook tab to select Properties.
In the Monitor Runbook Properties dialog, click the Logging tab, and then select both Store Activity-specific Returned Data and Store Common Returned Data.
Click Finish.
Right-click the Monitor Runbook tab to select Check In.
Test the runbook
In the Runbook Tester, you can test runbooks in a simulated runtime and debugging environment. You can run an entire runbook, step through it one activity at a time, or add breakpoints to stop the simulation at any activity that you select.
Use the following steps to test your runbook in the Runbook Tester.
To prepare your computer
Right-click Start to select Open Windows Explorer.
Create a
C:\Monitor
folder on your computer.Create a
C:\Source
folder on your computer.In the C:\Source folder, create a file with a txt extension, for example
text.txt
.
To test the runbook
In the Runbook Designer Design workspace, select the Monitor Runbook tab.
On the toolbar above the Runbook Designer Design workspace, click Runbook Tester.
In the Confirm Check out dialog box, click Yes.
In Runbook Tester, on the toolbar, click Step Over to start stepping through the runbook.
Tip
To increase the size of the Log pane, remove the Resource Browser pane by selecting View on the menu, and then clearing the Resource Browser option.
In Windows Explorer, browse to the C:\Source folder.
Copy test.txt to C:\Monitor.
Close Windows Explorer.
On the Runbook Tester toolbar, click Next.
After a few moments, note that the Log pane entry updates and shows an event for the Monitor Folder activity.
On the Log pane Click the Show Details link to see the contents of the data bus for that runbook.
Scroll down the list of properties. Note that the activity status is success indicating that the Monitor Folder activity detected the change in the folder.
On the Runbook Tester toolbar, click Next.
Notice that the Log pane changes and shows an event for the Send Event Log Message activity.
Click the Show Details link and note that the activity status is success indicating that the Send Event Log Message activity detected the change in the folder.
Close Runbook Tester.
On the Runbook Designer toolbar, click Check In.
See Also