无法在nagios

时间:2018-03-21 11:58:00

标签: nagios

我已经使用nagios check_by_ssh模块形成了一个获取已建立端口连接的命令。
我可以在运行命令时获取输出,但是在将命令放入commands.cfg文件后,我在GUI中看到“check_by_ssh:skip-stderr参数必须是整数”。对此提出任何建议都会有很大的帮助。

Command:
/usr/local/nagios/libexec/check_by_ssh -l fuseadmin -H <hostname> -C "netstat -punta | grep -i ESTABLISHED | wc -l | awk '{if (\$0>2500) {print \"CRITICAL: Established Socket Count: \"\$0} else {print \"OK: Established Socket Count: \"\$0}}'" -i ~/.ssh/id_dsa -E

OK: Established Socket Count: 67

Commands.cfg:
define command {
      command_name    netstat_cnt_estanblished_gt_2500_fuse01
      command_line   /usr/local/nagios/libexec/check_by_ssh -l fuseadmin -H a0110pcsgesb01 -C "netstat -punta | grep -i ESTABLISHED | wc -l 2>&1 | awk '{if (\$0>2500) {print \"CRITICAL: Established Socket Count: \"\$0} else {print \"OK: Established Socket Count: \"\$0}}'" -i ~/.ssh/id_dsa -E
}

Service Definition
#netstat_cnt_estanblished_gt_2500_csg2.0

define service{
        use                             generic-service         ; Name of service template to use
        host_name                       <hostname>
        service_description             Netstat Established Count
                event_handler                   send-service-trap-fms
        event_handler_enabled           1
        check_command                   netstat_cnt_estanblished_gt_2500_fuse01
        max_check_attempts              1
        notifications_enabled           1                      ; Service notifications are enabled
        check_period                    24x7                    ; The service can be checked at any time of the day
        max_check_attempts              3                       ; Re-check the service up to 3 times in order to determine its final (hard) state
        check_interval           2                     ; Check the service every 10 minutes under normal conditions
        retry_interval            2                     ; Re-check the service every two minutes until a hard state can be determined
        contact_groups                  fuse_users                  ; Notifications get sent out to everyone in the 'admins' group
        notification_options            w,u,c,r                 ; Send notifications about warning, unknown, critical, and recovery events
        notification_interval           30                      ; Re-notify about service problems every hour
        notification_period             24x7

       }

**由于合规性,我已将实际主机名更改为

1 个答案:

答案 0 :(得分:0)

here它说:

 check_by_ssh: print command output in verbose mode

right now it is not possible to print the command output of ssh. check_by_ssh
only prints the command itself. This patchs adds printing the output too. This
makes it possible to use ssh with verbose logging which helps debuging any
connection, key or other ssh problems.
Note: you must use -E,--skip-stderr=<high number>, otherwise check_by_ssh would
always exit with unknown state.

Example:

  ./check_by_ssh -H localhost -o LogLevel=DEBUG3 -C "sleep 1" -E 999 -v

含义:您只需要在定义中指定“-E”之后的数字,如-E 999,就像上面代码块中的示例所示)

...尽管如此,它令人困惑(可能是一个错误?),因为check_by_ssh的命令帮助说:

-E, --skip-stderr[=n]
    Ignore all or (if specified) first n lines on STDERR [optional]