How To Install Ubiquiti mFi controller on Debain(7.5.0) Linux

Add the following line to /etc/apt/sources.list

deb http://dl.ubnt.com/mfi/distros/deb/debian debian ubiquiti

Add GPG keys

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv C0A52C50
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10

Update the system

sudo apt-get update

Install the mFi software

sudo apt-get install mfi

Once it is finished installing you should be able to browse to https://yourserverip:6443 to access the mFi web page.

How To Install Ubiquiti’s UniFi Controller on Debian Linux

First add the following line to /etc/apt/sources.list

deb http://www.ubnt.com/downloads/unifi/distros/deb/debian debian ubiquiti

Next add the GPG key for UniFi and mongo-10

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv C0A52C50
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10

Update the system

sudo apt-get update

Install the UniFi software

sudo apt-get install unifi-rapid

Once it is finished installing you should be able to browse to https://yourserverip:8443 to access the UniFi web page.

How to Create a Local Storage Repository for XenServer

Find your hard drive and or partition.

cat /proc/partitions

The above command should give you a list of all the HDD’s and partitions on the system.

Find the UUID of the disk with the following command

ll /dev/disk/by-id

Find the UUID of your XenServer.

xe host-list

Create the storage repository.

 xe sr-create content-type=user device-config:device=/dev/disk/by-id/"Disk UUID" host-uuid="Host UUID" name-label=”Local Storage 2” shared=false type=lvm

example:

[root@XenServer ~]# cat /proc/partitions
major minor #blocks name

3 0 22378 loop0
6 0 285474816 sda   <--- Main HHD is is here, shows total size of disk
8 1 4193297 sda1 
8 2 4193297 sda2       
8 3 244085167 sda3  <--- This is the partition we need
252 0 4096 dm-0
252 1 105070592 dm-1
253 0 104857600 tda
253 1 4363264 tdb
[root@XenServer ~]# ll /dev/disk/by-id/
total 0
lrwxrwxrwx 1 root root 9 Oct 13 20:38 scsi-56234c232c92f371217ce8549f51e0nf1 -> ../../sda
lrwxrwxrwx 1 root root 10 Oct 13 20:38 scsi-56234c232c92f371217ce8549f51e0ff1-part1 -> ../../sda1
lrwxrwxrwx 1 root root 10 Oct 13 20:38 scsi-56234c232c92f371217ce8549f51e0ff1-part2 -> ../../sda2
lrwxrwxrwx 1 root root 10 Oct 13 20:38 scsi-56234c232c92f371217ce8549f51e0ff1-part3 -> ../../sda3   <-- This is the UUID for the partition
lrwxrwxrwx 1 root root 9 Oct 13 20:38 usb-Dell_Virtual_CDROM_1028_123456 -> ../../sr1
[root@XenServer ~]# xe host-list
uuid ( RO)                : dce4e7fe-8342-bd11-12c8-83caac124a4b   <--- UUID for XenServer
          name-label ( RW): XenServer001
    name-description ( RW): Default install of XenServer

[root@XenServer ~]# xe sr-create content-type=user device-config:device=/dev/disk/by-id/scsi-56234c232c92f371217ce8549f51e0ff1-part3 host-uuid=dce4e7fe-8342-bd11-12c8-83caac124a4b name-label="Local Storage" shared=false type=lvm

 

How to View Installed Programs in linux

Debian Based Distros

The below command should work for Debain, Ubuntu, and the Raspberry Pi Raspbian.

dpkg --get-selections

 

RPM Based Distros

The following works on Fedora, CentOS, ReHat.

rpm -qa

 

The above commands return all of the packages installed on a system.  If you want to look for a specific program or package you can use grep to filter the results.

rpm -qa | grep program

or

dpkg --get-selections | grep program

SNMP and Shell Script

First you will need to make sure SNMP is installed.

apt-get install snmpd snmp snmp-mibs-downloader

You’ll need to configure a new snmpd.conf file with

snmpconf

Run through the steps and when your done replace your current snmpd.conf file in /etc/snmp/ with the new one.

Now open up your new snmpd.conf file

vi /etc/snmp/snmpd.conf

and add the following to the bottom of the file.

extend myshscript /path/to/your.sh

Save and close the file and restart the snmpd service.

service snmpd restart

Now we need to find the OID of our new data point.  Do this by running

snmpwalk -v2c -c public localhost .1.3.6.1.4.1.8072.1.3.2

It should display something similar to the following.

root@localhost:/etc/snmp# snmpwalk -v2c -c public localhost .1.3.6.1.4.1.8072.1.3.2
iso.3.6.1.4.1.8072.1.3.2.1.0 = INTEGER: 1
iso.3.6.1.4.1.8072.1.3.2.2.1.2.4.118.111.108.116 = STRING: "/etc/snmp/volt.sh"
iso.3.6.1.4.1.8072.1.3.2.3.1.4.4.118.111.108.116 = INTEGER: 0
iso.3.6.1.4.1.8072.1.3.2.4.1.2.4.118.111.108.116.1 = STRING: "14.3"
root@localhost:/etc/snmp#

The OID we are interested in is the one on the last line.  If you run a snmpwalk command with the OID you should get your data point.

root@localhost:/etc/snmp# snmpwalk -v2c -c public localhost 1.3.6.1.4.1.8072.1.3.2.4.1.2.4.118.111.108.116.1
iso.3.6.1.4.1.8072.1.3.2.4.1.2.4.118.111.108.116.1 = STRING: "14.3"
root@localhost:/etc/snmp#

All that’s left is to add the OID to your SNMP monitor.  If You run into issues with your SNMP server not monitoring the OID, you might need do what I did in the above command, replace the beginning of the OID “iso.” with a “1”.

 

How to Create a LVM Logical Volume in Linux

First we need to create the Physical Volume.  Change “/dev/sda2” to your drive.

pvcreate /dev/sda2

Next we create the Volume Group.  You can change “VGname” to something else if you so desire.

vgcreate VGname /dev/sda2

And finally, create the Logical Volume.  The Logical Volume’s name will be home.  Change as needed.

lvcreate -l %100FREE -n home VGname

The above command will create a Logical Volume that uses all the free space avaliable in the Volume Group.  If you want the Logical Volume to be a specific size,  change “-l 100%FREE” to “-L 60G”.  Where “60G” is the size in GB.
Example:

lvcreate -L 60G -n home VGname

Your Logical Volume should be setup now.  You can list all your Logical Volumes with

lvdisplay

You may need to format the new logical volume to mount it.  Replace VGname and LVname for the Volume Group name and the Logical Volume name.

mkfs.ext4 /dev/VGname/LVname

Mount it with

mount /dev/VGname/LVname /mount/point

Some Basic MySQL Commands

Enter Mysql

mysql -u root -p

Create Database

create DATABASE testdb;

Select Database

use testdb;

Delete Database

drop DATABASE testdb;

Drop Table

drop table table_name;

Show Tables

show tables;

Show data in table

SELECT * FROM table_name;

Create Table

CREATE TABLE contacts_table (id INT, name VARCHAR(20), email VARCHAR(20));

Insert data into table

INSERT INTO contacts_table (id,name,email) VALUES(2,"John","John83@incredigeek.com");

List one row in table

SELECT * FROM table_name LIMIT 1;

Delete Row in Table

DELETE FROM table_name WHERE row_name=data_to_delete;

Delete all “users” from a WordPress database that do not contain admin in the username.

DELETE FROM `wp-users` WHERE user_login NOT LIKE "%admin%"

Add Auto Increment to Table

ALTER TABLE  `table_name` ADD  `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST;

Create table with Date and Time timestamp

CREATE TABLE table_name (id INT, timeStamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP);

Show MySQL Users

select * from mysql.users;

Create MySQL User

GRANT ALL ON mysqldb.* TO username@localhost IDENTIFIED BY 'password';

Delete MySQL user

DROP USER 'username'@'localhost';

Add Column to the end of MySQL Table

ALTER TABLE mysqltable ADD email VARCHAR(60);

Add Column to the begging of MySQL Table

ALTER TABLE mysqltable ADD email VARCHAR(60) FIRST;

Insert Column after Specific Column in MySQL Table

ALTER TABLE mysqltable ADD email VARCHAR(60) AFTER columnname;

Setup SNMP for Ubiquiti Radios

First lets install SNMP.

On Red Hat type systems such as Fedora and CentOS do the following

yum install -y net-snmp net-snmp-utils

If you are using a Debian based distro the you can use apt.

apt-get install snmp

You will need to make sure that SNMP is turned on in the radio under the Services tab.

Be sure to remember the SNMP Community string as that is needed in the next step.

Now try to connect to the device with the following command.

snmpwalk -v1 -c comunityname 192.168.1.20

You should receive something like the following.

...
IF-MIB::ifSpecific.5 = OID: SNMPv2-SMI::zeroDotZero
SNMPv2-MIB::snmpInPkts.0 = Counter32: 484
SNMPv2-MIB::snmpOutPkts.0 = Counter32: 471
SNMPv2-MIB::snmpInBadVersions.0 = Counter32: 0
SNMPv2-MIB::snmpInBadCommunityNames.0 = Counter32: 12
SNMPv2-MIB::snmpInBadCommunityUses.0 = Counter32: 0
...

If you received

Timeout: No Response from 192.168.1.20

Then either the SNMP Community name is wrong or the ip address is unreachable.

The following command will list all the interfaces on the device.

snmpwalk -v1 -c comunityname 192.168.1.20 ifDescr
IF-MIB::ifDescr.1 = STRING: lo
IF-MIB::ifDescr.2 = STRING: eth0
IF-MIB::ifDescr.3 = STRING: eth1
IF-MIB::ifDescr.4 = STRING: wifi0
IF-MIB::ifDescr.5 = STRING: ath0
IF-MIB::ifDescr.6 = STRING: br0

Notice the number at the end of the ifDescr, That number identifies the interface.  You will need that for the next command.

Now lets check the signal. Note that the last number of the OID(the OID is the last string of numbers) is the interface number of ath0.  Yours could be different depending on how you have the radio setup.

snmpwalk -v1 -c communityname 192.168.1.20 1.3.6.1.4.1.14988.1.1.1.1.1.4.5

Here is a short list of OID’s.  To use them just run the above command but replace the OID with the one you want.

RxRate of 5'th interface (ath0) of the device (bps): 1.3.6.1.4.1.14988.1.1.1.1.1.3.5
TxRate of 5'th interface (ath0) of the device (bps): 1.3.6.1.4.1.14988.1.1.1.1.1.2.5
Channel: 1.3.6.1.4.1.14988.1.1.1.1.1.7.5
Firmware Version: 1.2.840.10036.3.1.2.1.4
Hostname: 1.3.6.1.4.1.14988.1.1.1.1.1.5
AP MAC: 1.3.6.1.4.1.14988.1.1.1.1.1.6
Station MAC: 1.2.840.10036.1.1.1.1
Signal 1.3.6.1.4.1.41112.1.4.5.1.5.1 (OID seems to vary a little bit, from nanoBeam to nanoStation)

 

How to set a static ip address on CentOS, Fedora, or Red Hat Linux

Open up the following file with your favorite text editor. Change eth0 to the interface you need, like “wlan0” or “eth1”.

 vi /etc/sysconfig/network-scripts/ifcfg-eth0

The file should look something like the following.

DEVICE=eth0
HWADDR=0A:2G:F3:56:66:4B
TYPE=Ethernet
UUID=aeh9421c-6a62-712c-886d-347813g8d1dh
ONBOOT=no
NM_CONTROLLED=yes
BOOTPROTO=dhcp

To set the static IP address change “BOOTPROTO=dhcp” to “BOOTPROTO=static” and add the following to the end of the file. If you want/need the interface to come up when the computer boots up then be sure to change “ONBOOT=no” to “ONBOOT=yes”.

BROADCAST=192.168.1.255
DNS1=8.8.8.8
GATEWAY=192.168.1.1
IPADDR=192.168.1.110
NETMASK=255.255.255.0

Also, on some newer versions of CentOS you may need to add NM_DISABLED=no

So your file should now look like this.

DEVICE=eth0
HWADDR=0A:2G:F3:56:66:4B
TYPE=Ethernet
UUID=aeh9421c-6a62-712c-886d-347813g8d1dh
ONBOOT=yes
NM_CONTROLLED=no
BOOTPROTO=static
BROADCAST=192.168.1.255
DNS1=8.8.8.8
GATEWAY=192.168.1.1
IPADDR=192.168.1.110
NETMASK=255.255.255.0

Save the file and restart networking.

service network restart

Finally, check you IP address with ifconfig.

root@localhost ~]# ifconfig eth0
eth0      Link encap:Ethernet  HWaddr 0A:2G:F3:56:66:4B  
          inet addr:192.168.1.110  Bcast:192.168.1.255  Mask:255.255.255.0

How to Install Nagios 4.0.6 on CentOS 6.3

Install the prerequisite packages

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

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 downloads.sourceforge.net/project/nagios/nagios-4.x/nagios-4.0.6/nagios-4.0.6.tar.gz
wget nagios-plugins.org/download/nagios-plugins-2.0.2.tar.gz 

Extract the Nagios zip

 tar xvzf nagios-4.0.6.tar.gz
cd nagios-4.0.6

Compile and make it

./configure
make all
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