10.20. Command line tools

10.20.1. Indroduzione

Questi sono tutti i sotto-comandi del comando:

sanet-manage  <comando>  [ <parametri> ]

Note

Questo comando e' equivalente al comando:

python {{SANET_INSTALL_DIR}}/manage.py <comando> [ <parametri> ]

10.20.2. Main modules

10.20.2.1. django.contrib.auth

Management utility to create superusers.

10.20.2.2. core

10.20.2.2.2. broker_info

Mostra informazioni sullo stato del sistema di comunicazione tra i processi del sistema:

broker_info [--flat] [ --broker <connection string> ] [queues]

Warning

This is an internal Sanet command. It is not recommended to use this command.

10.20.2.2.3. cache_info

Syntax:

sanet-manage cache_info info

sanet-manage cache_info keys [ <patter> [ sorted ] ]

Extract informations about Sanet caching subsystem.

Warning

This is an internal Sanet command. It is not recommended to use this command.

10.20.2.2.4. change_password

Syntax:

sanet-manage change_password [options] [ <username> ]

Changes password of the given user username.

It username is not specified, the current shell user is used.

Example:

sanet-mange change_password user1

Note

This is an alias for the changepassword django command.

10.20.2.2.5. check_active_rrds

Syntax:

sanet-manage check_active_rrds

Prints informations about RRD files.

Warning

This is an internal Sanet command. It is not recommended to use this command.

10.20.2.2.6. check_logs_consistency

Syntax:

sanet-manage check_logs_consistency [--start YYYY-MM-DD] [--end YYYY-MM-DD]

Verifies inconsistent Condition logs selected between start and end dates.

Warning

This is an internal Sanet command. It is not recommended to use this command.

10.20.2.2.7. check_multiple_primary

Syntax:

sanet-manage check_multiple_primary [options]

Options:

--tenant <name>    Limit the check to the given tenant.

Verifies if there are multiple primary conditions configured for a monitored element.

Warning

This is an internal Sanet command. It is not recommended to use this command.

10.20.2.2.8. check_scheduling_config

Utiliti per segnalare "inconsistenze"/"incoerenze" di configurazione negli scheduling group.

10.20.2.2.9. check_schema

Syntax:

sanet-mange check_schema

Updates Sanet DataBase schema.

Warning

This is an internal Sanet command. It is not recommended to use this command.

10.20.2.2.10. clean_rrds

Syntax:

sanet-mange clean_rrds [options]

Removes orphans RRD files.

A RRD file is orphan when :

  • it's related to a deleted datasource.

  • it's related to a datasource with the save-value flag set to False.

Options:
  • --print-only : Does not perform any action.

  • --remove-no-save-value : Removes files linked to datasources with flag "save-value" set to False.

10.20.2.2.11. create_datasource_store

Syntax:

sanet-manage create_datasource_store [optioni] <path | id>

Initialize the storage (RRD file) for the given datasource.

Options:

--tenant <name>   Specify the tenant, otherwise the primary tenant is selected. 

Example:

sanet-manage create_datasource_store 'localhost;;datagroup-test;datasource1'

sanet-manage create_datasoruce_store 117634a4962841f2952695a92c3b6c1d

Warning

This is an internal Sanet command. It is not recommended to use this command.

10.20.2.2.12. create_super_user

Syntax:

sanet-manage create_super_user [options]

Create a new user with superuser privileges (flag set to true).

--username <username>
--email    <email>

Example:

sanet-manage create_super_user --username admin2 --email admin2@labs.it

Note

This is an alias for the createsuperuser django command.

10.20.2.2.13. datasource_produce_random_values

Syntax:

sanet-manage datasource_produce_random_values [ --tenant <name> ] <path datasource> <DD-MM-YYYY inizio> <DD-MM-YYYY fine> <minvalue>-<max>

Generate and stores random values for the given datasource, between the selected time range.

Warning

This is an internal Sanet command. It is not recommended to use this command.

Example:

sanet-manage datasource_produce_random_values 'localhost;;cpu-hr;cpuperc-hr' '01-01-2016' '01-03-2016' 0-1000

10.20.2.2.15. dbusage

Syntax:

sanet-manage dbusage

Show informations about DataBase's running queries.

Warning

This is an internal Sanet command. It is not recommended to use this command.

10.20.2.2.17. erase_queue

Syntax:

erase_queue <queue_id>

Erase the given IPC queue queue_id.

Warning

This is an internal Sanet command. It is not recommended to use this command.

10.20.2.2.18. exec_datagroup

Launch:

sanet-manage exec_datagroup [options] ( <UUID> | <path> )

Available options are:

-l <n>            Imposta il livello di logging al valore <n>, 1 debug massimo, 10 debug normale, 20 info.
--tenant <nome>   Esegue il datagroup del tenant specificato. Default: Tenant primario
10.20.2.2.18.1. Examples

Check the datagroup xha;;icmp-reachability

# python manage.py exec_datagroup 'xha;;icmp-reachability' -l 10
2013-07-25 19:03:19,656 DEBUG MainThread > Loading cache manager...
2013-07-25 19:03:19,662 DEBUG MainThread > Loading datasource store...
2013-07-25 19:03:19,672 DEBUG MainThread > Loading data...
2013-07-25 19:03:19,687 DEBUG MainThread > Using default tenant: <Tenant:10a279a6ce5c4438a98f9c33c0b77cde:site>
2013-07-25 19:03:19,692 DEBUG MainThread > Loading system symbols
2013-07-25 19:03:19,728 INFO MainThread > Loading extra symbols from ['sanet_extra.agent.functions.rtt_pingerd']
2013-07-25 19:03:19,740 DEBUG MainThread > ########################################################
2013-07-25 19:03:19,741 DEBUG MainThread > ###################### CHECKING ########################
2013-07-25 19:03:19,741 DEBUG MainThread > ########################################################
2013-07-25 19:03:19,741 DEBUG MainThread > Checking datagroup 1081cb2edf8f4a5ca49e68e6bdc83004 at 1374771799.74
2013-07-25 19:03:19,741 DEBUG MainThread > Loading previeous execution state...
2013-07-25 19:03:19,743 DEBUG MainThread > Loading free parameters
2013-07-25 19:03:19,748 DEBUG MainThread >   params 'probesize' = (3) 1472 
2013-07-25 19:03:19,763 DEBUG MainThread > -------------------------- Calculating datasource rttmin ---------------- 
2013-07-25 19:03:19,764 DEBUG MainThread > Evaluating datasource xha;;icmp-reachability;rttmin
2013-07-25 19:03:19,764 DEBUG MainThread > $delta = 11.4565660954
2013-07-25 19:03:19,765 DEBUG MainThread > getRttInfo_pingerd(ipv=None, host=2a01:4f8:110:3383::1, tries=None, probe=1472.0, timeout=None, frag=False, bind=None)
2013-07-25 19:03:19,765 WARNING MainThread > PINGERD_ADDRESS not defined in environment! Using normal ping
2013-07-25 19:03:19,765 DEBUG MainThread > Resolving ipv=6, host=2a01:4f8:110:3383::1
2013-07-25 19:03:19,767 DEBUG MainThread > 2a01:4f8:110:3383::1: Sending IPv6 pings.
2013-07-25 19:03:19,767 DEBUG MainThread > exec_ping: ping6 -c 1 -s 1472 -A -W 1.0 -n '2a01:4f8:110:3383::1'
2013-07-25 19:03:19,875 DEBUG MainThread > exec_ping: ping6 -c 1 -s 1472 -A -W 1.0 -n '2a01:4f8:110:3383::1'
2013-07-25 19:03:19,980 DEBUG MainThread > exec_ping: ping6 -c 1 -s 1472 -A -W 1.0 -n '2a01:4f8:110:3383::1'
2013-07-25 19:03:20,087 DEBUG MainThread > exec_ping: ping6 -c 1 -s 1472 -A -W 1.0 -n '2a01:4f8:110:3383::1'
2013-07-25 19:03:20,193 DEBUG MainThread > exec_ping: ping6 -c 1 -s 1472 -A -W 1.0 -n '2a01:4f8:110:3383::1'
2013-07-25 19:03:20,300 DEBUG MainThread > 2a01:4f8:110:3383::1: got ping answer #0 in 0.107907 s
2013-07-25 19:03:20,301 DEBUG MainThread > 2a01:4f8:110:3383::1: got ping answer #1 in 0.104681 s
2013-07-25 19:03:20,301 DEBUG MainThread > 2a01:4f8:110:3383::1: got ping answer #2 in 0.106491 s
2013-07-25 19:03:20,301 DEBUG MainThread > 2a01:4f8:110:3383::1: got ping answer #3 in 0.106536 s
2013-07-25 19:03:20,301 DEBUG MainThread > 2a01:4f8:110:3383::1: got ping answer #4 in 0.106056 s
2013-07-25 19:03:20,302 DEBUG MainThread > avg=0.1063342, min=0.104681, max=0.107907, loss=0.0
2013-07-25 19:03:20,303 DEBUG MainThread > Check result 1374771799.76, SV, 0.104681, [u"expression getICMPStat('rttmin', $node, $probesize) expanded to 0.104681"]
2013-07-25 19:03:20,303 DEBUG MainThread > Saving rttmin = 0.104681
2013-07-25 19:03:20,303 DEBUG MainThread > Saving rttmin/lastgoodcheck = 1374771800.303601
2013-07-25 19:03:20,304 DEBUG MainThread > -------------------------- Calculating datasource rttmax ---------------- 
2013-07-25 19:03:20,304 DEBUG MainThread > Evaluating datasource xha;;icmp-reachability;rttmax
2013-07-25 19:03:20,304 DEBUG MainThread > $delta = 11.9944171906
2013-07-25 19:03:20,306 DEBUG MainThread > getRttInfo_pingerd(ipv=None, host=2a01:4f8:110:3383::1, tries=None, probe=1472.0, timeout=None, frag=False, bind=None)
2013-07-25 19:03:20,307 DEBUG MainThread > SIMPLEVALUE CACHE HIT: 2a01:4f8:110:3383::1:1472:5:1.0:False:None:6 = (0.1063342, 0.104681, 0.107907, 0.0, []) <type 'tuple'>
2013-07-25 19:03:20,307 DEBUG MainThread > Check result 1374771800.3, SV, 0.107907, [u"expression getICMPStat('rttmax', $node, $probesize) expanded to 0.107907"]
2013-07-25 19:03:20,307 DEBUG MainThread > Saving rttmax = 0.107907
2013-07-25 19:03:20,307 DEBUG MainThread > Saving rttmax/lastgoodcheck = 1374771800.307629
2013-07-25 19:03:20,308 DEBUG MainThread > -------------------------- Calculating datasource rttavg ---------------- 
2013-07-25 19:03:20,308 DEBUG MainThread > Evaluating datasource xha;;icmp-reachability;rttavg
2013-07-25 19:03:20,308 DEBUG MainThread > $delta = 11.9975709915
2013-07-25 19:03:20,309 DEBUG MainThread > getRttInfo_pingerd(ipv=None, host=2a01:4f8:110:3383::1, tries=None, probe=1472.0, timeout=None, frag=False, bind=None)
2013-07-25 19:03:20,309 DEBUG MainThread > SIMPLEVALUE CACHE HIT: 2a01:4f8:110:3383::1:1472:5:1.0:False:None:6 = (0.1063342, 0.104681, 0.107907, 0.0, []) <type 'tuple'>
2013-07-25 19:03:20,309 DEBUG MainThread > Check result 1374771800.31, SV, 0.1063342, [u"expression getICMPStat('rttavg', $node, $probesize) expanded to 0.1063342"]
2013-07-25 19:03:20,310 DEBUG MainThread > Saving rttavg = 0.1063342
2013-07-25 19:03:20,310 DEBUG MainThread > Saving rttavg/lastgoodcheck = 1374771800.31033
2013-07-25 19:03:20,310 DEBUG MainThread > -------------------------- Calculating datasource lossperc ---------------- 
2013-07-25 19:03:20,310 DEBUG MainThread > Evaluating datasource xha;;icmp-reachability;lossperc
2013-07-25 19:03:20,311 DEBUG MainThread > $delta = 11.9995350838
2013-07-25 19:03:20,311 DEBUG MainThread > getRttInfo_pingerd(ipv=None, host=2a01:4f8:110:3383::1, tries=None, probe=1472.0, timeout=None, frag=False, bind=None)
2013-07-25 19:03:20,312 DEBUG MainThread > SIMPLEVALUE CACHE HIT: 2a01:4f8:110:3383::1:1472:5:1.0:False:None:6 = (0.1063342, 0.104681, 0.107907, 0.0, []) <type 'tuple'>
2013-07-25 19:03:20,312 DEBUG MainThread > Check result 1374771800.31, SV, 0.0, [u"expression getICMPStat('loss', $node, $probesize) expanded to 0"]
2013-07-25 19:03:20,312 DEBUG MainThread > Saving lossperc = 0.0
2013-07-25 19:03:20,312 DEBUG MainThread > Saving lossperc/lastgoodcheck = 1374771800.312801
2013-07-25 19:03:20,319 DEBUG MainThread > -------------------------- Calculating condition reach ---------------- 
2013-07-25 19:03:20,319 DEBUG MainThread > Checking condition reach
2013-07-25 19:03:20,319 DEBUG MainThread > $delta = 12.0010859966
2013-07-25 19:03:20,320 DEBUG MainThread > Saving reach/lastgoodcheck = 1374771800.320371
2013-07-25 19:03:20,320 DEBUG MainThread > Check result 1374771800.32, result=True, infos=[u' {lossperc@} < 1 expanded to (0 < 1)']
2013-07-25 19:03:20,320 DEBUG MainThread > Old state  : UP
2013-07-25 19:03:20,320 DEBUG MainThread > New state  : UP
2013-07-25 19:03:20,321 DEBUG MainThread > Updating condition state
2013-07-25 19:03:20,321 DEBUG MainThread >      UP -> UP
2013-07-25 19:03:20,321 DEBUG MainThread > Updating penalty--->TODO
2013-07-25 19:03:20,321 DEBUG MainThread > Checking all changed fields...
2013-07-25 19:03:20,321 DEBUG MainThread > ----------------------- Saving execution state ----------------------
2013-07-25 19:03:20,322 DEBUG MainThread >      lossperc = 0.0
2013-07-25 19:03:20,322 DEBUG MainThread >      lossperc/lastgoodcheck = 1374771800.312801
2013-07-25 19:03:20,322 DEBUG MainThread >      reach/lastgoodcheck = 1374771800.320371
2013-07-25 19:03:20,322 DEBUG MainThread >      rttavg = 0.1063342
2013-07-25 19:03:20,323 DEBUG MainThread >      rttavg/lastgoodcheck = 1374771800.31033
2013-07-25 19:03:20,323 DEBUG MainThread >      rttmax = 0.107907
2013-07-25 19:03:20,323 DEBUG MainThread >      rttmax/lastgoodcheck = 1374771800.307629
2013-07-25 19:03:20,323 DEBUG MainThread >      rttmin = 0.104681
2013-07-25 19:03:20,324 DEBUG MainThread >      rttmin/lastgoodcheck = 1374771800.303601
2013-07-25 19:03:20,324 DEBUG MainThread > ----------------------- Element fields to update ----------------------
2013-07-25 19:03:20,324 DEBUG MainThread > ----------------------- Pushing updates ----------------------
2013-07-25 19:03:20,325 DEBUG MainThread > Check finished. Update data = 
2013-07-25 19:03:20,331 DEBUG MainThread > 
[{'conditions_updates': {u'74d5c331cbeb44b093d76310cb65bcce': {'fields': {'lastdone': 1374771800.320735},
                                                               'infos': [u' {lossperc@} < 1 expanded to (0 < 1)'],
                                                               'time': 1374771800.319544,
                                                               'uuid': u'74d5c331cbeb44b093d76310cb65bcce'}},
  'datagroup_id': u'1081cb2edf8f4a5ca49e68e6bdc83004',
  'datagroup_updates': {},
  'datasources_updates': {u'09893adb00874763ade0ffaece3a58da': {'fields': {'lastdone': 1374771799.764363,
                                                                           'lastvalue': 0.104681},
                                                                'infos': [u"expression getICMPStat('rttmin', $node, $probesize) expanded to 0.104681"],
                                                                'time': 1374771799.764363,
                                                                'uuid': u'09893adb00874763ade0ffaece3a58da'},
                          u'5dca34f65bc949d0bf22d504b67ba976': {'fields': {'lastdone': 1374771800.308346,
                                                                           'lastvalue': 0.1063342},
                                                                'infos': [u"expression getICMPStat('rttavg', $node, $probesize) expanded to 0.1063342"],
                                                                'time': 1374771800.308346,
                                                                'uuid': u'5dca34f65bc949d0bf22d504b67ba976'},
                          u'5f2df9582cad41c5bc4b279a099cdef1': {'fields': {'lastdone': 1374771800.304476,
                                                                           'lastvalue': 0.107907},
                                                                'infos': [u"expression getICMPStat('rttmax', $node, $probesize) expanded to 0.107907"],
                                                                'time': 1374771800.304476,
                                                                'uuid': u'5f2df9582cad41c5bc4b279a099cdef1'},
                          u'8fb653003b914bba92c61e13ffc19d6f': {'fields': {'lastdone': 1374771800.31103,
                                                                           'lastvalue': 0.0},
                                                                'infos': [u"expression getICMPStat('loss', $node, $probesize) expanded to 0"],
                                                                'time': 1374771800.31103,
                                                                'uuid': u'8fb653003b914bba92c61e13ffc19d6f'}},
  'element_id': u'6bd8081044cf4f58a932f3c0ee265f13',
  'elements': {},
  'mtime': 1373626873.01769}]

10.20.2.2.19. exec_expr

Launch:

sanet-manage exec_expr [options] <node>[:<subentity>] [ <expression> ]

The program will evaluate a generic expression using informations about the specified node / subentity (interface, storage, device, service).

If node (or the subentity) are present inside SANET's configuration, the programm will load all default node/subentity variables .

Options:

--stdin           Additional parameters (and the expression) will be read line by line from standard input. The parameter expression can be read from standard input too. See later in this section.

--tenant <name>   The expression will be evaluated with data taken from the selected tenant instead of from the primary tenant. 
10.20.2.2.19.1. Examples

Generic expression on a generic host not defined inside SANET:

# python manage.py exec_expr localhost '1+1'

Output:

2013-07-25 18:53:46,638 DEBUG MainThread > Loading tenant environment
2013-07-25 18:53:46,654 DEBUG MainThread > Using default tenant: <Tenant:10a279a6ce5c4438a98f9c33c0b77cde:site>
...
...
...
2013-07-25 18:53:46,790 DEBUG MainThread > evaluated()
VALUE: 2
INFOS:

Retrieve SysName from node mason defined inside Sanet:

# python manage.py exec_expr mason '1.3.6.1.2.1.1.1.0@'

Output:

2013-07-25 18:55:31,989 DEBUG MainThread > Loading tenant environment
...
...
...
2013-07-25 18:55:32,201 DEBUG MainThread > evaluated()
VALUE: Linux mason 2.4.34.5 #12 Tue Jun 26 14:09:29 CEST 2007 i686
INFOS:
10.20.2.2.19.2. Specify additional variables and expression from standard input

Additional variables can be specified line by line throw standard input which must have the following syntax:

$variable_name [ "=" <type> ] "=" <value>

where:

  • $*variable_name* : Must be a valid expression variable (es: $foo)

  • type : (optional) Must be a valid type-string: num, string. Default is: string.

  • value : The symbols' value.

Example:

# python manage.py exec_expr --stdin mason '10 * $myvariable'
$myvariable=num=5

*Ctrl+D*

Output:

2013-07-25 18:57:53,205 DEBUG MainThread > Loading tenant environment
2013-07-25 18:57:53,220 DEBUG MainThread > Using default tenant: <Tenant:10a279a6ce5c4438a98f9c33c0b77cde:site>
...
...
...
2013-07-25 18:58:03,262 DEBUG MainThread > evaluated()
VALUE: 50.0
INFOS:
10.20.2.2.19.3. Specify the expression from standard input

If you want to specify the expression from standard input, you must append a blank line after parameters' lines and enter the expression string.

Esample:

# python manage.py exec_expr --stdin mason '10 * $myvariable'
$myvariable1=hello
$myvariable2=world
$myvariable3=it's
$myvariable4=me

$myvariable + 1
*Ctrl+D*

Output:

2013-07-25 18:57:53,205 DEBUG MainThread > Loading tenant environment
2013-07-25 18:57:53,220 DEBUG MainThread > Using default tenant: <Tenant:10a279a6ce5c4438a98f9c33c0b77cde:site>
...
...
...
2013-07-25 18:58:03,262 DEBUG MainThread > evaluated()
VALUE: 6
INFOS:

10.20.2.2.20. exec_timegraph

Launch:

sanet-manage exec_timegraph [opzioni] <datagroup> <timegraph name>

sanet-manage exec_timegraph [opzioni] <timegraphid>

Testare un timegraph

Le opzioni disponibili sono:

--tenant <nome>   Esegue il datagroup del tenant specificato. Default: Tenant primario

--seconds <n>     Imposta quanto indietro nel tempo rispetto all'istante di esecuzione utilizzare per calcolare i dati delle serie.

--export          Le serie del timegraph vengono esportate in formato CSV

--graph           Show graph with ascii.
10.20.2.2.20.1. Esempi

Alcuni esempi:

sanet-manege exec_timegraph 8f4e95cd2de54a888cfd92eb974ae83b --seconds=3000 --export

sanet-manage exec_timegraph 'localhost;;icmp-reachability'  rttgraph  --seconds=3000 --export

10.20.2.2.21. extract_conditions

Syntax:

sanet-manage extract_conditions [options]

List all the defined conditions.

Options:

--tenant <tenant>          Specify the tenant to use.

--priority_value <num>     Filter by priority value *num*.
--priority_label <label>   Filter by priority level *name*.

Output format:

<element type> , <primary flag> , <path>

Example:

node,*,localhost;;icmp-reachability;reach

10.20.2.2.22. fetch_ds_rrddata

Sintassi:

sanet-manage fetch_ds_data [-h] [--tenant <name> ] -- <path | uuid>  [-s <start>] [-e <end>]

Important

E' fondamentale che la sequenza di escape '--' venga indicata prima del <path> o <uuid>.

Opzioni:

-h               Mostra l'help
--tenant <name>  Specifica su quale tenant cercare il datasource <path>
-s <start>       Istante temporale di inizio estrazione.
-e <end>         Istante finale di inizio estrazione.

I parametri start e end permettono di specificare un valore nei seguenti formati:

  • timestamp (es. 121342342)

  • range tempolae supportato da RRDTOOL (es: -400s, -8h, ecc.)

Esempio:

sanet-manage fetch_ds_rrddata -- 'localhost;;cpu-hr;cpuperc-hr' -s -408s

10.20.2.2.23. fix_dead_users

Poiche' il database e' suddiviso in schemi, quando un utente viene cancellato il sistema di "delete cascade" di django potrebbe non "azzerare" correttamente i field "owner" in diverse tabelle.

Questo comando verifica e azzera il field "owner" se associato ad un User.id non piu' esistente.

10.20.2.2.24. fix_ds_storage_spec

Fix datasources storage and metadata informations.

Syntax:

fix_ds_storage_spec

The operations performed by this command depend of the used datasource storage backend. See Moduli di backend for details.

10.20.2.2.25. get_config

Lancio:

sanet-manage get_config [-J] [ key1 [, key2... ] ]

Esporta su standard output la configurazione

10.20.2.2.25.1. Output di tutta la configurazione

In assenza di parametri key1, ecc.. viene prodotta tutta la configurazione.

Ogni riga in output e' nel formato:

<variable> <valore>

Esempio:

$ sanet-manage get_config

...
BASE_DIR /opt/sanet3
BASE_URL_PREFIX 
BASE_WEB_URL_PREFIX web
BROKER_ADDRESS ('localhost',)
BROKER_AUTH ('sanet', 'sanet')
COMMENTS_ALLOW_PROFANITIES False
ADMINS ()
ADMIN_FOR ()
ALLOWED_INCLUDE_ROOTS ()
APPEND_SLASH True
AUTHENTICATION_BACKENDS ('sanet_common.django.auth.backends.dummy.DummyBackend',)
BASE_DIR /opt/sanet3
BASE_URL_PREFIX 
BASE_WEB_URL_PREFIX web
BROKER_ADDRESS ('localhost',)
BROKER_AUTH ('sanet', 'sanet')
CACHES {'default': {'LOCATION': '', 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache'}}
10.20.2.2.25.2. Configurazione in formato JSON

Con il parametro -J l'output prodotto e' un dizionario in formato JSON con tutte le chiavi estratte.

$ sanet-manage get_config  -J
{
        "SANET_INSTALL_DIR": "/home/dbilli/labs/sanet3/sanet-svn/branches/unstable-3/sanet",
        "SANET_PYTHON_BIN_PATH": null,
        "SANET_RELEASE": "3",
        "SANET_SUB_VERSION": "7",
        "SANET_VERSION": "3",
        "SANET_VERSION_FULL_RELEASE": "3.7.3",
        "SANET_VERSION_FULL_VERSION": "3.7",
        "SECRET_KEY": "0a#*qh2(*)d*7pa1b+fo)+47_a%bf7-xtllotfzz&h8vmc4#z!",
        "SECURE_BROWSER_XSS_FILTER": false,
        ...
        ...
}
10.20.2.2.25.3. Output di singoli parametri

Specificando nomi di parametri key1, key2, ec... si possono estrarre i valori di singoli parametri di configurazione.

Esempio 1:

# sanet-manage get_config DATABASE_NAME
sanet3

Esempio 2:

# sanet-manage get_config DATABASES
{'default': {'ENGINE': 'django.db.backends.postgresql_psycopg2', 'HOST': '127.0.0.1', 'PORT': 5432, 'NAME': 'sanet3_unstable37_test', 'USER': 'sanet', 'PASSWORD': 'sanet', 'ATOMIC_REQUESTS': False, 'AUTOCOMMIT': True, 'CONN_MAX_AGE': 0, 'OPTIONS': {}, 'TIME_ZONE': None, 'TEST': {'CHARSET': None, 'COLLATION': None, 'NAME': None, 'MIRROR': None}}}

Specificando piu' di una chiava ogni chiave rerra' prodotta su righe diverse:

# sanet-manage get_config DATABASE_NAME WEBSERVER_USER 
sanet3
www-data

Se viene indicato il paramet -J, il valore per ogni singola riga verra' formattato in formato JSON:

# sanet-manage get_config -J DATABASE_NAME WEBSERVER_USER  DATABASES  
"sanet3"
"www-data"
{ "default": { "ENGINE": "django.db.backends.postgresql_psycopg2", "HOST": "127.0.0.1", "PORT": 5432, "NAME": "sanet3_unstable37_test", "USER": "sanet", "PASSWORD": "sanet", "ATOMIC_REQUESTS": false, "AUTOCOMMIT": true, "CONN_MAX_AGE": 0, "OPTIONS": {}, "TIME_ZONE": null, "TEST": { "CHARSET": null, "COLLATION": null, "NAME": null, "MIRROR": null } }
10.20.2.2.25.4. Prefisso "json:" per le chiavi

Se viene aggiunto il prefisso "json:" alle chiavi specificate a riga di comando, i valori delle chiavi saranno formattati in formato JSON:

Esempio: Primo parametro non formattato, secondo e terzo parametro formatati in formato JSON

$ sanet-manage get_config  DATABASE_NAME json:BROKER_ADDRESS json:WEBSERVER_USER
sanet3_unstable37_test
["localhost", 6379]
"www-data"
10.20.2.2.25.5. Estrarre "sotto-chiavi"

Per estrarre "sotto-chiavi" o "sotto-elementi" e' possibile usare il formato "key1.key2.key3...".

$ sanet-manage get_config DATABASES.default.NAME  BROKER_ADDRESS  BROKER_ADDRESS.0
sanet3_unstable37_test
('localhost', 6379)
localhost
$ sanet-manage get_config DATABASES.default.NAME  json:BROKER_ADDRESS  json:BROKER_ADDRESS.0
sanet3_unstable37_test
["localhost", 6379]
"localhost"

10.20.2.2.26. get_ds_filename

Read datasources' path (or UUID) from stdin and returns the path of the related store file (RRD FILE)

Uso:

::

sanet-manage get_ds_filename [options]

Opzioni:

--tenant name           Seleziona il tenant di riferimento.
--usauuid               Legge da standainput UUID di datasource al posto di path.

Esempio 1:

sanet-manage get_ds_filename
localhost;;cpu-hr;cpuperc-hr
Cltr+D

localhost;;cpu-hr;cpuperc-hr /home/dbilli/labs/sanet_data2/var/lib/site/rrds/481c58593e2e43aba411b39ce2c71936.rrd

Esempio 2:

sanet-manage get_ds_filename --useuuid
481c58593e2e43aba411b39ce2c71936
Cltr+D

481c58593e2e43aba411b39ce2c71936 /home/dbilli/labs/sanet_data2/var/lib/site/rrds/481c58593e2e43aba411b39ce2c71936.rrd

10.20.2.2.27. get_ds_path

Reads DataSource UUIDS from stdin and returns the corrisponding Sanet Path.

Uso:

sanet-manage get_ds_path [options]

Opzioni:

--tenant name           Seleziona il tenant di riferimento.

Esempio 1:

sanet-manage get_ds_filename
481c58593e2e43aba411b39ce2c71936
Cltr+D
localhost;;cpu-hr;cpuperc-hr

10.20.2.2.28. get_ds_storeinfo

Syntax:

sanet-manage get_ds_storeinfo <path|id>

Returns informations (in JSON format) about the storage linked to the given datasource.

Example:

{
  "filename": "/home/dbilli/labs/sanet3/sanet-svn/branches/unstable-3/sanet/var/lib/827d1a46de1f4effb98042876190bf0d/rrds/95c525e498184de1a0a2d0857af3b7d9.rrd",
  "rrd_version": "0003",
  "step": 300,
  "last_update": 1667473800,
  "header_size": 584,
  "rra": {
    "0": {
      "cf": "AVERAGE",
      "rows": 115120,
      "cur_row": 220,
      "pdp_per_row": 1,
      "xff": 0.5,
      "cdp_prep[0].value": null,
      "cdp_prep[0].unknown_datapoints": 0
    }
  },
  "ds": {
    "data": {
      "index": 0,
      "type": "GAUGE",
      "minimal_heartbeat": 18000,
      "min": null,
      "max": null,
      "last_ds": "1.0",
      "value": 0,
      "unknown_sec": 0
    }
  }
}

10.20.2.2.29. sanetdinfo

Send commands to Sanet main daemon (sanetd).

Warning

This is an internal Sanet command. It is not recommended to use this command.

10.20.2.2.30. push_alarm

Push a raw alarm in Entables pipeline.

TODO

10.20.2.2.31. push_event

Push generic event and process it with the matching with passive datagroup

TODO

10.20.2.2.32. remove_old_logs

Rimuove (per uno o tutti i tenant) alcuni dati piu' vecchi di una data specificata o della retention di default.

I dati che vengono rimossi sono:
  • log delle variazioni di stato delle condition

  • allarmi di entables

La sintassi e':

remove_old_logs [options]
remove_old_logs [options] <YYYY-MM-GG>
remove_old_logs [options] <YYYY-MM-GG HH:MM>

Se viene specificata una data (in formato <YYYY-MM-GG> o <YYYY-MM-GG HH:MM>), verranno cancelli tutti i log precedenti a quella data.

Se non viene specificata una data, verranno cancellati tutti i log precedenti alla retention massima configurata nel file di configurazione di Sanet (DATA_RETENTION_MAX_DAYS).

Le opzioni sono:

--all                                Effettua l'operazione per tutti i tenant dell'installazione. (default: solo sul tenant primario).

--interval        <hours>            Cancella tutti i log un po' per volta, in tanti segmenti termporali di <hours> ore (default: 6 ore).                    

--include-tags    <tag path1>,...    Seleziona solo i log dei nodi taggati in uno dei tag elencati. (non finltra gli allarmi di entables  rimossi)
--exclude-tags    <tag path1>,...    Valido solo se usato con "--include-tags". Esclude le condition taggate nei nodi indicati.  (non finltra gli allarmi di entables  rimossi)
10.20.2.2.32.1. Selezionare solo i log di alcuni apparati

L'opzione "include-tags" permette di rimuovere solo i log dei nodi taggati nei tag specificati (e di tutti gli elementi figli).

Warning

questa opzione tiene conto dello stato del tagging al momento dell'elaborazione. Un nodo cancellato o non taggato non verra' incluso nell'elaborazione e i log corrispondenti non verranno rimossi.

Esempio: Cancella tutti i log dei nodi in "geo:/Geografico/Sede1" e "geo:/Geografico/Sede2"

sanet-manage remove_old_logs --include-tags geo:/Geografico/Sede1,geo:/Geografico/sede2

L'opzione "exclude-tags" serve per escludere da "include-tags" alcuni nodi.

Esempio: Come l'esempio precedente, ma escludendo i nodi presenti in "Vendor:/Vendor/Cisco"

sanet-manage remove_old_logs --include-tags geo:/Geografico/Sede1,geo:/Geografico/sede2 --exclude-tags Vendor:/Vendor/Cisco 2022-01-01

10.20.2.2.33. sanetdata

Lancio:

sanet-manage sanetdata
Questo comando effettua un checkup dell'installazione effettuando le seguenti operazioni automatiche:
  • inizializzazione di directory/file di sistema

  • aggiornamento del database da una release all'altra

  • fix di dati corrotti

Danger

questo comando deve essere SEMPRE eseguito quando sanet NON e' in esecuzione.

Note

Questo comando puo' essere lanciato un numero illimitato di volte.

Attention

Questo comando cancella le sessioni WEB attualmente memorizzate dal sistema. Una volta lanciato, tutte le sessioni WEB che richiedono autenticazione (login) devono essere ripristinate.

10.20.2.2.34. sanetdinfo

Send commands to Sanet main daemon (sanetd).

Warning

This is an internal Sanet command. It is not recommended to use this command.

10.20.2.2.35. statusdinfo

Syntax:

sanet-manage statusdinfo --status

Returns internal status of the statusd subprocess.

Warning

This is an internal Sanet command. It is not recommended to use this command.

10.20.2.2.36. test_user_password

Questo comando verifica le credenziali di accesso di un utente utilizzando il modulo di autenticazione configurato per il sistema:

sanet-manage test_user_password <username>

Esempio:

$ sanet-manage test_user_password foo
Password: *********
Invalid credentials

E' utile per controllare se il sistema di autenticazione utilizzato funziona correttamente:

10.20.2.2.38. test_user_password

Questo comando verifica le credenziali di accesso di un utente utilizzando il modulo di autenticazione configurato per il sistema:

sanet-manage test_user_password <username>

Esempio:

$ sanet-manage test_user_password foo
Password: *********
Invalid credentials

E' utile per controllare se il sistema di autenticazione utilizzato funziona correttamente:

10.20.2.3. cli

10.20.2.3.1. sanetcli

Questo comando lancia la CLI di sanet. I seguenti comandi sono equivalenti:

$ sanet-cli

$ sanet-manage sanetcli

10.20.2.4. tags

10.20.2.4.1. debug_tag_state

Questo comando serve per analizzare l'albero di calcolo degli stati di un TagTree e/o uno specifico Tag di quel Tree.

Utilizzo:

sanet-manage debug_tag_state  <nome tree>  [ <path tag completo ]

Esempio:

sanet-manage debug_tag_state  tree1
sanet-manage debug_tag_state  tree1  "tree1:/Global/Sedi"
sanet-manage debug_tag_state  tree1  "tree1:/Global/Sedi/Pontecchio Marconi"

10.20.2.4.2. fix_parental_relationships

Questo comando serve per analizzare l'albero dei tagtree e fixare eventuali "parentele" sbagliate nei datagroup.

Utilizzo:

sanet-manage fix_parental_relationships  <nome tree> [--tenant <nome tenant>]

Esempio:

sanet-manage fix_parental_relationships  geo

Warning

This is an internal Sanet command. It is not recommended to use this command.

10.20.2.4.3. get_missing_dgtag_number

Questo comando serve per analizzare l'albero dei tagtree e fixare eventuali "parentele" sbagliate nei datagroup.

Utilizzo:

sanet-manage get_missing_dgtag_number [--tenant <nome tenant>]

Esempio:

sanet-manage get_missing_dgtag_number

Warning

This is an internal Sanet command. It is not recommended to use this command.

10.20.2.4.4. get_tag_uuid

Usage:

sanet-manage get_tag_uuid  <tag path>

Prints on standard output the UUID of the given <tag path>.

Example:

$ sanet-manage get_tag_uuid geo:/geo
9677479ea62143ccb6c35e0913b43f57

If the give <tag path> does not exist, the command exits with return code -1.

10.20.2.4.5. get_untagged_nodes

Uso:

sanet-manage get_untagged_nodes [ --tenant <name> ] [ --trees <nomi tree> ]

Restituisce l'elenco dei nodi non presenti in nessuno dei tagtree esistenti (o elencati dal parametro trees) per il tenant tenant.

Esempio: Elenco di tutti i nodi non taggati dentro i tree geo e rancid

sanet-manage get_untagged_nodes --tenant site  --trees geo,rancid

10.20.2.4.7. tag_find_missing_dgs

Questo comando serve per taggare i datagroup non taggati insieme ai propri elementi.

Utilizzo:

sanet-manage tag_find_missing_dgs <tagtree id or name> [--tenant <nome tenant>]

Esempio:

sanet-manage tag_find_missing_dgs <tagtree id or name>

Warning

This is an internal Sanet command. It is not recommended to use this command.

10.20.2.4.8. tags_cleanup

Remove broken references to deleted elements (nodes, interface, conditions, ecc..)

Usage:

sanet-manage tags_cleanup

Warning

This is an internal Sanet command. It is not recommended to use this command.

10.20.2.5. diagnostic

10.20.2.5.1. diagnostic_whitelist_ctl

sanet-manage diagnostic_whitelist_ctl  add  <code> <path>
sanet-manage diagnostic_whitelist_ctl  del  <code> <path>

sanet-manage diagnostic_whitelist_ctl  list    > temp.txt

sanet-manage diagnostic_whitelist_ctl  import  < temp.txt

Parameter "<path>" can be "*".

10.20.2.5.2. find_and_notify_anomalies

Syntax:

sanet-manage find_and_notify_anomalies [options]

Searches for anomalies in Sanet's configuration and notifies them by email.

10.20.2.5.3. find_and_notify_anomalies

Syntax:

sanet-manage refresh_unconfigured_nodes

Searches and refreshes nodes with inconsistent configuration.

This is an INTERNAL command and should not be used for daily routine.

10.20.2.6. webui

10.20.2.6.1. clean_temp_web_data

Lancio:

sanet-manage clean_temp_web_data

Rimuove tutti i file temporanei prodotti dall'interfaccia web durante la gestione delle richieste.

Le directory che vengono controllate sono:

{{VAR_DIR}}/ <tenant uuid> / media / timegraph_images / *

10.20.3. Other modules

10.20.3.1. entables

10.20.3.1.1. entables_cmdline

Syntax:

sanet-manage entables_cmdline [options]

or:

entables [options]

See Comandi di gestione.

10.20.3.1.2. entables_ctl

Send commands to Entables's daemon.

Warning

This is an internal Sanet command. It is not recommended to use this command.

10.20.3.1.3. entables_delete_pending_alarm

Syntax:

sanet-manage entables_delete_pending_alarm [ --tenant <name> ] <uuid>

Questo comando cancella l'allarme con UUID uuid e che si trova in stato HOLD.

Warning

Questo e' un comando interno ed e' pensato per utilizzi di emergenza. Non utilizzatelo in ambienti di produzione all'interno di workflow per la gestione degli allarmi.

10.20.3.1.4. entables_server

INTERAL COMMAND. DO NOT USE.

10.20.3.1.5. entables_test_tags

Syntax:

sanet-manage entables_test_tags share/files/sanet_alarm_example.json  ' ${alarmid} '

Questo comando serve per testare manualmente i tags di entables a partire da un allarme di sanet in formato JSON:

Warning

Questo e' un comando di debug. Non utilizzare.

10.20.3.2. utils

10.20.3.2.1. analyze_log_flapping

Comando:

sanet-manage  analyze_log_flapping  <path>  [options] 

Esempi:

sanet-manage analyze_log_flapping 'localhost;;icmp-reachability;reach'         --start '2023-04-05 13:30:00'         --end   '2023-04-05 14:30:00'         --image /tmp/test.png

sanet-manage analyze_log_flapping 'localhost;;icmp-reachability;reach'        --start '2023-04-05 13:39:00'        --end   '2023-04-05 14:30:00'        --image /tmp/test.png        --flap_penalty_high 5        --flap_penalty_low 3        --flap_penalty 1        --flap_unpenalty 1

10.20.3.2.2. copy_log_from_db

Syntax:

sanet-manage copy_log_from_db <date> --connection-string "dbname=<name> user=<user> password=<pass> host=<hostname> port=<num>"

Example.

sanet-manage copy_log_from_db 2021-01-01 --connection-string "dbname=sanet3 user=sanet password=sanet host=localhost port=5432"

10.20.3.2.3. debug_extract_all_exprs

Extract all exprs used in condition,datasources,xforms,ecc.

Syntax:

sanet-manage debug_extract_all_exprs --tenant site

Example:

# sanet-manage debug_extract_all_exprs
site getICMPStat('loss', $node, $probesize)
site getICMPStat('rttavg', $node, $probesize)
site getICMPStat('rttmax', $node, $probesize)
site getICMPStat('rttmin', $node, $probesize)
site {lossperc@} < 1

10.20.3.2.4. exec_raw_sql

Syntax:

sanet-manage exec_raw_sql 

Read SQL commands from stdin and execute them as a SQL query.

# sanet-manage exec_raw_sql <<EOF
select *
  from table1
;
EOF

10.20.3.2.5. get_netdisco_ports

Esempio:

sanet-manage get_netdisco_ports --node sw2424.localnet.net

sanet-manage iface_status_traffic_stats -n localhost -e $(date -d "$(date -d"today" +%Y-%m-%d) " +%Y-%m-%d) -s $(date -d "$(date -d"today" +%Y-%m-%d) - 1 days" +%Y-%m-%d)

sanet-manage iface_status_traffic_stats -n localhost -e $(date -d "$(date -d"today" +%Y-%m-%d) + 1 days" +%Y-%m-%d) -s $(date -d "$(date -d"today" +%Y-%m-%d) " +%Y-%m-%d)

10.20.3.2.6. set_monitoring_agent

Assign nodes to agent, filtered by tag and/or name.

Syntax:

sanet-manage set_monitoring_agent --agent <name>   [ --tag <path> ] [  --name-regex NAME ]

Options:

-agent AGENT           Target agent's name

--tag  TAG             Select only nodes tagged inside tag with the given path

--name-regex NAME      Select only nodes matching the given regexp.

Example:

sanet-manage set_monitoring_agent --agent second-agent --name '.*'

Assign all nodes to the second-agent.

sanet-manage set_monitoring_agent --agent second-agent --tag 'geo:/earth/italy'

Assign all nodes inside tag 'geo:/earth/italy' to the second-agent.

sanet-manage set_monitoring_agent --agent cisco-switch-agent --tag 'vendor:/Vendors/cisco' --name 'sw-.*'

Assign all nodes inside tag 'geo:/earth/italy' to the second-agent.

10.20.3.2.7. show_exec_times

Syntax:

sanet-manage show_exec_times [ --tree <name>,<name>,<name,...] 

The program will show the total execution time for a single node. The total execution time for a node is calculated by summing all node's datagroups last execution time.

Options:

--tree      List of comma-seprated tagtree names.

            If the nodes is tagged inside anyone of the specified tagtree, the command will show the related tags' path.

Example:

# sanet-manage show_exec_times
NODE                                                   TIME  TAGS
internet                                              0.248  
# sanet-manage show_exec_times
NODE                                                   TIME  TAGS
internet                                              0.248  

10.20.3.2.8. test_flap_parameters

Comando per testare i parametri di flapping specificando una sequenza di stati UP/DOWN.

Esempio:

sanet-manage test_flap_parameters                   --sequence 0101010100000011111111               --image    /tmp/test.png

Esempio:

sanet-manage test_flap_parameters                   --sequence 01010100000000               --image    /tmp/test.png                --path 'localhost;;icmp-reachability;reach' 

Esempio:

sanet-manage test_flap_parameters                   --sequence 01010100000000               --image    /tmp/test.png                --flap_penalty 1000                     --flap_penalty_limit 40000                      --flap_penalty_high 600                 --flap_penalty_low 300                  --flap_half_life 30                     --flap_fa_as_dn 1 

Esempio:

sanet-manage test_flap_parameters                   --sequence 01010100000000               --image    /tmp/test.png                --path 'localhost;;icmp-reachability;reach'                     --flap_penalty 1000                     --flap_penalty_limit 40000                      --flap_penalty_high 600                 --flap_penalty_low 300                  --flap_half_life 30                     --flap_fa_as_dn 1