PDA

View Full Version : External scripts


Padawan.AVT
25-05-2009, 16:00
Hi everyone!

I have a question regarding external checks:

I have a script with string of parameters:
./check_GA.sh testuser pass123 MYHOST

When I'm adding it to Zabbix as below:

check_GA.sh[testuser pass123 MYHOST]

It doesn't return anything, but when I put the same in other script


less ./check_crmdocs_GA.sh
#!/bin/bash

cd /data/pandora/local/zabbix_scripts/externalscripts/ && ./check_GA.sh testuser pass123 MYHOST


and put it in Zabbix as

check_crmdocs_GA.sh[]

all work as it should. How can I make check_GA.sh[testuser pass123 MYHOST] work instead of using a bunch of unnecessary scripts?

Calimero
25-05-2009, 16:02
Did you set the "ExternalScripts" parameter in zabbix_server.conf ?

By the way, as far as I remember $1 is the host IP or DNS name.

Padawan.AVT
25-05-2009, 16:24
Yes,
ExternalScripts=/data/pandora/local/zabbix_scripts/externalscripts

You didn't get the problem: my external scripts work in Zabbix when they have no command-line parameters. If they have one they fail.
When I run them with parameters from command line all ok. Environmental variables and all stuff is set correctly.
If I put my script with parameters into another script without parameters, Zabbix processes it correctly.

In Bash (on which my scriptsa are written) $1 stands for the first argument in command line.

Silvery
25-05-2009, 16:35
But in Zabbix the $1 is reserved for the Host.
That means "testuser" is $2 in your example.

Padawan.AVT
25-05-2009, 18:05
Ah, that was the point :)
And my script did a check to accept only 3 parameters.

Thanks!