Beispiel #1
0
 function handle_action_rdp($MAPCFG, $objId)
 {
     $host_name = $MAPCFG->getValue($objId, 'host_name');
     $domain = $MAPCFG->getValue($objId, 'domain');
     $username = $MAPCFG->getValue($objId, 'username');
     // Get the host address! erm ... looks a little complicated...
     global $_BACKEND;
     $backendIds = $MAPCFG->getValue($objId, 'backend_id');
     $OBJ = new NagVisHost($backendIds, $host_name);
     $OBJ->setConfiguration($MAPCFG->getMapObject($objId));
     $OBJ->queueState(GET_STATE, DONT_GET_SINGLE_MEMBER_STATES);
     $_BACKEND->execute();
     $OBJ->applyState();
     $host_address = $OBJ->getStateAttr(ADDRESS);
     // Now generate the .rdp file for the user which is then (hopefully) handled
     // correctly by the users browser.
     header('Content-Type: application/rdp; charset=utf-8');
     header('Content-Disposition: attachment; filename=' . $host_name . '.rdp');
     echo 'full address:s:' . $host_address . "\n";
     if ($domain) {
         echo 'domain:s:' . $domain . "\n";
     }
     if ($username) {
         echo 'username:s:' . $username . "\n";
     }
 }
Beispiel #2
0
 function handle_action_win_ssh($MAPCFG, $objId)
 {
     $host_name = $MAPCFG->getValue($objId, 'host_name');
     // Get the host address! erm ... looks a little complicated...
     global $_BACKEND;
     $backendIds = $MAPCFG->getValue($objId, 'backend_id');
     $OBJ = new NagVisHost($backendIds, $host_name);
     $OBJ->setConfiguration($MAPCFG->getMapObject($objId));
     $OBJ->queueState(GET_STATE, DONT_GET_SINGLE_MEMBER_STATES);
     $_BACKEND->execute();
     $OBJ->applyState();
     $host_address = $OBJ->getStateAttr(ADDRESS);
     // Now generate the .cmd file for the user which is then (hopefully) handled
     // correctly by the users browser.
     header('Content-Type: application/cmd; charset=utf-8');
     header('Content-Disposition: attachment; filename=' . $host_name . '.cmd');
     echo "@echo off\n";
     echo "REM # This file has been generated by NagVis.\n";
     echo "REM # \n";
     echo "REM # Simply execute the file to connect to the host via SSH. We assume\n";
     echo "REM # that you have putty installed and in your system path.\n";
     echo "putty -ssh " . $host_address . " 22\n";
 }
Beispiel #3
0
 private function createHostObject($backendId, $name, $state, $config, $service_states)
 {
     $OBJ = new NagVisHost($backendId, $name);
     $OBJ->setState($state);
     // The services have to know how they should handle hard/soft
     // states. This is a little dirty but the simplest way to do this
     // until the hard/soft state handling has moved from backend to the
     // object classes.
     $OBJ->setConfiguration($config);
     // Put state counts to the object
     if ($service_states !== null) {
         $OBJ->addStateCounts($service_states);
     }
     // Fetch summary state and output
     $OBJ->fetchSummariesFromCounts();
     return $OBJ;
 }