ZABBIX Forums  
  #1  
Old 15-08-2011, 12:01
KimmoJ KimmoJ is offline
Junior Member
 
Join Date: Aug 2011
Posts: 12
Question Scripts for notification - some details elude me

Ok, I have a script that, when fed the proper command-line switches, will send a specific alert type (Growl, if it matters). Tried and tested from the command line, so that part is dealt with.

The issue now is the process of making Zabbix use it and feed it those command line switches.

As far as I can tell, step one is to do Administration \ Media Types and add the script there. Now - is this also where you specify those command line switches? Ie, "command.pl -H $1 -t $2" or some such?

From there, you go to Administration \ Users and make sure the users have that media type active. You can also enter an "send to" field... where does that come into play? Can you access that via a macro? It would be pretty ideal to get that to get fed to the command line (I could set up the user IP/DNS name there which would be all the per-user config I'd need.)

After that, you probably hit Configuration \ Actions and create an action. For this application I'd probably want some of those command line switches in subject and then the message sent as one big command line switch, or something along those lines - but I have no clue how these macro entries communicate with the script, if at all. Can it be done or are this macros just Zabbix internal and together they cook up a big blob of text that gets sent somehow?

Like I said, I don't really get the interactions here, the email notification media type just uses some magic so subject and message gets sent behind the scenes but how are you supposed to do this to talk to a script-based media event? Or can you?
Reply With Quote
  #2  
Old 15-08-2011, 23:26
eskytthe eskytthe is offline
Senior Member
Zabbix Certified Specialist
 
Join Date: May 2011
Location: Denmark
Posts: 348
Default

Hope this help:

Place your script in /home/zabbix/bin
(check AlertScriptsPath in your zabbix_server.conf file) and chmod 755 on script.

$1 is the “Send to” field from user media.
$2 is “Subject” field (in Action Operation)
$3 is “Message” field … lines concatenated (big blob of text)
Macros are “processed” to values before passed to the script.

BR
Erik
Reply With Quote
  #3  
Old 16-08-2011, 13:07
KimmoJ KimmoJ is offline
Junior Member
 
Join Date: Aug 2011
Posts: 12
Default

Thanks! I appreciate that, that info should be enough to get it going (hopefully).

Just to clarify - once you have the AlertPath settings done (already did that) you enter the script in the Media Type like so:

growl.pl $1 $2 $3

?
Reply With Quote
  #4  
Old 16-08-2011, 13:12
eskytthe eskytthe is offline
Senior Member
Zabbix Certified Specialist
 
Join Date: May 2011
Location: Denmark
Posts: 348
Default

Just
growl.pl
Parameters are "build in" as I understand it
Reply With Quote
  #5  
Old 16-08-2011, 13:16
KimmoJ KimmoJ is offline
Junior Member
 
Join Date: Aug 2011
Posts: 12
Default

Ahh... ok then the script needs some work, it expects specific switches on stdin. I was hoping there was a way to specify part static info and part macros on the stdin (ie, growl.pl -H $1 -s $2 -m $3, something like that).

Guess I'll go back to the drawing board.
Reply With Quote
  #6  
Old 16-08-2011, 13:24
eskytthe eskytthe is offline
Senior Member
Zabbix Certified Specialist
 
Join Date: May 2011
Location: Denmark
Posts: 348
Default

Good lock :-)
Reply With Quote
  #7  
Old 16-08-2011, 15:42
KimmoJ KimmoJ is offline
Junior Member
 
Join Date: Aug 2011
Posts: 12
Default

Fixed it: http://www.zabbix.com/forum/showpost...62&postcount=4

Thanks again for pointing me in the right direction about the command line variables!
Reply With Quote
Reply

Tags
actions, media type, notifications, script

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 02:37.