Variable substitution in custom email template for system monitor

SYSTEM INFORMATION
OS type and version Raspberry Linux 11
Webmin version 2.104

Somewhere I discovered that Webmin accepts variable substitution in a custom email template for a System and Server Status monitor. For example, Webmin will accept Status change noted on ${DATE} at ${TIME}. and inserts the system time and date as indicated. This page describes what I’m looking for but, curiously enough, does not list TIME or DATE.

My question: Is there a complete list of the allowable substitutions available somewhere? Can I substitute environment variables? Are there other possibilities such as HOSTNAME and such?

1 Like

@chucko,

I believe the variables mentioned for TIME and DATE are “system” variables set by your environment rather then Virtualmin specifically.

This does seem like a good question that could use further exploration…

Environment variables was my first thought too @tpnsolutions. But, unless I’m wrong, my environment doesn’t hold either of those variables. The env command doesn’t list either of them. And echo $DATE prints nothing.

Further research examining /usr/share/webmin/monitor.pl reveals an embedded function named make_message which appears to search the configured custom template for a list of key-words that seems to be limited to: HOST, DATE, TIME, STATUS, and SERVICE. So I’m guessing those 5 are the only variables that can be substituted within a custom template for a System/Service monitor.

I’d like to see a comprehensive list of Webmin variables too. I went looking for one recently, and couldn’t find anything.

TWO CORRECTIONS TO MY PREVIOUS POST

The script that implements the monitors is located in /usr/share/webmin/status/ not in /usr/share/webmin/ as I initially wrote.

Also, I incorrectly stated that SERVICE is one of the available replacments. That is wrong. The correct replacement for the name of the service being reported is DESC.

I agree with @keenmouse that a comprehensive list would be nice. But based on what I see from scanning the code, the variables that can be replaced are unique to each function. There doesn’t seem to be any application-wide variable-replacement feature. The replacements I noted above seem to exist only in the code related to System and Service Monitors. Reading the existing documentation I’ve been able to find, the information seems to differ on a function-by-function basis. :frowning: