Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Saturday, August 01, 2020

SCRCPY - No Frills Tool for Android Screen Mirroring

If you are Android user and wanted to Mirror your mobile or tablet screen on your laptop for presentations or want to control your phone from your computer without having to switch between the devices every now and then SCRCPY is the tool for you. It is OpenSource, free and easy to setup. Works out of the box once you enable Developer Options and Switch on USB Debugging on your Android Device.

Once it is setup, you can control your device from your computer using Keyboard and Mouse, make use of the larger screen real estate of your computer instead of your tiny mobile device screen. You can check your SMS, notifications, open your favorite apps, play games etc all from your computer. Best part - it works on Windows, Linux and MacOS

Now lets get to work.

First download SCRCPY that is suitable to your OS from the Github page link below


It would download a Zip file that you can unzip to a location of your choice.



Enable USB Debugging on your Device
1. Make sure your device is running on Android 5.0 or higher. You can get this information from About section in settings of your device
2. Enable Developer Options on your Device. To do this tap 7 to 8 times on the Build Number in the About section in the Settings screen
3. You will see that message will be displayed saying Developer Options have been enabled on your device
4. Now Return to the main Settings page and select Developer Options and scroll down to find USB Debugging and enable it.

Now Connect your device to your computer using a USB cable and in couple of seconds you would see a prompt on your phone to accept the fingerprint of the Computer, select allow this computer and click 'OK'

Got to SCRCPY folder and launch scrcpy-noconsole with Admin Privilege, on Windows you can right click and select run as administrator, on Linux and Mac OS you can launch it as super user from terminal. If everything worked as expected it would show up your mobile screen on your computer


1. Use your Mouse right click to wake your device.
2. Use left click to interact with your device.
3. Use Ctrl+R on keyboard to Rotate the screen
4. You can also Use Ctrl+P to Wake your device.

By default the mirroring function would keep the actual screen device active. Use Ctrl+O to Poweroff
the device screen, however, SCRCPY window would be still available for use

You can now launch your favorite apps on your phone without even touching your phone all from your computer with all the convenience of Keyboard and Mouse.

To take it to next level you can actually configure SCRCPY to work on Wifi so that you can get rid of the USB cable between your device and computer. For this follow below steps.

Make sure your Android Device and Computer are connected to the same WiFi network.
Find out the IP address of your Android Device from WiFi advanced settings

Connect your Android Device to your computer using the USB cable.
Open Command prompt in admin mode, navigate to SCRCPY folder and run below two command
adb tcpip 5555
adb connect DEVICE_IP:5555 (Replace DEVICE_IP with IP address your Android Device)


Disconnect cable from the device and launch scrcpy-noconsole

Now you can mirror your phone to your computer without any cable. Isn't it cool.

You can play games, watch OTT content from Apps that cannot be accessed on your computer, dial your contacts or receive calls, send and read SMS all without touching your mobile device or while it is charging in other room.


Reference:
https://developer.android.com/studio/command-line/adb#wireless
https://www.youtube.com/watch?v=vuTdxa-w1js

Sunday, March 06, 2016

Monitor EC2 Memory Usage using AWS CloudWatch

CloudWatch an AWS service provides rich set of tools to monitor health and resource utilization of various services on AWS. These metrics can be used to trigger an alarm, send notifications, even trigger actions based on these alarms.

 

One main metric that is missing from default CloudWatch metrics is Memory utilization of EC2 instances. Since AWS does not have access to EC2 instance at the Operating System level, only CPU, Network utilization, IO and other metrics that can be monitored through Hypervisor layer are available by default in AWS Console.

 

AWS provides a set of scripts that utilize CloudWatch API to send Memory Utilization info and make use of CloudWatch features to monitor and take action if alarms are raised.

The process of sending these custom metrics are different for Linux and Windows Instances. Even the process of installing pre-requisites on different Linux distributions is slightly different.

 

In this post we will see the process of installing and configuring CloudWatch Custom Metrics for Redhat derived Linux Distros, mainly RHEL, Amazon Linux and CentOS along with Windows to monitor Memory Utilization of the EC2 instance

 

Updated (27-March-2016) – Added Commands for Ubuntu Linux

 

List of all commands run on Linux are also available at the end of the post for easy

reference.

 

Step –1

Create an IAM user with access key. We do not need password or console access to this user.

 

image_thumb[32]

 

Copy and keep the Access key handy as we would need this every time we configure custom metrics to be sent to CloudWatch

 

Monday, May 28, 2012

Lighttpd health monitor on F5 Big IP Load balancer

If you are trying to use F5 Big IP LTM (Local Traffic Manager) to load balance webservers running Lighttpd and have configured default http health monitor from F5, you would notice that the F5 would treat the servers as non responsive and mark then down.

This is because the send string in the default monitor is configured as GET /\r\n which is not accepted by few standard webservers like lighttpd.

Lighttpd-G5-001

A simple solution to this problem is to create a custom monitor with the help of default http monitor.

Saturday, April 28, 2012

Ubuntu 12.04 has Hyper-V support Built-in

The latest release of Ubuntu 12.04 LTS (Long Term Support) code named Precise Pangolin from Canonical has many new features as in with any new release improving stability and speed. The interesting addition that will excite Microsoft shops and fans is built in support for Hyper-V eliminating the need to install Microsoft Linux Integration Components inside Ubuntu 12.04 when deployed as a VM

 

Ubuntu-1

 

image

 

As you can see in the above screenshots the kernel version is 3.2 which has Hyper-V IC modules and detects all Hyper-V synthetic devices like NIC, SCSI storage, has mouse integration and supports multiple vCPUs out of the box.

 

Hope to see other Linux distributions do the same soon.

 

Useful links

Click here to know more about Ubuntu new release and download links

Ubuntu home page

Click here to download 32 bit Desktop ISO image (701 MB)

Click here to download 64 bit Desktop ISO image (698 MB)

Click here for my earlier post on Linux IC and Hyper-V

Click here to know more about Pangolin

Tuesday, April 10, 2012

RHEL/CentOS on Hyper-V 2k8 R2 with LIC v3.2

Microsoft Officially supports RedHat, CentOS and SUSE Linux Distributions as VMs running on Hyper-V. Linux Integration Components (LIC) or Linux Integration Services are the software components released by Microsoft that need to be installed on Linux VMs to take full advantage of Hyper-V features.
 
  • Linux Integration Components are a set of drivers that enable synthetic device support in supported Linux virtual machines running on Microsoft Hyper-V
These components when installed on Linux mainly provide below features
 
1. Drivers : Synthetic network controller (NIC), IDE and SCSI storage controllers support
2. Time sync : Clock inside the virtual machine will be in synch with the clock on the Host
3. Integrated Shutdown : Shut down from either Hyper-V Manager or SCVMM
4. Symmetric Multi-Processing (SMP) Support : Support up to 4 virtual processors Per VM
5. Heartbeat : Allows Host to detect if the virtual machine is running and responsive
6. Integrated Mouse Support : Seamless mouse integration when used with the Linux GUI
 
If Linux IC are not installed one might be presented with one or all of the below errors
 
CEntOS-00
 
CEntOS-01
 
CEntOS-02
 
Note: This post assumes that one has install CentOS/RHEL/Scientific Linux 6.2 on HyperV and has mounted Linux IC v3.2.iso onto DVD Drive of VM. If not please follow link below this post for Picture guide of CentOS server minimal installation
 
The documentation available along with LIC v3.2 looks good, but, unfortunately when trying to install you will get an error similar to the below one
 
ls: cannot access kmod-hyper-v-rhel6-43.1.x86_64.rpm: no such file or directory
ls: cannot access hyper-v-rhel6-43.1.x86_64.rpm: no such file or directory RPM’s are missing
 
There is a simple work around to this by changing the working directory to the mount point of Linux IC drive and invoking ./install.sh script.
 
LIC-Error
 
Below are the commands to run to install Linux IC and reboot, once prompted, as shown in the above screenshot
 
mount /dev/cdrom /media
 
cd /media
 
./install.sh
 
reboot
 
When VM is rebooted you will notice that there is no network connectivity to your VM. Follow steps below for configuring network connectivity
vi /etc/sysconfig/network-scripts/ifcfg-eth0
 
Press i Key on keyboard and type the below lines
DEVICE="eth0"
ONBOOT="yes"
HWADDR=
TYPE=Ethernet
BOOTPROTO=dhcp
NAME="System eth0"
 
HWADDR is the MAC address of the NIC that can be found from settings menu of VM in Hyper-V (Below screenshot for your reference) and DHCP is the mode of getting IP Address
 
CEntOS-27b
 
Now use below Key Combination to save the file and close
Esc
Shift + :
wq
Enter
 
Use the below commands to edit, Save and close one more file
vi /etc/sysconfig/network
 
CEntOS-27c
 
Enter below text, save and close
NETWORKING=yes
 
CEntOS-27d
 
Now Run ifup eth0 and you should be connected to network or else take a reboot.
 
CEntOS-27e
 
With this our CentOS/RHEL/Scientific Linux 6.2 can take full advantage of Hyper-V synthetic drivers and is ready for production :)
 
Useful Links:-

Sunday, February 06, 2011

Get System Serial and Model from Command Line

Many times for some or the other reason we may need to look for serial number and model of the system. We generally do that turning our laptops upside down or by looking on CPU cabinet panels.

Well there’s a much easier way to look for them using command line. If you are running Windows just issue below commands in the command prompt.

      • For Serial Number
                •      wmic bios get serialnumber
      • For Manufacturer
      •      wmic csproduct get vendor

For Model
      •      wmic csproduct get name

image

The above commands make use of Windows Management Instrumentation (WMI)

If you use Linux, a tool called dmidecode comes to the rescue. Just issue below command in terminal with elevated privilege and you would get the necessary details

dmidecode –t system

Use sudo dmidecode –t system on Debian based Linux distros like Ubuntu

image

Use su dmidecode –t system on RPM based Linux distros like Fedora

image

dmidecode is available on most of the new distros by default. If it is not available on your system you can install it from the repository or get it from here to compile and install.