PDA

View Full Version : Creating an ITEM that runs a script


oliverm
02-09-2007, 17:35
Is it possible to get an item that runs a script and uses the outputed results as its value ?

I have a bespoke package that has an "api" (series of command tools really). I want to run one of them with params, and use the number it returns as an item. I can create a trigger to watch when that value reaches a certain level, and then alert on it.

Any ideas how to do this ? I'd also like to use the same technique to monitor the number of warnings/errors in the application/system event log.

Olly

gryphius
04-09-2007, 08:15
as far as I understand this would simply be a UserParameter in your zabbix_agentd.conf ?

UserParameter=SomeApplicaton.AValue,<your api command here with the args>

restart zabbix_agentd, denn add an Item in zabbix

Type Zabbix Agent
Key SomeApplication.AValue

clubbing80s
04-09-2007, 10:02
That would be correct, I have a number of items that run perl scripts i hacked together, to monitor services ..

mmm here's an example

UserParameter=spam ,/usr/bin/spamstat.pl $1
where /usr/bin/spamstat.pl is the script thats going to be run ..
where spam[] is the item i crated
where $1 is the value I set in the item to get the appropriate value

it the item is configured as
Description spam - number of HAM
Type ZABBIX agent
Key spam[ham]
Type of information Numeric (integer 64bit)
Units
Use multiplier
Update interval (in sec) 60
Flexible intervals (sec) No flexible intervals
New flexible interval Delay Period
Keep history (in days) 7
Keep trends (in days) 360
Status Active
Store value As is
Show value throw map As is
Applications none

Group linux_server


hope this helps clarify
g

On quest I have added the script I use here .. I took SpamAssassin logfile analyser (see file header) and altered it for use with zabbix, so real credit to the orignal authers ..
Hope it helps ...
I accept no responsablity / liabitly for the outcome of what my happen when the script is used .. Good luck ..lol

clubbing80s
04-09-2007, 16:16
ok .. got it uploaded ... wasnt reading the fine print .. aparently tar.gz is not an acceptable file format .. lol

mozzi
07-09-2007, 15:13
Okay

I have put this in my zabbix_agentd.conf
UserParameter=barracuda.latency,/root/Zab-Laten

in the file Zab-Laten I put the following
curl -s http://192.168.69.25:8000/cgi-bin/stats.cgi | egrep -e "latency" | sed s/[^0-9]//g

When I run it manually I get this:
root@mozzi:/etc/zabbix# zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf -t barracuda.latency
barracuda.latency [t|2]

Now what am I doing wrong? I get no data in zabbix!
The file is executable and I have(hopefully) setup the item correctly.

Mozzi