Example Gratia Record Uploader/Sender script

#! /usr/bin/python

import Gratia
import Metric

if __name__ == '__main__':
        Gratia.Initialize("/osg/0.9.0-RSV-third-test/gratia/probe/metric/ProbeConfig")
        r = Metric.MetricRecord()
        r.MetricName("org.osg.general.ping-host")
        r.MetricType("status")
        r.MetricStatus("OK")
        r.Timestamp("2008-04-24T19:32:11Z") # Or could enter it as seconds since epoch
        r.ServiceType("OSG-CE-General")
        r.ServiceUri("cobra.uits.indiana.edu")
        r.GatheredAt("dickinson.ucs.indiana.edu")
        r.SummaryData("OK")
        r.DetailsData("Host cobra.uits.indiana.edu is alive and responding to pings!")

        print Gratia.Send(r)

When the above script is run

When a Gratia sender script is run, it does two things:

  • Creates an XML file with the probe output content, under the current working directory at: ./MAGIC_VDT_LOCATION/gratia/var/tmp/gratiafiles/

  • Uploads that XML file to the Gratia collector machine defined in the ProbeConfig file (which is also set by the RSV metric probe, as shown in the above script.

A log of all the action that goes on behind the scenes is stored in log file within the following directory: CWD/MAGIC_VDT_LOCATION/gratia/var/logs/