generated from vst/haskell-template-hebele
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30 from vst/22-report-systemd-services-and-timers
Report Systemd Services and Timers
- Loading branch information
Showing
6 changed files
with
87 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ import qualified Data.List as List | |
import Data.Maybe (fromMaybe) | ||
import qualified Data.Scientific as S | ||
import qualified Data.Text as T | ||
import Lhp.Types (Report (_reportSystemdServices)) | ||
import qualified Lhp.Types as Types | ||
import Text.Read (readEither) | ||
import qualified Zamazingo.Ssh as Z.Ssh | ||
|
@@ -42,6 +43,8 @@ compileReport [email protected] {..} = do | |
_reportDistribution <- _mkDistribution _hostName kvs | ||
_reportDockerContainers <- _fetchHostDockerContainers _hostName | ||
_reportSshAuthorizedKeys <- _fetchHostSshAuthorizedKeys _hostName | ||
_reportSystemdServices <- _fetchHostSystemdServices _hostName | ||
_reportSystemdTimers <- _fetchHostSystemdTimers _hostName | ||
pure Types.Report {..} | ||
|
||
|
||
|
@@ -113,11 +116,37 @@ _fetchHostSshAuthorizedKeys | |
=> Z.Ssh.Destination | ||
-> m [T.Text] | ||
_fetchHostSshAuthorizedKeys h = | ||
filter (not . T.null . T.strip) . T.lines . Z.Text.unsafeTextFromBL <$> prog | ||
filter (not . T.null) . fmap T.strip . T.lines . Z.Text.unsafeTextFromBL <$> prog | ||
where | ||
prog = _toSshError h (Z.Ssh.runScript h $(embedStringFile "src/scripts/ssh-keys.sh") ["bash"]) | ||
|
||
|
||
-- | Attempts to find and return all systemd services on the remote | ||
-- host. | ||
_fetchHostSystemdServices | ||
:: MonadIO m | ||
=> MonadError LhpError m | ||
=> Z.Ssh.Destination | ||
-> m [T.Text] | ||
_fetchHostSystemdServices h = | ||
filter (not . T.null) . fmap T.strip . T.lines . Z.Text.unsafeTextFromBL <$> prog | ||
where | ||
prog = _toSshError h (Z.Ssh.runScript h $(embedStringFile "src/scripts/systemd-services.sh") ["bash"]) | ||
|
||
|
||
-- | Attempts to find and return all systemd timers on the remote | ||
-- host. | ||
_fetchHostSystemdTimers | ||
:: MonadIO m | ||
=> MonadError LhpError m | ||
=> Z.Ssh.Destination | ||
-> m [T.Text] | ||
_fetchHostSystemdTimers h = | ||
filter (not . T.null) . fmap T.strip . T.lines . Z.Text.unsafeTextFromBL <$> prog | ||
where | ||
prog = _toSshError h (Z.Ssh.runScript h $(embedStringFile "src/scripts/systemd-timers.sh") ["bash"]) | ||
|
||
|
||
-- | Smart constructor for remote host cloud information. | ||
_mkCloud | ||
:: MonadError LhpError m | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/usr/bin/env sh | ||
|
||
############# | ||
# PROCEDURE # | ||
############# | ||
|
||
## Check if systemctl (therefore systemd) is available: | ||
if ! which "systemctl" >/dev/null; then | ||
exit 0 | ||
fi | ||
|
||
## List services: | ||
systemctl list-unit-files --state enabled --type service | | ||
tail -n +2 | head -n -2 | awk '{print $1}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/usr/bin/env sh | ||
|
||
############# | ||
# PROCEDURE # | ||
############# | ||
|
||
## Check if systemctl (therefore systemd) is available: | ||
if ! which "systemctl" >/dev/null; then | ||
exit 0 | ||
fi | ||
|
||
## List timers: | ||
systemctl list-unit-files --state enabled --type timer | | ||
tail -n +2 | head -n -2 | awk '{print $1}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters