linux - how to ssh run a tail and then send data to a mysql database -
this code ssh's , runs tail command on remote hots. pass tailed data mysql database using local script called insertperfmon.sh.
how pass data generated in ssh session local shell script insertperfmon.sh. local shell script going send data database. however, need there first.
( ssh -nq -o stricthostkeychecking=no \ -i $pem_path/$pem_file $user@${host} -p $remote_port \ tail -n 5 $remote_home/data/perfmon* |insertperfmon.sh)
if insertperfmon.sh
is:
#!/bin/bash mydata=$(cat) echo $mydata # process & send $mydata database
the following should work:
<your_ssh_command> | bash insertperfmon.sh
Comments
Post a Comment