Search This Blog

Sunday, May 10, 2020

Monitor FreeNAS disk using PRTG Network Monitor

In the following post I will show how to monitor FreeNAS volumes using Paessler PRTG Network Monitor.

Currently I’m using FreeNAS version 11.3-U2 and Paessler PRTG Network Monitor version 20.3.0.

SNMP OID: 1.3.6.1.4.1.50536.1.1.1.1

First let’s find what is the allocation size unit, for this we will need to run snmpget for OID: 1.3.6.1.4.1.50536.1.1.1.1.3.1

We can use either SNMP Tester utility (can be download from Paessler site) or do snmpwalk on Linux machine.


Here we can see I get 4096, write down this value as we will need it later on.

Now we will use OID 1.3.6.1.4.1.50536.1.1.1.1.4.1 to get the size of the volume:



As you can see the value is: 1946157056, multiple this value in the allocation size unit (4096) will give us 7,971,459,301,376, divide it by 1,000,000,000 and you will get the volume size in GigaByte: 7971, which is 8TB – my current volume size.

Use OID: 1.3.6.1.4.1.50536.1.1.1.1.5.1 to get the used size, and OID: 1.3.6.1.4.1.50536.1.1.1.1.6.1 the get the free available size. Again, we will need to multiple the values in the allocation unit size and divide the result in 1,000,000,000 the get it in GBytes.

Now open PRTG desktop and add new sensor to your FreeNAS device, in the search line type “OID” and select SNMP Custom:



Type in the sensor name (Volume Use), and the OID value: 1.3.6.1.4.1.50536.1.1.1.1.5.1:


Scroll down, type Channel Name (Used In GB), Unit string (GBytes), in multiplication type the allocation unit (4096) and in Division type 1,000,000,000:



Click Save.

Repeat the same for OID 1.3.6.1.4.1.50536.1.1.1.1.6.1 to get the free available size in GBytes:



Click save.

Now you got 2 new sensors, one which show how much GByte are used and the other how much free GBytes you got for your FreeNAS.

 

 


Monday, December 30, 2019

Raspberry Pi Console server for Aruba AOS-CX switches



So, you got a bench of new Aruba AOS-CX switches, series 6300, and now you need to connect them to your network...



There are 2 ways to configure those, either using Aruba CX Bluetooth app or connecting using the console port.

The Aruba AOS-CX 63xx comes with USB type C console connector, which allow you to use any USB type C cable to your PC, but what about console server?



There are several USB type C console servers out there, but they are pretty expensive,
Here I use console server, for less than 150$, using Raspberry Pi and some cables.

First get a Raspberry Pi with all the required accessories (MicroSD with at least 8GB, power supply, case etc.)



You will also need 5 USB cables type A (male) to type C, those can be found easily.

After configuring the Raspberry Pi with all the basic settings (IP address, routes, enable remote access etc.), which is out of the scope of this post, let’s start the configuration of the console server functions.

Update and Install


sudo apt update
sudo apt upgrade -y
sudo apt-get install minicom -y
sudo apt install ser2net -y 


Allow user to dialout


Taking ownership of the serial port is as easy as adding the group dialout to your login id. You do that with the following command:

sudo usermod -a -G dialout pi

In the line above pi is the user you want to add a group to. If you are logged in as a different user, you'll have to use that username instead on the line above.

Serial Port discovery


Before we can configure ser2net we need to figure out where our serial adapters are listening. Normally serial ports are /dev/ttyS0 or ttyS1, but because we are using USB adapters they may show up as /dev/ttyUSB0 and ttyUSB1 etc.

Use this command to search for yours:


dmesg | grep tty


You’ll see something like this:

  

As you can see, I have my 1 port adapter plugged in, named ttyACM0.
With this information we can configure our ser2net.conf file.


Configuration


Create logging directory:

sudo mkdir /var/log/ser2net

When you install ser2net via apt it puts the configuration file in /etc. To edit it you can use nano with is already on your Pi:

sudo nano /etc/ser2net.conf

Inside you will find some default configuration lines at the bottom of the config file. We can easily edit these to meet our needs.


Let’s edit the ser2net configuration to get things going. The following is my configuration for each serial connection:

Login banner:

BANNER:aruba-b1:\r\nAruba Networks ERT Lab\r\n\r\nUNAUTHORIZED ACCESS TO THIS DEVICE IS PROHIBITED\r\nYou must have explicit, authorized permission to access or configure this device.\r\nUnauthorized attempts and actions to access or use this system may result in civil and/or\r\ncriminal penalties.\r\nAll activities performed on this device are logged and monitored.\r\n\r\nYou are connected to port \p device \d [\s]\r\n\r\nHostname: AOS-CX 6300-06\r\n\r\n


Serial connection with trace file:

192.168.10.145,3000:telnet:600:/dev/ttyACM0:115200 8DATABITS NONE 1STOPBIT aruba-b1
TRACEFILE:tr1:/var/log/ser2net/p-Y-M-D-H:i:s.U


This should be configured for each serial connection, as the Raspberry Pi only got 4 USB ports, you will need to configure 4 of those.

Here is my ser2net.conf complete file:


BANNER:aruba-b1:\r\nAruba Networks ERT Lab\r\n\r\nUNAUTHORIZED ACCESS TO THIS DEVICE IS PROHIBITED\r\nYou must have explicit, authorized permission to access or configure this device.\r\nUnauthorized attempts and actions to access or use this system may result in civil and/or\r\ncriminal penalties.\r\nAll activities performed on this device are logged and monitored.\r\n\r\nYou are connected to port \p device \d [\s]\r\n\r\nHostname: AOS-CX 6300-01\r\n\r\n

BANNER:aruba-b2:\r\nAruba Networks ERT Lab\r\n\r\nUNAUTHORIZED ACCESS TO THIS DEVICE IS PROHIBITED\r\nYou must have explicit, authorized permission to access or configure this device.\r\nUnauthorized attempts and actions to access or use this system may result in civil and/or\r\ncriminal penalties.\r\nAll activities performed on this device are logged and monitored.\r\n\r\nYou are connected to port \p device \d [\s]\r\n\r\nHostname: AOS-CX 6300-02\r\n\r\n

BANNER:aruba-b3:\r\nAruba Networks ERT Lab\r\n\r\nUNAUTHORIZED ACCESS TO THIS DEVICE IS PROHIBITED\r\nYou must have explicit, authorized permission to access or configure this device.\r\nUnauthorized attempts and actions to access or use this system may result in civil and/or\r\ncriminal penalties.\r\nAll activities performed on this device are logged and monitored.\r\n\r\nYou are connected to port \p device \d [\s]\r\n\r\nHostname: AOS-CX 6300-03\r\n\r\n

BANNER:aruba-b4:\r\nAruba Networks ERT Lab\r\n\r\nUNAUTHORIZED ACCESS TO THIS DEVICE IS PROHIBITED\r\nYou must have explicit, authorized permission to access or configure this device.\r\nUnauthorized attempts and actions to access or use this system may result in civil and/or\r\ncriminal penalties.\r\nAll activities performed on this device are logged and monitored.\r\n\r\nYou are connected to port \p device \d [\s]\r\n\r\nHostname: AOS-CX 6300-04\r\n\r\n

TRACEFILE:tr1:/var/log/ser2net/usb-console-port1
192.168.10.145,3000:telnet:600:/dev/ttyACM0:115200 8DATABITS NONE 1STOPBIT aruba-b1 tr=tr1

TRACEFILE:tr2:/var/log/ser2net/usb-console-port2
192.168.10.145,3001:telnet:600:/dev/ttyACM1:115200 8DATABITS NONE 1STOPBIT aruba-b2 tr=tr2

TRACEFILE:tr3:/var/log/ser2net/usb-console-port3
192.168.10.145,3002:telnet:600:/dev/ttyACM2:115200 8DATABITS NONE 1STOPBIT aruba-b3 tr=tr3

TRACEFILE:tr4:/var/log/ser2net/usb-console-port4
192.168.10.145,3003:telnet:600:/dev/ttyACM3:115200 8DATABITS NONE 1STOPBIT aruba-b4 tr=tr4

Save that file and let’s make sure Ser2Net starts up automatically:

sudo nano /etc/rc.local

Add the following above exit 0:


/usr/local/sbin/ser2net -n -c /etc/ser2net.conf

In order to stop/start ser2net use the following command:


sudo /etc/init.d/ser2net [stop|start]


Connect


Now use your favourite terminal app to connect to the console server:







And connect:


Summary


There are many more enhancements which we can use or add to this console server, such wireless AP/client, to connect using wireless network (the Raspberry Pi comes with 2.4 GHz and 5.0 GHz IEEE 802.11ac wireless card) similar to AirConsole.

We can even power up the Raspberry Pi, using the auxiliary USB port, which can be found on the AOS-CX switch, if you run out of power outlets in your rack.

Reference:


https://www.packet6.com/configuring-your-raspberry-pi-as-a-console-server/


Wednesday, November 13, 2019

Adding Aruba AOS-CX to EVE-NG


For EVE Community users:
Download arubacx.yml template file from the following link:
And upload the template file to the following location:
/opt/unetlab/html/templates

File name:
arubacx.yml
Location:
/opt/unetlab/html/templates
Content:
# Copyright (c) 2016, Andrea Dainese
# Copyright (c) 2018, Alain Degreffe
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#     * Redistributions of source code must retain the above copyright
#       notice, this list of conditions and the following disclaimer.
#     * Redistributions in binary form must reproduce the above copyright
#       notice, this list of conditions and the following disclaimer in the
#       documentation and/or other materials provided with the distribution.
#     * Neither the name of the UNetLab Ltd nor  the name of EVE-NG Ltd nor the
#       names of its contributors may be used to endorse or promote products
#       derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---
type: qemu
name: ArubaCX
cpulimit: 1
icon: Switch L3.png
cpu: 2
ram: 4096
ethernet: 7
eth_name:
- mgmt
eth_format: 1/1/{1-6}
console: telnet
shutdown: 1
qemu_arch: x86_64
qemu_nic: virtio-net-pci
qemu_options: -machine type=pc-1.0,accel=kvm -serial mon:stdio -nographic -no-user-config -nodefaults -rtc base=utc
...

SSH to EVE-NG
root@eve-ng:~# cd /opt/unetlab/html/includes/
Copy the sample config file to new file (config.php):
root@eve-ng:/opt/unetlab/html/includes# cp config.php.distribution config.php
Edit the config file as follow:
<?php
/* TEMPLATE MODE .missing or .hided
 *
 * .hided: will hide all template not present on system ( no image installed )
 * .missing: will display not selectable template not present ( no image installed )
 *
 */



DEFINE('TEMPLATE_DISABLED','.missing') ;



/* Define custom templates:
 *
 * Create for exemple /opt/unetlab/html/templates/mytemplate.php and Create
 /opt/unetlab/html/templates/othertemplate.php
 * Then uncomment lines below
 */

         $custom_templates = Array(
'arubacx' => 'Aruba CX Switch'
);


?>

Notes: EVE Community cookbook section 12.3
Next steps below are based on ArubaOS-CX_10_04_0001_ova.zip creation, for other image deployment, use proper names respectively.
1. Download  ArubaOS-CX_10_04_0001_ova.zip. The Aruba account is required to obtain this image.
2. SSH to EVE and login as root, from cli and create temporary working directory abc on the EVE's root:
root@eve-ng:~# mkdir abc
root@eve-ng:~# cd abc
3. Upload the downloaded OVA image to the EVE root/abc using for example FileZilla or WinSCP.
4. Unzip and Extract OVA image, for further use we will need on vmdk image which is inside OVA.
root@eve-ng:~/abc# unzip ArubaOS-CX_10_04_0001_ova.zip
Archive:  ArubaOS-CX_10_04_0001_ova.zip
  inflating: ArubaOS-CX_10_04_0001.ova  
 extracting: ArubaOS-CX_10_04_0001.ova.sig  
root@eve-ng:~/abc# tar xvf ArubaOS-CX_10_04_0001.ova
arubaoscx-disk-image-genericx86-p4-20190731183117.ovf
arubaoscx-disk-image-genericx86-p4-20190731183117.vmdk
root@eve-ng:~/abc#
5. Convert vmdk (red) hdd to the qcow2 format.
/opt/qemu/bin/qemu-img convert -f vmdk -O qcow2 arubaoscx-disk-image-genericx86-p4-20190731183117.vmdk virtioa.qcow2
6. Create new image folder
mkdir /opt/unetlab/addons/qemu/arubacx-10.04
8. Move your created prepared image files virtioa.qcow2 to the image directory
mv virtioa.qcow2 /opt/unetlab/addons/qemu/arubacx-10.04/
9. Delete temporary directory abc and fix permissions
root@eve-ng:~/abc# cd
root@eve-ng:~# rm -rf abc
root@eve-ng:~# /opt/unetlab/wrappers/unl_wrapper -a fixpermissions
Username and password for newly created image will be admin/ <NO PASSWORD>