Source

quechua / modules / channel / dionaeaHarvester / dionaeaHarvester.h

/* 
 * Quechua - the lightweight data mining framework
 *
 * Copyright (C) 2012 Marek Denis <quechua@octogan.net>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef DNCHAN_H
#define DNCHAN_H

#include "ev++.h"

#include "../../../include/types.h"
#include "../../../include/interface-channel.h"
#include "../../../include/python-interface.h"
#include "../../data/dionaeaconnections.h"
#include "selects.h"

bool exec_query(dbwork_t& w,dbresult_t& r, const char* q,bool commit = false);


class DionaeaHarvester : public Channel {
    
    struct credentials_s {
        string_t user;
        string_t password;
        string_t hostname;
        string_t database;
    };
    
    struct range_s {
        string_t from;
        string_t to;
    };

 public:
        DionaeaHarvester();
        virtual ~DionaeaHarvester();

        bool start();
        bool prepare();
        bool stop();

        bool notify();
        bool load_misc_conf(const setting_t& misc);
 protected:
        inline bool check_connection(const dbconnection_t* c);
        inline bool check_and_complain_connection(const dbconnection_t* c);

 private:
        int interval;
        range_s range;

        credentials_s credentials;
        dbconnection_t* connection;

        void fetch_data();
};

extern "C" Channel* create_channel();

#endif // DNCHAN_H