Nagios插件之登陆防火墙实现Session监控(2)

sprintf(status_information,"cur_session=%s, tcp_session=%s, half_open=%s, half_close=%s udp_session=%s icmp_session=%s, rawip_session=%s", cur_session, tcp_session, half_open, half_close, udp_session, icmp_session, rawip_session);

sprintf(performance_data,"cur_session=%s;;;; tcp_session=%s;;;; half_open=%s;;;; half_close=%s;;;; udp_session=%s;;;; icmp_session=%s;;;; rawip_session=%s;;;;", cur_session, tcp_session, half_open, half_close, udp_session, icmp_session, rawip_session);

exitstatus=CRITICAL;
  printf("%s - %s | %s\n", exit_status[exitstatus], status_information, performance_data);

return exitstatus;
 }

/*
// printf("active_status=%s\n",active_status);
// printf("active_ip_addr=%s\n",active_ip_addr);

// if(atoi(ping_avg)<200 && atoi(loss_packet)==0) {
 if(atoi(ping_avg)<200 && atoi(loss_packet_int)==0) {
  exitstatus=OK; 
 }
// else if(atoi(ping_avg)>=200 && atoi(ping_avg)<500 || atoi(loss_packet)>=10 && atoi(loss_packet)<=50) {
 else if(atoi(ping_avg)>=200 && atoi(ping_avg)<500 || atoi(loss_packet_int)>=10 && atoi(loss_packet_int)<=50) {
  exitstatus=WARNING; 
 }
// else if(atoi(ping_avg)>=500 || atoi(loss_packet)>50) {
 else if(atoi(ping_avg)>=500 || atoi(loss_packet_int)>50) {
  exitstatus=CRITICAL; 
 }
 else {
  exitstatus=CRITICAL; 
 }


// sprintf(status_information,"rta %s%s, loss %s",ping_avg,ping_unit,loss_packet);
 sprintf(status_information,"rta %s%s, loss %s%%",ping_avg,ping_unit,loss_packet_int);

// sprintf(performance_data,"rta=%s%s;200.000;500.000;0; pl=%s;40;80;; rtmax=%s%s;;;; rtmin=%s%s;;;;",ping_avg,ping_unit,loss_packet,ping_max,ping_unit,ping_min,ping_unit);
 sprintf(performance_data,"rta=%s%s;200.000;500.000;0; pl=%s%%;40;80;; rtmax=%s%s;;;; rtmin=%s%s;;;;",ping_avg,ping_unit,loss_packet_int,ping_max,ping_unit,ping_min,ping_unit);

//|rta=0.056ms;200.000;500.000;0; pl=0%;40;80;; rtmax=0.084ms;;;; rtmin=0.029ms;;;;

if(strstr(argv[1],"80_49")) {
         printf("%s - 192.20.198.121: %s | %s\n",exit_status[exitstatus],status_information,performance_data);
 }

if(strstr(argv[1],"80_50")) {
         printf("%s - 192.20.198.181: %s | %s\n",exit_status[exitstatus],status_information,performance_data);
 }

return exitstatus;
 */

sprintf(status_information,"cur_all_session=%s, tcp_all_session=%s, tcp_half_open=%s, tcp_half_close=%s udp_session=%s icmp_session=%s, rawip_session=%s", cur_session, tcp_session, half_open, half_close, udp_session, icmp_session, rawip_session);

sprintf(performance_data,"cur_all_session=%s;;;; tcp_all_session=%s;;;; tcp_half_open=%s;;;; tcp_half_close=%s;;;; udp_session=%s;;;; icmp_session=%s;;;; rawip_session=%s;;;;", cur_session, tcp_session, half_open, half_close, udp_session, icmp_session, rawip_session);

printf("%s - %s | %s\n", exit_status[exitstatus], status_information, performance_data);

return exitstatus;
}

--------------------------------------分割线 --------------------------------------

Ubuntu下配置Mrtg监控Nginx和服务器系统资源

使用 snmp+Mrtg 监控 Linux 系统

Mrtg服务器搭建(监控网络流量)

网络监控器Nagios全攻略

Nagios搭建与配置详解

Nginx环境下构建Nagios监控平台

在RHEL5.3上配置基本的Nagios系统(使用Nagios-3.1.2)

CentOS 5.5+Nginx+Nagios监控端和被控端安装配置指南

Ubuntu 13.10 Server 安装 Nagios Core 网络监控运用

--------------------------------------分割线 --------------------------------------

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/fce0a7d3436085837def526e665e2ec1.html