10 January 2017

Windows 10 - Remove Mail and Calendar

When setting up in built Mail app you may have:

"You must make your PC more secure to connect to this server...

Enforce these policies"

Removing the suspect email account may result in an Error with no further useful information.

Remove the Mail (and Calendar) app:

Powershell as admin:

Get-AppxPackage *windowscommunicationsapps* | Remove-AppxPackage

To re-install:

Get-AppxPackage -AllUsers| Foreach {Add-AppxPackage -DisableDevelopmentMode -Register “$($_.InstallLocation)\AppXManifest.xml”}

15 October 2016

Zabbix with MySQL on Ubuntu 16

Thanks to this post by thedutchlab.com and the official docs.

Install required packages

  1. Apache:
    apt-get install libapache2-mod-php7.0 php
  2. Install the missing php packages required on Ubuntu 16/php7:
    apt-get install php7.0-mbstring
    apt-get install php7.0-bcmath
    apt-get install php-xmlwriter
  3. MySQL: See previous post
    apt-get install php-mysql
  4. Zabbix
    apt-get install zabbix-server-mysql zabbix-frontend-php

Create the Database

  1. Refer to my previous post about creating MySQL databases.
  2. Change to the sql directory and unzip the files:
    cd /usr/share/zabbix-server-mysql/
    sudo gunzip *.gz
  3. Install them:
    mysql -u zabbix -p zabbix < schema.sql
    It will prompt for password then take a while
    mysql -u zabbix -p zabbix < images.sql
    mysql -u zabbix -p zabbix < data.sql
  4. Edit the zabbix config (see below)

Modify PHP

post_max_size = 16M
max_execution_time = 300
max_input_time = 300
date.timezone = "Europe/London"

Modify Zabix Config

  1. Edit the Zabbix Config to add the DB User/Pasword:
    vi /etc/zabbix/zabbix_server.conf
    Set DBPassword
  2. Edit the Zabbix php configuration:
    cp /usr/share/doc/zabbix-frontend-php/examples/zabbix.conf.php.example /etc/zabbix/zabbix.conf.php
    vi /etc/zabbix/zabbix.conf.php
    Set the database PASSWORD
  3. Copy the zabbix apache conf to apache.available:
    cp /usr/share/doc/zabbix-frontend-php/examples/apache.conf /etc/apache2/conf-available/zabbix.conf
    cd /etc/apache2/conf-available/
    a2enconf zabbix.conf
    a2enmod alias
    service apache2 restart
  4. Edit the Zabbix configuration:
    vi /etc/default/zabbix-server

Modify the php file for php7

You'll get an error about always_populate_raw_post_data but this is deprecated below php 7
  1. vi /usr/share/zabbix/include/classes/setup/CFrontendSetup.php
  2. Find the line: if (version_compare(PHP_VERSION, '5.6'
  3. Change to: if (version_compare(PHP_VERSION, '7.1'

Re-Start the Services

sudo service zabbix-server restart
sudo service apache2 restart

Install Agent on Minions

  1. apt-get update
    apt-get install zabbix-agent
  2. vi /etc/zabbix/zabbix_agentd.conf
    Amend Server=localhost replacing the IP address of your Zabbix install
  3. /etc/init.d/zabbix-agent start

Load the web Interface

wget http://localhost/zabbix

Default username/password: Admin/zabbix


Test PHP

  1. vi /var/www/html/test.php
  2. http://<host IP>/test.php
    Should Return: PHP Version 7.0.8-0ubuntu0.16.04.3... etc
  3. Try it in the zaabix directory:
    cp /var/www/html/test.php /usr/share/zabbix/test.php
  4. Turn on display errors:
    vi /etc/php/7.0/cli/php.ini
    display_errors        on
  5. Restart apache

Output PHP errors:

Wrap your error-ing script in a try catch:
     // existing code
} catch(Error $e) {
     echo $e->getMessage();

Also can try outputting error log to file:
error_log = /var/log/php_errors.log
touch the file:
touch /var/log/php_errors.log
chown www-data: /var/log/php_errors.log
chmod +rw /var/log/php_errors.log
tail /var/log/php_errors.log

Zabbix Server Log

vi /var/log/zabbix-server/zabbix_server.log

Also Check

  • Apache errors: /var/log/apache2/error.log
  • Error 500: Probably a problem with apache-php
  • Error 404: Re-check the installation steps, you have missed something as the web server/site doesn't exist.
  • If it's giving php errors like: Minimum required size of PHP post is 16M then check the php.ini file: if it has any syntax errors it will revert to defaults:
    cp /usr/lib/php/7.0/php.ini-production vi/etc/php/7.0/apache/php.ini

MySQL on Ubuntu

Install MySQL

  1. In stall MySQL:
    sudo apt-get update
    sudo apt-get install mysql-server
  2. Set the root password
  3. Secure it:
    sudo mysql_secure_installation
    Answer the questions including disallowing root remote login
  4. Test it:
    service mysql status
    mysqladmin -p -u root version

Create New MySQL User

  1. Start a mysql session:
    mysql -u root -p
  2. Show existing users:
  3. Create a new User:
    CREATE USER '<newuser>'@'localhost' IDENTIFIED BY '<password>';

Create New Database

e.g. for Zabbix monitoring tool (from official documentation):
  1. Start a mysql session:
    mysql -u root -p
  2. Show existing databases:
  3. Create the Database:
    create database zabbix character set utf8 collate utf8_bin;
  4. Grant Permissions to user 'zabbix':
    GRANT ALL PRIVILEGES ON zabbix.* to zabbix@localhost identified by '<password>';
  5. Flush the privileges:

03 October 2016

XenServer: Install v7.5

  1. In an existing linux system, plug in a USB drive and find where it is mapped:
    sudo fdisk -l
  2. Format it
    mkdosfs -F 32 -I /dev/sd?
  3. Unmap it if it's mapped:
    sudo fdisk -l
    df -h
    umount /dev/sdc?
  4. Down load Xenserver:
    wget [path to Xenserver iso]
  5. Burn the iso to the usb:
    dd if=/path/to/the.iso of=/dev/sdb bs=1M

02 October 2016

XenServer: Upgrade and Restore VMs

I recently carried out a destructive XenServer upgrade, and an in-place one. This are my notes for a third kind of situation: where you want to fresh install the XenServer OS but maintain the existing virtual machines.

UPDATE: This failed for me at the point of "Get the SCSI ID of the device/partition":


You need to preserve the VM meta data on a different disk to that containing the OS.

  1. Find the disk partitions to find a suitable candidate (lowercase L parameter):
    fdisk -l
    Look for /dev/mapper/XSLocalEXT... or similar (i.e. not dev/sda)
  2. List the mount points to find where it's mounted:
    df -h
    Look for "Mounted on" .../run/sr-mount/87e9a...
  3. Check that tallies with the XenServer VHD list:
    xe sr-list
  4. Create the backup on that disk:
    xe-backup-metadata -c -u87e9a25f...


  1. Find the key:
    Look for: PV /dev/sdb   VG XSLocalEXT-87e9a2...
  2. Re introduce the storage:
    xe sr-introduce uuid=39baf126... type=lvm name-label="Local storage" content-type=user
  3. Get the SCSI ID of the device/partition where the SR is:
    ls -l /dev/disk/by-id/
  4. Get the host UUID:
    xe host-list
  5. Create a PBD (physical block device) to link XenServer and the SR:
    xe pbd-create sr-uuid=87e9a25f... device-config:device=/dev/disk/by-id/scsi-3600... host-uuid=3ca23...

Other Tasks

  • SSH Keys: Setup any SSH keys you need
  • ISO Share: Re-set up your ISO share, if like mine it used the remaining space on the OS drive.
  • Salt-Minion: Reinstall and configure any configuration manager.

01 October 2016

Git on Inux: Creating a New Git Repository

Install Git

  1. Use the package manager to install git:
    CentOs: yum install git
    Ubuntu: apt-get install git

Initialise a Local Repository

  1. Change to your local git repository directory e.g.
    mkdir gitrepo
    cd gitrepo
  2. Initialise git:
    git init

Add a Remote Path

You might want to cache your credentials:
git config --global credential.helper "cache --timeout=3600"
  1. Ensure you're on master locally:
    git checkout master
  2. Add a remote path e.g.:
    git remote add origin [path]
    e.g. https://[somename].visualstudio.com/DefaultCollection/_git/[SomeProject]
  3. Set the local 'master' to track the remote 'master':
    git branch --set-upstream-to=origin/master master

Set the Default Git User

  1. Set your email:
    git config --global user.email "you@example.com"
  2. Set your name:
    git config --global user.name "Your Name"

Update your files

  1. Pull from remote: git pull
  2. Set a global ignore (or it will add system files): echo "*" > .gitignore
  3. Add files to the repo: git add .
    You'll need to explicitly add files as we have a global ignore
  4. Commit your local changes: git commit -m"Some commit message"
  5. Push to remote: git push

Linux: Set Fully Qualified Hostname

On a linux system you may find your hostname is just set tot the computer name e.g.

The problem is that this is not a valid fully qualified domain name.

To set a FQDM:
  1. Edit the hostname file:
    vi /etc/hostname
    vi /etc/hosts
  2. Add a suffix to your computer name e.g.
  3. Restart the hostname service:
    Ubuntu: service hostname restart
    /etc/init.d/hostname.sh start
    CentOS: systemctl restart systemd-hostnamed