diff --git a/README.md b/README.md index 015aeed..a8291a5 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,16 @@ Local LQL Client Requires a local lql unix socket. +Examples: + +- Fetch first row from the hosts table: + + $ lql-api localclient mysite -t hosts -c name -c address -c groups -l 1 + +- The same with stdin: + + $ echo -e "GET hosts\nColumns: name address groups\nLimit: 1" | lql-api localclient mysite + Usage: lql-api localclient [site] [flags] @@ -49,6 +59,8 @@ Flags: -s, --socket string Socket (default "/opt/omd/sites/{site}/tmp/run/live") ``` +See the Installing docs for it. + ### sshclient: SSH LQL Client ``` @@ -59,6 +71,16 @@ This version connects to the Check_MK Server by SSH. If you don't provide ssh-keyfile and ssh-password it will use your local agent. +Examples: + +- Fetch first row from the hosts table: + + $ lql-api sshclient mysite myinternal.host.name -U mysite -t hosts -c name -c address -c groups -l 1 + +- The same with stdin: + + $ echo -e "GET hosts\nColumns: name address groups\nLimit: 1" | lql-api sshclient mysite myinternal.host.name -U mysite + Usage: lql-api sshclient [site] [server] [flags] @@ -86,6 +108,16 @@ This version connects to the Check_MK Server by SSH. If you don't provide ssh-keyfile and ssh-password it will use your local agent. +Examples: + +- With Debug and a single connection: + + $ lql-api sshserver mysite myinternal.host.name -d -m 1 -x 1 -U mysite + +- Without Debug and maximum 5 connections: + + $ lql-api sshserver mysite myinternal.host.name -m 1 -x 5 -U mysite + Usage: lql-api sshserver [site] [server] [flags] diff --git a/cmd/localclient.go b/cmd/localclient.go index 3d1f05b..423224b 100644 --- a/cmd/localclient.go +++ b/cmd/localclient.go @@ -33,7 +33,19 @@ var localClientCmd = &cobra.Command{ Short: "Local LQL Client", Long: `Local LQL Client -Requires a local lql unix socket.`, +Requires a local lql unix socket. + +Examples: + +- Fetch first row from the hosts table: + + $ lql-api localclient mysite -t hosts -c name -c address -c groups -l 1 + +- The same with stdin: + + $ echo -e "GET hosts\nColumns: name address groups\nLimit: 1" | lql-api localclient mysite + +`, Args: cobra.ExactArgs(1), Run: func(cmd *cobra.Command, args []string) { sReplacer := strings.NewReplacer("{site}", args[0]) diff --git a/cmd/sshclient.go b/cmd/sshclient.go index 7506416..369b3f6 100644 --- a/cmd/sshclient.go +++ b/cmd/sshclient.go @@ -45,10 +45,21 @@ var sshClientCmd = &cobra.Command{ This version connects to the Check_MK Server by SSH. If you don't provide ssh-keyfile and ssh-password it will use your local agent. - `, + +Examples: + +- Fetch first row from the hosts table: + + $ lql-api sshclient mysite myinternal.host.name -U mysite -t hosts -c name -c address -c groups -l 1 + +- The same with stdin: + + $ echo -e "GET hosts\nColumns: name address groups\nLimit: 1" | lql-api sshclient mysite myinternal.host.name -U mysite + +`, Args: cobra.ExactArgs(2), Run: func(cmd *cobra.Command, args []string) { - sReplacer := strings.NewReplacer("{site}", args[1]) + sReplacer := strings.NewReplacer("{site}", args[0]) destSocket := sReplacer.Replace(cmd.Flag("socket").Value.String()) localSocket := sReplacer.Replace(path.Join(os.TempDir(), "lql-{site}-client.sock")) var tunnel *myssh.Tunnel diff --git a/cmd/sshserver.go b/cmd/sshserver.go index fdfc76a..8e16aec 100644 --- a/cmd/sshserver.go +++ b/cmd/sshserver.go @@ -43,7 +43,17 @@ var sshServerCmd = &cobra.Command{ This version connects to the Check_MK Server by SSH. If you don't provide ssh-keyfile and ssh-password it will use your local agent. - `, + +Examples: + +- With Debug and a single connection: + + $ lql-api sshserver mysite myinternal.host.name -d -m 1 -x 1 -U mysite + +- Without Debug and maximum 5 connections: + + $ lql-api sshserver mysite myinternal.host.name -m 1 -x 5 -U mysite +`, Args: cobra.ExactArgs(2), Run: func(cmd *cobra.Command, args []string) {