summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2017-01-16 19:29:20 +0100
committerDaniel Friesel <derf@finalrewind.org>2017-01-16 19:29:20 +0100
commit1c5ed449f3061d5105f55aca50114199356866f6 (patch)
tree2302e98ce934258178ddef61b33d70799d847a0e
parent40480626b1f4cf615883f6d285e779bd8dae7dc9 (diff)
basic output
-rw-r--r--index.pl14
-rw-r--r--templates/main.html.ep17
2 files changed, 29 insertions, 2 deletions
diff --git a/index.pl b/index.pl
index 72e2dcb..3025f41 100644
--- a/index.pl
+++ b/index.pl
@@ -1,7 +1,6 @@
#!/usr/bin/env perl
use Mojolicious::Lite;
-use Data::Dumper;
use DateTime;
use DBI;
use 5.020;
@@ -70,9 +69,22 @@ app->attr( dbh => sub { return $dbh } );
get '/' => sub {
my ($self) = @_;
+ my @hostdata;
+
+ my $hostdata_raw = $dbh->selectall_arrayref(
+ qq{select * from hostdata order by last_contact desc}
+ );
+ my @fields = (qw(hostname contact), @int_fields, @text_fields);
+
+ for my $host (@{$hostdata_raw}) {
+ push(@hostdata, {
+ map { ($fields[$_], $host->[$_]) } (0 .. $#fields)
+ });
+ }
$self->render(
'main',
+ hosts => \@hostdata,
version => $VERSION,
);
};
diff --git a/templates/main.html.ep b/templates/main.html.ep
index 025bb31..f5cae1d 100644
--- a/templates/main.html.ep
+++ b/templates/main.html.ep
@@ -1 +1,16 @@
-<p>ohai!</p>
+<div>
+ <table>
+ <tr>
+ <th>Hostname</th>
+ <th>Load</th>
+ <th>OS</th>
+ </tr>
+ % for my $host (@{$hosts}) {
+ <tr>
+ <td><%= $host->{hostname} %></td>
+ <td><%= $host->{load15} %></td>
+ <td>Debian <%= $host->{debian} %></td>
+ </tr>
+ % }
+ </table>
+</div>