Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/php
- <?php
- $host=$argv[1];
- $port="22";
- $username=$argv[2];
- $password=$argv[3];
- $dst=$argv[4];
- $repeat="1000";
- $ssh = ssh2_connect($host, $port);
- if(ssh2_auth_password ($ssh, $username, $password)){
- }
- $cmd = 'ping '.$dst . ' source ' . $host .' repeat 1000';
- $stream = ssh2_exec($ssh, $cmd);
- stream_set_blocking ($stream, true);
- $data = '';
- while($buffer = fread($stream, 4096)){
- $data .= $buffer;
- }
- fclose($stream);
- $result = substr($data,-46,-35);
- $caracteres = array(",", ".", "(" , "/1000)");
- $result = str_replace($caracteres, "", $result);
- $pacotes_perdidos=1000-$result;
- if ( $result != 1000){
- echo "WARNING - " . $pacotes_perdidos . " de 1000 .\n";
- exit(1);
- }else{
- echo "OK.\n";
- exit(0);
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement