コード例 #1
0
ファイル: Chipset.class.php プロジェクト: wAmpIre/netmon
 public function store()
 {
     //check if a chipset with the same name already exists
     $chipset_test = new Chipset(false, $this->getName());
     $chipset_test->fetch();
     if ($this->getChipsetId() != 0 and !($chipset_test->getChipsetId() != $this->getChipsetId() and $chipset_test->getName() == $this->getName())) {
         try {
             $stmt = DB::getInstance()->prepare("UPDATE chipsets SET\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tname = ?,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\thardware_name = ?,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tupdate_date = NOW()\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE id=?");
             $stmt->execute(array($this->getName(), $this->getHardwareName(), $this->getChipsetId()));
             return $stmt->rowCount();
         } catch (PDOException $e) {
             echo $e->getMessage();
             echo $e->getTraceAsString();
         }
     } elseif ($chipset_test->getChipsetId() == 0) {
         try {
             $stmt = DB::getInstance()->prepare("INSERT INTO chipsets (name, hardware_name, create_date, update_date)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tVALUES (?, ?, NOW(), NOW())");
             $stmt->execute(array($this->getName(), $this->getHardwareName()));
             $this->setChipsetId((int) DB::getInstance()->lastInsertId());
             return $this->getChipsetId();
         } catch (PDOException $e) {
             echo $e->getMessage();
             echo $e->getTraceAsString();
         }
     }
     return false;
 }
コード例 #2
0
ファイル: install.php プロジェクト: wAmpIre/netmon
        Config::writeConfigLine('mail_smtp_username', $_POST['mail_smtp_username']);
        Config::writeConfigLine('mail_smtp_password', $_POST['mail_smtp_password']);
        Config::writeConfigLine('mail_smtp_login_auth', $_POST['mail_smtp_login_auth']);
        Config::writeConfigLine('mail_smtp_ssl', $_POST['mail_smtp_ssl']);
        Config::writeConfigLine('twitter_consumer_key', "dRWT5eeIn9UiHJgcjgpPQ");
        Config::writeConfigLine('twitter_consumer_secret', "QxcnltPX2sTH8E7eZlxyZeqTIVoIoRjlrmUfkCzGSA");
        Config::writeConfigLine('enable_network_policy', 'false');
        Config::writeConfigLine('network_policy_url', 'http://picopeer.net/PPA-de.html');
        Config::writeConfigLine('template', "freifunk_oldenburg");
        Config::writeConfigLine('hours_to_keep_mysql_crawl_data', 5);
        Config::writeConfigLine('hours_to_keep_history_table', 72);
        Config::writeConfigLine('crawl_cycle_length_in_minutes', 10);
        Config::writeConfigLine('event_notification_router_offline_crawl_cycles', 6);
        Config::writeConfigLine('community_essid', 'deinestadt.freifunk.net');
        //create a default chipset
        $default_chipset = new Chipset(false, "", "Unbekannt");
        $default_chipset->store();
        //create an initial crawl cycle
        $crawl_cycle_id = Crawling::newCrawlCycle(10);
        //require_once(ROOT_DIR.'/cronjobs.php');
        header('Location: ./install.php?section=finish');
    }
} elseif ($_GET['section'] == "finish") {
    $config_path = "./config/config.local.inc.php";
    $file = Install::getFileLineByLine($config_path);
    $configs[0] = '$GLOBALS[\'installed\'] = true;';
    $file = Install::changeConfigSection('//INSTALLED', $file, $configs);
    Install::writeEmptyFileLineByLine($config_path, $file);
    $message[] = array('Netmon wurde erfolgreich installiert.', 1);
    $message[] = array('Die Installationsroutine wurde für weitere Zugriffe gesperrt.', 1);
    $message[] = array('Bitte registrieren Sie sich, der erste registrierte Benutzer bekommt automatisch volle Root-Rechte!', 1);
コード例 #3
0
ファイル: Router.class.php プロジェクト: wAmpIre/netmon
 public function setChipset($chipset)
 {
     if ($chipset instanceof Chipset) {
         $this->chipset = $chipset;
         return true;
     } else {
         $chipset = new Chipset($chipset);
         if ($chipset->fetch()) {
             $this->chipset = $chipset;
             return true;
         }
     }
     return false;
 }
コード例 #4
0
ファイル: RouterStatus.class.php プロジェクト: wAmpIre/netmon
 public function store()
 {
     if ($this->getStatusId() != 0 and $this->getCrawlCycleId() != 0 and $this->getRouterId() != 0 and $this->getStatus() != "") {
         echo "UPDATE NOT IMPLEMENTED NOW (and will possibly never be implemented because it is not needed...";
     } elseif ($this->getCrawlCycleId() != 0 and $this->getRouterId() != 0 and $this->getStatus() != "") {
         //check if there already exists an crawl item in this crawl cycle
         $tmp = new RouterStatus(false, $this->getCrawlCycleId(), $this->getRouterId());
         if (!$tmp->fetch()) {
             try {
                 $stmt = DB::getInstance()->prepare("INSERT INTO crawl_routers (router_id, crawl_cycle_id, crawl_date, status,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t   hostname, distname, distversion, chipset,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t   cpu, memory_total, memory_caching, memory_buffering,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t   memory_free, loadavg, processes, uptime, idletime,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t   local_time, batman_advanced_version, fastd_version,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t   kernel_version, configurator_version,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t   nodewatcher_version, firmware_version,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t   firmware_revision, openwrt_core_revision,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t   openwrt_feeds_packages_revision, client_count)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tVALUES (?, ?, NOW(), ?,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t?, ?, ?, ?,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t?, ?, ?, ?,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t?, ?, ?, ?, ?,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t?, ?, ?,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t?, ?,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t?, ?,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t?, ?,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t?, ?)");
                 $stmt->execute(array($this->getRouterId(), $this->getCrawlCycleId(), $this->getStatus(), $this->getHostname(), $this->getDistname(), $this->getDistversion(), $this->getChipset(), $this->getCpu(), $this->getMemoryTotal(), $this->getMemoryCaching(), $this->getMemoryBuffering(), $this->getMemoryFree(), $this->getLoadavg(), $this->getProcesses(), $this->getUptime(), $this->getIdletime(), $this->getLocaltime(), $this->getBatmanAdvancedVersion(), $this->getFastdVersion(), $this->getKernelVersion(), $this->getConfiguratorVersion(), $this->getNodewatcherVersion(), $this->getFirmwareVersion(), $this->getFirmwareRevision(), $this->getOpenwrtCoreRevision(), $this->getOpenwrtFeedsPackagesRevision(), $this->getClientCount()));
             } catch (PDOException $e) {
                 echo $e->getMessage();
                 echo $e->getTraceAsString();
             }
             //Update RRD-Files for graphs
             RrdTool::updateRouterMemoryHistory($this->getRouterId(), $this->getMemoryFree(), $this->getMemoryCaching(), $this->getMemoryBuffering());
             $processes = explode("/", $this->getProcesses());
             $processes[0] = isset($processes[0]) ? $processes[0] : 0;
             $processes[1] = isset($processes[1]) ? $processes[1] : 1;
             RrdTool::updateRouterProcessHistory($this->getRouterId(), $processes[0], $processes[1]);
             //create events
             $eventlist = new Eventlist();
             $router = new Router($this->getRouterId());
             $router->fetch();
             $last_router_status = new RouterStatus(false, (int) Crawling::getLastEndedCrawlCycle()['id'], $this->getRouterId());
             if ($last_router_status->fetch()) {
                 if ($this->getStatus() and $last_router_status->getStatus() and $this->getStatus() != $last_router_status->getStatus()) {
                     $eventlist->add(new Event(false, false, "router", $this->getRouterId(), "status", array('from' => $last_router_status->getStatus(), 'to' => $this->getStatus(), 'hostname' => $router->getHostname())));
                 }
                 if ($this->getUptime() and $last_router_status->getUptime() and $this->getUptime() < $last_router_status->getUptime()) {
                     $eventlist->add(new Event(false, false, "router", $this->getRouterId(), "reboot", array('hostname' => $router->getHostname())));
                 }
                 if ($this->getHostname() and $last_router_status->getHostname() and $this->getHostname() != $last_router_status->getHostname()) {
                     $eventlist->add(new Event(false, false, "router", $this->getRouterId(), "hostname", array('from' => $last_router_status->getHostname(), 'to' => $this->getHostname(), 'hostname' => $router->getHostname())));
                 }
                 if ($this->getChipset() and $last_router_status->getChipset() and $this->getChipset() != $last_router_status->getChipset()) {
                     $eventlist->add(new Event(false, false, "router", $this->getRouterId(), "chipset", array('from' => $last_router_status->getChipset(), 'to' => $this->getChipset(), 'hostname' => $router->getHostname())));
                 }
                 if ($this->getNodewatcherVersion() and $last_router_status->getNodewatcherVersion() and $this->getNodewatcherVersion() != $last_router_status->getNodewatcherVersion()) {
                     $eventlist->add(new Event(false, false, "router", $this->getRouterId(), "nodewatcher_version", array('from' => $last_router_status->getNodewatcherVersion(), 'to' => $this->getNodewatcherVersion(), 'hostname' => $router->getHostname())));
                 }
                 if ($this->getFirmwareVersion() and $last_router_status->getFirmwareVersion() and $this->getFirmwareVersion() != $last_router_status->getFirmwareVersion()) {
                     $eventlist->add(new Event(false, false, "router", $this->getRouterId(), "firmware_version", array('from' => $last_router_status->getFirmwareVersion(), 'to' => $this->getFirmwareVersion(), 'hostname' => $router->getHostname())));
                 }
                 if ($this->getBatmanAdvancedVersion() and $last_router_status->getBatmanAdvancedVersion() and $this->getBatmanAdvancedVersion() != $last_router_status->getBatmanAdvancedVersion()) {
                     $eventlist->add(new Event(false, false, "router", $this->getRouterId(), "batman_advanced_version", array('from' => $last_router_status->getBatmanAdvancedVersion(), 'to' => $this->getBatmanAdvancedVersion(), 'hostname' => $router->getHostname())));
                 }
                 if ($this->getDistversion() and $last_router_status->getDistversion() and $this->getDistversion() != $last_router_status->getDistversion()) {
                     $eventlist->add(new Event(false, false, "router", $this->getRouterId(), "distversion", array('from' => $last_router_status->getDistversion(), 'to' => $this->getDistversion(), 'hostname' => $router->getHostname())));
                 }
                 if ($this->getDistname() and $last_router_status->getDistname() and $this->getDistname() != $last_router_status->getDistname()) {
                     $eventlist->add(new Event(false, false, "router", $this->getRouterId(), "distname", array('from' => $last_router_status->getDistname(), 'to' => $this->getDistname(), 'hostname' => $router->getHostname())));
                 }
             }
             $eventlist->store();
             //Check if netmon already knows the given chipset and if
             //the router assigned to this status has the right chipset set
             if ($this->getStatus() == "online" and $router->getChipset()->getName() != $this->getChipset()) {
                 $chipset = new Chipset(false, $this->getChipset());
                 if (!$chipset->fetch()) {
                     $chipset->store();
                 }
                 $router->setChipsetId($chipset->getChipsetId());
                 $router->store();
             }
             //Return the ID of the inserted RouterStatus
             return DB::getInstance()->lastInsertId();
         }
     }
     return false;
 }
コード例 #5
0
ファイル: config.php プロジェクト: wAmpIre/netmon
         $message[] = array("Der Chipsatz wurde gespeichert.", 1);
     } else {
         $message[] = array("Der Chipsatz konnte nicht gespeichert werden.", 2);
     }
     Message::setMessage($message);
     header('Location: ./config.php?section=edit_hardware');
 } elseif ($_GET['section'] == "edit_hardware_name") {
     $chipset = new Chipset((int) $_GET['chipset_id']);
     $chipset->fetch();
     $smarty->assign('chipset', $chipset);
     $smarty->assign('message', Message::getMessage());
     $smarty->display("header.tpl.html");
     $smarty->display("config_edit_hardware_name.tpl.html");
     $smarty->display("footer.tpl.html");
 } elseif ($_GET['section'] == "insert_edit_chipset_name") {
     $chipset = new Chipset((int) $_GET['chipset_id'], $_POST['name'], $_POST['hardware_name']);
     if ($chipset->store()) {
         $message[] = array("Der Chipsatz wurde gespeichert.", 1);
     } else {
         $message[] = array("Der Chipsatz konnte nicht gespeichert werden.", 2);
     }
     Message::setMessage($message);
     header('Location: ./config.php?section=edit_hardware');
 } elseif ($_GET['section'] == "insert_delete_chipset") {
     if ($_POST['really_delete'] == 1) {
         $message[] = array("Diese Funktion ist aktuell nicht implementiert", 0);
         Message::setMessage($message);
         header('Location: ./config.php?section=edit_hardware');
     } else {
         $message[] = array("Zum löschen des Chipsets ist eine Bestätigung erforderlich!", 2);
         Message::setMessage($message);