comparison tasks.py @ 63:84a4c4cca4a5

separate the migration tasks
author drewp@bigasterisk.com
date Thu, 02 May 2024 23:05:14 -0700
parents 8134cd480817
children
comparison
equal deleted inserted replaced
62:8134cd480817 63:84a4c4cca4a5
55 55
56 56
57 def scrapeConfig(fn): 57 def scrapeConfig(fn):
58 return yaml.load(open(fn), yaml.FullLoader) 58 return yaml.load(open(fn), yaml.FullLoader)
59 59
60
61 metricsToMigrate = [
62 'currently_on_wifi',
63 'connected',
64 'house_power_kwh',
65 'house_power_price',
66 'house_power_w',
67 'lan_bytes_sent_from_created',
68 'lan_bytes_sent_from_total',
69 'lan_last_seen_time',
70 'maildir_count',
71 'mongodb_mongod_db_coll_avgobjsize',
72 'mongodb_mongod_db_coll_count',
73 'mongodb_mongod_db_coll_index_size',
74 'mongodb_mongod_db_coll_indexes',
75 'mongodb_mongod_db_coll_indexes_size',
76 'mongodb_mongod_db_coll_size',
77 'mongodb_mongod_db_coll_storage_size',
78 'mongodb_mongod_db_collections_total',
79 'mongodb_mongod_db_data_size_bytes',
80 'mongodb_mongod_db_index_size_bytes',
81 'mongodb_mongod_db_indexes_total',
82 'mongodb_mongod_db_objects_total',
83 'probe_duration_seconds',
84 'smartctl_device',
85 'smartctl_device_attribute',
86 'smartctl_device_available_spare',
87 'smartctl_device_available_spare_threshold',
88 'smartctl_device_block_size',
89 'smartctl_device_bytes_read',
90 'smartctl_device_bytes_written',
91 'smartctl_device_capacity_blocks',
92 'smartctl_device_capacity_bytes',
93 'smartctl_device_critical_warning',
94 'smartctl_device_interface_speed',
95 'smartctl_device_media_errors',
96 'smartctl_device_num_err_log_entries',
97 'smartctl_device_percentage_used',
98 'smartctl_device_power_cycle_count',
99 'smartctl_device_power_on_seconds',
100 'smartctl_device_smart_status',
101 'smartctl_device_smartctl_exit_status',
102 'smartctl_device_status',
103 'smartctl_device_temperature',
104 'zfs_dataset_logical_used_bytes',
105 'zfs_dataset_referenced_bytes',
106 'zfs_dataset_used_by_dataset_bytes',
107 'zfs_dataset_used_bytes',
108 'zfs_dataset_written_bytes',
109 'zfs_exporter_build_info',
110 'zfs_pool_allocated_bytes',
111 'zfs_pool_deduplication_ratio',
112 'zfs_pool_fragmentation_ratio',
113 'zfs_pool_free_bytes',
114 'zfs_pool_freeing_bytes',
115 'zfs_pool_health',
116 'zfs_pool_leaked_bytes',
117 'zfs_pool_readonly',
118 'zfs_pool_size_bytes',
119 'zfs_scrape_collector_duration_seconds',
120 'zfs_scrape_collector_success',
121 'zigbee_availability',
122 'zigbee_battery',
123 'zigbee_brightness',
124 'zigbee_contact',
125 'zigbee_link_quality',
126 'zigbee_occupancy',
127 'zpool_device_error_count',
128 'zpool_device_state',
129 'zpool_error_count',
130 'zpool_state',
131 ]
132
133
134 @task
135 def exportForeverMetrics(ctx):
136 svc = ctx.run('khost victoriametrics').stdout
137 for m in metricsToMigrate:
138 ctx.run(f'curl http://{svc}/m/api/v1/export/native?match={m} | gzip -c > export/{m}.native.gz')
139
140
141 @task
142 def ingestForeverMetrics(ctx):
143 svc = ctx.run('khost next-victoriametrics-forever-vminsert').stdout
144 for p in Path('export').glob('*.native.gz'):
145 print(f'importing {p}')
146 ctx.run(f'zcat {p} | curl -s http://{svc}/m/next/forever/vminsert/insert/0/prometheus/api/v1/import/native --data-binary @-')