Poller command line reference
From Sanet
Contents |
Poller command
Syntax
- python poller/main.py [-v] [-L level] [-T threads] [-cC target] [-mM measure] [-e node[:interface] [expression] ] [-n] [start|stop]
Starting
python poller/main.py start
Poller will be executed as a UNIX daemon.
Stopping
python poller/main.py stop
This will send the termination signal to the current running instance of Poller and will wait for safe Poller termination.
Disable demonize
It is possible to execute Poller as a simple shell process instead of a daemon by adding the -n option.
python poller/main -n start
When running in this mode it is useful to use the -v option in order make Poller print log informations on standard output.
python poller/main -v -n start
Other options
- -v
- Poller's log will be printed on standard output too. This option is useful only when poller is not running as daemon process.
- -T threads
- This option will force Poller to use a number of concurrent threads equal to threads. The maximum number of running thread is machine dependent.
- -S size
- This option will set threads' memory stacksize to size bytes.
- -p
- Poller's log will be sent to syslog system too.
- -L level
- This option will set the verbosity of the log produce by Poller. The level parameter is a numeric value greater than 0 or one of the followning mnemonic strings:
string numeric value DEBUG 10 INFO 20 WARNING 30 ERROR 40 CRITICAL 50
Perform simple tests
Test targets
To check a single target use the -c option:
python poller/main.py -c <target path> python poller/main.py -c <target id number>
In order to check a single target and update its status on DB use the -C option:
python poller/main.py -C <target path> python poller/main.py -C <target id number>
Example:
# python poller/main.py -v -L DEBUG -c mason::server-linux:reach-server 2010-12-10 17:47:46,166 INFO> Min cycle time parameter changed! Now is: 0 2010-12-10 17:47:46,168 INFO> Inil timestamp parameter changed! Now is: 1291298251.0 (2010-12-02 14:57:31) 2010-12-10 17:47:46,169 INFO> Init mail sender... 2010-12-10 17:47:46,169 INFO> [poller mailer] started 2010-12-10 17:47:46,169 DEBUG> Checking target: mason::server-linux:reach-server 2010-12-10 17:47:46,183 DEBUG> param probesize = 1418.0 2010-12-10 17:47:46,185 DEBUG> Getting node/ifaces data 2010-12-10 17:47:46,185 DEBUG> node 39,mason 2010-12-10 17:47:46,185 DEBUG> Loading target's 'privatestate' 2010-12-10 17:47:46,185 DEBUG> Loaded 'privatestate' field 2010-12-10 17:47:46,185 DEBUG> privatestate lastgoodcheck=1291916058 2010-12-10 17:47:46,186 DEBUG> CHECKING (mason::server-linux:reach-server, id=358) at 1291999666 (2010-12-10 17:47:46) 2010-12-10 17:47:46,186 DEBUG> Calculating basecheck params... 2010-12-10 17:47:46,186 DEBUG> loading node params (mason) 2010-12-10 17:47:46,186 DEBUG> calculating delta time: -1291916059 <type 'int'> (lastgoodcheck: 1291916058 2010-12-09 18:34:18) 2010-12-10 17:47:46,187 DEBUG> EVALUATING EXPRESSION 2010-12-10 17:47:46,187 DEBUG> EVALUATING: (Id(isReachable)( Id($node) Id($probesize))) 2010-12-10 17:47:46,187 DEBUG> isReachable(host=mason, probesize=1418.0, shorttries=3, keep_rtt=1, timeout=3) 2010-12-10 17:47:46,198 DEBUG> mason has 1 addresses: ['1.0.0.10'] 2010-12-10 17:47:46,199 DEBUG> 1.0.0.10: Sending IPv4 pings. 2010-12-10 17:47:46,199 DEBUG> ping 1.0.0.10: Using IP_PMTUDISC_PROBE 2010-12-10 17:47:46,200 DEBUG> ping 1.0.0.10: sending icmp #0 len=1426 2010-12-10 17:47:46,202 DEBUG> ping 1.0.0.10: sending icmp #1 len=1426 2010-12-10 17:47:46,203 DEBUG> ping 1.0.0.10: sending icmp #2 len=1426 2010-12-10 17:47:46,204 DEBUG> 1.0.0.10: got ping answer #0 in 0.000559091567993 s 2010-12-10 17:47:46,204 DEBUG> 1.0.0.10: got ping answer #1 in 0.000534057617188 s 2010-12-10 17:47:46,204 DEBUG> 1.0.0.10: got ping answer #2 in 0.000530958175659 s 2010-12-10 17:47:46,204 DEBUG> target mason pinged: host mason, addr 1.0.0.10, IPv4, latency: 0.541 ms avg, 0.531 ms min, 0.559 ms max. Loss: 0.00 %. 2010-12-10 17:47:46,205 DEBUG> Wrote rrd measure file = N:0.0:0.00054136912028:0.000559091567993 2010-12-10 17:47:46,205 DEBUG> Updated lastrttavg 0.00054136912028 2010-12-10 17:47:46,205 DEBUG> SAVING UPDATED SNMP VALUES (now=1291999666) 2010-12-10 17:47:46,205 DEBUG> Saved 'privatestate' field 2010-12-10 17:47:46,206 INFO> RESULT: True (type: <type 'bool'> ) 2010-12-10 17:47:46,206 INFO> INFO: host mason, addr 1.0.0.10, IPv4, latency: 0.541 ms avg, 0.531 ms min, 0.559 ms max. Loss: 0.00 %.,isReachable($node, $probesize) expands to True
Test measures
To check a single measure use the -m option:
python poller/main.py -m <measure path> python poller/main.py -m <measure id number>
In order to check and update a single measure use the -M option:
python poller/main.py -M <target path> python poller/main.py -M <target id number>
Example:
# python poller/main.py -v -L DEBUG -m mason::server-linux:loadavg-graph 2010-12-10 17:55:29,985 INFO> Min cycle time parameter changed! Now is: 0 2010-12-10 17:55:29,986 INFO> Inil timestamp parameter changed! Now is: 1291298251.0 (2010-12-02 14:57:31) 2010-12-10 17:55:29,987 INFO> Init mail sender... 2010-12-10 17:55:29,987 INFO> [poller mailer] started 2010-12-10 17:55:29,987 DEBUG> Checking measure: mason::server-linux:loadavg-graph 2010-12-10 17:55:30,027 DEBUG> param snmpport = 161.0 2010-12-10 17:55:30,028 DEBUG> Getting node/ifaces data 2010-12-10 17:55:30,028 DEBUG> node 39,mason 2010-12-10 17:55:30,028 DEBUG> CHECKING mason::server-linux:loadavg-graph (278) 2010-12-10 17:55:30,028 DEBUG> Calculating basecheck params... 2010-12-10 17:55:30,029 DEBUG> loading node params (mason) 2010-12-10 17:55:30,029 DEBUG> get measures current params from memory 2010-12-10 17:55:30,029 DEBUG> Checking expr1... 2010-12-10 17:55:30,029 DEBUG> converting: 1.3.6.1.4.1.2021.10.1.3.2:$community@$node:$snmpport 2010-12-10 17:55:30,030 DEBUG> Parsing expression: 1.3.6.1.4.1.2021.10.1.3.2:$community@$node:$snmpport 2010-12-10 17:55:30,031 DEBUG> Saving expr mason::server-linux:loadavg-graph.1 in cache: cache_expr.mason::server-linux:loadavg-graph.1 2010-12-10 17:55:30,032 DEBUG> EVALUATING: {1.3.6.1.4.1.2021.10.1.3.2:Id($community)@Id($node):Id($snmpport)} 2010-12-10 17:55:30,075 DEBUG> CACHED SNMP value mason1.3.6.1.4.1.2021.10.1.3.2 = '0.22' 2010-12-10 17:55:30,076 INFO> RESULT: 0.22, None
Test generic expression
Use the -e option:
python poller/main.py -e node[:interface] [expression]
The program will evaluate a generic expression using informations about the specified node/interface.
If node or iface are present inside SANET's configuration, the programm will load all default node/interface variables .
Additional parameters will be read line by line from standard input. The parameter expression can be read from standard input too. See later in this section.
Example:
$ echo | python poller/main.py -e foo ' (1 + 1) / 2' VALUE: 1.0 ( <type 'float'> ) INFO : (1 + 1) / 2 expands to ((1 + 1) / 2)
$ echo | python poller/main.py -e mason:eth1 ' $ifindex ' VALUE: 5 ( <type 'int'> ) INFO : $ifindex expands to 5
Specify additional variables from standard input
Additional variables can be specified line by line throw standard input which must have the following syntax:
- $variable_name [ = type ] = value
- $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.
The type parameter is optional.
Example:
foo@localhost$ cat | python poller/main.py -v -e localhost '1.3.6.1.2.1.1.1.0@' $snmpversion = num = 1 $community = public $snmpport = num = 161 *Cltr+D* VALUE: Linux mason 2.4.34.5 #12 Tue Jun 26 14:09:29 CEST 2007 i686 ( <class 'poller.SnmpExprParser.Types.SnmpValueType'> ) INFO : 1.3.6.1.2.1.1.1.0@ expands to Linux mason 2.4.34.5 #12 Tue Jun 26 14:09:29 CEST 2007 i686
Specify the expression from standard input
Sometimes the shell's quoting/escaping rules make it difficult to specify the expression as a command line argument.
It is possible to specify the expression from standard input too by leaving a blank line after the additional variables.
Example:
foo@localhost$ cat | python poller/main.py -v -L DEBUG -e localhost $snmpversion = num = 1 $community = public $snmpport = num = 161 1.3.6.1.2.1.1.1.0@ *Ctlr+D* VALUE: Linux mason 2.4.34.5 #12 Tue Jun 26 14:09:29 CEST 2007 i686 ( <class 'poller.SnmpExprParser.Types.SnmpValueType'> ) INFO : 1.3.6.1.2.1.1.1.0@ expands to Linux mason 2.4.34.5 #12 Tue Jun 26 14:09:29 CEST 2007 i686
pollerctl command
Syntax
- pollerctl [ command [ args ] ]
The pollerctl programs is used to send commands and to retrieve status informations about a running instance of the Poller.
Commands
- help
- Show the list of commands
- echo string
- Send the string to the poller and reads the replay. (for debug)
- ping
- Pings the poller.
- commit_and_stop
- Tell to the poller to commit pending changes and stop execution.
- get_commitqueuesize
- Returns the current size of the agent job commit queue.
- get_queuesize
- Returns the current size of the agent job execution queue.
- get_snmpcache_stats
- Returns snmp cache stats.
- get_stats
- Returns poller statistics.
- when_is id
- Returns the next execution time scheduled for the specified target or measure.
- short_stats
- Show statistic informations about Poller execution (up time, runnint threads, ecc....)
- show_schedule num
- Returns the next num li scheduled checks.
- set_log_level level.
- Set Poller log level (no parameter = INFO) to level.
- update_checks
- Reload (and reschedule) all targets and measures
- update_measure id
- Reload (and reschedule) a single measure. Argument id can be an ID or PATH.
- update_node id
- Reload (and reschedule) all the basechecks of the specified node. Argument id can be an ID or node name.
- update_target id
- Reload (and reschedule) a single target. Argument id can be an ID or PATH.