Managing hosts | laravel-server-monitor | Spatie

 SPATIE

  Laravel Server Monitor
=========================

spatie.be/open-source

  [Docs](https://spatie.be/docs)  [Laravel-server-monitor](https://spatie.be/docs/laravel-server-monitor/v1)  Monitoring-basics  Managing hosts

 Version   v1

 Other versions for crawler [v1](https://spatie.be/docs/laravel-server-monitor/v1)

- [ Introduction ](https://spatie.be/docs/laravel-server-monitor/v1/introduction)
- [ Postcardware ](https://spatie.be/docs/laravel-server-monitor/v1/postcardware)
- [ Requirements ](https://spatie.be/docs/laravel-server-monitor/v1/requirements)
- [ High level overview ](https://spatie.be/docs/laravel-server-monitor/v1/high-level-overview)
- [ Installation and setup ](https://spatie.be/docs/laravel-server-monitor/v1/installation-and-setup)
- [ Using the stand alone version ](https://spatie.be/docs/laravel-server-monitor/v1/using-the-stand-alone-version)
- [ Questions &amp; issues ](https://spatie.be/docs/laravel-server-monitor/v1/questions-and-issues)
- [ Changelog ](https://spatie.be/docs/laravel-server-monitor/v1/changelog)
- [ About us ](https://spatie.be/docs/laravel-server-monitor/v1/about-us)

Monitoring basics
-----------------

- [ Managing hosts ](https://spatie.be/docs/laravel-server-monitor/v1/monitoring-basics/managing-hosts)
- [ Built in checks ](https://spatie.be/docs/laravel-server-monitor/v1/monitoring-basics/built-in-checks)
- [ Listing hosts and checks ](https://spatie.be/docs/laravel-server-monitor/v1/monitoring-basics/listing-hosts-and-checks)
- [ Writing your own checks ](https://spatie.be/docs/laravel-server-monitor/v1/monitoring-basics/writing-your-own-checks)
- [ Notifications and events ](https://spatie.be/docs/laravel-server-monitor/v1/monitoring-basics/notifications-and-events)

Advanced usage
--------------

- [ Manually modifying hosts and checks ](https://spatie.be/docs/laravel-server-monitor/v1/advanced-usage/manually-configure-hosts-and-checks)
- [ Using your own model ](https://spatie.be/docs/laravel-server-monitor/v1/advanced-usage/using-your-own-model)
- [ Customizing notifications ](https://spatie.be/docs/laravel-server-monitor/v1/advanced-usage/customizing-notifications)
- [ Manipulating processes ](https://spatie.be/docs/laravel-server-monitor/v1/advanced-usage/manipulating-processes)

 Managing hosts
==============

###  On this page

1. [ Adding hosts ](#content-adding-hosts)
2. [ Deleting hosts ](#content-deleting-hosts)
3. [ Syncing from a file ](#content-syncing-from-a-file)
4. [ Manually modifying hosts and checks ](#content-manually-modifying-hosts-and-checks)

Adding hosts
--------------------------------------------------------------------------------------------

You can add hosts by running:

```
php artisan server-monitor:add-host
```

You'll be prompted for the name of your host, the ssh user and the port that should be used to connect to the server and which checks it should run.

On most systems the authenticity of the host will be verified when connecting to it for the first time. To avoid problems while running the check we recommend manually opening up an ssh connection to the server you want to monitor to get past that check.

Although we don't recommend this, you could opt to [disable the host authenticity check](http://linuxcommando.blogspot.be/2008/10/how-to-disable-ssh-host-key-checking.html) altogether. Be aware that this will leave yourself open to man in the middle attacks. If you want to go ahead with this option add `-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -q` to the `ssh_command_suffix` key in the `server-monitor` config file.

You can also prefix the SSH command. Just add your desired prefix to the `ssh_command_prefix` key in the config file.

Deleting hosts
--------------------------------------------------------------------------------------------------

Deleting hosts is a simple as running

```
php artisan server-monitor:delete-host
```

where `` is the name of the host you wish to delete.

Syncing from a file
-----------------------------------------------------------------------------------------------------------------

If you have a large number of hosts that you wish to monitor using the `server-monitor:add-host` becomes tedious fast. Luckily there's also a command to bulk import hosts and check from a json file:

```
php artisan server-monitor:sync-file
```

Here's an example of the structure that json file should have:

```
[
  {
    "name": "my-site.com",
    "ssh_user": "forge",
    "ip": "1.2.3.4",
    "checks": [
      "diskspace", "mysql"
    ]
  },
  {
    "name": "another-site.be",
    "ssh_user": "forge",
    "checks": [
      "diskspace"
    ]
  }
]
```

Manually modifying hosts and checks
-----------------------------------------------------------------------------------------------------------------------------------------------------------------

Instead of using artisan commands you may opt to [manually configure](https://docs.spatie.be/laravel-server-monitor/v1/advanced-usage/manually-configure-hosts-and-checks) the hosts and checks in the database
