Penguin
Annotated edit history of NagiosNotes version 1, including all changes. View license author blame.
Rev Author # Line
1 MattBrown 1 ! Passive Service / Host Checks
2
3 Passive checks allow you to feed status information into [Nagios] at a time of your choosing rather than having [Nagios] continuously poll some device.
4
5 The typically way to implement them is using NSCA (Nagios Service Command Acceptor)
6
7 NSCA runs on the same server as [Nagios] and listens on a port to accept incoming results.
8
9 __Example Nagios Passive service template__
10 <verbatim>
11 # APC UPS Passive Check
12 define service {
13 use generic-service
14 name g-apc-ups
15
16 service_description APC UPS Power
17 max_check_attempts 1
18 normal_check_interval 5
19 retry_check_interval 1
20 notification_interval 30
21 notification_period 24x7
22 notification_options u,w,c,r
23
24 contact_groups admin-lists
25
26 flap_detection_enabled 0
27 active_checks_enabled 0
28 check_command check_ping
29
30 register 0
31 }
32 # Machines connected to an APC ups
33 define service {
34 use g-apc-ups
35 hostgroup_name ups_servers
36 }
37 </verbatim>
38
39 __Example NSCA config__
40 <verbatim>
41 ####################################################
42 # NSCA Daemon Config File
43 # Last Modified: 25 Feb 2005
44 ####################################################
45
46 # PORT NUMBER
47 server_port=5667
48
49 # ALLOWED HOST ADDRESSES
50 allowed_hosts=192.168.70.10,192.168.70.234
51 # Plaintext passwords!
52 password=your-password
53 decryption_method=1
54
55 nsca_user=nagios
56 nsca_group=nagios
57 debug=0
58 command_file=/var/log/nagios/rw/nagios.cmd
59 alternate_dump_file=/var/log/nagios/rw/nsca.dump
60 aggregate_writes=0
61 append_to_file=0
62 max_packet_age=30
63 </verbatim>
64
65 __Example to generate a passive event__
66 <verbatim>
67 #!/bin/bash
68 #
69 # Setup some defaults to be used by the notification scripts
70
71 HOSTNAME=`hostname`
72 NAGIOS_HOST="x.x.x.x"
73 NSCA_CONFIG="/etc/nsca.conf"
74 SERVICE="APC UPS Power"
75
76 send_alert() {
77
78 echo "$HOSTNAME $SERVICE $1 $2
79 " | /usr/bin/send_nsca -H $NAGIOS_HOST -c $NSCA_CONFIG &>/dev/null
80
81 }
82 </verbatim>
83
84 Source the above script and then call ''send_alert "0" "Status Msg here"''
85
86 * 0 == OK
87 * 1 = WARNING
88 * 2 = CRITICAL