Read from file after reboot works in Debugger but not in production

(imported topic written by RichB91)

Please keep in mind when you look at this code and wonder what good it does, that it is just for an example of a problem. All the code that doesn’t relate directly to the problem has been removed to make it much more readable.

There are two tasks that get put in to a baseline. One task manages actions before the reboot and the other, not surprisingly, handles the post-reboot actions.

To manage a challenge we have around some servers not rebooting properly, we’re logging the current time to a temporary file just before issuing the

Restart 5

command and then, after the reboot, the 2nd task is supposed to read that value from the temp file and uses

((Now - Uptime of Operating System) > (Line of File (Parameter " LogPathFile")) as Time)

to confirm that the reboot completed in the expected window.

Test Version 1

When the tasks are run in the Fixlet Debugger’s Action tab, and I cancel the reboot (so I can actually copy the contents of the output in the Client Log sub-tab),

color=green

everything works as expected[/color].

Test Version 2

When I comment out the

// Restart 5

in the Pre-Reboot task and then run the two tasks as a single baseline from the BES console,

color=green

everything works as expected[/color].

Test Version 3

When I run the two tasks as a single baseline from the BES console, and let the

Restart 5

actually reboot the test system, I get a

color=red

Relevance substitution failed[/color] error.

Primary Question

Why does this work both in the Fixlet Debugger, and as a Baseline when the Restart 5 is skipped, but not as a Baseline when the Restart 5 is included?

Text of Pre-Reboot Task

color=blue

// Pre-Reboot Task

Continue If {name of operating system as string as lowercase contains “win”}

Parameter “LogPathFile” = “C:\Temp\RebootTimeStamp.txt”

Delete __appendfile

Delete {Parameter “LogPathFile”}

Appendfile {Now}

Copy __Appendfile {Parameter “LogPathFile”}

Restart 5[/color]

Text of Post-Reboot Task

color=blue

// Post-Reboot Task

Continue If {name of operating system as string as lowercase contains “win”}

Parameter “LogPathFile” = “C:\Temp\RebootTimeStamp.txt”

Continue If {Exists File (Parameter “LogPathFile”)}

Parameter “RebootTime” = “{Line of File (Parameter “LogPathFile”)}”

If {((Now - Uptime of Operating System) > (Line of File (Parameter “LogPathFile”)) as Time)}

Parameter “OKToProceed” = “Yes”

Else

Parameter “OKToProceed” = “No”

EndIf[/color]

Output to Client Log sub-tab of Action tab of Fixlet Debugger

—Pre-Reboot Task – When prompted “Are you sure you want to restart?�� I click No.

STATUS: Running action…

Command succeeded (evaluated true) continue if {name of operating system as string as lowercase contains “win”}

Command succeeded parameter “LogPathFile” = “C:\Temp\RebootTimeStamp.txt”

Command succeeded delete __appendfile

Command succeeded delete C:\Temp\RebootTimeStamp.txt

Command succeeded appendfile {Now}

Command succeeded (file created) appendfile Wed, 22 Dec 2010 14:45:07 -0500

Command succeeded appendfile Wed, 22 Dec 2010 14:45:07 -0500

Command succeeded copy __Appendfile C:\Temp\RebootTimeStamp.txt

  • Result —

Evaluation completed successfully!

—Post-Reboot Task

STATUS: Running action…

Command succeeded (evaluated true) continue if {name of operating system as string as lowercase contains “win”}

Command succeeded parameter “LogPathFile” = “C:\Temp\RebootTimeStamp.txt”

Command succeeded (evaluated true) continue if {Exists File (Parameter “LogPathFile”)}

color=green

Command succeeded parameter “RebootTime” = “Wed, 22 Dec 2010 14:45:07 -0500”[/color]

Command succeeded parameter “OKToProceed” = “No”

  • Result —

Evaluation completed successfully!

Output to C:\Program Files\BigFix Enterprise\BES Client__BESData__Global\Logs\20101222.log when // Restart 5 is commented out.

At 14:59:39 -0500 - opsite193 (http://mercury.

companyname

.com:52311/cgi-bin/bfgather.exe/opsite193)

Relevant - (fixlet:148435)

Relevant - TEST: Read file after reboot part 1 (fixlet:148436)

At 14:59:46 -0500 -

Report posted successfully.

At 14:59:49 -0500 - opsite193 (http://mercury.

companyname

.com:52311/cgi-bin/bfgather.exe/opsite193)

Relevant - TEST: Read file after reboot part 2 (fixlet:148437)

At 14:59:49 -0500 -

ActionLogMessage: (action 148435 ) Action signature verified

ActionLogMessage: (action 148435 ) starting group action

ActionLogMessage: (action 148436 ) starting sub action

At 14:59:50 -0500 - actionsite (http://mercury.

companyname

.com:52311/cgi-bin/bfgather.exe/actionsite)

Command succeeded (evaluated true) continue if {name of operating system as string as lowercase contains “win”} (fixlet 148436)

Command succeeded parameter “LogPathFile” = “C:\Temp\RebootTimeStamp.txt” (fixlet 148436)

Command succeeded delete __appendfile (fixlet 148436)

Command failed (File not found) delete C:\Temp\RebootTimeStamp.txt (fixlet 148436)

Command succeeded appendfile {Now} (fixlet 148436)

Command succeeded (file created) appendfile Wed, 22 Dec 2010 14:59:50 -0500 (fixlet 148436)

Command succeeded appendfile Wed, 22 Dec 2010 14:59:50 -0500 (fixlet 148436)

Command succeeded copy __Appendfile C:\Temp\RebootTimeStamp.txt (fixlet 148436)

At 14:59:50 -0500 -

ActionLogMessage: (action 148436 ) ending sub action

At 14:59:50 -0500 - opsite193 (http://mercury.

companyname

.com:52311/cgi-bin/bfgather.exe/opsite193)

Not Relevant - TEST: Read file after reboot part 1 (fixlet:148436)

At 14:59:52 -0500 -

ActionLogMessage: (action 148437 ) starting sub action

At 14:59:53 -0500 - actionsite (http://mercury.

companyname

.com:52311/cgi-bin/bfgather.exe/actionsite)

Command succeeded (evaluated true) continue if {name of operating system as string as lowercase contains “win”} (fixlet 148437)

Command succeeded parameter “LogPathFile” = “C:\Temp\RebootTimeStamp.txt” (fixlet 148437)

Command succeeded (evaluated true) continue if {Exists File (Parameter “LogPathFile”)} (fixlet 148437)

color=green

Command succeeded parameter “RebootTime” = “Wed, 22 Dec 2010 14:59:50 -0500” (fixlet 148437)[/color]

Command succeeded parameter “OKToProceed” = “No” (fixlet 148437)

At 14:59:53 -0500 -

ActionLogMessage: (action 148437 ) ending sub action

Output to C:\Program Files\BigFix Enterprise\BES Client__BESData__Global\Logs\20101222.log when Restart 5 is allowed to actually reboot the test machine.

At 15:50:50 -0500 - opsite193 (http://mercury.

companyname

.com:52311/cgi-bin/bfgather.exe/opsite193)

Relevant - (fixlet:148459)

Relevant - TEST: Read file after reboot part 1 (fixlet:148460)

At 15:50:59 -0500 -

Report posted successfully.

At 15:51:03 -0500 - opsite193 (http://mercury.

companyname

.com:52311/cgi-bin/bfgather.exe/opsite193)

Relevant - TEST: Read file after reboot part 2 (fixlet:148461)

At 15:51:03 -0500 -

ActionLogMessage: (action 148459 ) Action signature verified

ActionLogMessage: (action 148459 ) starting group action

ActionLogMessage: (action 148460 ) starting sub action

At 15:51:04 -0500 - actionsite (http://mercury.

companyname

.com:52311/cgi-bin/bfgather.exe/actionsite)

Command succeeded (evaluated true) continue if {name of operating system as string as lowercase contains “win”} (fixlet 148460)

Command succeeded parameter “LogPathFile” = “C:\Temp\RebootTimeStamp.txt” (fixlet 148460)

Command succeeded delete __appendfile (fixlet 148460)

Command succeeded delete C:\Temp\RebootTimeStamp.txt (fixlet 148460)

Command succeeded appendfile {Now} (fixlet 148460)

Command succeeded (file created) appendfile Wed, 22 Dec 2010 15:51:04 -0500 (fixlet 148460)

Command succeeded appendfile Wed, 22 Dec 2010 15:51:04 -0500 (fixlet 148460)

Command succeeded copy __Appendfile C:\Temp\RebootTimeStamp.txt (fixlet 148460)

At 15:51:04 -0500 -

ActionLogMessage: (action 148460 ) ending sub action

.

.

.

At 15:55:18 -0500 -

ActionLogMessage: (action 148459 ) Action signature verified

ActionLogMessage: (action 148461 ) starting sub action

At 15:55:23 -0500 - actionsite (http://mercury.

companyname

.com:52311/cgi-bin/bfgather.exe/actionsite)

Command succeeded (evaluated true) continue if {name of operating system as string as lowercase contains “win”} (fixlet 148461)

Command succeeded parameter “LogPathFile” = “C:\Temp\RebootTimeStamp.txt” (fixlet 148461)

Command succeeded (evaluated true) continue if {Exists File (Parameter “LogPathFile”)} (fixlet 148461)

At 15:55:24 -0500 - actionsite (http://mercury.

companyname

.com:52311/cgi-bin/bfgather.exe/actionsite)

color=red

Command failed (Relevance substitution failed) parameter “RebootTime” = “{Line of File (Parameter “LogPathFile”)}” (fixlet 148461)[/color]

At 15:55:25 -0500 -

ActionLogMessage: (action 148461 ) ending sub action

At 15:55:29 -0500 -

ActionLogMessage: (action 148459 ) ending group action (completed)

(imported comment written by MrFixit)

I’ve observed that there are circumstances that an action may “look ahead” for relevance substitutions. In some cases it will happen even before the action starts. I’ve not documented all of the triggers, instead what I do now is assume that will happen and write relevance in a way that it wouldn’t fail regardless of the order that the action may test it.

I would use something like this so it wouldn’t fail even if the file or line wasn’t present.

parameter “RebootTime” = “{if (exists file (Parameter “LogPathFile”) whose (exists line of it)) then (line of file (Parameter “LogPathFile”)) else “missing”}”

Note: I wrote that without debugger so you’ll want to validate the syntax.

-Gary