---
layout: docs
title: CLI Tool & Scripting
breadcrumb: [ "advanced.html", "Advanced" ]
---

== Command Line Tool

The command line tool 'thruk' allows the export of excel files and
other reports. When using the source installation, the cli tool is in
script/thruk, when using the packages it will be installed in
'/usr/bin/thruk' and should be directly available in your PATH. Using
the cli tool makes it easy to send regular reports by cron/mail.

Examples:

export the event log as excel file:

------------
  %> thruk -A thrukadmin 'showlog.cgi?view_mode=xls' > eventlog.xls
------------

More examples can be found in the man page or by running 'thruk -h'.



== Scripting

It is possible to do comprehensive scripting with Thruk. For example
set downtimes automatically, schedule reports or change the objects
of your monitoring core configuration.

See link:/api/Thruk/Utils/CLI.html[CLI API] for details and examples.

There are also some scripting examples in the examples folder.


== Curl & Wget
{% include new_since.ad version="2.10" %}
Even when using the Cookie Authentication, it is still possible to use wget
or curl for fetching pages.

------------
  %> curl "http://thrukadmin:thrukadmin@localhost/thruk/cgi-bin/status.cgi?format=json"
------------


== Integration With 3rd Party Software

=== Configuration Generators
If your Object configuration is generated by a 3rd party config
generator, you can export some additional information which is then
displayed in the configuration section of each host or service.
Just export the special custom variables: '_SRC', '_SRC2' or '_SRC3'.
image:source/config_3rd_party.png[3rd Party Config Generator]


== Environment Variables

Most scripts, either `Server Actions` or `Hooks` have access to special environment
variables.

These are the standard variables available:

    ** `REMOTE_USER`          username of the logged in user
    ** `REMOTE_USER_GROUPS`   contact groups of the current user
    ** `REMOTE_USER_ALIAS`    contact alias name (if available)
    ** `REMOTE_USER_EMAIL`    contact email address (if available)
    ** `THRUK_REQ_URL`        contains the current url
