Special Commands

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

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}]

exec_expr

Launch:

cd $SANET_INSTALL_DIR
python manage.py 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. 

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:

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:

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: