How do I get the system-serial-number for Xen Server? - citrix

I would like to find out how could I be able to retrieve the system-serial-number of virtual machines installed on Citrix XenServer. I had referred to How to get unique ID of a Citrix XenServer VM from the guest OS? but still could not get with the given solution in this post.
I am able to get the system-serial-number for the virtual machines install on vSphere Client using
Example:
$ dmidecode -t 1 | grep -i serial
Serial Number: VMware-xx xx xx xx xx xx xx xx-xx xx xx xx xx xx xx xx
The virtual machines were running on RHEL 6.5 (for both Xen and vSphere).
When the same command was being executed to retrieve the serial number on the Citrix XenServer VM, the below error messages will be displayed:
$ dmidecode -t 1 | grep -i serial
# dmidecode 2.12
# No SMBIOS nor DMI entry point found, sorry.
Had also tried the below command on the Xen Server, it does not work too.
$ lshal | grep -i serial

On VMware, both serial numbers and system UUID returns equivalent values. Exemple:
Serial Number: VMware-56 4d 36 0a d3 df f6 ad-8c 21 07 c2 4d 58 d6 42
UUID: 564D360A-D3DF-F6AD-8C21-07C24D58D642
Basically the serial number is the UUID (with some extra spaces) prefixed with VMware.
There is a standard and easy way to get the system UUID which works on VMware and VirtualBox (and maybe other hypervisors):
# dmidecode -s system-uuid
564D360A-D3DF-F6AD-8C21-07C24D58D642
Hope this helps.

Related

Unable to communicate with GDM-8341 DMM on Raspberry pi

The GDM-8341 DMM is not recognized as a VCP when you plug it into the raspberry pi, which means you can't use pyserial or pyvisa to talk to the instrument.
This problem was really frustrating, but this post here sent me on the right path:
https://www.raspberrypi.org/forums/viewtopic.php?t=219232
sudo modprobe cp210x
sudo sh -c 'echo 2184 0030 > /sys/bus/usb-serial/drivers/cp210x/new_id'
(verify your vid/pid match 2184 and 0030 respectively)
After entering that "dmesg | grep tty" shows "usb 1-1.3: cp210x converter now attached to ttyUSB0"
Now pyvisa works.
Hope this saves someone a lot of time.

vnstat not updating on certain interfaces

vnstat is updating only one interface every five minutes. I have to use
vnstat -u
to manually update the rest of interfaces. All interfaces are already enabled, but only one interface is updating every 5 minutes.
Check which user the vnstat daemon is running as using ps aux | grep [v]nstat.
I recently had the same problem and after priming the database with
vnstat -u -i eth0 as root the vnstat process couldn't write to the /var/lib/vnstat/eth0
file as it was running as user "vnstat".
If vnstat is running as user "vnstat" ensure that it has permission to write to /var/lib/vnstat/eth0.
When you add the interface for eth0 or ppp0 or whatever, make sure you do it as the vnstat user. ie
sudo -u vnstat vnstat -i ppp0 -u
If you run this as root first you are will have problems even if you chmod the file in /var/lib/vnstat. This is due to the creation of a back file called .ppp0 which you might miss if you are not looking for it. There will be an error in syslog saying that the backup file cannot be written.
So I was having a similar problem where i was getting the following:
$ vnstat -i eno1
eno1: not enough data available yet
I also tried every other command while pointing to eno1. I would sometimes even get:
Error: Unable to create database backup "/var/lib/vnstat/.eno1"
OR
Segmentation fault (core dumped)
I tried reinstalling, and everything else under the sun.
Following Andrew's answer to the 't' returned:
Error: Unable to open database "/var/lib/vnstat/eno1" for writing: Permission denied
so instead I did the following, but I'm not sure which one of these commands did the trick.
$ sudo vnstat -i eno1 -u
$ sudo vnstat -u -i eno1
Then I checked to see if the interface was working again:
$ sudo vnstat -i eno1
which returned:
>
Database updated: Wed Dec 5 10:17:37 2018
(eno1) since 1969-12-31
rx: 2 KiB tx: 1 KiB total: 3 KiB
monthly
rx | tx | total | avg. rate
------------------------+-------------+-------------+---------------
Dec '69 2 KiB | 1 KiB | 3 KiB | 0.00 kbit/s
------------------------+-------------+-------------+---------------
estimated -- | -- | -- |
daily
rx | tx | total | avg. rate
------------------------+-------------+-------------+---------------
today 2 KiB | 1 KiB | 3 KiB | 0.00 kbit/s
------------------------+-------------+-------------+---------------
estimated -- | -- | -- |
Now its finally able to read and write to eno1 log. I noticed this problem since conky was not showing up any stats reports on today && Month && total. I wasn't expecting anything under month, but after a couple days I was expecting something under hours.
I realise the rest will take a while to populate with data. But now I know for sure it is working. Also, my conky app is finally displaying the information.
However, prior to this solution, I had already chmod the file.
Additional info for newbies such as myself:
- make sure to check which interface you are using, I often see solutions for eth0 and others that do not appear when using "$ ifconfig". Enter:
$ ifconfig
and you should see on the left hand side of the results the interface name. Mine are, eno1, lo, and wlo1.
next to the label: "Link encap:" it should say if it is wireless, ethernet, or local loopback
lo is the local loopback a.k.a localhost/127.0.0.1
What I am not sure of, in my case, is the difference between eno1 and wlo1. they both say "Ethernet". I wonder if doesn't have something to do with my direct wifi printer.

Whois query works with telnet but not netcat

I am trying to write an advanced whois client, so I have been experimenting with sending commands to whois servers using netcat (nc) in Arch Linux. For example, this works great:
$ echo domain google.com | nc whois.crsnic.net 43
# => nc outputs whois data for google.com
However, the whois server that handles suffixes like .br.com is whois.centralnic.net and that server seems to not work with netcat. When I give it any query, it seems to simply close the connection without a response:
$ echo foobar | nc whois.centralnic.net 43
# => No output from nc.
I successfully made the same query using telnet:
$ telnet whois.centralnic.net 43
Trying 193.105.170.136...
Connected to whois.centralnic.net.
Escape character is '^]'.
foobar
DOMAIN NOT FOUND
Connection closed by foreign host.
So what could possibly make a server behave differently for telnet than netcat?
I thought maybe it was a timing issue, so I unsuccessfully tried:
$ { sleep 4; echo foobar; sleep 4; } | nc whois.centralnic.net 43
# => No output from nc.
I saw that netcat has a -T option to make it behave more like telnet, so I unsuccessfully tried:
$ { sleep 4; echo foobar; sleep 4; } | nc -T whois.centralnic.net 43
# => No output from nc.
In my production system I will not be using netcat or telnet, but there seems to be some strange networking issue happening here and I would like to be aware of it. Can anyone shed some light on why netcat would work for all the whois servers but only telnet will work for whois.centralnic.net?
The service expects CRLF in its request, not just LF;
This works (on Ubuntu, there are multiple netcat versions, so can't speak for yours)
$ echo -e "foobar\r\n" | nc whois.centralnic.net 43
DOMAIN NOT FOUND

How to make sure a xen DomU is HVM or PV

i used virt-install to create a DomU image, but i cannot make sure the DomU created is a HVM or a PV.....anyone has any ideas?
On Citrix XenServer 6.2, looking at all the parameters of the VM you'll see refferences to PV or HVM:
# xe vm-list name-label=myVM params=all|grep PV-[kd]
PV-kernel ( RW):
PV-drivers-version (MRO): major: 6; minor: 2; micro: 0; build: 70442
PV-drivers-up-to-date ( RO): true
It turns out, in case of a linux VM, you can see if its PV:
[myVM]$ dmesg | egrep "Booting|Xen ver"
Booting paravirtualized kernel on Xen
Xen version: 4.1.5 (preserve-AD)
I'm not quite sure why PV-kernel does not reflect this. For more details see
determine-which-guest-is-running-on-xen-hvm-or-pv-guest and
is-there-an-os-command-i-can-run-to-determine-if-running-inside-a-xen-based-virt.
Run
virsh edit VM_NAME
Then look for the element inside the element. If the value is linux is PVM.
If your Dom0 is a linux machine , can you please check the output of command "ps -eaf | grep qemu" ? It should state the type of guest running on it (in case it is xen hypervisor that is being used).
The output corresponding to pv guest machine will end with "-M xenpv" and output corresponding to hvm/pvhvm guest machines should end with "-M xenfv". This is what i find in my case.
# ps -eaf | grep qemu
/usr/lib/xen/bin/qemu-dm -d 419 -serial pty -domain-name pvm_guest -videoram 4 -vnc 0.0.0.0:0 -vncunused -M xenpv
/usr/lib/xen/bin/qemu-dm -d 429 -domain-name hvm_guest -videoram 4 -k en-us -vnc 0.0.0.0:0 -vncunused -vcpus 1 -vcpu_avail 0x1 -boot c -serial pty -acpi -net nic,vlan=1,macaddr=00:16:3e:40:94:4f,model=rtl8139 -net tap,vlan=1,ifname=tap429.0,bridge=br0 -M xenfv

How to send one byte symbol to server socket with netcat?

There's already a working server service via socket, and I would like to test it via netcat. I'm using Mac OS X Lion. Currently, I'm able to connect to server via port, to send packet, but the packet contains wrong value. Here are the details:
I need to send 'm' symbol to the server and the server will return 00000000, a zero byte as a response. Server guy told me, server receives 'A0' when I'm sending 'm', and server receives '313039A' when I'm sending '109'. How to define sending format or something, I just need to send 'm' (01101101)?
You can send just "m" with
echo -n 'm' | nc <server> <port>
You can easily check what you're sending on your local machine:
# in one Terminal start the listener:
$ nc -l 1234 | hexdump -C
00000000 6d |m|
00000001
# in other Terminal send the packet:
$ echo -n 'm' | nc 127.0.0.1 1234
nc will happily send/receive NUL bytes - there is no problem with that:
# sending side
$ echo -n X | tr X '\000' | nc 127.0.0.1 1234
# receiving side
$ nc -l 1234 | hexdump -C
00000000 00 |.|
00000001