Skip to Content

From the Virtyx Blog

Setting Up the Virtyx Agent On a Headless Raspberry Pi

By Ben Burwell • December 19, 2017

We work hard to make sure the Virtyx agent can be easily deployed on whatever hardware our customers are using. While the Virtyx agent is most commonly run on endpoints (end-user desktops and laptops) and servers, the Raspberry Pi provides a convenient platform for some specialized monitoring tasks. In this blog post, I will describe how to set up a Raspberry Pi to run the Virtyx agent.

Equipment

  • A Raspberry Pi (I used a Raspberry Pi Zero W, but similar steps should work for other models)
  • A Micro SD card
  • A computer with the capability to mount the SD card
  • A power source for the Raspberry Pi
  • An Ethernet cable and available network port (if not using a wireless Pi)

Installing Raspbian

First, head over to the Raspberry Pi website and download the Raspbian Stretch Lite image. While that’s downloading, grab a copy of Etcher. Etcher is a cross-platform program for burning SD cards for use in IoT devices.

Once you’ve downloaded Raspbian and installed Etcher, connect the SD card to your computer and fire up Etcher. Follow the instructions to choose your SD card and the Raspbian ZIP archive, and burn the image. This may take a few minutes.

Pre-Boot Configuration

After Etcher finishes burning the image to the SD card, mount it on your computer. We need to enable the SSH server so you can use a truly headless setup, and if you are using a Raspberry Pi with WiFi, you’ll also need to configure the network settings.

For the following steps, I’ll assume you have a Unix-like environment at your disposal.

First, cd into the mount point of the SD card. The volume will likely be named boot. Create an empty file named ssh:

$ touch ssh

Next, if you’re using a Raspberry Pi with a wireless card, you’ll want to configure the WPA Supplicant.

$ cat << EOF > wpa_supplicant.conf
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=US

network={
 ssid="your_SSID"
 psk="your_PSK"
 key_mgmt=WPA-PSK
}
EOF

Replace country=US with the two-letter ISO-3166 country code corresponding to your country, and replace your_SSID with the SSID of the WiFi network to join, and your_PSK with your WPA pre-shared key.

Booting the Raspberry Pi

Unmount the SD card from your computer and plug it into the Pi. Connect the Pi to your network with an Ethernet cable if applicable, and connect the power cable. The Pi will take a moment to boot and acquire an IP address.

Using whatever method will work on your network, identify the IP address for your Pi. You should be able to examine the DHCP leases on your router. Alternately, a method that may yield helpful results is by using the arp(8) command to search for all the devices on your network with the b8:27:eb MAC address prefix which is assigned to the Raspberry Pi Foundation:

$ arp -a | grep b8:27:eb

Congratulations, this is a list of all the Raspberry Pis on your network! Once you’ve identified the IP address of your Pi, you’ll need to SSH in:

$ ssh pi@<PI_IP_ADDRESS>

When prompted for the password, enter raspberry. When you initially log in, you should change the password by running the passwd program. You can also modify your Raspberry Pi’s configuration by running the raspi-config program.

Installing the Virtyx Agent

First, log in to Virtyx to retrieve your API key from your Settings page. While you’re SSH’d into your Raspberry Pi, use curl to download the latest Virtyx agent and install it. You’ll want to run these commands as root:

pi@pi $ sudo su
root@pi# curl https://download.virtyx.com/standalone/latest/virtyx_agent_linux_arm6.zip > agent.zip
root@pi# unzip agent.zip
root@pi# mkdir -p /.virtyx
root@pi# mv agent /usr/local/bin/virtyx-agent
root@pi# echo "{\"apiKey\":\"<YOUR_API_KEY>\"}" > /.virtyx/config.json
root@pi# virtyx-agent -install
root@pi# virtyx-agent -start

You should now have the Virtyx agent running on your Raspberry Pi. You can verify this by heading over to your Virtyx dashboard and looking for your new agent.

Now, you can add tasks as usual to start monitoring your internal network. Happy monitoring!


Come join our team - we're hiring!

Get Started for Free
Read More

By Ben Burwell • October 22, 2018

By Ben Burwell • October 19, 2018

By Jim Maniscalco • September 27, 2018

By Ethan Mick • September 20, 2018

By Jim Maniscalco • September 14, 2018

Start using Virtyx today.

If you manage computers or servers, Virtyx can make your life easier.