Package: netscaler-exporter
netscaler_exporterOverviewDescriptionPrometheus exporter for Netscaler (CITRIX ADC)This exporter collect metrics from netscaler HTTP REST API.It is a python HTTP server that exposes metrics to http (default port 9247) that can be then scrapped by Prometheus.This exporter is strongly inspired fromcitrix-adc-metrics-exporterIt allows you collect several netscalers by adding them to the YAML config file and then specifying a target parameter in Prometheus configuration.Config: (see conf/netscaler_exporter.yml)netscalers:-host:host.domain#    port: 443user:'user'password:'password'#   protocol: https#   verify_ssl: false#   timeout: 20#   keep_session: true # default#   default_labels:#     - name: netscaler_specific_data#       value: my_label#       proxy:#         url: http://my.proxy.domain:port/#         protocol: httpsweblisten:address:0.0.0.0port:9259logger:level:infofacility:syslogmetrics_file:"conf/metrics/*_metrics.yml"UsageThe exporter may run as a unix command with module installation or as standalone python script without instalation.
iUsage as a system commandthe easiest way is to install from pip:pip3install--upgradenetscaler_exporterthen you can use the entry point create by the installer of the module in /usr/local/bin/netscaler_exporter or in [venv]/bin/netscaler_exporter for venv context.
The recommanded usage is in venv.Usage as a Python ScriptTo use the exporter, few packages needs to be installed. This can be done using:pip3install-rrequirements.txtContents of requirements.txtPrometheus-client>=0.8.0requests==2.23.0PyYAML==5.3.1tenacity==6.2.0urllib3>=1.25.9Jinja2>=2.11.2python-dateutil>=0.6.12Consider, to extract the archiv file in /tmp folder; this will generate a folder /tmp/netscaler_exporter_[version].create a directory where you want, by example /opt/netscaler_exporter_[version],move the /tmp/netscaler_exporter_[version]/netscaler_exporter_package directory to /opt/eeam_exporter_[version]create a command file to launch the exporter in dir /opt/netscaler_exporter_[version]vi/opt/netscaler_exporter_X.Y.Z/netscaler_exporter_cmd#!/usr/libexec/platform-python# -*- coding: utf-8 -*-importre
importsys
fromnetscaler_exporter.netscaler_exporterimportmainif__name__=='__main__':sys.argv[0]=re.sub(r'(-script\.pyw|\.exe)?$','',sys.argv[0])sys.exit(main())Then edit the conf/config.yml file and add your settings.Try your config by executing the command in try modeexample with the default dumy config file:python3veeam_exporter_cmd-n-vexporter command line optionsto start the exporter:./netscaler_exporter&By default, it will load the file config.yml to perform action.Detail optionsusage:netscaler_exporter_cmd[-h][-bBASE_PATH][-cCONFIG_FILE][-FFILTER_PATH][-fLOGGER.FACILITY][-l{error,warning,info,debug}][-oMETRICS_FILE][-mMETRIC][-n][-tTARGET][-wWEB.LISTEN_ADDRESS][-V][-v]collectorforCitrixNetscaler.

optionalarguments:-h,--helpshowthishelpmessageandexit-bBASE_PATH,--base_pathBASE_PATHsetbasedirectorytofinddefaultfiles.-cCONFIG_FILE,--config_fileCONFIG_FILEpathtoconfigfiles.-FFILTER_PATH,--filter_pathFILTER_PATHsetfilterdirectorytofindfilterfiles.-fLOGGER.FACILITY,--logger.facilityLOGGER.FACILITYloggerfacility(syslogorfilepath).-l{error,warning,info,debug},--logger.level{error,warning,info,debug}loggerlevel.-oMETRICS_FILE,--metrics_fileMETRICS_FILEcollectthemetricsfromthespecifiedfileinsteadofconfig.-mMETRIC,--metricMETRICcollectonlythespecifiedmetricnamefromthemetrics_file.-n,--dry_modecollectthemetricsthenexit;displayresultstostdout.-tTARGET,--targetTARGETIndry_modecollectmetricsonspecifiedtarget.iDefaultfirstfromconfigfile.-wWEB.LISTEN_ADDRESS,--web.listen-addressWEB.LISTEN_ADDRESSAddresstolistenonforwebinterfaceandtelemetry.-V,--versiondisplayprogramversionandexit..-v,--verboseverbosemode;displaylogmessagetostdout.To test your configuration you can launch the exporter in dry_mode:./netscaler_exporter-v-n-thost.domainThis command will try to connect to the 'host.domain' netscaler with parameters specified in config.yml, exposes the collected metrics, and eventually the warning or errors, then exits.Prometheus configSince several netscalers can be set in the exporter, Prometheus addresses each server by adding a target
parameter in the url. The "target" must be the same (lexically) that in exporter config file.-job_name:"citrix_netscaler"scrape_interval:30sscrape_timeout:20smetrics_path:/metricsstatic_configs:-targets:[netscalerhost.domain]labels:environment:"PROD"-targets:[netscalerhost2.domain]labels:environment:"PROD"#    file_sd_configs:#      - files: [ "/etc/prometheus/citrix_exp/*.yml" ]relabel_configs:-source_labels:[__address__]target_label:__param_target-source_labels:[__param_target]target_label:instance-target_label:__address__replacement:"netscaler-exporter-hostname.domain:9258"# The netscaler exporter's real hostname.MetricsThe collected metrics are defined in separeted files positionned in the folder conf/metrics.
All values, computations, labels are defined in the metrics files, meaning that the exporter doesn't nothing internally on values. The configuration fully drive how values are rendered.Currently collected metrics are:All metrics are defined in the configuration files (conf/metrics/*.yml). You can retrive all metric names here. Most of them have help text too.STATSNS nitro nameLB vserver stats"lbvserver"CS vserver stats"csvserver"HTTP stats"protocolhttp"TCP stats"protocoltcp"UDP stats"protocoludp"IP stats"protocolip"Interface stats"Interface" (capital 'i')Service stats"service"Service group stats"services"Bandwidth Capacity stats"nscapacity"SSL stats"ssl"SSL Certicates stats"sslcertkey"SSL vserver stats"sslvserver"System info stats"system"System memory stats"systemmemory"System cpu stats"systemcpu"High Availability stats"hanode.yml"AAA stats"aaa"ADC Probe success"1" if login is successful, else "0"Extending metricsExported metrics, are defined in the YAML config files. The value can use Jinja2 templating language. The format of the configuration is inspired from Ansible tasks representation.
So a metric configuration file, consists in a list of actions to perform.There are five possible actions:url: to collect metrics from HTTP APIset_fact: to assign value to variablesactions: to perform a list of (sub-)actionsmetrics: to define metrics to expose/return to Prometheusdebug: to display debug text to logger.All actions have default "attributes":name: the name of action or metric counter for metrics action.vars: to set vars to global symbols' table.with_items: to loop on current action with a list of items.loop_var: to set the name of the variable that will receive the current value in the loop. Default is 'item'.when: a list of condition (and) that must be check and be true to perform the action.The "attributes" are analyzed in the order specified in previous table; it means that you can't use "item" var (obtained from 'with_items' directive) in the vars section because it is not yet defined when the 'vars' section is evaluated. If you need that feature, you will have to consider 'with_items' in an 'actions' section (see metrics/backup_jobs_sessions_metrics.yml).actionparameterdescriptionremarkurla string that's representing the entity to collect without '/nitro/v1'http://host.domain:port/nitro/v1**[url]**. e.g.: /stat/systemvar_namethe name ofthe variable to store the results. Default is '_root' meaning that the resulting JSON object is directly store in symbols table.set_factlist of variable to definevar_name: valuemetricsdefine the list of metrics to exposemetric_prefixa prefix to add to all metric namefinal name will be [metric_prefix]_[metric_name]'a metric'namethe name of the metrichelpthe help message added to the metric (and displayed in grafana explorer)type 'gauge' or 'counter'the type of the prometheus metricvaluethe numeric value itselflabelsa list of name value pairs to qualify the metricA metric configuration file is so at minimum, an action containing list of two actions, one for collecting values on netscaler with 'url', one to define the resulting metric for prometheusi with 'metrics':example:----name:my_custom_metricactions:# first action-name:collect elementsurl:/stat/system# second action-name:proceed elementsmetric_prefix:citrixadc_custmetricmetrics:-name:cpu_numberhelp:constant number of cpu for appliancetype:countervalue:"{{system.numcpus}}"...