SINT Service Monitor — UPGRADING AN EXISTING INSTALL
====================================================

Use this when the machine ALREADY has SINT Service Monitor on it.
For a machine that has never had it, use DEPLOY.txt instead.

You need Administrator rights. It takes about a minute.
Nothing you have configured is lost.


THE WHOLE PROCEDURE
-------------------
1. Copy this whole folder onto the machine.
   Anywhere is fine - the Desktop is easiest.
   Do NOT copy it over the top of the installed folder.

2. RIGHT-CLICK  Upgrade-Service.bat  and choose "Run as administrator".

3. It shows you where the old version is and where the new one is.
   Type  Y  and press Enter.

4. Wait until it says UPGRADE COMPLETE, then close the window.

5. Optional check: run ServiceMonitor.UI.exe as administrator and
   confirm your ticked services are still ticked.

That is the entire process. Do not copy files by hand.


WHAT THE SCRIPT DOES FOR YOU
----------------------------
- Checks you are an Administrator.
- Finds the existing installation by itself. You do not type any paths.
- Stops the monitor service and closes the Service Monitor window.
- Backs up the old version to a folder ending in ".old" next to it.
- Copies the new program files in.
- Starts the service again and confirms it is running.

If any step fails it stops and tells you what to do. It will not leave
you half-upgraded without saying so.


WHAT IS KEPT
------------
Everything you configured is kept, because it does not live in the
program folder. It lives in:

    C:\ProgramData\SINT\ServiceMonitor\

  config.json  - which services are monitored, and the email settings
  state.json   - crash history
  logs\        - log files

The upgrade never touches that folder.

smtp-defaults.json is deliberately NOT copied over. The email settings
are already saved in config.json, and on many machines that seed file
was deleted on purpose after the first install.


IF SOMETHING GOES WRONG
-----------------------
The old version is saved next to the installed folder with ".old" on
the end. For example:

    C:\Program Files\SINT\ServiceMonitor        <- new version
    C:\Program Files\SINT\ServiceMonitor.old    <- previous version

To go back:
  1. Open Services.msc, stop "SINT Service Monitor".
  2. Delete the folder without ".old" on the end.
  3. Rename the ".old" folder back to the original name
     (remove the ".old").
  4. In Services.msc, start "SINT Service Monitor" again.

Once you are happy the upgrade worked, you can delete the ".old"
folder to free up disk space.

For errors, look in Event Viewer > Windows Logs > Application and
filter for the source "SINT Service Monitor".


WHAT IS NEW IN VERSION 1.2.0
----------------------------
1. Outages are now logged from both ends. Previously the log went quiet after
   a service stopped, so a service that was off for hours looked the same as
   one that stopped a minute ago. Now you get:
     - the stop, with what caused it (see below),
     - a "STILL DOWN after N hours" line every 30 minutes while it is down,
     - the start, with the total downtime.

2. Clean stops are investigated. The monitor searches the Windows event logs
   around the stop and reports whether it was a user (naming the account), a
   Windows Update (naming the KB), a software or SQL update (naming the
   product), or a machine restart (naming who restarted it). If it cannot
   tell, it says so instead of guessing, and always logs the raw evidence.

   NOTE: Windows itself does not log a clean service stop on current builds,
   so this is correlation. For a definite name every time, enable
   "Audit Process Creation" = Success and "Include command line in process
   creation events" = Enabled. See DEPLOY.txt.

3. Crash History now shows outage counts, total downtime, longest outage,
   what is down right now, and what the last stop was attributed to. A
   service that is currently down sorts to the top and reads "DOWN NOW".

WHAT WAS NEW IN VERSION 1.1.0
-----------------------------
1. Crash handling now escalates instead of giving up after one restart:

     1st crash  -> restarted after 10 seconds
     2nd crash  -> left stopped for 20 minutes, then restarted
     3rd crash  -> not restarted, "please investigate" email

   Counting is per service and resets after 60 minutes of running cleanly.

2. "About" button - shows which version this machine is running. It reports
   the UI and the monitor service separately and warns you if they differ,
   which is how you spot an upgrade that did not finish.

3. "Crash History..." button - shows crashes per service over the last
   24 hours / 7 days / 30 days, so you can tell whether a site has an
   ongoing problem rather than a one-off.

4. "Site name" in Settings - names this site in alert emails and in the
   Crash History window. Blank means the machine name is used. Worth
   setting during the upgrade while you are on the machine anyway.

No configuration changes are required - existing config.json files keep
working exactly as they are, and existing crash history is preserved.
See DEPLOY.txt for the full description.

AFTER UPGRADING
---------------
Open ServiceMonitor.UI.exe as administrator and click "About". It should
show version 1.2.0 for BOTH the UI and the service. While you are there,
click "Settings..." and set the Site name if it is not already set.
