ZABBIX Forums  
  #1  
Old 21-11-2017, 16:15
lmaza lmaza is offline
Junior Member
 
Join Date: Nov 2015
Location: Argentina
Posts: 12
Lightbulb Suggest Script linked to item

It would be interesting, that you could add scripts related to LLD.
For example, if we create a rule that discovers all Windows services, we can create a script to start the service that is stopped, but for that we need the service name variable.

It is also necessary to be able to modify the timeout of the scripts, since 3 seconds is too little for several scripts.

Thanks a lot!
Reply With Quote
  #2  
Old 21-11-2017, 20:22
kloczek kloczek is offline
Senior Member
 
Join Date: Jun 2006
Location: UK/London
Posts: 872
Default

You can use your own scripts if you want.
Examples of such scrips you can find in my templates on https://github.com/kloczek/zabbix-templates
For example:
1) OS Linux template uses:
Code:
system.run["awk 'BEGIN {print \"{\\"data\\":[\"; ORS=\"\"} {if (NR!=1) {print \",\n\"}; print \"{\\"{#DISK}\\":\\"\" $3 \"\\"}\"} END {print \"\n]}\"}' /proc/diskstats"]
in DSK: LLD to generate list of block devices.
2) OS Solaris uses similar item in own DSK LLD
Code:
system.run["iostat -x|awk 'BEGIN {print \"{\\"data\\":[\"; ORS=\"\"} {if (NR>3) {print \",\n\"}; if (NR>2) print \"{\\"{#DISK}\\":\\"\" $1 \"\\"}\"} END {print \"]}\"}'"]
Other examples in the same template are in ZFS::L2ARC: and ZPOOL: LLDs used on generate list of L2ARC vdevs and list of ZFS pools
3) Service MySQL template uses
Code:
system.run["{$MYSQL_CMD} 'show databases'|awk 'BEGIN {print \"{\\"data\\":[\"; ORS=\"\"} {if (NR>1) {print \",\n\"}; print \"{\\"{#DB}\\":\\"\" $1 \"\\"}\"} END {print \"]}\"}'"]
to generate list of databases which needs to be monitored.

You can adapt that way to use system.run[] with some power shell oneliners.
Reply With Quote
  #3  
Old 21-11-2017, 20:43
lmaza lmaza is offline
Junior Member
 
Join Date: Nov 2015
Location: Argentina
Posts: 12
Smile

Quote:
Originally Posted by kloczek View Post
You can use your own scripts if you want.
Examples of such scrips you can find in my templates on https://github.com/kloczek/zabbix-templates
For example:
1) OS Linux template uses:
Code:
system.run["awk 'BEGIN {print \"{\\"data\\":[\"; ORS=\"\"} {if (NR!=1) {print \",\n\"}; print \"{\\"{#DISK}\\":\\"\" $3 \"\\"}\"} END {print \"\n]}\"}' /proc/diskstats"]
in DSK: LLD to generate list of block devices.
2) OS Solaris uses similar item in own DSK LLD
Code:
system.run["iostat -x|awk 'BEGIN {print \"{\\"data\\":[\"; ORS=\"\"} {if (NR>3) {print \",\n\"}; if (NR>2) print \"{\\"{#DISK}\\":\\"\" $1 \"\\"}\"} END {print \"]}\"}'"]
Other examples in the same template are in ZFS::L2ARC: and ZPOOL: LLDs used on generate list of L2ARC vdevs and list of ZFS pools
3) Service MySQL template uses
Code:
system.run["{$MYSQL_CMD} 'show databases'|awk 'BEGIN {print \"{\\"data\\":[\"; ORS=\"\"} {if (NR>1) {print \",\n\"}; print \"{\\"{#DB}\\":\\"\" $1 \"\\"}\"} END {print \"]}\"}'"]
to generate list of databases which needs to be monitored.

You can adapt that way to use system.run[] with some power shell oneliners.
Thanks koloczek, but that's not what I'm looking for.
LLD is ok, I can detect, for example, all services from windows. Also, I Can detect if It's is running or not. When, If It's stop, the trigger alert me. I'm looking for create a script for start this service from zabbix UI. In this case I need run the command "sc start {#SERVICE.NAME}". Service Name is a variable from LLD but the zabbix dosen't available this function.
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 06:05.