Skip to content
This repository was archived by the owner on Oct 11, 2023. It is now read-only.

Simulation Service Developer Reference Guide

Devis Lucato edited this page Dec 14, 2017 · 11 revisions

Contents

SSH into a VM

  1. Enable SSH in the Network Security Group

  2. Set username and password for VM

  3. SSH into a VM

Viewing Logs

  1. How to view logs

  2. Copying log files to another machine

  3. Changing the log level

Viewing simulated data

  1. Viewing message throughput and connected devices in the Azure Portal

  2. Viewing simulated data using Remote Monitoring V2

Accessing the VM

1. Enable SSH in the Network Security Group

  • Go to Azure portal > [your resource group] > Network Security Group > Inbound security rules.
  • Select "SSH"
  • Change action to "Allow" and save.

2. Set username and password for VM

In order to access the VM, you will need to set a username and password for your VM.

  • Go to Azure portal > [your resource group] > Virtual Machine > reset password. image
  • Enter a new username and password.

3. SSH into a VM

  • Find your VM's SSH address from the Azure Portal.

    • Go to Azure portal > [your resource group] > Virtual Machine > Overview. The address will be listed in the top panel.
    • You can also select "Connect" from your VM's portal page which will display your ssh command.
  • Sign into a VM.

    • Open a bash window.
      • If using Windows Command Prompt, you can enable bash with the instructions here
    • To sign into a VM using bash, use your username (from above) followed by the IP address of the VM and enter your sign in credentials.
    ssh myusername@12.34.567.890

Viewing Logs

How to view logs

  1. Open a bash window.

  2. SSH into your VM

  3. Navigate to the /app folder

    cd /app
  4. Run the logs.sh script.

    sudo ./logs.sh
  5. This will show you the real-time log output of all running services.

Copying log files to another machine

  1. Open a bash terminal.
  2. SSH into the VM using the instructions above in SSH into a VM
  3. Find your container name or id with docker ps.
  4. Write the logs for a container to disk:
    docker logs <containerid> >& simlog.log
  5. Ensure the log data is present:
    sudo nano container.log
  6. Open a second bash terminal on your local machine.
  7. Copy the file local:
    scp <username>@<vm ip>:container.log c:/temp/container.log

Changing the log level

  1. Open a bash terminal.
  2. SSH into the VM using the instructions above in SSH into a VM
  3. Navigate to the /app folder and edit the environment variables file.
    cd /app
    sudo nano env-vars
  4. Add the following line to the environment variables file. Supported values are ["Debug", "Info", "Warn", "Error"].
export LOG_LEVEL="[your log level choice]"
  1. Press control+X to exit and save the file
  2. Restart the service with the new log level with:
sudo ./start.sh

Viewing simulated data

Viewing message throughput and connected devices in the Azure Portal

  1. Go to Azure portal > [your resource group] > IotHub > Metrics.

  2. Select the values that you'd like to view. For example, connected devices, messages sent, etc...

  3. If you just started your simulation you may need to wait a few minutes for the devices to show up in the portal.

    image

Viewing simulated data using Remote Monitoring V2

If you have a Remote Monitoring V2 deployment, you can enter the hub connection string for the hub from the Remote Monitoring deployment instead of the one deployed with Device Simulation.

Using an RMv2 Hub works well and allows you to see the data show up in the RMv2 dashboard.