Skip to content

Commit

Permalink
Added TextFileCollector, SVCSCollector now enabled for all zones
Browse files Browse the repository at this point in the history
  • Loading branch information
n27051538 committed Jan 12, 2021
1 parent bbdf13b commit 5bf4ddd
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ May be it also will work on x86 platform, but this is not tested.
- 2020 Feb 04. Added UpTime in UpTimeCollector.
- 2020 Feb 09. Added DiskErrorCollector, ZpoolCollector, FmadmCollector, SVCSCollector, FCinfoCollector
- 2020 Dec 17. Added PrtdiagCollector, MetaStatCollector, MetaDBCollector
- 2021 Jan 05. Added TextFileCollector, SVCSCollector now enabled for all zones (Thanks to Marcel Peter)

## Provides info about:
- Solaris Zones CPU Usage with processor sets info (PerZoneCpuCollector);
Expand All @@ -29,6 +30,7 @@ May be it also will work on x86 platform, but this is not tested.
- Zpool devices health via 'zpool status' command (ZpoolCollector)
- prtdiag -v return code(PrtdiagCollector)
- Solaris Volume Manager disk status (MetaStatCollector, MetaDBCollector).
- Get info from text files *.prom in folder provided by text_file_path var (TextFileCollector).

## Grafana dashboard.
Dashboard config is located in file grafana-dashboard-solaris.json
Expand Down
34 changes: 31 additions & 3 deletions solaris_exporter.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
#!/usr/bin/python
"""
sparc-exporter
version 1.0
version v2021Jan05
2020 Jan 31. Initial
2020 Feb 04. Added UpTime in UpTimeCollector.
2020 Feb 09. Added DiskErrorCollector, ZpoolCollector, FmadmCollector, SVCSCollector, FCinfoCollector
2020 Dec 17. Added PrtdiagCollector, MetaStatCollector, MetaDBCollector
2021 Jan 05. Added TextFileCollector, SVCSCollector now enabled for all zones (Thanks to Marcel Peter)
Written by Alexander Golikov for collecting SPARC Solaris metrics for Prometheus.
Tested on Solaris 11.3.25, 11.4.4, 10u11(limited) SPARC.
Expand All @@ -25,6 +28,8 @@
- System Services health via 'svcs -x' command (SVCSCollector);
- Whole system health via 'fmadm faulty' (FmadmCollector), requires pfexec of '/usr/sbin/fmadm'.
- Zpool devices health via 'zpool status' command (ZpoolCollector)
- Solaris Volume Manager disk status (MetaStatCollector, MetaDBCollector).
- Get info from text files *.prom in folder provided by text_file_path var (TextFileCollector).
Installation. To use this exporter you need python2.7 and its modules prometheus_client, psutil.
Expand Down Expand Up @@ -73,10 +78,13 @@
import psutil
from psutil import _psutil_sunos as cext
import os
from prometheus_client.core import REGISTRY, Counter, Gauge, GaugeMetricFamily, CounterMetricFamily
from prometheus_client.core import REGISTRY, Counter, Gauge, GaugeMetricFamily, CounterMetricFamily, UntypedMetricFamily
from prometheus_client.parser import text_string_to_metric_families
from prometheus_client import start_http_server
from glob import glob

exporter_port = 9100
text_file_path = '/opt/solaris_exporter/'
dictionaries_refresh_interval_sec = 600
disk_operations_dictionary = {
'reads': 'number of read operations',
Expand Down Expand Up @@ -925,6 +933,25 @@ def collect(self):
yield prtdiag


class TextFileCollector(object):
"""
Read Input from a textfile to include in output. Thanks to Marcel Peter
"""
TextFileCollector_run_time = Gauge('solaris_exporter_textfile_processing', 'Time spent processing request')

def collect(self):
with self.TextFileCollector_run_time.time():
fpath = text_file_path
fnames = glob(fpath + '*.prom')
for file_name_r in fnames:
# filename to open for read
with open(file_name_r, 'r') as text_object:
output = text_object.read()
for family in text_string_to_metric_families(output):
yield family
text_object.close


# replace start_http_server() method to capture error messages in my_http_error_handler()
# remove this to revert to prometheus_client.start_http_server
from BaseHTTPServer import HTTPServer
Expand Down Expand Up @@ -967,6 +994,8 @@ def my_http_error_handler(request, client_address):
UpTimeCollector(),
NetworkCollector(),
DiskSpaceCollector(),
SVCSCollector(),
TextFileCollector(),
]

zones, rc, timeouted = run_shell_command('/usr/sbin/zoneadm list -icp', 3)
Expand All @@ -991,7 +1020,6 @@ def my_http_error_handler(request, client_address):
DiskErrorCollector(),
ZpoolCollector(),
FCinfoCollector(),
SVCSCollector(),
FmadmCollector(),
PrtdiagCollector(),
MetaDBCollector(),
Expand Down

0 comments on commit 5bf4ddd

Please sign in to comment.