部分的な目標は、一定範囲のホストに定期的に接続し、一部のログを中央サーバーに再同期することであり、手動で呼び出すと問題なく動作します。
python ./apex2zabbix.py --sync="Client_Service_Platform Emtity"
ただし、cron を介して呼び出されると、リモート rsync ステップで .EOF で終了します。
command = "/usr/bin/rsync -e ssh -a %s --compress=9 -pgtov %s %s --exclude='*' %s@%s:%s%s %s" % (remote_rsync_binary, excluded_expression, filters_expression, user, ip, source_path, file_filter, target_path)
p = pexpect.spawn(command, timeout=360)
i = p.expect([ssh_new_conn,'[pP]assword:',pexpect.EOF])
print 'Initial pexpect command output: ', i
if i == 0:
# send 'yes'
p.sendline('yes')
i = p.expect(['[pP]assword:',pexpect.EOF])
if i == 0:
# send the password
p.sendline(passwd)
p.expect(pexpect.EOF)
elif i == 1:
# send the password
p.sendline(passwd)
p.expect(pexpect.EOF)
elif i == 2:
print "key or connection timeout"
pass
戻る
Initial pexpect command output: 2
何が原因でしょうか?ありがとう