protected void buildList()
        {
            Intent statusIntent;
            Server yastServer;
            Bundle b;

            statusIntent = Intent;
            b = statusIntent.Extras;
            yastServer = new Server(b);
            statusModule = yastServer.getStatusModule();
            try {
                graphs = statusModule.getGraphs();
            } catch(SAXException ex) {
                graphs = null;
            }

            try {
                logs = statusModule.getLogs();
            } catch(Exception ex) {
                // Unable to get logs
                logs = null;
                Android.Util.Log.Error("SystemStatusActivity", ex.Message);
            }

            populateAdapter ();
        }
        public void fetchMetricData()
        {
            Bundle b;
            Server yastServer;
            string resource_type;
            StatusModule statusModule;
            List<Metric> networkMetrics;

            b = Intent.Extras;
            resource_type = b.GetString("RESOURCE_TYPE");
            yastServer = new Server(b);
            metric = null;
                    // TODO: figure out how many data points we want to graph on this small screen

            if (resource_type == "Network")
            {
                try {
                    statusModule = yastServer.getStatusModule();
                    networkMetrics = statusModule.getMetric(Metric.NETWORK);
                                    // FIXME: We are using "eth0" in the meantime, but we should be able to show the other interfaces
                                    // Also, each interface has different types, here we are hard-coding "if_packets" (aka, rx and tx)
                    string id = null;
                    foreach (Metric m in networkMetrics) {
                        if (m.getTypeInstance () != null && m.getTypeInstance().CompareTo("eth0") == 0
                            && m.getType () != null && m.getType().CompareTo("if_packets") == 0) {
                            id = m.getId ();
                            break;
                        }
                    }
                    timeStamp = (int) (new Date ().Time / 1000);
                                    timeStampStart = timeStamp - (60 * length);
                                    metric = statusModule.getMetricData(id,
                                                    timeStampStart,
                                                    timeStamp);
                    if (metric != null) {
                    // FIXME: GraphArrayList<E>orts one value only,
                            List<Value> xmlValues = (List<Value>) metric.getValues ();
                                            // FIXME: We are using the first value, however the graph should show all the values available, for
                                            // example "if_packets" has "tx" and "rx" values.
                        float [] fvalues = xmlValues[0].getValues ().ToArray();
                        values = new float [fvalues.Length];
                        for (int x=0; x<fvalues.Length; x++) {
                            values[x] = fvalues[x];
                            }
                    }
                } catch (Exception e) {
                    Android.Util.Log.Error("DisplayResourceActivity", e.Message);
                }
            }
            Task returnRes = new Task (() => {
                buildGraph ();
                fetchMetricDataProgress.Dismiss ();
            });
            RunOnUiThread (returnRes.Start);
        }
Example #3
0
        private void getServer(long serverId)
        {
            database = dbhelper.ReadableDatabase;
            ICursor sc;
            try {
                sc = database.Query(YastroidOpenHelper.SERVERS_TABLE_NAME, new string[] {
                            "_id", "name", "scheme", "hostname", "port", "user", "pass", "grp" },
                    YastroidOpenHelper.SERVERS_ID + "=" + serverId, null, null, null, null);

                sc.MoveToFirst();
                s = new Server(sc.GetInt(0), sc.GetString(1), sc.GetString(2), sc
                    .GetString(3), sc.GetInt(4), sc.GetString(5), sc
                                .GetString(6), sc.GetInt(7));
                sc.Close();
                database.Close();
            } catch (Exception e) {
                Log.Error("BACKGROUND_PROC", e.Message);
            }
        }
Example #4
0
        /*
         * (non-Javadoc)
         *
         * @see android.app.Activity#onCreate(android.os.Bundle)
         */
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.server);
            yastServer = new Server (Intent.Extras);

            moduleList = new List<Module>();
            moduleAdapter = new ModuleAdapter (this, Resource.Layout.module_list_row, moduleList);

            // Set the Header on this Activity
            View header = LayoutInflater.Inflate(Resource.Layout.server_header, null);
            TextView serverName = header.FindViewById<TextView>(Resource.Id.server_name);
            TextView serverHost = header.FindViewById<TextView>(Resource.Id.server_address);
            //TextView serverUptime = (TextView)header.FindViewById(Resource.Id.server_uptime); // Not available yet
            serverName.Text = yastServer.getName();
            serverHost.Text = yastServer.getHostname();
            //serverUptime.setText("Uptime: " + "8 days, 8 Hours"); //Not available yet

            ListView.AddHeaderView(header);
            ListAdapter = moduleAdapter;
        }
Example #5
0
        public Server getServer(int id)
        {
            database = dbhelper.ReadableDatabase;
            Server s = null;
            try {
                ICursor sc = database.Query(YastroidOpenHelper.SERVERS_TABLE_NAME,
                        new string[] { "_id", "name", "scheme", "hostname", "port",
                                "user", "pass", "grp" }, "_id="+id, null, null, null, null);

                if(sc.Count == 1) {
                    s = new Server(sc.GetInt(0), sc.GetString(1), sc
                                .GetString(2), sc.GetString(3), sc.GetInt(4), sc
                                .GetString(5), sc.GetString(6), sc.GetInt(7));
                    }
                sc.Close();
                database.Close();
            } catch (Exception e) {
                Log.Error("BACKGROUND_PROC", e.Message);
            }
            return s;
        }
Example #6
0
        void getServers()
        {
            database = dbhelper.ReadableDatabase;
            ICursor sc;
            try {
                if (groupId == YastroidOpenHelper.GROUP_DEFAULT_ALL) {
                    sc = database.Query(YastroidOpenHelper.SERVERS_TABLE_NAME, new [] {
                            "_id", "name", "scheme", "hostname", "port", "user", "pass", "grp" },
                            null, null, null, null, null);
                } else {
                    sc = database.Query(YastroidOpenHelper.SERVERS_TABLE_NAME, new [] {
                            "_id", "name", "scheme", "hostname", "port", "user", "pass", "grp" },
                        YastroidOpenHelper.SERVERS_GROUP + "=" + groupId, null, null, null, null);
                }

                sc.MoveToFirst();
                Server s;
                serverList.Clear ();
                if (!sc.IsAfterLast) {
                    do {
                        s = new Server(sc.GetInt(0), sc.GetString(1), sc.GetString(2),
                            sc.GetString(3), sc.GetInt(4), sc.GetString(5),
                            sc.GetString(6), sc.GetInt(7));
                        serverList.Add(s);
                    } while (sc.MoveToNext());
                }
                sc.Close();
                database.Close();
                Log.Info("Server Array", "" + serverList.Count);
            } catch (Exception e) {
                Log.Error("BACKGROUND_PROC", e.Message);
            }

            serverAdapter.Clear();
            if (serverList != null && serverList.Count > 0) {
                for (int i = 0; i < serverList.Count; i++)
                    serverAdapter.Add(serverList[i]);
            } else {
                // Add button 'Add new Server'
            }
            serverAdapter.NotifyDataSetChanged();
        }