I’m trying to put in my view information on a remote Linux pdv. Until then I can do it via SSH with phpseclib plugin.
However, as I have more than one, in my view I create a div to list information. If a pdv is offline
the current state is showing the error 110 timeout.
What I need is to handle this error and put into the field in div table as type "No Connection". Below is the code of the control and view
respectively:
Controller:
public function actionPDV($ip)
{
$ssh = Yii::app()->phpseclib->createSSH2($ip);
if (!$ssh->login('root', 'senha'))
{
exit('Falha no login');
}
else
{
$eth0= $ssh->exec("cat /root/direcao/dpdv/dpdv_client.conf | grep -n ^ | grep ^4: | cut -d: -f2");
$pdv = substr($eth0, 10, 3);
echo $pdv;
}
}
View:
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="language" content="en" />
<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/tabela.css" />
</head>
<body>
<div class="container">
<div class="barra_titulo">
<div class="coluna">PDV</div>
<div class="coluna">IP</div>
<div class="coluna">Gateway</div>
<div class="coluna">Status</div>
</div>
<!-- PDV 1 -->
<div class="linha">
<div class="coluna"><?php $this->actionPDV('10.0.0.105');?></div>
<div class="coluna"><?php $this->actionIP('10.0.0.105');?></div>
<div class="coluna"><?php $this->actionGateway('10.0.0.105');?></div>
<div class="coluna"><?php $this->actionStatus('10.0.0.105');?></div>
</div>
</div>
</body>
I appreciate the help.