Search Exchange
Search All Sites
Nagios Live Webinars
Let our experts show you how Nagios can help your organization.Login
Directory Tree
GenerateRDPFile
0.1
2011-09-02
- Nagios 3.x
GPL
84584
File | Description |
---|---|
GenerateRDPFile | GenerateRDPFile |
Generating RDP files in Nagios.txt | Generating RDP Files notes |
Meet The New Nagios Core Services Platform
Built on over 25 years of monitoring experience, the Nagios Core Services Platform provides insightful monitoring dashboards, time-saving monitoring wizards, and unmatched ease of use. Use it for free indefinitely.
Monitoring Made Magically Better
- Nagios Core on Overdrive
- Powerful Monitoring Dashboards
- Time-Saving Configuration Wizards
- Open Source Powered Monitoring On Steroids
- And So Much More!
I ran into this link when I was trying to figure out how to open Remote Desktop directly from Nagios:
http://www.monitoring-portal.org/wbb/index.php?page=Thread&postID=108422&l=2
It was originally created for use in Nagvis, but I have modified it to suit my needs and implemented it in Nagios instead.
First, you need to create a file in the Nagiossbin folder called "GenerateRDPFile" or something that works for you. Then fill it with this code (file provided above):
******************************
#!/bin/sh
ADDRESS=$(echo ${QUERY_STRING} | grep -oE "(^|[?&])address=b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)b" | cut -f 2 -d "=" | head -n1)
HOST=$(echo ${QUERY_STRING} | grep -oE "(^|[?&])host=.+" | cut -f 2 -d "=" | head -n1)
echo Content-type: application/octet-stream
echo "content-disposition: attachment;filename=$HOST.rdp"
echo
echo screen mode id:i:1
echo desktopwidth:i:800
echo desktopheight:i:600
echo session bpp:i:16
echo winposstr:s:0,9,603,284,1891,1335
echo auto connect:i:0
echo full address:s:$ADDRESS
echo compression:i:1
echo keyboardhook:i:2
echo audiomode:i:2
echo redirectdrives:i:0
echo redirectprinters:i:1
echo redirectcomports:i:0
echo redirectsmartcards:i:1
echo displayconnectionbar:i:1
echo autoreconnection enabled:i:1
echo alternate shell:s:
echo shell working directory:s:
echo disable wallpaper:i:0
echo disable full window drag:i:0
echo disable menu anims:i:0
echo disable themes:i:0
echo disable cursor setting:i:0
echo bitmapcachepersistenable:i:1
echo redirectclipboard:i:1
echo redirectposdevices:i:0
echo authentication level:i:0
echo prompt for credentials:i:0
echo negotiate security layer:i:1
echo remoteapplicationmode:i:0
echo allow desktop composition:i:0
echo allow font smoothing:i:1
echo gatewayhostname:s:
echo gatewayusagemethod:i:0
echo gatewaycredentialssource:i:4
echo gatewayprofileusagemethod:i:0
echo drivestoredirect:s:
echo promptcredentialonce:i:1
*******************************
Then make it executable: "chmod 755 GenerateRDPFile".
Then use this bit as an action_url or notes_url for your hosts (or in your windows-server template so it will be applied to all of your Windows servers): "/nagios/cgi-bin/GenerateRDPFile?address=$HOSTADDRESS$&host=$HOSTNAME$"
Save, check your config, then restart Nagios. When you click on your extra actions or notes icon it will produce an RDP file with the host_name of the server. When you run it it will use the IP address to access the server with RDP.
This can also be extended for use with VNC files as well. Hope this is helpful to some of you.
http://www.monitoring-portal.org/wbb/index.php?page=Thread&postID=108422&l=2
It was originally created for use in Nagvis, but I have modified it to suit my needs and implemented it in Nagios instead.
First, you need to create a file in the Nagiossbin folder called "GenerateRDPFile" or something that works for you. Then fill it with this code (file provided above):
******************************
#!/bin/sh
ADDRESS=$(echo ${QUERY_STRING} | grep -oE "(^|[?&])address=b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)b" | cut -f 2 -d "=" | head -n1)
HOST=$(echo ${QUERY_STRING} | grep -oE "(^|[?&])host=.+" | cut -f 2 -d "=" | head -n1)
echo Content-type: application/octet-stream
echo "content-disposition: attachment;filename=$HOST.rdp"
echo
echo screen mode id:i:1
echo desktopwidth:i:800
echo desktopheight:i:600
echo session bpp:i:16
echo winposstr:s:0,9,603,284,1891,1335
echo auto connect:i:0
echo full address:s:$ADDRESS
echo compression:i:1
echo keyboardhook:i:2
echo audiomode:i:2
echo redirectdrives:i:0
echo redirectprinters:i:1
echo redirectcomports:i:0
echo redirectsmartcards:i:1
echo displayconnectionbar:i:1
echo autoreconnection enabled:i:1
echo alternate shell:s:
echo shell working directory:s:
echo disable wallpaper:i:0
echo disable full window drag:i:0
echo disable menu anims:i:0
echo disable themes:i:0
echo disable cursor setting:i:0
echo bitmapcachepersistenable:i:1
echo redirectclipboard:i:1
echo redirectposdevices:i:0
echo authentication level:i:0
echo prompt for credentials:i:0
echo negotiate security layer:i:1
echo remoteapplicationmode:i:0
echo allow desktop composition:i:0
echo allow font smoothing:i:1
echo gatewayhostname:s:
echo gatewayusagemethod:i:0
echo gatewaycredentialssource:i:4
echo gatewayprofileusagemethod:i:0
echo drivestoredirect:s:
echo promptcredentialonce:i:1
*******************************
Then make it executable: "chmod 755 GenerateRDPFile".
Then use this bit as an action_url or notes_url for your hosts (or in your windows-server template so it will be applied to all of your Windows servers): "/nagios/cgi-bin/GenerateRDPFile?address=$HOSTADDRESS$&host=$HOSTNAME$"
Save, check your config, then restart Nagios. When you click on your extra actions or notes icon it will produce an RDP file with the host_name of the server. When you run it it will use the IP address to access the server with RDP.
This can also be extended for use with VNC files as well. Hope this is helpful to some of you.
Reviews (1)
bysvissa, August 15, 2012
Hey, This helped me a lot.
This didn't worked for me, i have changed the first 2 lines, then it worked like a charm..
ADDRESS=$(echo ${QUERY_STRING} | grep -oE "address=.*" | cut -f 1 -d "&" | cut -f 2 -d "=" | head -n1)
HOST=$(echo ${QUERY_STRING} | grep -oE "(^|[?&])host=.+" | cut -f 2 -d "=" | head -n1)
Thanks,
Sri
This didn't worked for me, i have changed the first 2 lines, then it worked like a charm..
ADDRESS=$(echo ${QUERY_STRING} | grep -oE "address=.*" | cut -f 1 -d "&" | cut -f 2 -d "=" | head -n1)
HOST=$(echo ${QUERY_STRING} | grep -oE "(^|[?&])host=.+" | cut -f 2 -d "=" | head -n1)
Thanks,
Sri