Download file from the web using curl

The following command basically does the same thing as wget.  This can come in handy since OS X and some linux distros do not ship with wget by default.

curl -O -L www.incredigeek.com/home/downloads/wget/wget-1.14.tar.gz

The two options do the following

-O, –remote-name Write output to a file named as the remote file
-L, –location Follow redirects (H)

Ubiquiti AirMax SSH Commands

ssh ubnt@192.168.1.20

AP:

list how many devices are connected.

wstalist |grep \"mac\" |wc -l
or
wstalist |grep -c \"mac\" 

List connected devices

wstalist

List ip’s of connected devices

wstalist |grep \"lastip\" | awk '{print $3}' | sed s/\"/\ /g | sed s/,//g

List connected devices with the device name and ip address of device

wstalist |grep -A1 \"name\" | sed s/\"/\ /g | sed s/,//g | grep -v "\--"

List connected devices along with device name, and signal.

wstalist |grep -A6 \"name\" | grep -E -v 'rx|tx|associd|aprepeater' | sed s/\"/\ /g | sed s/,//g | grep -v "\--"

 

Station:

Signal:

mca-status | grep signal

Signal, essid, frequency, noise, and ccq:

mca-status | grep -A4 essid

List basic info like device name, mac address, firmware version, platform, etc.

mca-status | head -n 1

Show Firmware Version:

mca-status | head -n 1 | awk -F, '{print $3}'

 

 

 

 

 

Control LED from Command Line – Raspberry Pi

Replace “4” with the GPIO pin your using.

echo "4" > /sys/class/gpio/export

Setup the direction.  If it was a button or switch we would change “out” to “in”.

echo "out" > /sys/class/gpio/gpio4/direction

Turn the LED on.

echo "1" > /sys/class/gpio/gpio4/value

Turn the LED off.

echo "0" > /sys/class/gpio/gpio4/value

1 = on and 0 = off.

 

How to Install Nagios 4.0.8 on CentOS 6.5

Install the prerequisite packages

yum install gd gd-devel httpd php gcc glibc glibc-common make perl wget

If you want to monitor SNMP you should install net-snmp now

yum install net-snmp net-snmp-utils
service snmpd start
chkconfig snmpd on

Create the Nagios user.

useradd -m nagios
passwd nagios
groupadd nagcmd
usermod -a -G nagcmd nagios
usermod -a -G nagcmd apache

Create a directory to download and build Nagios from

mkdir /root/nagios
cd /root/nagios

Download Nagios and the Nagios plugins

wget http://sourceforge.net/projects/nagios/files/nagios-4.x/nagios-4.0.8/nagios-4.0.8.tar.gz
wget nagios-plugins.org/download/nagios-plugins-2.0.3.tar.gz 

Extract the Nagios zip

tar xvzf nagios-4.0.8.tar.gz
cd nagios-4.0.8

Compile and make it

./configure
make all
make install
make install-init
make install-commandmode
make install-config
make install-webconf

Create a password so you can login to the web interface

htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

Enable Nagios on startup

 chkconfig nagios on

Start the service

service nagios start

Install the plugins.

cd ..
tar xvzf nagios-plugins-2.0.2.tar.gz
cd nagios-plugins-2.0.2
./configure
make
make install

Start apache and make sure it starts on boot.

service httpd start
chkconfig httpd on

You should now be able to access Nagios by going to https://nagiosserverip/nagios

If you run into issues check your firewall and make sure SELinux is disabled.

How To Enable/Disable SELinux

Disable SELinux

You can manually edit the SELinux config file in /etc/selinux/config and change the variable SELINUX=enforcing to disabled

vi /etc/selinux/config
...
SELINUX=disabled
...

or you can use this little command

sed -i.bak -e 's/^SELINUX=.*/SELINUX=disabled/g' /etc/selinux/config

Enable SELinux

You can enable SELinux manually the same as above but set SELINUX=disabled to SELINUX=enforcing

vi /etc/selinux/config
...
SELINUX=enforcing
...

or

sed -i.bak -e 's/^SELINUX=.*/SELINUX=enforcing/g' /etc/selinux/config

How to Allow a Port Through Firewalld

Note: If you have SELinux enabled you’ll need to allow the port in semanage.

Basic syntax

 firewall-cmd --zone=public --add-port=(port number)/(protocal)

So the command to allow port 80 through the firewall would be

firewall-cmd --zone=public --add-port=http/tcp
or
firewall-cmd --zone=public --add-port=80/tcp

The above command only works for the running instance of firewalld.  If you want to add the port permanetely you need to run the above command and then run it again with “–permanent” added to the end of the command.

example:

firewall-cmd --zone=public --add-port=http/tcp
firewall-cmd --zone=public --add-port=http/tcp --permanent

How To Install Zenoss 4.2.5 on CentOS 6.5

First you need to remove mysql-libs

yum remove mysql-libs

Install wget

yum install -y wget

Download the Zenoss install script archive

wget https://github.com/zenoss/core-autodeploy/tarball/4.2.5 -O auto.tar.gz

Extract the archive

tar zxvf auto.tar.gz

and execute the install script

cd zenoss-core-autodeploy-*
./core-autodeploy.sh

Follow the prompts and when it’s finished navigate to http://yourserverip:8080 to complete the install.

Install Wireless Broadcom Driver for Fedora 21

Run the following commands as root

rpm -Uvh http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noarch.rpm
rpm -Uvh http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-stable.noarch.rpm

Update the system and then download the driver.

yum update
yum install kmod-wl

When the above commands finish reboot the computer

reboot

How To “Unblock” an IP from cPHulk from the Command Line

cPHulk uses a MySQL database to keep track of different IP’s to block, white list, black list, etc.

When there have been X amount of failed login attempts from an IP, cPHulk adds an entry for the IP in the brutes table.

To “unblock” the IP we need to delete the entry.

open up the cPHulk MySQL database.

root@localhost [~]# mysql cphulkd

If your interested you can view all tables that cPHulk uses.

show tables;

Take a look at all the IP’s in the brutes table.

SELECT IP FROM brutes;

example:

mysql> SELECT IP FROM brutes;
+---------------+
| IP            |
+---------------+
| 30.134.41.221 |     <--  IP we want to unblock
| 31.134.40.251 |
+---------------+
2 rows in set (0.00 sec)

mysql>

To unblock the IP we just need to delete the row that has the IP address we want.

mysql> DELETE FROM brutes WHERE IP="30.134.41.221";

It should return the following.

mysql> DELETE FROM brutes WHERE IP="30.134.41.221";
Query OK, 1 row affected (0.00 sec)

mysql>

Exit MySQL.

mysql> exit
Bye
root@localhost [~]#

 

How To Install Ubiquiti AirVision on Debain 7.5

Download the airVision Debian deb from Ubiquiti’s website.

http://www.ubnt.com/download/

Next upload the airvision.deb file to your server.

Install prerequisites

apt-get install openjdk-7-jre-headless

Install airVision

dpkg -i unifi-video_3.0.8~Debian7_amd64.deb

Once it finishes installing open up a web browser and go to https://yourserverip:7443 to finish setting up the controller