Saturday, December 31, 2016

FIX "CRITICAL – Socket timeout after 10 seconds" - Nagios

How to fix “CRITICAL – Socket timeout after 10 seconds” error?
We can fix this by increasing the “Socket timeout” value from the default 10 seconds to let’s say 20.

We can do this by adding a parameter to a specific command defined in commands.cfg file on your Nagios server. Commands.cfg file is usually located at /usr/local/nagios/etc/objects/commands.cfg (if you compiled Nagios) or /etc/nagios/commands.cfg (if you installed Nagios from RPM).

Read more about commands.cfg in my post “Nagios configuration – How to configure Nagios” post.

BEFORE (/usr/local/nagios/etc/objects/commands.cfg):

define command {
 command_name    check_nrpe
 command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
 }
AFTER (/usr/local/nagios/etc/objects/commands.cfg):

define command {
 command_name    check_nrpe
 command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$ -t 20
 }
There are also other commands that support the “-t” parameter! Be sure to add a “-t 20” parameter to the command you had “CRITICAL – Socket timeout after 10 seconds” problems with ??

Friday, December 30, 2016

Block YouTube HTTPS Traffic In Squid & Iptables

Blocking 443 traffic in iptables or squid (Transparent proxy) is possible with below rule

Iptables Rule to Block YouTube in IPTABLES

iptables -I FORWARD -p tcp --dport 80 -m string --string 'youtube.com' --algo bm --to 65535 -j DROP
iptables -I FORWARD -p tcp --dport 443 -m string --string 'youtube.com' --algo bm --to 65535 -j DROP

Above rules will block entire traffic destine to 443 port but you can apply same rule on particular single ip, range of ips or complete network.

To Apply Same Rule on Single IP Address or Subnet

iptables -I FORWARD -p tcp --dport 443 -s 192.168.2.10 -m string --string ‘youtube.com’ --algo bm --to 65535 -j DROP

You can also block "facebook", "twitter" or other https websites with above method.