ZABBIX Forums  

Go Back   ZABBIX Forums > Zabbix Discussions and Feedback > Zabbix Cookbook

Reply
 
Thread Tools Display Modes
  #1  
Old 16-06-2009, 10:27
skygge skygge is offline
Member
 
Join Date: Jun 2009
Posts: 32
Default "SSH Connect" in Dashboard context menu - HOWTO

Hi all,

I want to tell you how to connect to hosts over SSH using context menu in Zabbix dashboard page.
I really missed this feature so I made it single-handedly.

As you know, scripts are executed on server side, there's no way to run "putty" on your PC that way.

I used SSH java applet "MindTerm" which I installed on Zabbix PHP front-end server, here is download link:
http://www.appgate.com/index/products/mindterm

Download this applet and unpack to directory on server where is your Zabbix PHP front-end located.
In my example it is /var/www/html/zabbix/mindterm

After downloading and extracting, you must sign your applet with certificate.
Proper tools are provided with Java JDK package.

Here's the procedure:

Generate key:
Code:
keytool -genkey -keyalg rsa -alias testkey
Export key:
Code:
keytool -export -alias testkey -file testcert.crt
Check JAR file:
Code:
jar tvf mindterm.jar
Sign JAR file:
Code:
jarsigner mindterm.jar testkey
Verify sign:
Code:
jarsigner -verify -verbose -certs mindterm.jar
So, we have signed SSH applet.
How to use it?

First, create a script in Zabix Administration panel.
The script doesn't need to do anything, you may use command that does nothing,
eg.: /bin/echo "Hello world!" > /dev/null

In my example I created (for testing) a little bash script that does nothing:



And the script itself (/home/zabbix/bin/test):

Code:
#!/bin/sh
exit 0

We need the Zabbix "scriptid", you can find it in your browser status bar when you hover your script name on the list.

It looks like this. My sriptid=6, as you can see:



Then we need to modify Zabbix page "scripts_exec.php" in main directory of Zabbix PHP front-end.

The concept:
I want to run java applet in result message window, when I click "SSH Connect" in dashboard context menu, with specified destination host IP passed by applet parameter, without typing IP by hand.
So we need to know IP of chosen host, and our scriptid.

The modified file "scripts_exec.php" is attached to this post.
You can replace this file (backup the old one first), changing scriptid and path to applet .jar file only.
That's all.

How it works?



Do you like it?

Final words:
Remember, although applet is located on server, it runs on your desktop, so you need access to hosts you want connect to.
I always need to connect to my VPN server when I'm out of office before I use this tool to connect to servers inside my company network.
Of course your browser must support JAVA.

If you want to use this feature in IE, you will need "mindterm_ie.cab" file,
which is NOT included in MindTerm applet archive.
But it's easy to find it with google, just up to 5 min. searching.


In the same way you can add more features, eg. "VNC view" using this applet:
http://www.tightvnc.com/download.html

Any comments welcomed.
Environment used in this example: Zabbix 1.6.4 on Linux server

Have fun!
Skygge.

PS. This is my first post here. Sorry 4 my bad english. Zabbix is great!
Attached Files
File Type: php scripts_exec.php (10.7 KB, 1437 views)

Last edited by skygge; 18-06-2009 at 13:31.
Reply With Quote
  #2  
Old 16-06-2009, 12:45
alixen alixen is offline
Senior Member
 
Join Date: Apr 2006
Location: Paris, France
Posts: 462
Default

Wow ! Excellent !

I hope that this kind of functionality will be included in a future version of Zabbix.

Alixen
Reply With Quote
  #3  
Old 16-06-2009, 15:19
Alexei Alexei is offline
Zabbix developer, product manager
 
Join Date: Sep 2004
Location: Riga, Latvia
Posts: 5,649
Lightbulb

Thanks for the excellent HOWTO! Well done.
__________________
Alexei Vladishev
Creator of Zabbix, Product manager
New York | Tokyo | Riga
My Twitter
Reply With Quote
  #4  
Old 16-06-2009, 15:35
alixen alixen is offline
Senior Member
 
Join Date: Apr 2006
Location: Paris, France
Posts: 462
Default Open source applet

Hi,

mindterm applet is not open source.
Does anybody know an SSH or a remote desktop client applet whose licencing is compatible with GPL ?

Thanks,
Alixen
Reply With Quote
  #5  
Old 22-06-2009, 16:59
troffasky troffasky is offline
Senior Member
 
Join Date: Jul 2008
Posts: 257
Default

Quote:
Originally Posted by skygge View Post
Remember, although applet is located on server, it runs on your desktop, so you need access to hosts you want connect to.
It is possible to tunnel with SSH, so Zabbix server could make a connection to host, and client could make a connection to the Zabbix server.
Code:
ssh client ---> Zabbix server ---> hostB
An alternative - when logging in with SSH, it is possible to specify a command to execute. So the client could log into the Zabbix server and specify a command of 'remotelogin.sh hostB'. remotelogin.sh would be a script created by Zabbix, containing the necessary details to get onto hostB without further intervention from the user.

This isn't limited to SSH of course. The Zabbix server could presumably tunnel anything, turning Zabbix into a remote management gateway.
Reply With Quote
  #6  
Old 22-06-2009, 17:09
skygge skygge is offline
Member
 
Join Date: Jun 2009
Posts: 32
Default

But it's not so secure, isn't it?

Edit: BTW, I was looking for an GPL applet lately, but I found nothing interesting...

Last edited by skygge; 22-06-2009 at 17:20.
Reply With Quote
  #7  
Old 22-06-2009, 17:46
troffasky troffasky is offline
Senior Member
 
Join Date: Jul 2008
Posts: 257
Default

Which 'it' are you talking about?
Reply With Quote
  #8  
Old 24-06-2009, 16:02
koska koska is offline
Junior Member
 
Join Date: Apr 2009
Location: France
Posts: 7
Default

Hi,

It looks very nice but I have a problem with the new scripts_exec.php.

When I put it, all my scripts work but I have an error message.



Any ideas ?

Cheers
Reply With Quote
  #9  
Old 26-06-2009, 11:17
Msth Msth is offline
Junior Member
 
Join Date: Dec 2005
Posts: 12
Default

Hi,

at first, thanks for the great job.

But on my side it won't work. I got two errors :

When i try to open an connection via ssh to the Server. I get following error in the server log.

[Fri Jun 26 10:09:48 2009] [error] [client 172.16.22.53] File does not exist: /var/www/zabbix/com.mindbright.application.MindTerm.class, referer: http://reamon2-vm.realan.de/zabbix/s...c30a52d2086f94
[Fri Jun 26 10:10:11 2009] [error] [client 172.16.22.53] File does not exist: /var/www/zabbix/com.mindbright.application.MindTerm.class, referer: http://reamon2-vm.realan.de/zabbix/s...c30a52d2086f94

And the secound is the same error like koska.


i use the last Version 1.6.5

cu Mario
Reply With Quote
  #10  
Old 26-06-2009, 12:01
skygge skygge is offline
Member
 
Join Date: Jun 2009
Posts: 32
Default

hmmm... hard for me to say what is wrong, I got it working with no errors... maybe you (both) can attach your scripts_exec.php so I could see the code and check it? Your scriptid is really 200200000000003? It's a quite big number...

Another, "file does not exists" mean that script couldn't find applet file, do you correctly replace the path to mindterm.jar in scripts_exec.php?

Cheers,
Skygge

ps. I upgraded my Zabbix server to 1.6.5 and it's working still without any changes.

Last edited by skygge; 26-06-2009 at 14:50.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 17:36.