Skip to content

Commit

Permalink
refactor: rename CLI application and repository from lhp to hostpatrol
Browse files Browse the repository at this point in the history
  • Loading branch information
vst committed Apr 14, 2024
1 parent 993fc48 commit 58e96d7
Show file tree
Hide file tree
Showing 11 changed files with 97 additions and 97 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ jobs:
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
run: |
gh release upload "${{ steps.release.outputs.tag_name }}" /tmp/lhp-static-linux-x86_64
gh release upload "${{ steps.release.outputs.tag_name }}" /tmp/hostpatrol-static-linux-x86_64
32 changes: 16 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<h1 align="center">
<div>
<img alt="logo" src="https://github.com/vst/lhp/assets/374793/cad6706b-0384-4a71-9ca5-21ade9ce3d1e" />
<img alt="logo" src="https://github.com/vst/hostpatrol/assets/374793/cad6706b-0384-4a71-9ca5-21ade9ce3d1e" />
</div>
<div>Host Patrol</div>
<sub>Lazy Hacker's Linux Host Patrol</sub>
<p></p>
<div>
<img alt="GitHub Release" src="https://img.shields.io/github/v/release/vst/lhp?display_name=tag&style=for-the-badge">
<img alt="GitHub Issues or Pull Requests" src="https://img.shields.io/github/issues/vst/lhp?style=for-the-badge">
<img alt="GitHub Issues or Pull Requests" src="https://img.shields.io/github/issues-pr/vst/lhp?style=for-the-badge">
<img alt="GitHub Release" src="https://img.shields.io/github/v/release/vst/hostpatrol?display_name=tag&style=for-the-badge">
<img alt="GitHub Issues or Pull Requests" src="https://img.shields.io/github/issues/vst/hostpatrol?style=for-the-badge">
<img alt="GitHub Issues or Pull Requests" src="https://img.shields.io/github/issues-pr/vst/hostpatrol?style=for-the-badge">
</div>
</h1>

Host Patrol (`lhp`) is a command-line application to retrieve
Host Patrol (`hostpatrol`) is a command-line application to retrieve
information from remote hosts. The information is retrieved over SSH
by executing small [scripts]. Then, the information is compiled into
JSON to be further analysed or visualised on its [Website].
Expand Down Expand Up @@ -48,19 +48,19 @@ Currently, the easiest way to install the command-line application is
via Nix:

```sh
nix profile install --file https://github.com/vst/lhp/archive/v<VERSION>.tar.gz app
nix profile install --file https://github.com/vst/hostpatrol/archive/v<VERSION>.tar.gz app
```

## Usage

`lhp` assumes that you are able to connect to remote hosts via SSH:
`hostpatrol` assumes that you are able to connect to remote hosts via SSH:

```sh
ssh my-host
```

Indeed, `lhp` uses `ssh` under the hood. Therefore, if you can `ssh`,
you can `lhp`!
Indeed, `hostpatrol` uses `ssh` under the hood. Therefore, if you can `ssh`,
you can `hostpatrol`!

> [!NOTE]
>
Expand All @@ -71,7 +71,7 @@ you can `lhp`!
You can pass hosts via CLI arguments:

```sh
lhp compile --host my-host-1 --host my-host-2 > /tmp/lhp-report.json
hostpatrol compile --host my-host-1 --host my-host-2 > /tmp/hostpatrol-report.json
```

This command connects to hosts sequentially and ignores problematic
Expand All @@ -81,7 +81,7 @@ To use parallel mode, use `--parallel` flag. In this case, if any of
the hosts cause an error, entire operation will fail:

```sh
lhp compile --parallel --host my-host-1 --host my-host-2 > /tmp/lhp-report.json
hostpatrol compile --parallel --host my-host-1 --host my-host-2 > /tmp/hostpatrol-report.json
```

Alternatively, you can use a configuration file which has additional
Expand Down Expand Up @@ -133,13 +133,13 @@ Then, you can use this configuration file instead of specifying hosts
individually on the command-line:
```sh
lhp compile --config config.yaml > /tmp/lhp-report.json
hostpatrol compile --config config.yaml > /tmp/hostpatrol-report.json
```

..., or mix with `--host` option:

```sh
lhp compile --config config.yaml --host a-host --host b-host > /tmp/lhp-report.json
hostpatrol compile --config config.yaml --host a-host --host b-host > /tmp/hostpatrol-report.json
```

Users can process/analyse the JSON output themselves or use [Website]
Expand Down Expand Up @@ -170,7 +170,7 @@ hpack &&
find . -iname "*.nix" -not -path "*/nix/sources.nix" -and -not -path "*/website/node_modules/*.nix" -print0 | xargs --null nixpkgs-fmt &&
hlint app/ src/ test/ &&
cabal build -O0 &&
cabal run -O0 lhp -- --version &&
cabal run -O0 hostpatrol -- --version &&
cabal v1-test &&
cabal haddock -O0
```
Expand All @@ -188,8 +188,8 @@ under [MIT License].

<!-- REFERENCES -->

[Issue 32]: https://github.com/vst/lhp/issues/32
[Website]: https://thenegation.com/lhp
[Issue 32]: https://github.com/vst/hostpatrol/issues/32
[Website]: https://thenegation.com/hostpatrol
[os-release]: https://www.freedesktop.org/software/systemd/man/latest/os-release.html
[scripts]: ./src/scripts
[Website source-code]: ./website
Expand Down
2 changes: 1 addition & 1 deletion build-static.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ GHC_VERSION="9.4.8"
DOCKER_IMAGE="quay.io/benz0li/ghc-musl:${GHC_VERSION}"

## Executable name:
EXECUTABLE_NAME="lhp"
EXECUTABLE_NAME="hostpatrol"

## Final executable name:
FINAL_EXECUTABLE_NAME="${EXECUTABLE_NAME}-static-$(uname --kernel-name | tr '[:upper:]' '[:lower:]')-$(uname --machine)"
Expand Down
2 changes: 1 addition & 1 deletion default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ let
find . -iname "*.nix" -not -path "*/nix/sources.nix" -and -not -path "*/website/node_modules/*.nix" -print0 | xargs --null nixpkgs-fmt --check
hlint app/ src/ test/
cabal build -O0
cabal run -O0 lhp -- --version
cabal run -O0 hostpatrol -- --version
cabal v1-test
cabal haddock -O0
'';
Expand Down
16 changes: 8 additions & 8 deletions package.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
name: lhp
name: hostpatrol
version: 0.0.11
github: vst/lhp
github: vst/hostpatrol
license: MIT
author: Vehbi Sinan Tunalioglu
maintainer: [email protected]
copyright: Copyright (c) 2024 Vehbi Sinan Tunalioglu
extra-source-files:
- README.md
- CHANGELOG.md
description: Please see the README on GitHub at <https://github.com/vst/lhp#readme>
description: Please see the README on GitHub at <https://github.com/vst/hostpatrol#readme>
dependencies:
- base >= 4.7 && < 5
library:
Expand Down Expand Up @@ -37,7 +37,7 @@ library:
- typed-process
- yaml
executables:
lhp:
hostpatrol:
main: Main.hs
source-dirs: app
ghc-options:
Expand All @@ -48,9 +48,9 @@ executables:
- '-rtsopts'
- '-with-rtsopts=-N'
dependencies:
- lhp
- hostpatrol
tests:
lhp-test:
hostpatrol-test:
main: Spec.hs
source-dirs: test/spec
ghc-options:
Expand All @@ -61,13 +61,13 @@ tests:
- '-rtsopts'
- '-with-rtsopts=-N'
dependencies: []
lhp-doctest:
hostpatrol-doctest:
main: doctest.hs
source-dirs: test/doctest
ghc-options:
- '-Wall'
- '-Werror'
- '-threaded'
dependencies:
- lhp
- hostpatrol
- doctest
2 changes: 1 addition & 1 deletion src/Lhp/Cli.hs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ infoModHeader =
-- | Footer 'OA.InfoMod'.
infoModFooter :: OA.InfoMod a
infoModFooter =
OA.footer "See <https://github.com/vst/lhp> for help and feedback."
OA.footer "See <https://github.com/vst/hostpatrol> for help and feedback."


-- | Tests a parser with given arguments.
Expand Down
10 changes: 5 additions & 5 deletions src/Lhp/Meta.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,24 @@ import qualified Data.Time as Time
import Data.Version (Version, showVersion)
import qualified GitHash as Githash
import qualified Language.Haskell.TH as TH
import qualified Paths_lhp as Paths
import qualified Paths_hostpatrol as Paths
import qualified System.Info


-- | Application name.
--
-- >>> name
-- "lhp"
-- "hostpatrol"
name :: T.Text
name = "lhp"
name = "hostpatrol"


-- | Application title.
--
-- >>> title
-- "Lazy Hacker's Linux Host Patrol"
-- "Lazy Hacker's Host Patrol"
title :: T.Text
title = "Lazy Hacker's Linux Host Patrol"
title = "Lazy Hacker's Host Patrol"


-- | Application version.
Expand Down
54 changes: 27 additions & 27 deletions src/Lhp/Remote.hs
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ compileHostReport ch = do
h@Types.Host {..} <- _makeHostFromConfigHostSpec ch
kvs <- (++) <$> _fetchHostInfo h <*> _fetchHostCloudInfo h
let _hostReportHost = h
_hostReportHostname <- _toParseError _hostName $ _getParse pure "LHP_GENERAL_HOSTNAME" kvs
_hostReportTimezone <- _toParseError _hostName $ _getParse pure "LHP_GENERAL_TIMEZONE" kvs
_hostReportHostname <- _toParseError _hostName $ _getParse pure "HOSTPATROL_GENERAL_HOSTNAME" kvs
_hostReportTimezone <- _toParseError _hostName $ _getParse pure "HOSTPATROL_GENERAL_TIMEZONE" kvs
_hostReportCloud <- _mkCloud _hostName kvs
_hostReportHardware <- _mkHardware _hostName kvs
_hostReportKernel <- _mkKernel _hostName kvs
Expand Down Expand Up @@ -230,16 +230,16 @@ _mkCloud
-> m Types.Cloud
_mkCloud h kvs =
_toParseError h $ do
_cloudName <- fromMaybe "UNKNOWN" <$> _findParse pure "LHP_CLOUD_NAME" kvs
_cloudHostId <- _findParse pure "LHP_CLOUD_ID" kvs
_cloudHostType <- _findParse pure "LHP_CLOUD_TYPE" kvs
_cloudHostRegion <- _findParse pure "LHP_CLOUD_REGION" kvs
_cloudHostAvailabilityZone <- _findParse pure "LHP_CLOUD_AVAILABILITY_ZONE" kvs
_cloudHostLocalHostname <- _findParse pure "LHP_CLOUD_LOCAL_HOSTNAME" kvs
_cloudHostLocalAddress <- _findParse pure "LHP_CLOUD_LOCAL_ADDRESS" kvs
_cloudHostRemoteHostname <- _findParse pure "LHP_CLOUD_PUBLIC_HOSTNAME" kvs
_cloudHostRemoteAddress <- _findParse pure "LHP_CLOUD_PUBLIC_ADDRESS" kvs
_cloudHostReservedAddress <- _findParse pure "LHP_CLOUD_RESERVED_ADDRESS" kvs
_cloudName <- fromMaybe "UNKNOWN" <$> _findParse pure "HOSTPATROL_CLOUD_NAME" kvs
_cloudHostId <- _findParse pure "HOSTPATROL_CLOUD_ID" kvs
_cloudHostType <- _findParse pure "HOSTPATROL_CLOUD_TYPE" kvs
_cloudHostRegion <- _findParse pure "HOSTPATROL_CLOUD_REGION" kvs
_cloudHostAvailabilityZone <- _findParse pure "HOSTPATROL_CLOUD_AVAILABILITY_ZONE" kvs
_cloudHostLocalHostname <- _findParse pure "HOSTPATROL_CLOUD_LOCAL_HOSTNAME" kvs
_cloudHostLocalAddress <- _findParse pure "HOSTPATROL_CLOUD_LOCAL_ADDRESS" kvs
_cloudHostRemoteHostname <- _findParse pure "HOSTPATROL_CLOUD_PUBLIC_HOSTNAME" kvs
_cloudHostRemoteAddress <- _findParse pure "HOSTPATROL_CLOUD_PUBLIC_ADDRESS" kvs
_cloudHostReservedAddress <- _findParse pure "HOSTPATROL_CLOUD_RESERVED_ADDRESS" kvs
pure Types.Cloud {..}


Expand All @@ -252,9 +252,9 @@ _mkHardware
-> m Types.Hardware
_mkHardware h kvs =
_toParseError h $ do
_hardwareCpuCount <- _getParse _parseRead "LHP_HW_CPU" kvs
_hardwareRamTotal <- _getParse (fmap (_roundS 2 . _toGB) . _parseRead) "LHP_HW_RAM" kvs
_hardwareDiskRoot <- _getParse (fmap (_roundS 2 . _toGB) . _parseRead) "LHP_HW_DISK" kvs
_hardwareCpuCount <- _getParse _parseRead "HOSTPATROL_HW_CPU" kvs
_hardwareRamTotal <- _getParse (fmap (_roundS 2 . _toGB) . _parseRead) "HOSTPATROL_HW_RAM" kvs
_hardwareDiskRoot <- _getParse (fmap (_roundS 2 . _toGB) . _parseRead) "HOSTPATROL_HW_DISK" kvs
pure Types.Hardware {..}


Expand All @@ -266,12 +266,12 @@ _mkKernel
-> m Types.Kernel
_mkKernel h kvs =
_toParseError h $ do
_kernelNode <- _getParse pure "LHP_KERNEL_NODE" kvs
_kernelName <- _getParse pure "LHP_KERNEL_NAME" kvs
_kernelRelease <- _getParse pure "LHP_KERNEL_RELEASE" kvs
_kernelVersion <- _getParse pure "LHP_KERNEL_VERSION" kvs
_kernelMachine <- _getParse pure "LHP_KERNEL_MACHINE" kvs
_kernelOs <- _getParse pure "LHP_KERNEL_OS" kvs
_kernelNode <- _getParse pure "HOSTPATROL_KERNEL_NODE" kvs
_kernelName <- _getParse pure "HOSTPATROL_KERNEL_NAME" kvs
_kernelRelease <- _getParse pure "HOSTPATROL_KERNEL_RELEASE" kvs
_kernelVersion <- _getParse pure "HOSTPATROL_KERNEL_VERSION" kvs
_kernelMachine <- _getParse pure "HOSTPATROL_KERNEL_MACHINE" kvs
_kernelOs <- _getParse pure "HOSTPATROL_KERNEL_OS" kvs
pure Types.Kernel {..}


Expand All @@ -283,12 +283,12 @@ _mkDistribution
-> m Types.Distribution
_mkDistribution h kvs =
_toParseError h $ do
_distributionId <- _getParse pure "LHP_DISTRO_ID" kvs
_distributionName <- _getParse pure "LHP_DISTRO_NAME" kvs
_distributionVersion <- _getParse pure "LHP_DISTRO_VERSION" kvs
_distributionRelease <- _getParse pure "LHP_DISTRO_VERSION_ID" kvs
_distributionCodename <- _findParse pure "LHP_DISTRO_VERSION_CODENAME" kvs
_distributionDescription <- _getParse pure "LHP_DISTRO_PRETTY_NAME" kvs
_distributionId <- _getParse pure "HOSTPATROL_DISTRO_ID" kvs
_distributionName <- _getParse pure "HOSTPATROL_DISTRO_NAME" kvs
_distributionVersion <- _getParse pure "HOSTPATROL_DISTRO_VERSION" kvs
_distributionRelease <- _getParse pure "HOSTPATROL_DISTRO_VERSION_ID" kvs
_distributionCodename <- _findParse pure "HOSTPATROL_DISTRO_VERSION_CODENAME" kvs
_distributionDescription <- _getParse pure "HOSTPATROL_DISTRO_PRETTY_NAME" kvs
pure Types.Distribution {..}


Expand Down
2 changes: 1 addition & 1 deletion src/Lhp/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{-# LANGUAGE OverloadedStrings #-}

-- | This module defines public data and type definitions to represent
-- a complete lhp report.
-- a complete Host Patrol report.
module Lhp.Types where

import qualified Autodocodec as ADC
Expand Down
42 changes: 21 additions & 21 deletions src/scripts/cloud.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,28 +37,28 @@ _check_command curl
#############

if curl --silent --fail --max-time 2 http://169.254.169.254/latest/dynamic/instance-identity/document >/dev/null; then
_print_var "LHP_CLOUD_NAME" "AWS"
_print_var "LHP_CLOUD_ID" "$(curl -s http://169.254.169.254/latest/meta-data/instance-id)"
_print_var "LHP_CLOUD_TYPE" "$(curl -s http://169.254.169.254/latest/meta-data/instance-type)"
_print_var "LHP_CLOUD_REGION" "$(curl -s http://169.254.169.254/latest/meta-data/placement/region)"
_print_var "LHP_CLOUD_AVAILABILITY_ZONE" "$(curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone)"
_print_var "LHP_CLOUD_LOCAL_HOSTNAME" "$(curl -s http://169.254.169.254/latest/meta-data/local-hostname)"
_print_var "LHP_CLOUD_LOCAL_ADDRESS" "$(curl -s http://169.254.169.254/latest/meta-data/local-ipv4)"
_print_var "LHP_CLOUD_PUBLIC_HOSTNAME" "$(curl -s http://169.254.169.254/latest/meta-data/public-hostname)"
_print_var "LHP_CLOUD_PUBLIC_ADDRESS" "$(curl -s http://169.254.169.254/latest/meta-data/public-ipv4)"
_print_var "HOSTPATROL_CLOUD_NAME" "AWS"
_print_var "HOSTPATROL_CLOUD_ID" "$(curl -s http://169.254.169.254/latest/meta-data/instance-id)"
_print_var "HOSTPATROL_CLOUD_TYPE" "$(curl -s http://169.254.169.254/latest/meta-data/instance-type)"
_print_var "HOSTPATROL_CLOUD_REGION" "$(curl -s http://169.254.169.254/latest/meta-data/placement/region)"
_print_var "HOSTPATROL_CLOUD_AVAILABILITY_ZONE" "$(curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone)"
_print_var "HOSTPATROL_CLOUD_LOCAL_HOSTNAME" "$(curl -s http://169.254.169.254/latest/meta-data/local-hostname)"
_print_var "HOSTPATROL_CLOUD_LOCAL_ADDRESS" "$(curl -s http://169.254.169.254/latest/meta-data/local-ipv4)"
_print_var "HOSTPATROL_CLOUD_PUBLIC_HOSTNAME" "$(curl -s http://169.254.169.254/latest/meta-data/public-hostname)"
_print_var "HOSTPATROL_CLOUD_PUBLIC_ADDRESS" "$(curl -s http://169.254.169.254/latest/meta-data/public-ipv4)"
elif curl --silent --fail --max-time 2 http://169.254.169.254/metadata/v1/ >/dev/null; then
_print_var "LHP_CLOUD_NAME" "DO"
_print_var "LHP_CLOUD_ID" "$(curl -s http://169.254.169.254/metadata/v1/id)"
_print_var "LHP_CLOUD_REGION" "$(curl -s http://169.254.169.254/metadata/v1/region)"
_print_var "LHP_CLOUD_LOCAL_ADDRESS" "$(curl -s http://169.254.169.254/metadata/v1/interfaces/private/0/ipv4/address)"
_print_var "LHP_CLOUD_PUBLIC_ADDRESS" "$(curl -s http://169.254.169.254/metadata/v1/interfaces/public/0/ipv4/address)"
_print_var "LHP_CLOUD_RESERVED_ADDRESS" "$(curl -s http://169.254.169.254/metadata/v1/reserved_ip/ipv4/ip_address)"
_print_var "HOSTPATROL_CLOUD_NAME" "DO"
_print_var "HOSTPATROL_CLOUD_ID" "$(curl -s http://169.254.169.254/metadata/v1/id)"
_print_var "HOSTPATROL_CLOUD_REGION" "$(curl -s http://169.254.169.254/metadata/v1/region)"
_print_var "HOSTPATROL_CLOUD_LOCAL_ADDRESS" "$(curl -s http://169.254.169.254/metadata/v1/interfaces/private/0/ipv4/address)"
_print_var "HOSTPATROL_CLOUD_PUBLIC_ADDRESS" "$(curl -s http://169.254.169.254/metadata/v1/interfaces/public/0/ipv4/address)"
_print_var "HOSTPATROL_CLOUD_RESERVED_ADDRESS" "$(curl -s http://169.254.169.254/metadata/v1/reserved_ip/ipv4/ip_address)"
elif curl --silent --fail --max-time 2 http://169.254.169.254/latest/meta-data/network-config >/dev/null; then
_print_var "LHP_CLOUD_NAME" "HETZNER"
_print_var "LHP_CLOUD_ID" "$(curl -s http://169.254.169.254/latest/meta-data/instance-id)"
_print_var "LHP_CLOUD_REGION" "$(curl -s http://169.254.169.254/latest/meta-data/region)"
_print_var "LHP_CLOUD_AVAILABILITY_ZONE" "$(curl -s http://169.254.169.254/latest/meta-data/availability-zone)"
_print_var "LHP_CLOUD_PUBLIC_ADDRESS" "$(curl -s http://169.254.169.254/latest/meta-data/public-ipv4)"
_print_var "HOSTPATROL_CLOUD_NAME" "HETZNER"
_print_var "HOSTPATROL_CLOUD_ID" "$(curl -s http://169.254.169.254/latest/meta-data/instance-id)"
_print_var "HOSTPATROL_CLOUD_REGION" "$(curl -s http://169.254.169.254/latest/meta-data/region)"
_print_var "HOSTPATROL_CLOUD_AVAILABILITY_ZONE" "$(curl -s http://169.254.169.254/latest/meta-data/availability-zone)"
_print_var "HOSTPATROL_CLOUD_PUBLIC_ADDRESS" "$(curl -s http://169.254.169.254/latest/meta-data/public-ipv4)"
else
_print_var "LHP_CLOUD_NAME" "UNKNOWN"
_print_var "HOSTPATROL_CLOUD_NAME" "UNKNOWN"
fi
Loading

0 comments on commit 58e96d7

Please sign in to comment.