Determining a Tally Interval

SMS is configured with 16 default tally intervals. The intervals for a site are maintained in the site control file. The values are stored in the order as shown in the following table. For details on accessing these values in the site control file, see the example at the end of this topic.

Schedule Tally interval Class
Since 12:00AM 0001128000100008 SMS_ST_RecurInterval
Since 04:00AM 0081128000100008 SMS_ST_RecurInterval
Since 08:00AM 0101128000100008 SMS_ST_RecurInterval
Since 12:00PM 0181128000100008 SMS_ST_RecurInterval
Since 04:00PM 0201128000100008 SMS_ST_RecurInterval
Since 08:00PM 0281128000100008 SMS_ST_RecurInterval
Since Sunday 0001128000192000 SMS_ST_RecurWeekly
Since Monday 00011280001A2000 SMS_ST_RecurWeekly
Since Tuesday 00011280001B2000 SMS_ST_RecurWeekly
Since Wednesday 00011280001C2000 SMS_ST_RecurWeekly
Since Thursday 00011280001D2000 SMS_ST_RecurWeekly
Since Friday 00011280001E2000 SMS_ST_RecurWeekly
Since Saturday 00011280001F2000 SMS_ST_RecurWeekly
Since 1st of month 000A470000284400 SMS_ST_RecurMonthlyByDate
Since 15th of month 000A4700002BC400 SMS_ST_NonRecurring
Since site installation 0001128000080008 SMS_ST_NonRecurring

The Schedule column is the beginning value of the tally interval. You interpret the beginning value of the tally interval as "Give me the tallies since Monday." The end of the tally interval is always the current time. The complete tally interval is the same as asking "Give me all the tallies from Monday to the current time."

You can use only the tally intervals listed in the previous table in your queries. When you use a tally interval not from the list, you are returned an object that contains no data. The following example shows you how to use the tally interval to retrieve the message count during a specific time interval.

// This query asks for the counts of informational, warning, and error
// messages since Monday. Note that you cannot add other conditions like
// SiteCode to the WHERE clause. Adding other conditions will generate
// an error.
SELECT Infos, Warnings, Errors
FROM SMS_SiteDetailSummarizer
WHERE TallyInterval = "00011280001A2000"

The classes listed in the tally interval table are embedded schedule token classes that you can use to interpret the interval string. You use the ReadFromString method of the SMS_ScheduleMethods class to interpret an interval string. This method breaks the interval string into its components and returns the appropriate embedded object.

The following example shows you how to access the site control file to determine the tally intervals for that site.

  [C/C++]
    IEnumWbemClassObject  *penumSCICompSet = NULL;   //SMS_SCI_Component enumeration
    IWbemClassObject      *pinstSCIComp = NULL;      //Instance of SMS_SCI_Component
    IWbemClassObject      *pinstProperty = NULL;     //Embedded property instance
    _bstr_t                bstrQuery;
    _variant_t             vPropertySet;             //Array of embedded PropLists
    long                   LBound, UBound, i;
    unsigned long          ulReturned;


    bstrQuery = L"SELECT PropLists FROM SMS_SCI_Component "
                L"WHERE ComponentName = \"SMS_COMPONENT_STATUS_SUMMARIZER\" "
                L"AND   SiteCode = \"<sitecode>\" ";

    //Query the actual site control file - you do not need your own copy.
    hr = pServices->ExecQuery(_bstr_t(L"WQL"), bstrQuery,
                              WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY,
                              NULL, &penumSCICompSet);

    //The query returns only one instance in the enumeration.
    hr = penumSCICompSet->Next(WBEM_INFINITE, 1, &pinstSCIComp, &ulReturned);
    hr = pinstSCIComp->Get(_bstr_t(L"PropLists"), 0, &vPropertySet, 0, 0);

    SafeArrayGetLBound(V_ARRAY(&vPropertySet), 1, &LBound);
    SafeArrayGetUBound(V_ARRAY(&vPropertySet), 1, &UBound);

    for (i = LBound; i <= UBound; i++)
    {
        SafeArrayGetElement(V_ARRAY(&vPropertySet), &i, &pinstProperty);

        hr = pinstProperty->Get(_bstr_t(L"PropertyListName"), 0, &vTemp, 0, 0);

        if ( _bstr_t(vTemp) == _bstr_t(L"Summary_Intervals") )
        {
            _bstr_t      bstrIntervalList = L"Interval values:\n";
            BSTR         bstrInterval;                 //Interval from the array.
            _variant_t   vIntervals;                   //Array of interval values.
            long         LBoundInterval, UBoundInterval, j;

            //Get the array of interval values.
            hr = pinstProperty->Get(_bstr_t(L"Values"), 0, &vIntervals, 0, 0);
            SafeArrayGetLBound(V_ARRAY(&vIntervals), 1, &LBoundInterval);
            SafeArrayGetUBound(V_ARRAY(&vIntervals), 1, &UBoundInterval);

            //Build a list of interval values for display in the message box.
            for (j = LBoundInterval; j <= UBoundInterval; j++)
            {
                SafeArrayGetElement(V_ARRAY(&vIntervals), &j, &bstrInterval);
                bstrIntervalList = bstrIntervalList + bstrInterval + L"\n";
                SysFreeString(bstrInterval);
            }

            MessageBox(HWND_DESKTOP, (const char *)bstrIntervalList,
                       "Display Intervals", MB_OK);

            pinstProperty->Release();
            pinstProperty = NULL;

            break;
        }
        pinstProperty->Release();
        pinstProperty = NULL;
    }

    penumSCICompSet->Release();
    pinstSCIComp->Release();

[Visual Basic]
    Dim services As SWbemServices
    Dim SCIComponent As SWbemObject             'SMS_SCI_Component class
    Dim SCIComponentSet As SWbemObjectSet       'Enumeration of SMS_SCI_Component
    Dim Query As String
    Dim sIntervals As String
    Dim i As Integer
    Dim vProperty As Variant                    'Embedded property

    Set services = GetObject("winmgmts:root/sms/site_<sitecode>")

    Query = "SELECT PropLists FROM SMS_SCI_Component " & _
            "WHERE ComponentName = 'SMS_COMPONENT_STATUS_SUMMARIZER' " & _
            "AND SiteCode = '<sitecode>' "

    'You do not need to get a copy of the site control file just to read it.
    Set SCIComponentSet = services.ExecQuery(Query, , wbemFlagForwardOnly Or wbemFlagReturnImmediately)

    'The query returns only one instance.
    For Each SCIComponent In SCIComponentSet
        For Each vProperty In SCIComponent.PropLists
            If vProperty.PropertyListName = "Summary_Intervals" Then

                For i = 0 To UBound(vProperty.Values)
                    sIntervals = sIntervals & vProperty.Values(i) & vbCrLf
                Next

                MsgBox "Interval values: " & vbCrLf & sIntervals
            End If
        Next
    Next