[root@localhost nagios-plugins-2.2.1]# yum -y install net-snmp net-snmp-utils
[root@localhost nagios-plugins-2.2.1]# ./configure --with-nagios-user=nagios --with-nagios-group=nagios
[root@localhost nagios-plugins-2.2.1]# make && make install 此时再看libexec插件目录下就有check_hpjd插件,打印机的监控方式有点类似于Nagios监控Windows上的NSClient++,可以参看http://jim123.blog.运维网.com/4763600/1956790,在Nagios配置好后就有打印的配置模板,同NSClient++中一样修改下模板:
/usr/local/nagios/etc/objects/printer.cfg
define hostgroup{
hostgroup_name network-printers
alias Network Printers
}
########################################################################################
/usr/local/nagios/etc/servers/192.168.1.254.cfg
define host{
use generic-printer ; Inherit default values from a template
host_name hplj200 ; The name we're giving to this printer
alias HP LaserJet 200dn ; A longer name associated with the printer
address 192.168.1.254 ; IP address of the printer
hostgroups network-printers ; Host groups this printer is associated with
contact_groups admins
}
define service{
use generic-service ; Inherit values from a template
host_name hplj200 ; The name of the host the service is associated with
service_description Printer Status ; The service description
check_command check_hpjd!-C public ; The command used to monitor the service
check_interval 10 ; Check the service every 10 minutes under normal conditions
retry_interval 1 ; Re-check the service every minute until its final/hard state is determined
max_check_attempts 2
notifications_enabled 1
}
define service{
use generic-service
host_name hplj200
service_description PING
check_command check_ping!3000.0,80%!5000.0,100%
check_interval 10
retry_interval 1
max_check_attempts 2
notifications_enabled 1
} 当然如果是多台的话,也可以配置成通用模板,然后根据定义好的cfg_dir去配置多个文件:
/usr/local/nagios/etc/objects/printer.cfg
define host{
name network-printers
check_period 24x7
check_interval 5
retry_interval 1
max_check_attempts 4
check_command check-host-alive
notification_period 24x7
notification_interval 30
notification_options d,r
contact_groups admins
register 0
}
define service{
name network-printers
max_check_attempts 4
normal_check_interval 3
retry_check_interval 1
register 0
check_period 24x7
process_perf_data 1
} 配置好后重启Nagios后就可以实现打印机的监控