I'm posting a new question because I've learnt a lot from another question so I believe I've now refined what the problem is...
I want to run a command from the Zabbix server that will query several hosts on a variety of ports.
So I've created a file called /usr/share/zabbix/externalscripts/flexlm.sh with the following command:
lmutil lmstat -A -c $1@$2 | grep -c "license server UP"
I made the file executable using chmod 755.
I created a new group in Zabbix called 'FlexLM servers'.
I created a new template called 'FlexLM licence status', assigned to the above group. In Macros section of the template, I've created two macros, {$FLEXLM_SERVER} and {$FLEXLM_PORT} - I left the 'value' fields blank because I didn't know what to put there. Then within the template I created a new Item, with Type = Script, and the following item key:
flexlm.sh["{$FLEXLM_PORT}","{$FLEXLM_SERVER}"]
I then click Test, and in the 'Test item' box that popped up I set a value for both Macros (one specific server and one specific port), but when I click 'Get value' I get 'Cannot execute script: undefined return value'.
Now, I understand that this is due to the fact that the script is using $1 and $2 as the variables, but Zabbix is sending it $FLEXLM_PORT and $FLEXLM_SERVER.
Therefore could anyone explain what syntax I need to add above the command in the above script to define the variables and 'map' the Zabbix ones to $1 and $2?
Many thanks.
I want to run a command from the Zabbix server that will query several hosts on a variety of ports.
So I've created a file called /usr/share/zabbix/externalscripts/flexlm.sh with the following command:
lmutil lmstat -A -c $1@$2 | grep -c "license server UP"
I made the file executable using chmod 755.
I created a new group in Zabbix called 'FlexLM servers'.
I created a new template called 'FlexLM licence status', assigned to the above group. In Macros section of the template, I've created two macros, {$FLEXLM_SERVER} and {$FLEXLM_PORT} - I left the 'value' fields blank because I didn't know what to put there. Then within the template I created a new Item, with Type = Script, and the following item key:
flexlm.sh["{$FLEXLM_PORT}","{$FLEXLM_SERVER}"]
I then click Test, and in the 'Test item' box that popped up I set a value for both Macros (one specific server and one specific port), but when I click 'Get value' I get 'Cannot execute script: undefined return value'.
Now, I understand that this is due to the fact that the script is using $1 and $2 as the variables, but Zabbix is sending it $FLEXLM_PORT and $FLEXLM_SERVER.
Therefore could anyone explain what syntax I need to add above the command in the above script to define the variables and 'map' the Zabbix ones to $1 and $2?
Many thanks.
Comment