sending data to telegraf from windows git bash - telegraf

How exactly can I send data to telegraf from windows command prompt / git bash?
I'm trying to send data in unix bash to telegraf.
In bash I do:
echo -e "my_db,owner=me,field=value" | nc -u4 -w1 my.telefra.host.com 1231;

You can use telegraf exec input plugin.
It allows you to execute any sort of command, including powershell, cmd, git bash etc. For instance, if I want to run powershell command,
commands = ["powershell -command <command>"]
Same can be done for git bash,
commands = ["<path>\bash.exe <command>"]

Related

Start tcsh in a specific directory

Does tcsh support launching itself in a remote directory via an argument?
The setup I am dealing with does not allow me to chdir to the remote directory before invoking tcsh, and I'd like to avoid having to create a .sh file for this workflow.
Here are the available arguments I see for v6.19:
> tcsh --help
tcsh 6.19.00 (Astron) 2015-05-21 (x86_64-unknown-Linux) options wide,nls,dl,al,kan,rh,color,filec
-b file batch mode, read and execute commands from 'file'
-c command run 'command' from next argument
-d load directory stack from '~/.cshdirs'
-Dname[=value] define environment variable `name' to `value' (DomainOS only)
-e exit on any error
-f start faster by ignoring the start-up file
-F use fork() instead of vfork() when spawning (ConvexOS only)
-i interactive, even when input is not from a terminal
-l act as a login shell, must be the only option specified
-m load the start-up file, whether or not owned by effective user
-n file no execute mode, just check syntax of the following `file'
-q accept SIGQUIT for running under a debugger
-s read commands from standard input
-t read one line from standard input
-v echo commands after history substitution
-V like -v but including commands read from the start-up file
-x echo commands immediately before execution
-X like -x but including commands read from the start-up file
--help print this message and exit
--version print the version shell variable and exit
This works, but is suboptimal because it launches two instances of tcsh:
tcsh -c 'cd /tmp && tcsh'

how to execute oozie shell action with script having curl command

Apologies, as i have not tried this earlier.
Hi,
I need to create oozie workflow that exeuctes a shell script. The shell script has curl command which downloads a specific file from client's repo.
As commands in shell scripts are only able to recognize hdfs directories, how could i execute the script.?
Lets say below is the Sample code:
curl -o ~/test.jar http://central.maven.org/maven2/commons-lang/commons-lang/2.6/commons-lang-2.6.jar
hdfs dfs -copyFromLocal ~/test.jar /user/sr/test2
How can i execute the script with above two commands using oozie.?
I found the answer...
data=curl http://central.maven.org/maven2/commons-lang/commons-lang/2.6/commons-lang-2.6.csv
echo "$data" | hdfs dfs -appendToFile - /path/to/hdfs/directory/PPP.csv

Use remote server env variable in ksh via an SSH command

I can't find any answer to this "easy looking" problem.
I would like to execute an ssh command using a ksh shell or script which use an env variable of the SERVER.
Example:
ssh user#server "ls $DIR"
Where $DIR is an env variable define on the server (in this case: a directory path) and not the $DIR define on my client env.
In worst case scenario I can use something like env | grep DIR | cut -d "=" -f 2
to get the var but it looks weird.
Thanks for any help.
ssh user#server "ls $DIR"
Double-quoted strings undergo variable interpolation. So "$DIR" is being replaced on the local system, then the shell invokes the ssh command with the resulting string.
To pass the literal command through to the remote system, use single quotes:
ssh user#server 'ls $DIR'
The SSH command execution shell is a non-interactive shell, whereas your normal shell is either a login shell or an interactive shell.
In fact not all environment varialbles are available in non-interactive shell, you need to check ksh manual to figure out the configuration files that ksh reads when running in non-interactive mode, in case of bash those are roughly following
/etc/profile
~/.bash_profile
~/.bash_login
~/.profile
Just find out the corresponding ones for ksh and move/copy your DIR environment variable definition to there on sever side.

How to use BroadcasetIntent() function in Monkeyrunner

Can anyone let me know how to use device.broadcastIntent function for the create contact using python script
device.broadcastIntent('android.intent.action.INSERT',
'vnd.android.cursor.dir/contact', {'name':'user1501488', 'phone':'123-15489'})
For shell command try this
device.shell("am start -a android.intent.action.INSERT
-t vnd.android.cursor.dir/contact -e name 'user1501488' -e phone 123-15489")

Problem with plink output

I'm using plink to run a command on a Unix remote machine.
The command is:
ls -1trd testegrep.txt |tail -1 |xargs tail -f| grep 's';
The way I'm sending this command is by using a file with a set of commands like:
plink.exe -ssh -t -l user -pw pwd tst.url.pt -m commands.out
When I run the command this way the plink does not receive any input. It seems that is waiting for input.
But if I run:
plink.exe -ssh -t -l user -pw pwd tst.url.pt "ls -1trd testegrep.txt |tail -1 |xargs tail -f| grep 's';"
I get the expected result.
I'm not using the plink with a file with the command because I choose so. I'm using a test automation software that allows me to run tests on remote hosts and this is the way the tool works.
Any thoughts on what is going wrong?
I tested the command you provided and it worked without problems.
Maybe the problem is related to:
The server's host key is not cached in the registry.
The path to the file is not correct.
The file is empty.
include server hostkey
most importantly, you need to include the unix profile using the -m paramater
You can include all your commands in the same file where the profile is kept also.
$Output = ((plink.exe -hostkey hostkey -l UNAME -i SSHKEY -P 22 -ssh server -batch -m PROFILE) | ? {$_ -ne ""})

Resources