Skip to content

Commit

Permalink
re-enable goto plugin without gosa-si dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
bzapiec committed Feb 28, 2018
1 parent cd31adf commit e7f4515
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 363 deletions.
7 changes: 2 additions & 5 deletions addons/goto/class_filterGotoEvents.inc
Expand Up @@ -4,7 +4,7 @@ class filterGotoEvents extends filterLDAP {
{
global $config;

$o_queue = new gosaSupportDaemon(TRUE,5);
$o_queue = NULL;
$events = DaemonEvent::get_event_types( SYSTEM_EVENT);

/* Get tags that will be used in queue searches */
Expand All @@ -13,10 +13,7 @@ class filterGotoEvents extends filterLDAP {
$event_tags[] = $evt['s_Queued_Action'];
}

$entries = $o_queue->get_queued_entries($event_tags,0,9999999,"id");
if ($o_queue->is_error()){
msg_dialog::display(_("Error"), sprintf(_("Cannot load queue entries: %s"), "<br><br>".$o_queue->get_error()), ERROR_DIALOG);
}
$entries = array();

/* Assign entries by id.
*/
Expand Down
40 changes: 2 additions & 38 deletions addons/goto/class_gotoLogView.inc
Expand Up @@ -8,7 +8,7 @@ class gotoLogView extends plugin
var $parent;
var $config;

var $o_queue;
var $o_queue = NULL;

var $selected_date;
var $selected_date_str;
Expand All @@ -33,10 +33,6 @@ class gotoLogView extends plugin

$this->initTime = microtime(TRUE);

/* Try to fetch logs for the given event (mac)
*/
$this->o_queue = new gosaSupportDaemon();

/* Load ldap object if given
and use this macAddress.
*/
Expand All @@ -55,34 +51,6 @@ class gotoLogView extends plugin
$this->standalone = FALSE;
}

/* Query for log files
*/
$res = $this->o_queue->get_log_info_for_mac($this->mac);
if($this->o_queue->is_configured() && $this->o_queue->is_error()){
msg_dialog::display(_("Error"), $this->o_queue->get_error(), ERROR_DIALOG);
}else{
$tmp = array();
foreach($res as $mac => $logs){
if($mac != $this->mac) continue;

foreach($logs as $name => $log){
if(isset($log['FILES'])){
foreach($log['FILES'] as $fkey => $fval){
$tmp[] = array(
'MAC' => $mac,
'DATE' => $log['REAL_DATE'],
'DATE_STR'=> $log['DATE_STR'],
'FILE' => $fval);
}
}
}
}

/* Check if there is at least one log file
*/
$this->logs = $tmp;
}

// Create the filter list
$this->logSelector= new sortableListing($this->logs, $this->convertFilterList($this->logs));
$this->logSelector->setDeleteable(false);
Expand Down Expand Up @@ -152,11 +120,7 @@ class gotoLogView extends plugin

function get_log($mac,$date,$file)
{
$res = $this->o_queue->get_log_file($mac,$date,$file);
if($this->o_queue->is_configured() && $this->o_queue->is_error()){
msg_dialog::display(_("Error"), $this->o_queue->get_error(), ERROR_DIALOG);
}
$res = nl2br(htmlentities($res));
$res = nl2br(htmlentities(""));
return($res);
}

Expand Down
59 changes: 6 additions & 53 deletions addons/goto/class_gotomasses.inc
Expand Up @@ -39,11 +39,12 @@ class gotomasses extends management
var $acl_base;
var $acl_category;

var $o_queue = NULL;

function __construct(&$config, $ui)
{
/* Include config object */
$this->config= &$config;
$this->o_queue = new gosaSupportDaemon(TRUE,5);
$this->events = DaemonEvent::get_event_types( SYSTEM_EVENT);
$this->acl_base = $config->current['BASE'];
$this->acl_category = "gotomasses/";
Expand Down Expand Up @@ -275,23 +276,6 @@ class gotomasses extends management
{
if($this->acl_is_removeable("")){
timezone::get_default_timezone();
foreach($this->ids_to_remove as $id){
$entry = $this->o_queue->get_entries_by_id(array($id));
if(isset($entry['ANSWER1'])){
$entry = $entry['ANSWER1'];
if( $entry['STATUS'] == "waiting" &&
$entry['HEADERTAG'] == "trigger_action_reinstall"){
$evt = new DaemonEvent_reinstall($this->config,$entry);
if($evt->get_timestamp(FALSE) < time()){
$r_evt = new DaemonEvent_localboot($this->config);
$r_evt->add_targets(array($entry['MACADDRESS']));
$r_evt->set_type(TRIGGERED_EVENT);
$this->o_queue->append($r_evt);
}
}
}
}
$this->o_queue->remove_entries($this->ids_to_remove);
$this->save();
}
}
Expand Down Expand Up @@ -322,10 +306,6 @@ class gotomasses extends management
$tmp->add_targets($update_ids);
$tmp->set_type(TRIGGERED_EVENT);
$this->recently_removed = $update_ids;
if(!$this->o_queue->append($tmp)){
msg_dialog::display(_("Error"), sprintf(_("Cannot update queue entry: %s"),$id) , ERROR_DIALOG);
return(FALSE);
}
}else{
msg_dialog::display(_("Error"),
sprintf(_("Required class '%s' cannot be found: job not aborted!"),
Expand Down Expand Up @@ -379,11 +359,7 @@ class gotomasses extends management
{
if(is_object($this->dialogObject)){
$this->dialogObject->save_object();
if(!$this->o_queue->append($this->dialogObject)){
msg_dialog::display(_("Service infrastructure"),msgPool::siError($this->o_queue->get_error()),ERROR_DIALOG);
}else{
$this->current = -1;
}
$this->current = -1;
}
$this->closeDialogs();
}
Expand Down Expand Up @@ -425,9 +401,9 @@ class gotomasses extends management
}

if($type == "up" && $next != 0){
return($this->o_queue->update_entries(array($id),array("timestamp" => $next)));
return TRUE;
}elseif($type == "down" && $last != 0){
return($this->o_queue->update_entries(array($id),array("timestamp" => $last)));
return TRUE;
}
}

Expand Down Expand Up @@ -473,14 +449,6 @@ class gotomasses extends management
}
}

/* Tell the daemon that we have entries to update.
*/
if(count($update_ids)){
if(!$this->o_queue->update_entries($update_ids,$data)){
msg_dialog::display(_("Error"), sprintf(_("Cannot update queue entry: %s"),$id) , ERROR_DIALOG);
return(FALSE);
}
}
return(TRUE);
}

Expand Down Expand Up @@ -508,14 +476,6 @@ class gotomasses extends management
}
}

/* Tell the daemon that we want to update some entries
*/
if(count($update_ids)){
if(!$this->o_queue->update_entries($update_ids,$data)){
msg_dialog::display(_("Error"), sprintf(_("Cannot update queue entries.")) , ERROR_DIALOG);
return(FALSE);
}
}
return(TRUE);
}

Expand Down Expand Up @@ -544,14 +504,7 @@ class gotomasses extends management
}
}

/* Tell the daemon that we want to update some entries
*/
if(count($update_ids)){
if(!$this->o_queue->update_entries($update_ids,$data)){
msg_dialog::display(_("Error"), sprintf(_("Cannot update queue entry: %s"),$id) , ERROR_DIALOG);
return(FALSE);
}
}

return(TRUE);
}

Expand Down
4 changes: 0 additions & 4 deletions admin/ogroups/goto/class_termgroup.inc
Expand Up @@ -199,10 +199,6 @@ class termgroup extends plugin
$tmp = new $evt['CLASS_NAME']($this->config);
$tmp->add_targets($macaddresses);
$tmp->set_type(TRIGGERED_EVENT);
$o_queue = new gosaSupportDaemon();
if(!$o_queue->append($tmp)){
msg_dialog::display(_("Service infrastructure"),msgPool::siError($o_queue->get_error()),ERROR_DIALOG);
}
}
} else {
msg_dialog::display(_("Event error"),
Expand Down
23 changes: 2 additions & 21 deletions admin/systems/goto/class_terminalGeneric.inc
Expand Up @@ -191,10 +191,6 @@ class termgeneric extends plugin
$tmp = new $evt['CLASS_NAME']($this->config);
$tmp->add_targets(array($this->netConfigDNS->macAddress));
$tmp->set_type(TRIGGERED_EVENT);
$o_queue = new gosaSupportDaemon();
if(!$o_queue->append($tmp)){
msg_dialog::display(_("Service infrastructure"),msgPool::siError($o_queue->get_error()),ERROR_DIALOG);
}
}
}else{
msg_dialog::display(_("Event error"),
Expand Down Expand Up @@ -242,11 +238,7 @@ class termgeneric extends plugin
$smarty->assign("inheritTimeServer",$this->inheritTimeServer);

/* Check if terminal is online */
if (gosaSupportDaemon::ping($this->netConfigDNS->macAddress)){
$smarty->assign("actions", set_post(array("halt" => _("Switch off"),"reboot" => _("Reboot"))));
} else {
$smarty->assign("actions", set_post(array("wake" => _("Wake up"))));
}
$smarty->assign("actions", set_post(array("wake" => _("Wake up"))));

/* Arrays */
$smarty->assign("modes", set_post($this->modes));
Expand Down Expand Up @@ -288,8 +280,7 @@ class termgeneric extends plugin
$smarty->assign("ntpservers", set_post($tmp));
$smarty->assign("fai_activated",$this->fai_activated);

$si_url = $this->config->get_cfg_value("core","gosaSupportURI");
$smarty->assign("si_activated",!empty($si_url));
$smarty->assign("si_activated",FALSE);

/* Variables */
foreach(array("gotoMode", "gotoTerminalPath", "gotoSwapServer","gotoSyslogServer", "gotoNtpServer") as $val){
Expand Down Expand Up @@ -352,12 +343,6 @@ class termgeneric extends plugin
update_accessTo($this->cn,"");
}

/* Clean queue form entries with this mac
*/
if(class_available("gosaSupportDaemon") && tests::is_mac($this->netConfigDNS->orig_macAddress)){
$q = new gosaSupportDaemon();
$q->clean_queue_from_mac($this->netConfigDNS->orig_macAddress);
}
}
}

Expand Down Expand Up @@ -615,15 +600,11 @@ another location! */
*/
if ($activate && class_available("DaemonEvent")){
$events = DaemonEvent::get_event_types(SYSTEM_EVENT | HIDDEN_EVENT);
$o_queue = new gosaSupportDaemon();
if(isset($events['TRIGGERED']['DaemonEvent_installation_activation'])){
$evt = $events['TRIGGERED']['DaemonEvent_installation_activation'];
$tmp = new $evt['CLASS_NAME']($this->config);
$tmp->set_type(TRIGGERED_EVENT);
$tmp->add_targets(array($this->netConfigDNS->macAddress));
if(!$o_queue->append($tmp)){
msg_dialog::display(_("Service infrastructure"),msgPool::siError($o_queue->get_error()),ERROR_DIALOG);
}
}
}
}
Expand Down
98 changes: 3 additions & 95 deletions admin/systems/goto/class_terminalInfo.inc
Expand Up @@ -99,101 +99,9 @@ class terminfo extends plugin
$smarty->assign("mem", progressbar(0,100,15,true));
$smarty->assign("swap", progressbar(0,100,15,true));

/* Check if terminal is online */
if (gosaSupportDaemon::ping($this->macAddress)){
$smarty->assign("status", _("on-line"));
$smarty->assign("active", "true");

/* Fill data if we have snmp */
$host= $this->cn;

/* Use 'goto' as snmp community or the configured value from the config */
$community= 'goto';
$str= $this->config->get_cfg_value("terminfo", "snmpCommunity");
if(!empty($str)){
$community = $str;
}

/* Get memory informations */
if(!is_callable("snmpget")){
$MemFree = false;
}else{
$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));
;
}
$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));
}

/* 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", "<img alt=\""._("running")."\" src=\"images/true.png\">");
break;
case 1:
$smarty->assign("$pname", "<img alt=\""._("not running")."\" src=\"images/false.png\">");
break;
default:
$smarty->assign("$pname", _("not defined"));
}
}
} else {
foreach(array("uptime", "sshd", "X", "saned", "artsd", "cupsd") as $val){
$smarty->assign("$val", "<i>"._("unknown status")."</i>");
}
}
/* 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.= "<tr><td><b>$device</b></td><td>".progressbar($usage,100,16,true)."</td></tr>\n";
}
$smarty->assign("partitions", $partitions);
} else {
$smarty->assign("status", _("off-line"));
$smarty->assign("active", "false");
}
/* Check if terminal is online - due to lack of the daemon consider offline */
$smarty->assign("status", _("off-line"));
$smarty->assign("active", "false");

/* Set floppy and cdrom status */
foreach(array("Floppy", "Cdrom") as $val){
Expand Down

0 comments on commit e7f4515

Please sign in to comment.