**NOTE: This feature has been introduced into the version 2.5.0**

Sometimes, you will need to check the status of an Opush server without connecting a phone;
then, Spushnik is here for you.

Spushnik is a Java webapp probe able to check the status of an Opush server instance.
It may be installed anywhere, you only have to be able to access to the Opush service.
The only prerequise is to have a user account on OBM.

**NOTE: Comming with Opush release 3.0.0 or higher, the Spushnik port has changed**

If you upgrade Spushnik using the [Opush release 3.0.0 or higher](http://www.obm.org/docs/opush/opush.html) repository,
you will need to change the port in the Healthcheck configuration file (_/etc/obm/healthcheck.ini_).
It's now a standalone server with it's own port: **8083**.

## Installation

#### Debian Squeeze

Modify your /etc/apt/sources.list by adding "contrib" and "non-free".
Example could be found on [Installing OBM On Debian Squeeze page](http://obm.org/wiki/install-obm-debian-squeeze)

Modify your /etc/apt/sources.list by adding "release" OBM repository:

deb http://deb.obm.org/opush/stable opush opush

And finally

wget -q http://deb.obm.org/obmgpg.pub -O - | apt-key add -
aptitude update
aptitude install spushnik

#### CentOS 6

First, you must install OpenJDK to have the java alternatives preconfigured properly for jre and java_sdk.
Example could be found on [Installing OBM 2.4.1 on CentOS 6 page](http://obm.org/wiki/install-obm-241-centos-6)

You have to create a yum repo file containing "release" OBM repository:



And finally

yum install spushnik

## Usage

On a linux client computer, type the following command:

curl http://Spushnik_IP:Spushnik_port/spushnik/foldersync?serviceUrl=https://Opush_IP/Microsoft-Server-ActiveSync -v -H "Accept: application/json" -H "Content-type: application/json" -X POST -d 'input_JSON'


* _Spushnik_IP_ is the IP of the server where spushnik is running
* _Spushnik_port_ is the port of the web server (Jetty on default installation) where spushnik is running (**8082** with **OBM 2.5**, **8083** with **OBM 3.0+**)
* _Opush_IP_ is the IP of the server where spushnik is running
* _input_JSON_ is the input JSON

#### Input JSON

"pkcs12":"'`base64 pkcs12_file -w0`'"


* _loginAtDomain_value_ **mandatory**: is the login of an existing user of the Opush target (ex.: user@opush.com)
* _password_value_ **mandatory**: is the password corresponding to the Opush user
* _pkcs12_password_ **optional**: is the password of the PKCS#12, replace _https_ with _http_ when not given
* _pkcs12_file_ **optional**: is the full path to the PKCS#12 bundle encoded in base64 (ex.: /tmp/user.p12)

#### PKCS#12

Some phones support client certificate authentication, this is possible with Opush by configuring the [reverse proxy](http://obm.org/wiki/installation).
In order to run Spushnik with certificate behaviour, you have to generate the PKCS#12 file.
This can be done with **openssl** on the Opush frontend server:

openssl genrsa -out user.key 2048
openssl req -new -key user.key -out user.csr
openssl ca -config /var/lib/obm-ca/ca.cnf -in user.csr -out user.pem -cert /var/lib/obm-ca/cacert.pem -keyfile /var/lib/obm-ca/private/cakey.pem -days 365
openssl pkcs12 -export -inkey user.key -in user.pem -out user.p12 -name "usera"

And then copy the user.p12 file to your client computer.

#### Output JSON

On success, the service will return a JSON like this:


On error during folder sync scenario, for example on IMAP server not started, the JSON will look like this:

{"status":2,"messages":["HTTP error: 500"]}

On error accessing to Spushnik, the result may look like:

curl: (7) couldn't connect to host

Status value map:

* _0_: success
* _1_: warning
* _2_: error

## Healthcheck

A Opush folder sync scenario is executed by [healthcheck](http://obm.org/wiki/obm-health-check-system) invoking spushnik. To make it work, you must add this block in /etc/obm/healthcheck.ini



* _Spushnik_IP_ is the IP of the server where spushnik is running
* _Spushnik_port_ is the port of the web server (Jetty on default installation) where spushnik is running (8082 with OBM 2.5, 8083 with OBM 3.0+)

## Under the hood

Spushnik implements a folder sync scenario, which acccess all backends and so all dependencies needed by Opush.
With such a scenario, Spushnik give us the state of health of Opush and components it depends on.
Women's shoes