You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

Introduction

Historically opReports has relied solely on being run on demand via the GUI or command line, or periodically with cron; However with version 2.6.1 we've added another feature that extends these capabilities: the opReports Scheduler. The scheduler is meant to act a bit like "at" (a venerable but not especially well known Unix tool, companion of cron) but fine-tuned and optimized for opReports.

The  idea of the scheduler is that you can define opReports "jobs" to be taken care of at a particular time in the future, and such jobs can consist of actions to be taken both at the commencement and the termination of the reporting job period.

Limitations

As of version 2.6.1 this feature is to be considered a bit experimental and some of the details will likely have to change during the next few releases.

  • Currently only the scheduling of Interface Utilisation Reports is supported.
  • Scheduled jobs are currently one-offs, but support for jobs that run periodically is planned.
  • The NMIS remote control feature is very much geared towards Interface Utilisation Reports at this time.
  • At this time the only action to take at the beginning of a job is enabling NMIS and setting the listed interfaces and nodes for collection; This capability set will definitely be extended.

Scheduling Reports

Scheduled jobs are controlled by a JSON file that defines the job parameters. The scheduler looks for these files in /usr/local/opmantek/conf/schedule, but this is configurable (see <omk_schedule> in conf/opReports.nmis).

All job files must be called <something>.json, and only letters, digits, dot, underscore and hyphen are allowed in the file name. All other files are silently ignored. (You can thus disable a job by naming it something like !disabled_job.json.)

A job file will normally consist of one "hash" datastructure, with the following properties (list subject to change/amendment):

PropertyValuesDescription

type

"util" (fixed!)The report type to generate. This MUST be present to advise the scheduler what to do. See Limitations above.
description"some text"A free-form description of the scheduled job. Optional.
start1-14-2015 20:00:00

The date + time the report collection is to start at. This uses the same format  as elsewhere in opReports (e.g. "4-jan-2014 17:23:06")

end The date + time the report collection is to end at.
node_intf_list/some/where/some.fileThe file describing the nodes and interfaces to collect. See section below for format.
util_threshold80

The desired interface utilisation threshold value (in percent), default: 80 (percent).

util_threshold_mincount1

The desired minimum number of threshold exceedences for flagging the interface as over-limit, default: 1.

format

 

"html"
"csv"
The format the  report should be saved in.
targetfile/some/where/new.fileWhere the report should be saved. This has to be a full path, and the file this points to will  be overwritten when the report is generated.
control_nmis

"true"

"false"

Whether NMIS should be "remote controlled" or left in peace. See section on Remote Controlling NMIS below.
nmis_options"mthread=true maxthreads=15"Options to be given to nmis.pl type=update. Optional, and ignored if control_nmis is false.

Besides these the scheduler will also manage certain other properties for internal use, and you should not modify these! (Currently this includes the properties "active" and "completed".)

The scheduler checks the start and end dates and determines whether any actions need to be taken; if the start time has been reached, then the job is marked as active (and optionally NMIS is remote controlled). When the end time has been reached for an active job, the relevant report is created, the job is marked inactive and completeed (and optionally NMIS can be controlled once more).

When the scheduled run is over, the job file will not be removed and remain behind; you can therefore reuse a job file by simply updating it with new start and end dates, and target file.

Scheduler  Activation

The opReports scheduler at this time is not a long-lived daemon process, but  rather meant to be run suitably frequently from cron. The scheduler does log to opreports.log, but also prints error messages of higher urgency to STDERR, where cron will pick them up and mail them to root (or whatever recipient you have set up).

Here is a recommended cron snippet for /etc/cron.d/opReports:

# Run the opReports Scheduler every 10 minutes
11,21,31,41,51 * * * * root /usr/local/opmantek/bin/opReports-scheduler.pl

If you prefer a per-user crontab, simply remove the "root" column. Naturally, if your scheduled jobs are expected to start or finish on full hours only, then you could reduce the scheduler's run frequency.

Remote-Controlling NMIS

This experimental feature is meant for Interface Utilisation Reports at this time. If your job has control_nmis to true, then the following actions are taken:

  • When the job starts, NMIS is reconfigured with global_collect true and with ONLY the wanted nodes and interfaces (identified by the node_intf_list file) set to collect true. All other interface collection activity is disabled with global_nocollect_ifDescr. An nmis.pl type=update run  will then be performed, and the NMIS data collection commences as normal.
  • When the job  completes, NMIS is disabled, with global_collect set to false.

Node and Interface List

The node and interface list can be given in two forms, JSON and Plain Text:

 

  • JSON: it's expected to be a valid JSON document, consisting of a hash of nodename and value being a list of the interfaces in question.
    E.g.
{ "testnode": [ "eth0" ], "othernode" : [ 1, 2, "Tunnel20" ] }
  • Plain Text: a text file, one entry per line.
    Each entry must start with the nodename, followed by one or more TAB characters, and one or more interfaces (again separated by TAB characters). If you list a node on multiple lines then all  listed  interfaces will be combined into a single list.
    E.g.

    testnode   2   14    eth0
    othernode  Dialer1
    testnode   17

For both JSON and Plain Text formats, interfaces can be identified by the numeric SNMP interface index, or by the SNMP ifDescr property.

 

 

  • No labels