I’d love to user the username of the person logged in, like what shows in the dashboard display inside of a url action … something like $USERNAME$
. Is there such a template variable available?
Found it! $USER_ID$ (is there anyway to find out stuff like this without a lot of searching?)
For what purpose do you need the currently logged in user?
Custom icon action for Windows hosts that integrates bringing up an RDP to the host, just wanted to fill in the user automatically.
Wow that’s cool!
Can you share your solution ? To open RDP to the host that will be really very nice!
I wrote a cgi-bin program in bash (but you could do this in whatever language). Then setup an action (Global Settings -> Custom icon and actions) a show in column one… with something like:
https://somehost.example.com/cgi-bin/rdp?host=$HOSTNAME$&user=$USER_ID$
#!/bin/bash
# The cgi-bin/rdp program
# REQUEST_URI look like /cgi-bin/rdp?host=hostname&user=username
rdphost=`echo "$REQUEST_URI" | sed -n 's,.*[?&]host=\([A-Za-z0-9-][A-Za-z0-9-]*\).*,\1,p'`
rdpuser=`echo "$REQUEST_URI" | sed -n 's,.*[?&]user=\([A-Za-z0-9-][A-Za-z0-9-]*\).*,\1,p'`
rdpdomain=EXAMPLE
rdpfulldomain=example.com
if [ "$rdphost" ]; then
cat <<HERE
Content-type: application/rdp
Content-disposition: attachment;filename=${rdphost}.rdp
redirectclipboard:i:1
redirectposdevices:i:0
redirectprinters:i:1
redirectcomports:i:1
full address:s:${rdphost}.${rdpfulldomain}
username:s:${rdpuser}
domain:s:${rdpdomain}
HERE
fi
You’d put the script wherever you would normally put cgi programs on your web server. Btw, this does not have to reside on the checkmk server (ours doesn’t).
This does the same in PHP:
<?php
if ( $_REQUEST["host"] && $_REQUEST["user"] ) {
header("Content-Type: application/rdp");
header("Content-disposition: attachment;filename=".$_REQUEST["host"].".rdp");
printf("redirectclipboard:i:1\nredirectposdevices:i:0\nredirectprinters:i:1\nredirectcomports:i:1\n");
printf("full address:s:%s\n", $_REQUEST["host"]);
printf("username:s:%s\n", $_REQUEST["user"]);
} else {
printf("Hostname or Username not set\n");
}
?>
You can put that as rdp.php
in the document root folder of the system apache instance on your monitoring server. On Debian that would be /var/www/html
.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed. Contact @fayepal if you think this should be re-opened.