新网创想网站建设,新征程启航

为企业提供网站建设、域名注册、服务器等服务

perl学习之nagios脚本

  1. #!/usr/bin/perl 
  2. use strict; 
  3. use Getopt::Long; 
  4. use LWP::Simple; 
  5. use lib "/usr/lib64/nagios/plugins"; 
  6. use utils qw ($TIMEOUT %ERRORS &print_revision &support); 
  7. my $HOSTADDRESS; 
  8. Getopt::Long::GetOptions( 
  9.         'h=s' => \$HOSTADDRESS 
  10. ); 
  11. if (defined ($HOSTADDRESS)){ 
  12.         my $content = get("http://$HOSTADDRESS:8080/health.html"); 
  13.                 if ( $content ne '' ){ 
  14.         print "sling is running now!\n"; 
  15.         exit $ERRORS{'OK'}; 
  16. }else{ 
  17.         print "sling is not running,health page not found!!\n"; 
  18.         exit $ERRORS{'UNKNOWN'}; 

根据查看的nagios官网,如果用perl写监控脚本,必须使用strict模块,定义的所有变量都必须使用my声明,Getopt::Long模块可以为perl脚本传参,lib是指定nagios里utils.pm的位置,引用utils模块,nagios自带的%ERRORS可以为我们返回状态code。

北海网站建设公司成都创新互联,北海网站设计制作,有大型网站制作公司丰富经验。已为北海上千多家提供企业网站建设服务。企业网站搭建\成都外贸网站建设公司要多少钱,请找那个售后服务好的北海做网站的公司定做!


分享文章:perl学习之nagios脚本
本文来源:http://www.wjwzjz.com/article/pscdis.html
在线咨询
服务热线
服务热线:028-86922220
TOP