Monthly Archives: October 2016

nagios check_apt

 

Return code of 127 is out of bounds – plugin may be missing

captura-de-ecra%cc%83-2016-10-19-as-15-28-05

On the check_command, I had to prepend check_nrpe! since we are using the nrpe client on the server to read and return us the desired value.

No output returned from plugin

no_output_returned_from_plugin

On the check_command, I had to append, with for example !1, since we need to pass $$ARG1$$

NRPE: Command ‘check_apt’ not defined

captura-de-ecra%cc%83-2016-10-19-as-17-13-52

Check you /etc/nagios/nrpe.cfg you need to set it up there.

 

Well, I got it working!

On nagios nrpe server my /etc/nagios/nrpe.cfg I add the following line

command[check_apt]=/usr/lib/nagios/plugins/check_apt

Restart nagios-nrpe

service nagios-nrpe-server restart

 

On nagios server my /etc/nagios/hosts/s4.domain.com.cfg this is what I have

define service {
   use                     generic-service
   host_name               s4.domain.com
   service_description     SYS: system updates
   check_command           check_nrpe!check_apt!1
}

Restart nagios server

service nagios restart

Hooray!

captura-de-ecra%cc%83-2016-10-20-as-07-30-19

 

iptables unban ip and ban entire subnet

iptables

unban ip

List entries with line numbers

iptables -L -v --line-numbers

Delete entry

iptables -D name_of_chain number_of_line_with_IP_that_you_want_to_delete

Let’s imagine that we want to unban 91.194.16.60! chain name is ‘f2b-sshd‘ and line number is 10!

f2b-ssh-unban

iptables -D f2b-sshd 10
Ban entire subnet

Example (banning some chinese sh*t)

iptables -A INPUT -s 119.249.54.0/24 -j DROP
iptables -A INPUT -s 121.18.238.0/24 -j DROP

 

Ubuntu Nagios NRPE – 1, 2, 3 install!

 

0. Update the system

apt-get update && apt-get upgrade

1. Install nagios nrpe & nagios plugins

apt-get install nagios-nrpe-server nagios-plugins

2. Configure NRPE

vi /etc/nagios/nrpe.cfg

Search for server_address and replace 120.0.0.1 for the public ip of this machine.
Search for allowed_hosts and replace 120.0.0.1 for the IP of your nagios server.

3. Restart NRPE

/etc/init.d/nagios-nrpe-server restart

That’s kinda it…