Commandline Parameters
Access all Checkmk commands with ./cmdbsyncer checkmk <command> <account>.
| Command | Description |
|---|---|
| export_hosts | Export hosts to the Checkmk instance |
| export_groups | Create Checkmk groups based on your rules |
| export_rules | Export Checkmk setup rules to the instance (supports --dry-run, see below) |
| export_tags | Export host tag group configuration to Checkmk |
| export_users | Create, update, or disable users in Checkmk |
| export_ldap_connections | Create, update or delete the LDAP connections for the Checkmk login |
| export_downtimes | Export scheduled downtimes to Checkmk |
| export_notifications | Export notification rules to Checkmk (2.4 / 2.5 only) |
| export_dcd_rules | Export DCD (Dynamic Configuration) rules to Checkmk |
| export_bi_aggregations | Export BI aggregation rules to Checkmk |
| export_bi_rules | Export BI rules to Checkmk |
| activate_changes | Activate pending changes on the Checkmk instance |
| bake_and_sign_agents | Bake agents — requires bakery_key_id and bakery_passphrase in account settings |
| import_v2 | Import hosts from Checkmk 2.x into the Syncer |
| import_v1 | Import hosts from Checkmk 1.x into the Syncer |
| inventorize_hosts | Run inventory to fetch attributes from Checkmk into the Syncer |
| show_hosts | Print all hosts that would be exported to Checkmk |
| show_labels | List all labels that would be set in Checkmk after the sync |
| show_missing_hosts | Show hosts present in Checkmk but not in the Syncer |
| assign_template | Assign a CMDB template to every host of a Checkmk folder (see below) |
| analyse_rules | Find Setup Rules whose export lists hundreds of hostnames and suggest a host label (account optional) |
Improve Setup Rules that name every host individually
Since 4.3
analyse_rules finds the Setup Rules whose export ends up listing hundreds of
hostnames in one condition, and the host attribute that could replace that list.
It can apply the change for you. See
Rule Optimization for the full description.
./cmdbsyncer checkmk analyse_rules --min-hosts 50
| Option | Description |
|---|---|
--min-hosts |
Only report rules built from at least this many hosts (default: 10). |
--top |
How many of the largest rules to report (default: 20). |
--apply |
Make the change instead of only reporting it. |
--hash-labels |
With --apply: match on a hash instead of letting raw attribute values through as Checkmk labels. |
The account argument is optional, and nothing is ever sent to Checkmk.
Assign a CMDB template from a Checkmk folder
Since 4.3
Unlike the commands above, assign_template takes extra arguments — the Checkmk
folder and the template name:
./cmdbsyncer checkmk assign_template <account> <folder> <template> [--dry-run]
It reads the hosts of the given Checkmk folder and assigns the named CMDB template to
each host that exists in the Syncer. Use --dry-run to preview which hosts would be
changed without writing anything.
Try the rule export out before it runs
Since 4.3.5
export_rules takes --dry-run. The run still reads Checkmk and still
calculates every rule, but nothing is sent to the site — no rule is created,
updated, deleted or moved:
./cmdbsyncer checkmk export_rules <account> --dry-run
Every change the run decided on is printed with the ruleset and, for a rule Checkmk already has, its rule id:
- a create with the folder, the condition and the value it would write,
- an update with the value and the difference behind it (a changed value, a changed host list or a rewritten description),
- a delete with the reason it is no longer needed,
followed by a summary line such as
3 change(s) pending: 1x CREATE, 1x DELETE, 1x UPDATE. The same lines are
written to the run log under Settings → Log, each marked [dry-run].
Use it to read a changed Value Template before it reaches the site, and to see
what a disabled rule or a new remove_orphaned_rules setting would delete.
Rule order is not part of a dry run
The reorder step is skipped. It builds its move chain from the ids Checkmk returns for the rules created in the run, and a dry run creates none — so there is nothing it could truthfully report.
Debugging
Add --debug to any command to raise exceptions and enable verbose logging. Add --debug-rules=hostname to inspect rule outcomes for a specific host. See Debugging for details.
On export_rules, --debug also prints the difference behind every rule the run deletes.
Add --dry-run to simulate an export without making any changes. Add --save-requests to write all planned API requests to a file for review.