Hi Xavier,
Thanks for your help. We’ve ultimately gone for a different option where we hack the modules bash initialisation scripts on all of our nodes, which is just slightly less awkward for us then modifying all our existing module files. This is only short-term anyway, we’ll have an upgraded system soon enough.
Thanks again though, good to know the `trace` approach was futile!
Cheers,
Lex.
> On 25 Jan 2024, at 6:11 pm, Xavier Delaruelle <xav...@gm...> wrote:
>
> Hi Lex,
>
> `trace` command requires to be used in modulecmd.tcl customization
> script (siteconfig.tcl). This is not available on Modules 3.
>
> I recommend setting up an `exec` command in every modulefiles you want
> to log activity.
>
> if { [module-info mode] in {load unload} } {
> exec logger -t module "$env(USER) [module-info mode] [module-info name]"
> }
>
> The above code snippet should send a log message toward your log
> system when module is loaded or unloaded.
>
> Regards,
> Xavier
>
>> Le jeu. 25 janv. 2024 à 07:26, Lex Gallon via Modules-interest
>> <mod...@li...> a écrit :
>>
>> Hi all,
>>
>> Firstly, apologies if this is a silly question. I've never used TCL outside of module files before.
>>
>> I'm on a shared system where we are stuck with Modules v3.2.10 (TCL 8.5). I've been trying to enable logging so we have a record of which modules are being loaded most often, but I've been struggling to configure it properly.
>>
>> Under `man module`, I found that I can add a `~/.modulerc` which gets executed on any module commands. Further, under `man modulefile`, I found that I can log to a personal file using
>> ```
>> #%Module1.0
>> module-trace on load
>> module-log trace /home/lexg/modules.log
>> ```
>>
>> This is alright, if I execute `module load cuda`, I see some output like
>> ```
>> bash load cuda <...> = TCL_OK(0)
>> ```
>>
>> However, subsequent module load commands simply keep appending to the first line, rather than starting on newlines. Is there any way to change this?
>>
>> I then tried to use the `trace` command in TCL similar to the examples in https://modules.readthedocs.io/en/latest/cookbook/log-module-commands.html, but I could never get this to produce any output at all. One configuration I tried just to get *any* output upon `module load` was:
>> ```
>> proc printArguments args {
>> foreach arg $args {
>> puts stderr $arg
>> }
>> }
>>
>> trace add execution module leave printArguments
>> ```
>>
>> I also tried outputting to files (`exec echo "BLAH" > /home/lexg/modules.log`) but to no avail.
>>
>> I could find no real examples of `trace add execution` outside of the cookbook example linked above. Is there a way to use `trace` so I can better format the output, or am I stuck with module-log? Thanks in advance.
>>
>> LEX GALLON
>> Research Officer, Monash e-Research Centre
>> _______________________________________________
>> Modules-interest mailing list
>> Mod...@li...
>> https://lists.sourceforge.net/lists/listinfo/modules-interest
>
>
> _______________________________________________
> Modules-interest mailing list
> Mod...@li...
> https://lists.sourceforge.net/lists/listinfo/modules-interest
|