X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=plugins%2Fadmin%2Fsystems%2Fclass_terminalInfo.inc;h=c51b7846fb5d29864952169debd246e815cf2175;hb=d59800c1cb10d2d61ac402e4e4e5253a19810a02;hp=e41f7295b4f57c3f90392807f025460c4804d726;hpb=84d2c065af9ce3f287fef380606a593a0cda5a81;p=gosa.git
diff --git a/plugins/admin/systems/class_terminalInfo.inc b/plugins/admin/systems/class_terminalInfo.inc
index e41f7295b..c51b7846f 100644
--- a/plugins/admin/systems/class_terminalInfo.inc
+++ b/plugins/admin/systems/class_terminalInfo.inc
@@ -1,4 +1,5 @@
is_account && $this->parent == NULL){
@@ -66,131 +68,148 @@ class terminfo extends plugin
return;
}
- /* Default entry? */
- if ($this->cn == "default"){
- $display= "
";
- $display.= _("This is a virtual terminal which has no properties to show here.");
- $display.= "
";
- } else {
- /* Get template object */
- $smarty= get_smarty();
- $display= "";
+ $smarty= get_smarty();
+ $display= "";
+ if(!is_callable("snmpget")){
+ print_red(_("There is no php snmp module installed, can't gather any informations."));
- $smarty->assign("staticAddress", "");
-
-
- /* Prevent undefined variable .... */
$smarty->assign("load", progressbar(0,100,15,true));
$smarty->assign("mem", progressbar(0,100,15,true));
$smarty->assign("swap", progressbar(0,100,15,true));
-
- /* Check if terminal is online */
- $query= "fping -q -r 1 -t 500 ".$this->cn;
- exec ($query, $dummy, $retval);
-
- if ($retval == 0){
- $smarty->assign("status", _("online"));
- $smarty->assign("active", "true");
-
- /* Fill data if we have snmp */
- $host= $this->cn;
- $community= 'goto';
-
- /* Get memory informations */
- $MemFree= @snmpget($host, $community, "UCD-SNMP-MIB::memory.memAvailReal.0");
- if ($MemFree != FALSE){
- $MemFree= preg_replace('/^.*[=:] ([0-9.]+)$/', '\\1', $MemFree);
- $MemTotal= @snmpget($host, $community, "UCD-SNMP-MIB::memory.memTotalReal.0");
- $MemTotal= preg_replace('/^.*[=:] ([0-9.]+)$/', '\\1', $MemTotal);
- if ($MemTotal != 0){
- $smarty->assign("mem",progressbar( (int)(($MemTotal - $MemFree)*100/$MemTotal),100,15,true));
- ;
+ foreach(array("uptime", "sshd", "X", "saned", "artsd", "cupsd","status","ghNetNic", "ghIdeDev", "ghScsiDev","FloppyDevice", "CdromDevice","active") as $val){
+ $smarty->assign("$val", ""._("unknown status")."");
+ }
+
+
+ $display ="";
+ }else
+ /* Default entry? */
+ if ($this->cn == "default"){
+ $display= "
";
+ $display.= _("This is a virtual terminal which has no properties to show here.");
+ $display.= "
";
+ } else {
+ /* Get template object */
+
+ $smarty->assign("staticAddress", "");
+
+
+ /* Prevent undefined variable .... */
+ $smarty->assign("load", progressbar(0,100,15,true));
+ $smarty->assign("mem", progressbar(0,100,15,true));
+ $smarty->assign("swap", progressbar(0,100,15,true));
+
+ /* Check if terminal is online */
+ $query= "fping -q -r 1 -t 500 ".$this->cn;
+ exec ($query, $dummy, $retval);
+
+ if ($retval == 0){
+ $smarty->assign("status", _("online"));
+ $smarty->assign("active", "true");
+
+ /* Fill data if we have snmp */
+ $host= $this->cn;
+ $community= 'goto';
+
+ /* Get memory informations */
+ if(is_callable("snmpget")){
+ $MemFree = false;
+ }else{
+ $MemFree= @snmpget($host, $community, "UCD-SNMP-MIB::memory.memAvailReal.0");
}
- $SwapFree= @snmpget($host, $community, "UCD-SNMP-MIB::memory.memAvailSwap.0");
- $SwapFree= preg_replace('/^.*[=:] ([0-9.]+)$/', '\\1', $SwapFree);
- $SwapTotal= @snmpget($host, $community, "UCD-SNMP-MIB::memory.memTotalSwap.0");
- $SwapTotal= preg_replace('/^.*[=:] ([0-9.]+)$/', '\\1', $SwapTotal);
- if ($SwapTotal != 0){
+ if ($MemFree != FALSE){
+ $MemFree= preg_replace('/^.*[=:] ([0-9.]+)$/', '\\1', $MemFree);
+ $MemTotal= @snmpget($host, $community, "UCD-SNMP-MIB::memory.memTotalReal.0");
+ $MemTotal= preg_replace('/^.*[=:] ([0-9.]+)$/', '\\1', $MemTotal);
+ if ($MemTotal != 0){
+ $smarty->assign("mem",progressbar( (int)(($MemTotal - $MemFree)*100/$MemTotal),100,15,true));
+ ;
+ }
+ $SwapFree= @snmpget($host, $community, "UCD-SNMP-MIB::memory.memAvailSwap.0");
+ $SwapFree= preg_replace('/^.*[=:] ([0-9.]+)$/', '\\1', $SwapFree);
+ $SwapTotal= @snmpget($host, $community, "UCD-SNMP-MIB::memory.memTotalSwap.0");
+ $SwapTotal= preg_replace('/^.*[=:] ([0-9.]+)$/', '\\1', $SwapTotal);
+ if ($SwapTotal != 0){
#$smarty->assign("swap", (int)(($SwapTotal - $SwapFree)*100/$SwapTotal));
- $smarty->assign("swap", progressbar(0,100,15,true));
- }
+ $smarty->assign("swap", progressbar(0,100,15,true));
+ }
- /* Get system uptime */
- $sysup= @snmpget($host, $community, "SNMPv2-MIB::sysUpTime.0");
- $smarty->assign("uptime", preg_replace('/^.* ([0-9:]+)\..*$/', '\\1', $sysup));
-
- /* Get system load */
- $sysload= @snmpget($host, $community, "UCD-SNMP-MIB::laLoad.2");
- $sysload= preg_replace('/^.*[=:] ([0-9.]+)$/', '\\1', $sysload);
-
- $smarty->assign("load", progressbar($sysload*100,100,15,true));
-
- /* Get status for key processes */
- $processes= @snmpwalk($host, $community, "UCD-SNMP-MIB::prNames");
- $check4= array("sshd", "cupsd", "artsd", "X", "saned");
- foreach ($check4 as $pname){
- $eflag= -1;
- foreach ($processes as $key => $val){
- $process= preg_replace('/^.*[:=] (.*)$/', '\\1', $val);
- if ($process == $pname){
- $index= preg_replace('/^.*\.([0-9]+) [:=] .*$/', '\\1', $val);
- $res= @snmpget($host, $community, "UCD-SNMP-MIB::prErrorFlag.$index");
- $eflag= preg_replace('/^.*[:=] /', '', $res);
- break;
+ /* Get system uptime */
+ $sysup= @snmpget($host, $community, "SNMPv2-MIB::sysUpTime.0");
+ $smarty->assign("uptime", preg_replace('/^.* ([0-9:]+)\..*$/', '\\1', $sysup));
+
+ /* Get system load */
+ $sysload= @snmpget($host, $community, "UCD-SNMP-MIB::laLoad.2");
+ $sysload= preg_replace('/^.*[=:] ([0-9.]+)$/', '\\1', $sysload);
+
+ $smarty->assign("load", progressbar($sysload*100,100,15,true));
+
+ /* Get status for key processes */
+ $processes= @snmpwalk($host, $community, "UCD-SNMP-MIB::prNames");
+ $check4= array("sshd", "cupsd", "artsd", "X", "saned");
+ foreach ($check4 as $pname){
+ $eflag= -1;
+ foreach ($processes as $key => $val){
+ $process= preg_replace('/^.*[:=] (.*)$/', '\\1', $val);
+ if ($process == $pname){
+ $index= preg_replace('/^.*\.([0-9]+) [:=] .*$/', '\\1', $val);
+ $res= @snmpget($host, $community, "UCD-SNMP-MIB::prErrorFlag.$index");
+ $eflag= preg_replace('/^.*[:=] /', '', $res);
+ break;
+ }
+ }
+ switch ($eflag){
+ case 0:
+ $smarty->assign("$pname", "
");
+ break;
+ case 1:
+ $smarty->assign("$pname", "
");
+ break;
+ default:
+ $smarty->assign("$pname", _("not defined"));
}
}
- switch ($eflag){
- case 0:
- $smarty->assign("$pname", "
");
- break;
- case 1:
- $smarty->assign("$pname", "
");
- break;
- default:
- $smarty->assign("$pname", _("not defined"));
+ } else {
+ foreach(array("uptime", "sshd", "X", "saned", "artsd", "cupsd") as $val){
+ $smarty->assign("$val", ""._("unknown status")."");
}
}
- } else {
- foreach(array("uptime", "sshd", "X", "saned", "artsd", "cupsd") as $val){
- $smarty->assign("$val", ""._("unknown status")."");
+ /* Check for mounted partitions (show max 8 partitions) */
+ $partitions= "";
+ for ($n= 1; $n<9; $n++){
+ $device= @snmpget($host, $community, "UCD-SNMP-MIB::dskDevice.$n");
+ if ($device == ""){
+ break;
+ }
+ $device= preg_replace('/^STRING: */', '', $device);
+ $usage= @snmpget($host, $community, "UCD-SNMP-MIB::dskPercent.$n");
+ $usage= preg_replace('/^INTEGER: */', '', $usage);
+ $partitions.= "$device | ".progressbar($usage,100,16,true)." |
\n";
}
+ $smarty->assign("partitions", $partitions);
+ } else {
+ $smarty->assign("status", _("offline"));
+ $smarty->assign("active", "false");
}
- /* Check for mounted partitions (show max 8 partitions) */
- $partitions= "";
- for ($n= 1; $n<9; $n++){
- $device= @snmpget($host, $community, "UCD-SNMP-MIB::dskDevice.$n");
- if ($device == ""){
- break;
+ /* Set floppy and cdrom status */
+ foreach(array("Floppy", "Cdrom") as $val){
+ $name= "goto".$val."Enable";
+ if ($this->$name == "YES"){
+ $status= _("present");
+ } else {
+ $status= "-";
}
- $device= preg_replace('/^STRING: */', '', $device);
- $usage= @snmpget($host, $community, "UCD-SNMP-MIB::dskPercent.$n");
- $usage= preg_replace('/^INTEGER: */', '', $usage);
- $partitions.= "$device | ".progressbar($usage,100,16,true)." |
\n";
+ $smarty->assign($val."Device", $status);
}
- $smarty->assign("partitions", $partitions);
- } else {
- $smarty->assign("status", _("offline"));
- $smarty->assign("active", "false");
- }
- /* Set floppy and cdrom status */
- foreach(array("Floppy", "Cdrom") as $val){
- $name= "goto".$val."Enable";
- if ($this->$name == "YES"){
- $status= _("present");
- } else {
- $status= "-";
+ /* Show main page */
+ foreach(array("ghNetNic", "ghIdeDev", "ghScsiDev") as $val){
+ if (!count($this->$val)){
+ $this->$val= "-";
+ }
+ $smarty->assign($val, $this->$val);
}
- $smarty->assign($val."Device", $status);
- }
-
- /* Show main page */
- foreach(array("ghNetNic", "ghIdeDev", "ghScsiDev") as $val){
- if (!count($this->$val)){
- $this->$val= "-";
- }
- $smarty->assign($val, $this->$val);
}
foreach(array("ghCpuType", "ghMemSize", "macAddress", "ghUsbSupport",
"ghGfxAdapter", "ghSoundAdapter", "gotoLastUser", "ghInventoryNumber") as $val){
@@ -198,16 +217,12 @@ class terminfo extends plugin
$smarty->assign($val, $this->$val);
}
$display= $smarty->fetch (get_template_path('info.tpl', TRUE));
- }
return ($display);
}
function remove_from_parent()
{
- $ldap= $this->config->get_ldap_link();
- $ldap->rmdir($this->dn);
- show_ldap_error($ldap->get_error());
}
@@ -218,7 +233,6 @@ class terminfo extends plugin
}
-
/* Save to LDAP */
function save()
{