The Cacti Manual
Prev | Chapter 20. Command Line Scripts | Next

# Add Graph Permissions

This script is used to specify special graph permissions to users. The list of parameters is displyed as usual when calling the script with the parameter `--help`

    shell>php -q add_perms.php --help

    Add Permissions Script 1.0, Copyright 2004-2017 - The Cacti Group

    A simple command line utility to add permissions to tree items in Cacti

    usage: add_perms.php [ --user-id=[ID] ]
        --item-type=[graph|tree|host|graph_template]
        --item-id [--quiet]

    Where item-id is the id of the object of type item-type
    List Options:
        --list-users
        --list-trees
        --list-graph-templates
        --list-graphs --host-id=[ID]

## List Users

The list of users is retrieved by calling the script with the parameter `--list-users`. It goes like

    shell>php -q add_perms.php --list-users

    Known Users:
    id      username        full_name
    1       admin   Administrator
    3       guest   Guest Account

## List Trees

The list of trees is retrieved by calling the script with the parameter `--list-trees`. It goes like

    shell>php -q add_perms.php --list-trees

    Known Trees:
    id      sort method                     name
    1       Manual Ordering (No Sorting)    Default Tree

## List Graph Templates

The list of available graph templates is retrieved by calling the script with the parameter `--list-graph-templates`. It goes like

    shell>php -q add_perms.php --list-graph-templates

    Known Graph Templates:(id, name)
    2       Interface - Traffic (bits/sec)
    3       ucd/net - Available Disk Space
    4       ucd/net - CPU Usage
    5       Karlnet - Wireless Levels
    6       Karlnet - Wireless Transmissions
    7       Unix - Ping Latency
    8       Unix - Processes
    9       Unix - Load Average
    ...

## List Graphs for given Hosts

To be able to add a permissions to a specific Graph, the id of that very graph is required. Thus, a `--list-graphs --host-id=[id]` option was implemented

    shell>php -q add_perms.php --list-graphs --host-id=1

    Known Host Graphs: (id, name, template)
    1       Localhost - Memory Usage        	Linux - Memory Usage
    2       Localhost - Load Average        	Unix - Load Average
    3       Localhost - Logged in Users     	Unix - Logged in Users
    4       Localhost - Processes   		Unix - Processes
    5       Localhost - Traffic - eth0      	Interface - Traffic (bits/sec, 95th Percentile)
    33      Localhost - Used Space - Memory Buffers Host MIB - Available Disk Space
    34      Localhost - Used Space - Real Memory    Host MIB - Available Disk Space
    35      Localhost - Used Space - Swap Space     Host MIB - Available Disk Space
    36      Localhost - Used Space - /      	Host MIB - Available Disk Space
    37      Localhost - Used Space - /sys   	Host MIB - Available Disk Space
    38      Localhost - Used Space - /boot  	Host MIB - Available Disk Space

## Add Graph Permissions to specific Users

There are various ways to define graph permissions to specific users. First, we will add graph permissions for a given host. This is done using the parameter `--item-type=host` as follows

    shell>php -q add_perms.php --user-id=4 --item-type=host --item-id=1

`--user-id=4` must specify an existing users. Else, an error message will be printed. As `--item-type=host` is given, `--item-id=1` must specify a valid host. Again, if no host with this specific id exists, an error message will be printed. No output is produced on successful operations.

Next, we will add graph permissions for a given tree. This is done using the parameter `--item-type=tree` as follows

    shell>php -q add_perms.php --user-id=4 --item-type=tree --item-id=1

`--user-id=4` must specify an existing users. Else, an error message will be printed. As `--item-type=tree` is given, `--item-id=1` must specify a valid tree (the Default Tree in this case). Again, if no tree with this specific id exists, an error message will be printed. No output is produced on successful operations.

Adding graph permissions for a given graph template is done using the parameter `--item-type=graph_template` as follows

    shell>php -q add_perms.php --user-id=4 --item-type=graph_template --item-id=25

`--user-id=4` must specify an existing users. Else, an error message will be printed. As `--item-type=graph_template` is given, `--item-id=1` must specify a valid graph_template (the Interface - Traffic (bytes/sec) in this case). Again, if no graph template with this specific id exists, an error message will be printed. No output is produced on successful operations.

Last but not least we add graph permissions for a given graph by using the parameter `--item-type=graph` as follows

    shell>php -q add_perms.php --user-id=4 --item-type=graph --item-id=8

`--user-id=4` must specify an existing users. Else, an error message will be printed. As `--item-type=graph` is given, `--item-id=1` must specify a valid graph. Again, if no graph template with this specific id exists, an error message will be printed. No output is produced on successful operations.

Prev | Home | Next
Add Items to a Tree | Up | Debugging