19.08.2013 Views

BES DATABASE API

BES DATABASE API

BES DATABASE API

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>BES</strong> <strong>DATABASE</strong> <strong>API</strong><br />

Overview<br />

A user of the BigFix Enterprise Suite (<strong>BES</strong>) may sometimes wish to make customized queries against the <strong>BES</strong> SQL<br />

database, perhaps to generate a web page or other report. To make simple queries reasonably easy, we have provided<br />

a set of views of the <strong>BES</strong> database that are easy to understand and work with, and which we will attempt to leave<br />

unchanged in future versions of the database.<br />

The functionality discussed in this document was introduced in database version “Enterprise 1.3” included in builds<br />

4.0.0.1 and later.<br />

View Schema<br />

These views were created with the goals of simplicity and stability. They are slightly de-normalized for the sake of<br />

simplicity.<br />

<strong>BES</strong>_FIXLETS<br />

ν Sitename<br />

ν ID<br />

ν Name<br />

The <strong>BES</strong>_FIXLETS view provides a list of all Fixlets which this <strong>BES</strong> database currently knows about. This table is<br />

useful for joining against the <strong>BES</strong>_RELEVANT_FIXLETS and <strong>BES</strong>_ACTIONS table to get the Fixlet name.<br />

Example: “select Sitename, ID, Name from <strong>BES</strong>_Fixlets where Sitename = ‘Enterprise Security’ order by Sitename,<br />

ID”<br />

<strong>BES</strong>_COLUMN_HEADINGS<br />

ν ComputerID<br />

ν Name<br />

ν Value<br />

ν IsFailure<br />

The <strong>BES</strong>_COLUMN_HEADINGS view provides access to all the retrieved property information collected about<br />

client computers by the <strong>BES</strong> database. Retrieved properties which return multiple results will be expressed in this<br />

view by a value field which contains the multiple results separated by a newline character.<br />

Example: “select ComputerID, Name, Value, IsFailure from <strong>BES</strong>_COLUMN_HEADINGS where Name = ‘Total<br />

HD Space’ order by ComputerID”<br />

<strong>BES</strong>_RELEVANT_FIXLETS<br />

ν Sitename<br />

ν ID<br />

ν ComputerID<br />

The <strong>BES</strong>_RELEVANT_Fixlets view contains an entry for every {Fixlet, computer} pair in which the Fixlet is<br />

relevant on that computer.<br />

Example: “Select F.Sitename, F.ID, F.Name, R.ComputerID from <strong>BES</strong>_FIXLETS F, <strong>BES</strong>_RELEVANT_FIXLETS R<br />

where F.Sitename = R.Sitename AND F.ID = R.ID”<br />

Revised 18 Nov, 2004 Copyright © BigFix, Inc. 2004. Page 1 of 4


<strong>BES</strong>_ACTIONS<br />

ν ActionID<br />

ν ComputerID<br />

ν Name<br />

ν Username<br />

ν StartTime<br />

ν FixletID<br />

ν Sitename<br />

ν ActionStatus<br />

The <strong>BES</strong>_ACTIONS view contains an entry for every {action, computer} pair where the action was received by the<br />

computer.<br />

Example: “select * from <strong>BES</strong>_ACTIONS where ActionStatus = ‘Executed’”<br />

<strong>BES</strong>_RELEVANT_FIXLET_HISTORY<br />

ν Sitename<br />

ν ID<br />

ν ComputerID<br />

ν FirstBecameRelevant<br />

ν LastBecameRelevant<br />

ν LastBecameNonRelevant<br />

The <strong>BES</strong>_RELEVANT_FIXLET_HISTORY view contains an entry for every {Fixlet, Computer} pair that has ever<br />

been relevant, with timestamps indicating the first time it became relevant, the last time it became relevant (the same<br />

as FirstBecameRelevant if it only became relevant once), and the last time it became non-relevant. Some of these<br />

fields may be NULL if the event in question never occurred or if it occurred before upgrading to the <strong>BES</strong> 4.0 Server.<br />

<strong>BES</strong>_FIXLET_PROPERTIES<br />

ν Sitename<br />

ν ID<br />

ν PropertyName<br />

ν PropertyValue<br />

The <strong>BES</strong>_FIXLET_PROPERTIES view lists the different properties associated with each Fixlet, such as the<br />

severity.<br />

Example: “select BF.Sitename, BF.ID, BF.Name, BFP.PropertyValue AS 'Severity'<br />

from <strong>BES</strong>_FIXLETS BF, <strong>BES</strong>_FIXLET_PROPERTIES BFP<br />

where BF.SItename = BFP.Sitename AND BF.ID = BFP.ID AND BFP.PropertyName = 'Source Severity'”<br />

Future Changes<br />

In the future we may add additional columns to some of these views, introduce new views and/or stored procedures.<br />

The tables outlined here will only be changed if the underlying content changes in such a way as to make them<br />

inapplicable.<br />

Example Report Generation<br />

The following perl script, with the appropriate dns name and login supplied in line #15, will access the database and<br />

print out the contents of the four principal views in HTML tables.<br />

# viewbesdb.pl<br />

#<br />

# An example cgi script which shows the contents of a<br />

Copyright © BigFix, Inc. 2004. Page 2 of 4


# <strong>BES</strong> database.<br />

#<br />

# peter_loer@bigfix.com / feb 2002<br />

use strict;<br />

use CGI;<br />

use DBI;<br />

use CGI::Carp qw(fatalsToBrowser);<br />

$| = 1;<br />

my $dbh = DBI->connect("dbi:ODBC:bes_locke", "bigfix", "bigfix")<br />

or die "unable to connect to db";<br />

print "content-type: text/html\n\n";<br />

print "";<br />

print "Contents of <strong>BES</strong> database on LOCKE";<br />

# Print out all column headings<br />

{<br />

print "Column Headings";<br />

print "";<br />

print "ComputerIDName";<br />

print "ValueIsFailure";<br />

my $query = "select ComputerID, Name, Value, IsFailure ";<br />

$query .= "from <strong>BES</strong>_COLUMN_HEADINGS";<br />

my $sth = $dbh->prepare($query);<br />

$sth->execute();<br />

my @row;<br />

while(@row = $sth->fetchrow_array){<br />

print "";<br />

print join("", @row);<br />

print "";<br />

}<br />

print "";<br />

}<br />

# Print out all relevant fixlets<br />

{<br />

print "Relevant Fixlets";<br />

print "";<br />

print "SitenameID";<br />

print "ComputerID";<br />

my $query = "select Sitename, ID, ComputerID from <strong>BES</strong>_RELEVANT_FIXLETS";<br />

my $sth = $dbh->prepare($query);<br />

$sth->execute();<br />

my @row;<br />

while(@row = $sth->fetchrow_array){<br />

print "";<br />

print join("", @row);<br />

print "";<br />

}<br />

print "";<br />

}<br />

# Print out all actions<br />

{<br />

print "Actions";<br />

print "";<br />

print "ActionIDComputerID";<br />

print "NameUsernameStart Time";<br />

print "FixletIDSitenameActionStatus";<br />

my $query = "select ActionID, ComputerID, Name, Username, StartTime, ";<br />

$query .= "FixletID, Sitename, ActionStatus from <strong>BES</strong>_ACTIONS";<br />

my $sth = $dbh->prepare($query);<br />

$sth->execute();<br />

my @row;<br />

while(@row = $sth->fetchrow_array){<br />

print "";<br />

print join("", @row);<br />

print "";<br />

Copyright © BigFix, Inc. 2004. Page 3 of 4


}<br />

}<br />

print "";<br />

# Print out all known fixlets<br />

{<br />

print "Known Fixlets";<br />

print "";<br />

print "SitenameIDName";<br />

my $sth = $dbh->prepare("select Sitename, ID, Name from <strong>BES</strong>_FIXLETS");<br />

$sth->execute();<br />

my @row;<br />

while(@row = $sth->fetchrow_array){<br />

print "";<br />

print join("", @row);<br />

print "";<br />

}<br />

}<br />

print "";<br />

BigFix, Inc. Headquarters<br />

6121 Hollis Street<br />

Emeryville, California 94608<br />

[t] 510 652-6700<br />

[f] 510 652-6742<br />

[e] enterprisesupport@bigfix.com<br />

Copyright © BigFix, Inc. 2004. Page 4 of 4

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!