Time-Variant Taskers

Time-variant taskers resources can be configured using Tcl. Any procedure can be defined in the namespace VovResources and then used to compute the resource list.

If the first characters in the argument for the option -r is the sequence VovResources::, then the taskers resources are computed by executing the argument as a Tcl command.

For a list of predefined procedures, refer to Predefined VovResources:: ProceduresPredefined VovResources::Procedures.

A special case of a resource is the local disk space on a host, which varies according to the files stored there. There may be jobs that require a minimum amount of space to run successfully. The vovtasker implements vtk_fs_stat (see vtk_fs) to handle such requirements. An example is provided further below.

An alternative is to use load sensors. However, in the case of free disk space, vtk_fs_stat is recommended because it is more efficient.

For example, taskers can be set up to offer one set of resources during the day and another set of resources during the night. The following example is a script that computes the resource "nothing" between 5am and 8pm, and the standard resources during the night. In addition, Tasker: vtk_tasker_set_timeleft is used to control the maximum expected duration of the jobs sent to the tasker.
namespace eval VovResources {
    proc Night { args } {
        # Return the standard resources during the night and suspend the tasker
        # during the day.  During the night, the tasker progressively reduces the
        # maximum length of the jobs it accept.
        set NIGHT_RESOURCES  "@STD@ $args"
        set EVENING_START  19
        set MORNING_END     6
        set HH [clock format [clock seconds] -format "%H"]
        regsub {^0} $HH "" HH; # Strip leading 0.
        if { $HH >= $MORNING_END && $HH < $EVENING_START } {
            # -- During the day, suspend the tasker.
            vtk_tasker_set_timeleft  0
        } else {
            # -- During the night, compute the time left.
            set hoursLeft  [expr $MORNING_END - $HH]
            set hoursLeft  [expr $hoursLeft >= 0 ? $hoursLeft : $hoursLeft + 24]
            set timeleft   [expr $hoursLeft * 3600]
            vtk_tasker_set_timeleft $timeleft
        return $NIGHT_RESOURCES
% vovtasker -r "VovResources::Night hspice"
These procedures are evaluated:
  • Every minute, or at the interval that was selected with the option -U
  • After the completion of each job.

The standard procedures are defined in the script $VOVDIR/etc/tasker_scripts/taskerRes.tcl. It is recommended to review these procedures before implementing your own procedures in $VOVDIR/local/taskerRes.tcl.

Free Disk Space

The following script monitors free disk space using vtk_fs_stat. This example script adds the resources WORK and SCRATCH; the values of these resources will be the amount of disk space in MB on the corresponding filesystem.
namespace eval VovResources {
    proc FsCheck { args } {
        # Usage:
        #   VovResources::FsCheck -fs WORK /work -fs SCRATCH /scratch -r  @STD@ -r xx
        set resources {}
        while { $args != {} } {
            set arg [shift args]
            switch -- $arg {
                "-fs" {
                    set name [shift args]
                    set dir  [shift args]

                    set space [vtk_fs_stat $dir]
                    lappend resources "$name#$space"
                "-r" {
                    lappend resources [shift args]
        return [join $resources]
% vovtasker -r "VovResources::FsCheck WORK /work"