// Path: src/com/clavain/muninmxcd.java
// public static Properties p      = null;
// 
// Path: src/com/clavain/utils/Database.java
// public static boolean dbAddAllAlertWithId(Integer p_aid)
// {
//     boolean retval = false;
//     try 
//     {
//         Connection conn = connectToDatabase(p);
//         java.sql.Statement stmt = conn.createStatement();  
//         ResultSet rs = stmt.executeQuery("SELECT alerts.*,nodes.hostname FROM alerts LEFT JOIN nodes ON alerts.node_id = nodes.id WHERE alerts.id = " + p_aid);
//         while(rs.next())
//         {
//             Alert av = new Alert();
//             av.setAlert_id(rs.getInt("id"));
//             av.setCondition(rs.getString("condition"));
//             av.setGraphName(rs.getString("graphname"));
//             av.setPluginName(rs.getString("pluginname"));
//             av.setRaise_value(rs.getBigDecimal("raise_value"));
//             av.setNum_samples(rs.getInt("num_samples"));
//             av.setAlert_limit(rs.getInt("alert_limit"));
//             av.setHostname(rs.getString("hostname"));
//             av.setNode_id(rs.getInt("node_id"));
//             com.clavain.muninmxcd.v_alerts.add(av);
//             retval = true;
//         }
//     } catch (Exception ex)
//     {
//         logger.error("Add Alert "+p_aid+" failed." + ex.getLocalizedMessage());
//         ex.printStackTrace();
//     }   
//     return retval;
// }    
// 
// Path: src/com/clavain/utils/Database.java
// public static Connection connectToDatabase(Properties p)
// {
//     Connection conn;
//     try {
//         logger.debug("Connecting to MySQL");
//         conn =
//            DriverManager.getConnection("jdbc:mysql://"+p.getProperty("mysql.host")+":"+p.getProperty("mysql.port")+"/"+p.getProperty("mysql.db")+"?" +
//                                        "user="+p.getProperty("mysql.user")+"&password="+p.getProperty("mysql.pass")+"&autoReconnect=true&failOverReadOnly=false&maxReconnects=10");
// 
//         return(conn);
// 
//     } catch (Exception ex) {
//         // handle any errors
//         logger.fatal("Error connecting to database: " + ex.getMessage());
//         return(null);
//     }
// }  


import static com.clavain.muninmxcd.p;
import java.sql.ResultSet;
import static com.clavain.utils.Database.dbAddAllAlertWithId;
import static com.clavain.utils.Database.connectToDatabase;
import java.sql.Connection;
        {
            Connection conn = connectToDatabase(p);   
            java.sql.Statement stmt = conn.createStatement();
            ResultSet rs = stmt.executeQuery("SELECT * from users WHERE id = " + user_id);
            while(rs.next())
            {
                return rs.getInt("sms_tickets");
            }
        } catch (Exception ex)
        {
            com.clavain.muninmxcd.logger.error("Error in retrieving SMSTicket Count for User: " + user_id + " with: " + ex.getLocalizedMessage());
        }
        return 0;
    }      
    
    public static String getCustomerEMail(Integer user_id)
    {
        try 
        {
            Connection conn = connectToDatabase(p);   
            java.sql.Statement stmt = conn.createStatement();
            ResultSet rs = stmt.executeQuery("SELECT * from users WHERE id = " + user_id);
            while(rs.next())
            {
                return rs.getString("email");
            }
        } catch (Exception ex)
        {
            com.clavain.muninmxcd.logger.error("Error in retrieving SMSTicket Count for User: " + user_id + " with: " + ex.getLocalizedMessage());
        }
// Path: src/com/clavain/muninmxcd.java
// public static Properties p      = null;
// 
// Path: src/com/clavain/utils/Database.java
// public static boolean dbAddAllAlertWithId(Integer p_aid)
// {
//     boolean retval = false;
//     try 
//     {
//         Connection conn = connectToDatabase(p);
//         java.sql.Statement stmt = conn.createStatement();  
//         ResultSet rs = stmt.executeQuery("SELECT alerts.*,nodes.hostname FROM alerts LEFT JOIN nodes ON alerts.node_id = nodes.id WHERE alerts.id = " + p_aid);
//         while(rs.next())
//         {
//             Alert av = new Alert();
//             av.setAlert_id(rs.getInt("id"));
//             av.setCondition(rs.getString("condition"));
//             av.setGraphName(rs.getString("graphname"));
//             av.setPluginName(rs.getString("pluginname"));
//             av.setRaise_value(rs.getBigDecimal("raise_value"));
//             av.setNum_samples(rs.getInt("num_samples"));
//             av.setAlert_limit(rs.getInt("alert_limit"));
//             av.setHostname(rs.getString("hostname"));
//             av.setNode_id(rs.getInt("node_id"));
//             com.clavain.muninmxcd.v_alerts.add(av);
//             retval = true;
//         }
//     } catch (Exception ex)
//     {
//         logger.error("Add Alert "+p_aid+" failed." + ex.getLocalizedMessage());
//         ex.printStackTrace();
//     }   
//     return retval;
// }    
// 
// Path: src/com/clavain/utils/Database.java
// public static Connection connectToDatabase(Properties p)
// {
//     Connection conn;
//     try {
//         logger.debug("Connecting to MySQL");
//         conn =
//            DriverManager.getConnection("jdbc:mysql://"+p.getProperty("mysql.host")+":"+p.getProperty("mysql.port")+"/"+p.getProperty("mysql.db")+"?" +
//                                        "user="+p.getProperty("mysql.user")+"&password="+p.getProperty("mysql.pass")+"&autoReconnect=true&failOverReadOnly=false&maxReconnects=10");
// 
//         return(conn);
// 
//     } catch (Exception ex) {
//         // handle any errors
//         logger.fatal("Error connecting to database: " + ex.getMessage());
//         return(null);
//     }
// }  


// Path: src/com/clavain/alerts/Helpers.java
import static com.clavain.muninmxcd.p;
import java.sql.ResultSet;
import static com.clavain.utils.Database.dbAddAllAlertWithId;
import static com.clavain.utils.Database.connectToDatabase;
import java.sql.Connection;

        {
            Connection conn = connectToDatabase(p);   
            java.sql.Statement stmt = conn.createStatement();
            ResultSet rs = stmt.executeQuery("SELECT * from users WHERE id = " + user_id);
            while(rs.next())
            {
                return rs.getInt("sms_tickets");
            }
        } catch (Exception ex)
        {
            com.clavain.muninmxcd.logger.error("Error in retrieving SMSTicket Count for User: " + user_id + " with: " + ex.getLocalizedMessage());
        }
        return 0;
    }      
    
    public static String getCustomerEMail(Integer user_id)
    {
        try 
        {
            Connection conn = connectToDatabase(p);   
            java.sql.Statement stmt = conn.createStatement();
            ResultSet rs = stmt.executeQuery("SELECT * from users WHERE id = " + user_id);
            while(rs.next())
            {
                return rs.getString("email");
            }
        } catch (Exception ex)
        {
            com.clavain.muninmxcd.logger.error("Error in retrieving SMSTicket Count for User: " + user_id + " with: " + ex.getLocalizedMessage());
        }
        return null;        