Changeset 3490329
- Timestamp:
- 03/24/2026 07:50:02 PM (4 days ago)
- Location:
- satollo-monitor
- Files:
-
- 47 added
- 7 edited
- 3 copied
-
tags/1.0.2 (added)
-
tags/1.0.2/admin (added)
-
tags/1.0.2/admin/abilities (added)
-
tags/1.0.2/admin/abilities/index.php (added)
-
tags/1.0.2/admin/abilities/logs.php (added)
-
tags/1.0.2/admin/abilities/nav.php (added)
-
tags/1.0.2/admin/activate.php (added)
-
tags/1.0.2/admin/admin-ajax.php (added)
-
tags/1.0.2/admin/admin.php (added)
-
tags/1.0.2/admin/aiclient (added)
-
tags/1.0.2/admin/aiclient/index.php (added)
-
tags/1.0.2/admin/aiclient/logs.php (added)
-
tags/1.0.2/admin/aiclient/nav.php (added)
-
tags/1.0.2/admin/assets (added)
-
tags/1.0.2/admin/assets/admin.css (added)
-
tags/1.0.2/admin/assets/plotly-3.3.0.min.js (added)
-
tags/1.0.2/admin/emails (added)
-
tags/1.0.2/admin/emails/index.php (added)
-
tags/1.0.2/admin/emails/logs.php (added)
-
tags/1.0.2/admin/emails/nav.php (added)
-
tags/1.0.2/admin/http (added)
-
tags/1.0.2/admin/http/index.php (added)
-
tags/1.0.2/admin/http/logs.php (added)
-
tags/1.0.2/admin/http/nav.php (added)
-
tags/1.0.2/admin/index.php (added)
-
tags/1.0.2/admin/menu.php (added)
-
tags/1.0.2/admin/rest (added)
-
tags/1.0.2/admin/rest/index.php (added)
-
tags/1.0.2/admin/rest/logs.php (added)
-
tags/1.0.2/admin/rest/nav.php (added)
-
tags/1.0.2/admin/scheduler (added)
-
tags/1.0.2/admin/scheduler/filters.php (added)
-
tags/1.0.2/admin/scheduler/index.php (added)
-
tags/1.0.2/admin/scheduler/jobs.php (added)
-
tags/1.0.2/admin/scheduler/logs.php (added)
-
tags/1.0.2/admin/scheduler/nav.php (added)
-
tags/1.0.2/admin/scheduler/schedules.php (added)
-
tags/1.0.2/admin/settings.php (added)
-
tags/1.0.2/admin/users (added)
-
tags/1.0.2/admin/users/index.php (added)
-
tags/1.0.2/admin/users/logs.php (added)
-
tags/1.0.2/admin/users/nav.php (added)
-
tags/1.0.2/admin/users/roles.php (added)
-
tags/1.0.2/readme.txt (added)
-
tags/1.0.2/satollo-monitor.php (added)
-
tags/1.0.2/uninstall.php (added)
-
trunk/admin/activate.php (modified) (1 diff)
-
trunk/admin/admin.php (modified) (1 diff)
-
trunk/admin/aiclient (added)
-
trunk/admin/aiclient/index.php (copied) (copied from satollo-monitor/trunk/admin/rest/index.php) (5 diffs)
-
trunk/admin/aiclient/logs.php (copied) (copied from satollo-monitor/trunk/admin/rest/logs.php) (6 diffs)
-
trunk/admin/aiclient/nav.php (copied) (copied from satollo-monitor/trunk/admin/rest/nav.php) (1 diff)
-
trunk/admin/assets/admin.css (modified) (1 diff)
-
trunk/admin/menu.php (modified) (3 diffs)
-
trunk/admin/settings.php (modified) (1 diff)
-
trunk/readme.txt (modified) (3 diffs)
-
trunk/satollo-monitor.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
satollo-monitor/trunk/admin/activate.php
r3481978 r3490329 23 23 PRIMARY KEY (`id`), 24 24 KEY `name` (`name`) 25 ) $charset_collate;"; 26 27 dbDelta($sql); 28 if ($wpdb->last_error) { 29 error_log($wpdb->last_error); 30 } 31 32 $sql = "CREATE TABLE `" . $wpdb->prefix . "monitor_aiclient` ( 33 `id` int(11) NOT NULL AUTO_INCREMENT, 34 `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, 35 `provider` varchar(200) NOT NULL DEFAULT '', 36 `model` varchar(200) NOT NULL DEFAULT '', 37 `tokens` int NOT NULL DEFAULT 0, 38 `duration` double DEFAULT 0, 39 `context` varchar(50) NOT NULL DEFAULT '', 40 PRIMARY KEY (`id`) 25 41 ) $charset_collate;"; 26 42 -
satollo-monitor/trunk/admin/admin.php
r3484639 r3490329 70 70 } 71 71 break; 72 case 'aiclient': 73 switch ($subpage) { 74 case 'logs': 75 include __DIR__ . '/aiclient/logs.php'; 76 break; 77 default: 78 include __DIR__ . '/aiclient/index.php'; 79 } 80 break; 72 81 case 'http': 73 82 switch ($subpage) { -
satollo-monitor/trunk/admin/aiclient/index.php
r3484639 r3490329 1 1 <?php 2 3 2 defined('ABSPATH') || exit; 4 3 … … 7 6 global $wpdb; 8 7 9 $per_day = $wpdb->get_results("select date(created) as date, count(*) as total from {$wpdb->prefix}monitor_rest where created > DATE_SUB(NOW(), INTERVAL 30 DAY) group by date(created) order by date(created) asc");8 $per_day = $wpdb->get_results("select date(created) as date, count(*) as total, sum(tokens) as tokens from {$wpdb->prefix}monitor_aiclient where created > DATE_SUB(NOW(), INTERVAL 30 DAY) group by date(created) order by date(created) asc"); 10 9 $per_day_x = []; 11 10 $per_day_y = []; … … 14 13 $per_day_x[] = $data->date; 15 14 $per_day_y[] = $data->total; 15 $per_day_tokens[] = $data->tokens; 16 16 } 17 18 17 ?> 19 18 <?php include __DIR__ . '/../menu.php'; ?> 20 <div class="wrap" id="monitor-emails">19 <div class="wrap"> 21 20 <?php include __DIR__ . '/nav.php'; ?> 21 22 <div id="graph-calls" style="margin: 2rem 0"></div> 23 <div id="graph-tokens" style="margin: 2rem 0"></div> 24 25 <script> 26 jQuery(function () { 27 var layout = { 28 title: {text: 'Calls per day'} 29 }; 30 var data = [{ 31 x: <?= json_encode($per_day_x); ?>, 32 y: <?= json_encode($per_day_y); ?>, 33 type: 'scatter' 34 } 35 36 ]; 37 38 Plotly.newPlot('graph-calls', data, layout); 39 40 var layout = { 41 title: {text: 'Calls per day'} 42 }; 43 var data_tokens = [{ 44 x: <?= json_encode($per_day_x); ?>, 45 y: <?= json_encode($per_day_tokens); ?>, 46 type: 'scatter' 47 } 48 49 ]; 50 51 Plotly.newPlot('graph-tokens', data_tokens, { 52 title: {text: 'Tokens per day'} 53 }); 54 }); 55 </script> 22 56 23 57 <table class="widefat" style="width: auto"> … … 26 60 <th><?php esc_html_e('Date', 'satollo-monitor'); ?></th> 27 61 <th><?php esc_html_e('Count', 'satollo-monitor'); ?></th> 62 <th><?php esc_html_e('Tokens', 'satollo-monitor'); ?></th> 28 63 </tr> 29 64 </thead> … … 33 68 <td><?php echo esc_html($data->date); ?></td> 34 69 <td><?php echo esc_html($data->total); ?></td> 70 <td><?php echo esc_html($data->tokens); ?></td> 35 71 </tr> 36 72 <?php } ?> -
satollo-monitor/trunk/admin/aiclient/logs.php
r3484639 r3490329 11 11 check_admin_referer('monitor-action'); 12 12 if (isset($_POST['clear'])) { 13 $wpdb->query("truncate {$wpdb->prefix}monitor_ rest");13 $wpdb->query("truncate {$wpdb->prefix}monitor_aiclient"); 14 14 } 15 15 } … … 28 28 $columns = [ 29 29 'created' => __('Created', 'satollo-monitor'), 30 'code' => __('Code', 'satollo-monitor'), 31 'method' => __('Method', 'satollo-monitor'), 32 'route' => __('Route', 'satollo-monitor'), 33 'params' => __('Params', 'satollo-monitor'), 30 'provider' => __('Provider', 'satollo-monitor'), 31 'model' => __('Model', 'satollo-monitor'), 32 'tokens' => __('Tokens', 'satollo-monitor'), 33 'duration' => __('Duration (s)', 'satollo-monitor'), 34 'context' => __('Context', 'satollo-monitor'), 34 35 ]; 35 36 return $columns; … … 47 48 $per_page = 50; 48 49 $current_page = $this->get_pagenum(); 49 $total_items = (int) $wpdb->get_var("select count(*) from {$wpdb->prefix}monitor_ rest");50 $total_items = (int) $wpdb->get_var("select count(*) from {$wpdb->prefix}monitor_aiclient"); 50 51 51 52 $this->set_pagination_args([ … … 54 55 ]); 55 56 56 $this->items = $wpdb->get_results($wpdb->prepare("select * from {$wpdb->prefix}monitor_ rest order by id desc limit %d offset %d",57 $this->items = $wpdb->get_results($wpdb->prepare("select * from {$wpdb->prefix}monitor_aiclient order by id desc limit %d offset %d", 57 58 $per_page, ($current_page - 1) * $per_page)); 58 59 } … … 62 63 case 'created': 63 64 return esc_html($item->created); 64 case 'method': 65 return esc_html($item->method); 66 case 'code': 67 return esc_html($item->code); 68 case 'route': 69 return esc_html($item->route); 65 case 'model': 66 return esc_html($item->model); 67 case 'tokens': 68 return esc_html($item->tokens); 69 case 'provider': 70 return esc_html($item->provider); 71 case 'duration': 72 return round($item->duration, 3); 70 73 case 'context': 71 74 return esc_html($item->context); … … 98 101 <?php wp_nonce_field('monitor-action'); ?> 99 102 <button name="clear" class="button button-secondary"><?php esc_html_e('Clear', 'satollo-monitor'); ?></button> 100 <a href="<?php echo esc_attr(get_rest_url()); ?>" class="button button-secondary" target="_blank"><?php esc_html_e('See main endpoint', 'satollo-monitor'); ?></a>101 103 </form> 102 104 -
satollo-monitor/trunk/admin/aiclient/nav.php
r3482094 r3490329 1 1 <?php defined('ABSPATH') || exit; ?> 2 2 <p> 3 <a href="?page=monitor§ion= rest"><?php esc_html_e('Overview', 'satollo-monitor'); ?></a>4 | <a href="?page=monitor§ion= rest&subpage=logs"><?php esc_html_e('Logs', 'satollo-monitor'); ?></a>3 <a href="?page=monitor§ion=aiclient"><?php esc_html_e('Overview', 'satollo-monitor'); ?></a> 4 | <a href="?page=monitor§ion=aiclient&subpage=logs"><?php esc_html_e('Logs', 'satollo-monitor'); ?></a> 5 5 </p> -
satollo-monitor/trunk/admin/assets/admin.css
r3484639 r3490329 72 72 } 73 73 74 #monitor-menu-nav a.monitor-on::after { 75 content: ""; 76 position: relative; 77 top: -5px; 78 display: inline-block; 79 width: 8px; 80 height: 8px; 81 background-color: #ff69b4; 82 border-radius: 50%; 83 margin-left: 3px; 84 vertical-align: middle; 85 /* Adds a soft green glow around the dot */ 86 box-shadow: 0 0 0 rgba(255, 105, 180, 0.4); 87 animation: pulse 2s infinite; 88 } 89 90 @keyframes pulse { 91 0% { box-shadow: 0 0 0 0 rgba(255, 105, 180, 0.7); } 92 70% { box-shadow: 0 0 0 6px rgba(255, 105, 180, 0); } 93 100% { box-shadow: 0 0 0 0 rgba(255, 105, 180, 0); } 94 } 74 95 75 96 /* GENERAL */ -
satollo-monitor/trunk/admin/menu.php
r3481978 r3490329 1 1 <?php 2 2 defined('ABSPATH') || exit; 3 4 $monitor_settings = get_option('monitor_settings'); 5 $abilities_on = isset($monitor_settings['abilities']); 6 $rest_on = isset($monitor_settings['rest']); 7 $emails_on = isset($monitor_settings['emails']); 8 $http_on = isset($monitor_settings['http']); 9 $scheduler_on = isset($monitor_settings['scheduler']); 10 $aiclient_on = isset($monitor_settings['aiclient']); 3 11 ?> 4 12 … … 7 15 <div id="monitor-menu-nav"> 8 16 <ul> 9 <li><a href="?page=monitor§ion=scheduler">Scheduler</a></li> 10 <li><a href="?page=monitor§ion=http">HTTP</a></li> 11 <li><a href="?page=monitor§ion=abilities">Abilities</a></li> 12 <li><a href="?page=monitor§ion=rest">REST API</a></li> 13 <li><a href="?page=monitor§ion=emails">Emails</a></li> 17 <li><a href="?page=monitor§ion=scheduler" class="<?= $scheduler_on ? 'monitor-on' : '' ?>">Scheduler</a></li> 18 <li><a href="?page=monitor§ion=http" class="<?= $http_on ? 'monitor-on' : '' ?>">HTTP</a></li> 19 <li><a href="?page=monitor§ion=abilities" class="<?= $abilities_on ? 'monitor-on' : '' ?>">Abilities</a></li> 20 <li><a href="?page=monitor§ion=aiclient" class="<?= $aiclient_on ? 'monitor-on' : '' ?>">AI Client</a></li> 21 <li><a href="?page=monitor§ion=rest" class="<?= $rest_on ? 'monitor-on' : '' ?>">REST API</a></li> 22 <li><a href="?page=monitor§ion=emails" class="<?= $emails_on ? 'monitor-on' : '' ?>">Emails</a> </li> 14 23 <li><a href="?page=monitor§ion=users">Users</a></li> 15 24 <li><a href="?page=monitor§ion=settings">Settings</a></li> … … 22 31 jQuery(function () { 23 32 jQuery('#monitor-menu-nav a').each(function () { 24 if (location.href.indexOf(this.href) >= 0) {25 jQuery(this).addClass('monitor-active');26 }33 if (location.href.indexOf(this.href) >= 0) { 34 jQuery(this).addClass('monitor-active'); 35 } 27 36 }); 28 37 }); -
satollo-monitor/trunk/admin/settings.php
r3481978 r3490329 29 29 <?php wp_nonce_field('monitor-save'); ?> 30 30 <table class="form-table" role="presentation"> 31 <tr> 32 <th> 33 <?php esc_html_e('Monitor AI Client', 'satollo-monitor'); ?> 34 </th> 35 <td> 36 <input type="checkbox" value="1" name="data[aiclient]" <?= isset($data['aiclient']) ? 'checked' : ''; ?>> 37 </td> 38 </tr> 31 39 <tr> 32 40 <th> -
satollo-monitor/trunk/readme.txt
r3484639 r3490329 5 5 Tested up to: 6.9 6 6 Requires PHP: 8.1 7 Stable tag: 1.0. 17 Stable tag: 1.0.2 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 32 32 * Scheduler runs with detailed jobs data 33 33 * Abilities invocation 34 * AI Client calls (WP 7.0+) 34 35 35 Please, [read the official page for more details](ht ps://www.satollo.net/plugins/monitor) for more detail, examples of problems and solutions.36 Please, [read the official page for more details](https://www.satollo.net/plugins/monitor) for more detail, examples of problems and solutions. 36 37 37 38 = Contacts, Requests, Bugs = … … 79 80 == Changelog == 80 81 82 = 1.0.2 = 83 84 * Added monitoring of AI Client (WP 7.0+) 85 81 86 = 1.0.1 = 82 87 -
satollo-monitor/trunk/satollo-monitor.php
r3484639 r3490329 6 6 * Plugin Name: Monitor: Scheduler, Emails, API, HTTP and more 7 7 * Description: Records and displays WP events: abilities calls, scheduler job executions, http calls, emails, and so on 8 * Version: 1.0. 18 * Version: 1.0.2 9 9 * Author: Stefano Lissa 10 10 * Author URI: https://www.satollo.net … … 18 18 defined('ABSPATH') || exit; 19 19 20 define('SATOLLO_MONITOR_VERSION', '1.0. 1');20 define('SATOLLO_MONITOR_VERSION', '1.0.2'); 21 21 22 22 /** @var wpdb $wpdb */ … … 298 298 return $result; 299 299 }, 99, 3); 300 } 301 302 if (!empty($monitor_settings['aiclient'])) { 303 global $monitor_aiclient_log_start; 304 add_action('wp_ai_client_before_generate_result', function ($event) { 305 global $monitor_aiclient_log_start; 306 $monitor_aiclient_log_start = microtime(true); 307 }); 308 309 add_action('wp_ai_client_after_generate_result', function ($event) { 310 global $wpdb, $monitor_settings, $monitor_aiclient_log_start; 311 /** @var WordPress\AiClient\Events\AfterGenerateResultEvent $event */ 312 313 $context = monitor_get_context(); 314 315 $tokens = $event->getResult()->getTokenUsage()->getTotalTokens(); 316 $model = $event->getModel()->metadata()->getName() ?? ''; 317 $provider = $event->getModel()->providerMetadata()->getName() ?? ''; 318 319 $wpdb->insert($wpdb->prefix . 'monitor_aiclient', [ 320 'provider' => $provider, 321 'model' => $model, 322 'tokens' => $tokens, 323 'context' => $context, 324 'duration' => microtime(true) - $monitor_aiclient_log_start]); 325 }); 326 300 327 } 301 328
Note: See TracChangeset
for help on using the changeset viewer.