#!/usr/bin/perl

## $Id: mrtg-obec.pl,v 1.1 2000/11/27 22:47:14 lord Exp $
##-----------------------------------------------------
## NNTP->RDBMS gateway for OBEC project.
## http://obec.sourceforge.net/
## Vadim Zaliva <lord@crocodile.org>
##-----------------------------------------------------
##
## Small perl script to view OBEC stats via MRTG.
##
##-----------------------------------------------------

use DBI;

my $dsn         = "DBI:mysql:database=OBEC;host=localhost";
my $db_user     = "ofetch";
my $db_password = "12oF2";
  
$dbh = DBI->connect($dsn, $db_user, $db_password);
$drh = DBI->install_driver("mysql");

$stmt  = $dbh->prepare("select COUNT(*) AS NT, SUM(Views) AS NV FROM Texts");
$stmt->execute();
if(my $ref = $stmt->fetchrow_hashref())
  {
    print $ref->{'NT'} . "\n";
    print $ref->{'NV'} . "\n";
    print "0\nOBEC\n";
    $stmt->finish();
    $dbh->disconnect();
    exit(0);
  } 
else
  {
    $stmt->finish();
    $dbh->disconnect();
    exit(1);
  }

