From 2ed76a345f3c1675eddce61045d303c5f9788b8f Mon Sep 17 00:00:00 2001 From: Nikolas Garofil Date: Sun, 15 Nov 2009 19:44:37 +0100 Subject: [PATCH] Added support for $pid_vmpeak, $pid_vmsize, $pid_vmlck, $pid_vmhwm, $pid_vmrss, $pid_vmdata, $pid_vmstk, $pid_vmexe, $pid_vmlib, $pid_vmpte --- ChangeLog | 2 + doc/variables.xml | 100 ++++++++++++++++++++++++++++++++++ extras/nano/conky.nanorc | 2 +- extras/vim/syntax/conkyrc.vim | 2 +- src/conky.c | 70 ++++++++++++++++++++++++ src/core.c | 40 ++++++++++++++ src/proc.c | 67 +++++++++++++++++++++++ src/proc.h | 10 ++++ src/text_object.h | 10 ++++ 9 files changed, 301 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index c56f4d07..74edf4c7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,8 @@ * Added support for $uid_name and $gid_name * Renamed $running_processes to $running_threads * Added real $running_processes + * Added support for $pid_vmpeak, $pid_vmsize, $pid_vmlck, $pid_vmhwm, + $pid_vmrss, $pid_vmdata, $pid_vmstk, $pid_vmexe, $pid_vmlib, $pid_vmpte 2009-11-14 * Added support for $pid_state and $pid_state_short diff --git a/doc/variables.xml b/doc/variables.xml index 961c39b1..9ebeaacf 100644 --- a/doc/variables.xml +++ b/doc/variables.xml @@ -2714,6 +2714,106 @@ The file system gid of the process + + + + + + + + Peak virtual memory size of the process + + + + + + + + + + Virtual memory size of the process + + + + + + + + + + Locked memory size of the process + + + + + + + + + + Peak resident set size ("high water mark") of the process + + + + + + + + + + Resident set size of the process + + + + + + + + + + Data segment size of the process + + + + + + + + + + Stack segment size of the process + + + + + + + + + + Text segment size of the process + + + + + + + + + + Shared library code size of the process + + + + + + + + + + Page table entries size of the process + + diff --git a/extras/nano/conky.nanorc b/extras/nano/conky.nanorc index e61ede10..a27c4380 100644 --- a/extras/nano/conky.nanorc +++ b/extras/nano/conky.nanorc @@ -11,7 +11,7 @@ color green "\<(alignment|append_file|background|border_inner_margin|border_oute color yellow "\<(above|below|bottom_left|bottom_right|bottom_middle|desktop|dock|no|none|normal|override|skip_pager|skip_taskbar|sticky|top_left|top_right|top_middle|middle_left|middle_right|middle_middle|undecorated|yes)\>" ## Variables -color brightblue "\<(acpiacadapter|acpifan|acpitemp|addr|addrs|alignc|alignr|apcupsd|apcupsd_cable|apcupsd_charge|apcupsd_lastxfer|apcupsd_linev|apcupsd_load|apcupsd_loadbar|apcupsd_loadgauge|apcupsd_loadgraph|apcupsd_model|apcupsd_name|apcupsd_status|apcupsd_temp|apcupsd_timeleft|apcupsd_upsmode|apm_adapter|apm_battery_life|apm_battery_time|audacious_bar|audacious_bitrate|audacious_channels|audacious_filename|audacious_frequency|audacious_length|audacious_length_seconds|audacious_main_volume|audacious_playlist_length|audacious_playlist_position|audacious_position|audacious_position_seconds|audacious_status|audacious_title|battery|battery_bar|battery_percent|battery_short|battery_time|blink|bmpx_album|bmpx_artist|bmpx_bitrate|bmpx_title|bmpx_track|bmpx_uri|buffers|cached|cmdline_to_pid|color|color0|color1|color2|color3|color4|color5|color6|color7|color8|color9|combine|conky_build_arch|conky_build_date|conky_version|cpu|cpubar|cpugauge|cpugraph|curl|desktop|desktop_name|desktop_number|disk_protect|diskio|diskio_read|diskio_write|diskiograph|diskiograph_read|diskiograph_write|downspeed|downspeedf|downspeedgraph|draft_mails|else|endif|entropy_avail|entropy_bar|entropy_perc|entropy_poolsize|eval|eve|exec|execbar|execgauge|execgraph|execi|execibar|execigauge|execigraph|execp|execpi|flagged_mails|font|forwarded_mails|freq|freq_g|fs_bar|fs_bar_free|fs_free|fs_free_perc|fs_size|fs_type|fs_used|fs_used_perc|goto|gw_iface|gw_ip|hddtemp|head|hr|hwmon|i2c|i8k_ac_status|i8k_bios|i8k_buttons_status|i8k_cpu_temp|i8k_left_fan_rpm|i8k_left_fan_status|i8k_right_fan_rpm|i8k_right_fan_status|i8k_serial|i8k_version|ibm_brightness|ibm_fan|ibm_temps|ibm_volume|iconv_start|iconv_stop|if_empty|if_existing|if_gw|if_match|if_mixer_mute|if_mounted|if_mpd_playing|if_running|if_smapi_bat_installed|if_up|if_updatenr|if_xmms2_connected|image|imap_messages|imap_unseen|include|ioscheduler|kernel|laptop_mode|lines|loadavg|loadgraph|lua|lua_bar|lua_gauge|lua_graph|lua_parse|machine|mails|mboxscan|mem|membar|memeasyfree|memfree|memgauge|memgraph|memmax|memperc|mixer|mixerbar|mixerl|mixerlbar|mixerr|mixerrbar|moc_album|moc_artist|moc_bitrate|moc_curtime|moc_file|moc_rate|moc_song|moc_state|moc_timeleft|moc_title|moc_totaltime|monitor|monitor_number|mpd_album|mpd_artist|mpd_bar|mpd_bitrate|mpd_elapsed|mpd_file|mpd_length|mpd_name|mpd_percent|mpd_random|mpd_repeat|mpd_smart|mpd_status|mpd_title|mpd_track|mpd_vol|nameserver|new_mails|nodename|nvidia|obsd_product|obsd_sensors_fan|obsd_sensors_temp|obsd_sensors_volt|obsd_vendor|offset|outlinecolor|pb_battery|pid_chroot|pid_cmdline|pid_cwd|pid_environ|pid_environ_list|pid_exe|pid_openfiles|pid_parent|pid_state|pid_state_short|pid_stderr|pid_stdin|pid_stdout|pid_uid|pid_euid|pid_suid|pid_fsuid|pid_gid|pid_egid|pid_sgid|pid_fsgid|platform|pop3_unseen|pop3_used|pre_exec|processes|read_tcp|replied_mails|rss|running_processes|running_threads|scroll|seen_mails|shadecolor|smapi|smapi_bat_bar|smapi_bat_perc|smapi_bat_power|smapi_bat_temp|sony_fanspeed|stippled_hr|swap|swapbar|swapfree|swapmax|swapperc|sysname|tab|tail|tcp_portmon|template0|template1|template2|template3|template4|template5|template6|template7|template8|template9|texeci|threads|time|to_bytes|top|top_io|top_mem|top_time|totaldown|totalup|trashed_mails|tztime|gid_name|uid_name|unflagged_mails|unforwarded_mails|unreplied_mails|unseen_mails|updates|upspeed|upspeedf|upspeedgraph|uptime|uptime_short|user_names|user_number|user_terms|user_times|user_time|utime|voffset|voltage_mv|voltage_v|weather|wireless_ap|wireless_bitrate|wireless_essid|wireless_link_bar|wireless_link_qual|wireless_link_qual_max|wireless_link_qual_perc|wireless_mode|words|xmms2_album|xmms2_artist|xmms2_bar|xmms2_bitrate|xmms2_comment|xmms2_date|xmms2_duration|xmms2_elapsed|xmms2_genre|xmms2_id|xmms2_percent|xmms2_playlist|xmms2_size|xmms2_smart|xmms2_status|xmms2_timesplayed|xmms2_title|xmms2_tracknr|xmms2_url)\>" +color brightblue "\<(acpiacadapter|acpifan|acpitemp|addr|addrs|alignc|alignr|apcupsd|apcupsd_cable|apcupsd_charge|apcupsd_lastxfer|apcupsd_linev|apcupsd_load|apcupsd_loadbar|apcupsd_loadgauge|apcupsd_loadgraph|apcupsd_model|apcupsd_name|apcupsd_status|apcupsd_temp|apcupsd_timeleft|apcupsd_upsmode|apm_adapter|apm_battery_life|apm_battery_time|audacious_bar|audacious_bitrate|audacious_channels|audacious_filename|audacious_frequency|audacious_length|audacious_length_seconds|audacious_main_volume|audacious_playlist_length|audacious_playlist_position|audacious_position|audacious_position_seconds|audacious_status|audacious_title|battery|battery_bar|battery_percent|battery_short|battery_time|blink|bmpx_album|bmpx_artist|bmpx_bitrate|bmpx_title|bmpx_track|bmpx_uri|buffers|cached|cmdline_to_pid|color|color0|color1|color2|color3|color4|color5|color6|color7|color8|color9|combine|conky_build_arch|conky_build_date|conky_version|cpu|cpubar|cpugauge|cpugraph|curl|desktop|desktop_name|desktop_number|disk_protect|diskio|diskio_read|diskio_write|diskiograph|diskiograph_read|diskiograph_write|downspeed|downspeedf|downspeedgraph|draft_mails|else|endif|entropy_avail|entropy_bar|entropy_perc|entropy_poolsize|eval|eve|exec|execbar|execgauge|execgraph|execi|execibar|execigauge|execigraph|execp|execpi|flagged_mails|font|forwarded_mails|freq|freq_g|fs_bar|fs_bar_free|fs_free|fs_free_perc|fs_size|fs_type|fs_used|fs_used_perc|goto|gw_iface|gw_ip|hddtemp|head|hr|hwmon|i2c|i8k_ac_status|i8k_bios|i8k_buttons_status|i8k_cpu_temp|i8k_left_fan_rpm|i8k_left_fan_status|i8k_right_fan_rpm|i8k_right_fan_status|i8k_serial|i8k_version|ibm_brightness|ibm_fan|ibm_temps|ibm_volume|iconv_start|iconv_stop|if_empty|if_existing|if_gw|if_match|if_mixer_mute|if_mounted|if_mpd_playing|if_running|if_smapi_bat_installed|if_up|if_updatenr|if_xmms2_connected|image|imap_messages|imap_unseen|include|ioscheduler|kernel|laptop_mode|lines|loadavg|loadgraph|lua|lua_bar|lua_gauge|lua_graph|lua_parse|machine|mails|mboxscan|mem|membar|memeasyfree|memfree|memgauge|memgraph|memmax|memperc|mixer|mixerbar|mixerl|mixerlbar|mixerr|mixerrbar|moc_album|moc_artist|moc_bitrate|moc_curtime|moc_file|moc_rate|moc_song|moc_state|moc_timeleft|moc_title|moc_totaltime|monitor|monitor_number|mpd_album|mpd_artist|mpd_bar|mpd_bitrate|mpd_elapsed|mpd_file|mpd_length|mpd_name|mpd_percent|mpd_random|mpd_repeat|mpd_smart|mpd_status|mpd_title|mpd_track|mpd_vol|nameserver|new_mails|nodename|nvidia|obsd_product|obsd_sensors_fan|obsd_sensors_temp|obsd_sensors_volt|obsd_vendor|offset|outlinecolor|pb_battery|pid_chroot|pid_cmdline|pid_cwd|pid_environ|pid_environ_list|pid_exe|pid_openfiles|pid_parent|pid_state|pid_state_short|pid_stderr|pid_stdin|pid_stdout|pid_uid|pid_euid|pid_suid|pid_fsuid|pid_gid|pid_egid|pid_sgid|pid_fsgid|pid_vmpeak|pid_vmsize|pid_vmlck|pid_vmhwm|pid_vmrss|pid_vmdata|pid_vmstk|pid_vmexe|pid_vmlib|pid_vmpte|platform|pop3_unseen|pop3_used|pre_exec|processes|read_tcp|replied_mails|rss|running_processes|running_threads|scroll|seen_mails|shadecolor|smapi|smapi_bat_bar|smapi_bat_perc|smapi_bat_power|smapi_bat_temp|sony_fanspeed|stippled_hr|swap|swapbar|swapfree|swapmax|swapperc|sysname|tab|tail|tcp_portmon|template0|template1|template2|template3|template4|template5|template6|template7|template8|template9|texeci|threads|time|to_bytes|top|top_io|top_mem|top_time|totaldown|totalup|trashed_mails|tztime|gid_name|uid_name|unflagged_mails|unforwarded_mails|unreplied_mails|unseen_mails|updates|upspeed|upspeedf|upspeedgraph|uptime|uptime_short|user_names|user_number|user_terms|user_times|user_time|utime|voffset|voltage_mv|voltage_v|weather|wireless_ap|wireless_bitrate|wireless_essid|wireless_link_bar|wireless_link_qual|wireless_link_qual_max|wireless_link_qual_perc|wireless_mode|words|xmms2_album|xmms2_artist|xmms2_bar|xmms2_bitrate|xmms2_comment|xmms2_date|xmms2_duration|xmms2_elapsed|xmms2_genre|xmms2_id|xmms2_percent|xmms2_playlist|xmms2_size|xmms2_smart|xmms2_status|xmms2_timesplayed|xmms2_title|xmms2_tracknr|xmms2_url)\>" color brightblue "\$\{?[0-9A-Z_!@#$*?-]+\}?" color cyan "(\{|\}|\(|\)|\;|\]|\[|`|\\|\$|<|>|!|=|&|\|)" diff --git a/extras/vim/syntax/conkyrc.vim b/extras/vim/syntax/conkyrc.vim index 78b52b27..ab6b12fa 100644 --- a/extras/vim/syntax/conkyrc.vim +++ b/extras/vim/syntax/conkyrc.vim @@ -50,7 +50,7 @@ syn region ConkyrcVar start=/\$\w\@=/ end=/\W\@=\|$/ contained contains=ConkyrcV syn match ConkyrcVarStuff /{\@<=/ms=s contained nextgroup=ConkyrcVarName -syn keyword ConkyrcVarName contained nextgroup=ConkyrcNumber,ConkyrcColour skipwhite acpiacadapter acpifan acpitemp addr addrs alignc alignr apcupsd apcupsd_cable apcupsd_charge apcupsd_lastxfer apcupsd_linev apcupsd_load apcupsd_loadbar apcupsd_loadgauge apcupsd_loadgraph apcupsd_model apcupsd_name apcupsd_status apcupsd_temp apcupsd_timeleft apcupsd_upsmode apm_adapter apm_battery_life apm_battery_time audacious_bar audacious_bitrate audacious_channels audacious_filename audacious_frequency audacious_length audacious_length_seconds audacious_main_volume audacious_playlist_length audacious_playlist_position audacious_position audacious_position_seconds audacious_status audacious_title battery battery_bar battery_percent battery_short battery_time blink bmpx_album bmpx_artist bmpx_bitrate bmpx_title bmpx_track bmpx_uri buffers cached cmdline_to_pid color color0 color1 color2 color3 color4 color5 color6 color7 color8 color9 combine conky_build_arch conky_build_date conky_version cpu cpubar cpugauge cpugraph curl desktop desktop_name desktop_number disk_protect diskio diskio_read diskio_write diskiograph diskiograph_read diskiograph_write downspeed downspeedf downspeedgraph draft_mails else endif entropy_avail entropy_bar entropy_perc entropy_poolsize eval eve exec execbar execgauge execgraph execi execibar execigauge execigraph execp execpi flagged_mails font forwarded_mails freq freq_g fs_bar fs_bar_free fs_free fs_free_perc fs_size fs_type fs_used fs_used_perc goto gw_iface gw_ip hddtemp head hr hwmon i2c i8k_ac_status i8k_bios i8k_buttons_status i8k_cpu_temp i8k_left_fan_rpm i8k_left_fan_status i8k_right_fan_rpm i8k_right_fan_status i8k_serial i8k_version ibm_brightness ibm_fan ibm_temps ibm_volume iconv_start iconv_stop if_empty if_existing if_gw if_match if_mixer_mute if_mounted if_mpd_playing if_running if_smapi_bat_installed if_up if_updatenr if_xmms2_connected image imap_messages imap_unseen include ioscheduler kernel laptop_mode lines loadavg loadgraph lua lua_bar lua_gauge lua_graph lua_parse machine mails mboxscan mem membar memeasyfree memfree memgauge memgraph memmax memperc mixer mixerbar mixerl mixerlbar mixerr mixerrbar moc_album moc_artist moc_bitrate moc_curtime moc_file moc_rate moc_song moc_state moc_timeleft moc_title moc_totaltime monitor monitor_number mpd_album mpd_artist mpd_bar mpd_bitrate mpd_elapsed mpd_file mpd_length mpd_name mpd_percent mpd_random mpd_repeat mpd_smart mpd_status mpd_title mpd_track mpd_vol nameserver new_mails nodename nvidia obsd_product obsd_sensors_fan obsd_sensors_temp obsd_sensors_volt obsd_vendor offset outlinecolor pb_battery pid_chroot pid_cmdline pid_cwd pid_environ pid_environ_list pid_exe pid_openfiles pid_parent pid_state pid_state_short pid_stderr pid_stdin pid_stdout pid_uid pid_euid pid_suid pid_fsuid pid_gid pid_egid pid_sgid pid_fsgid platform pop3_unseen pop3_used pre_exec processes read_tcp replied_mails rss running_processes running_threads scroll seen_mails shadecolor smapi smapi_bat_bar smapi_bat_perc smapi_bat_power smapi_bat_temp sony_fanspeed stippled_hr swap swapbar swapfree swapmax swapperc sysname tab tail tcp_portmon template0 template1 template2 template3 template4 template5 template6 template7 template8 template9 texeci threads time to_bytes top top_io top_mem top_time totaldown totalup trashed_mails tztime gid_name uid_name unflagged_mails unforwarded_mails unreplied_mails unseen_mails updates upspeed upspeedf upspeedgraph uptime uptime_short user_names user_number user_terms user_times user_time utime voffset voltage_mv voltage_v weather wireless_ap wireless_bitrate wireless_essid wireless_link_bar wireless_link_qual wireless_link_qual_max wireless_link_qual_perc wireless_mode words xmms2_album xmms2_artist xmms2_bar xmms2_bitrate xmms2_comment xmms2_date xmms2_duration xmms2_elapsed xmms2_genre xmms2_id xmms2_percent xmms2_playlist xmms2_size xmms2_smart xmms2_status xmms2_timesplayed xmms2_title xmms2_tracknr xmms2_url +syn keyword ConkyrcVarName contained nextgroup=ConkyrcNumber,ConkyrcColour skipwhite acpiacadapter acpifan acpitemp addr addrs alignc alignr apcupsd apcupsd_cable apcupsd_charge apcupsd_lastxfer apcupsd_linev apcupsd_load apcupsd_loadbar apcupsd_loadgauge apcupsd_loadgraph apcupsd_model apcupsd_name apcupsd_status apcupsd_temp apcupsd_timeleft apcupsd_upsmode apm_adapter apm_battery_life apm_battery_time audacious_bar audacious_bitrate audacious_channels audacious_filename audacious_frequency audacious_length audacious_length_seconds audacious_main_volume audacious_playlist_length audacious_playlist_position audacious_position audacious_position_seconds audacious_status audacious_title battery battery_bar battery_percent battery_short battery_time blink bmpx_album bmpx_artist bmpx_bitrate bmpx_title bmpx_track bmpx_uri buffers cached cmdline_to_pid color color0 color1 color2 color3 color4 color5 color6 color7 color8 color9 combine conky_build_arch conky_build_date conky_version cpu cpubar cpugauge cpugraph curl desktop desktop_name desktop_number disk_protect diskio diskio_read diskio_write diskiograph diskiograph_read diskiograph_write downspeed downspeedf downspeedgraph draft_mails else endif entropy_avail entropy_bar entropy_perc entropy_poolsize eval eve exec execbar execgauge execgraph execi execibar execigauge execigraph execp execpi flagged_mails font forwarded_mails freq freq_g fs_bar fs_bar_free fs_free fs_free_perc fs_size fs_type fs_used fs_used_perc goto gw_iface gw_ip hddtemp head hr hwmon i2c i8k_ac_status i8k_bios i8k_buttons_status i8k_cpu_temp i8k_left_fan_rpm i8k_left_fan_status i8k_right_fan_rpm i8k_right_fan_status i8k_serial i8k_version ibm_brightness ibm_fan ibm_temps ibm_volume iconv_start iconv_stop if_empty if_existing if_gw if_match if_mixer_mute if_mounted if_mpd_playing if_running if_smapi_bat_installed if_up if_updatenr if_xmms2_connected image imap_messages imap_unseen include ioscheduler kernel laptop_mode lines loadavg loadgraph lua lua_bar lua_gauge lua_graph lua_parse machine mails mboxscan mem membar memeasyfree memfree memgauge memgraph memmax memperc mixer mixerbar mixerl mixerlbar mixerr mixerrbar moc_album moc_artist moc_bitrate moc_curtime moc_file moc_rate moc_song moc_state moc_timeleft moc_title moc_totaltime monitor monitor_number mpd_album mpd_artist mpd_bar mpd_bitrate mpd_elapsed mpd_file mpd_length mpd_name mpd_percent mpd_random mpd_repeat mpd_smart mpd_status mpd_title mpd_track mpd_vol nameserver new_mails nodename nvidia obsd_product obsd_sensors_fan obsd_sensors_temp obsd_sensors_volt obsd_vendor offset outlinecolor pb_battery pid_chroot pid_cmdline pid_cwd pid_environ pid_environ_list pid_exe pid_openfiles pid_parent pid_state pid_state_short pid_stderr pid_stdin pid_stdout pid_uid pid_euid pid_suid pid_fsuid pid_gid pid_egid pid_sgid pid_fsgid pid_vmpeak pid_vmsize pid_vmlck pid_vmhwm pid_vmrss pid_vmdata pid_vmstk pid_vmexe pid_vmlib pid_vmpte platform pop3_unseen pop3_used pre_exec processes read_tcp replied_mails rss running_processes running_threads scroll seen_mails shadecolor smapi smapi_bat_bar smapi_bat_perc smapi_bat_power smapi_bat_temp sony_fanspeed stippled_hr swap swapbar swapfree swapmax swapperc sysname tab tail tcp_portmon template0 template1 template2 template3 template4 template5 template6 template7 template8 template9 texeci threads time to_bytes top top_io top_mem top_time totaldown totalup trashed_mails tztime gid_name uid_name unflagged_mails unforwarded_mails unreplied_mails unseen_mails updates upspeed upspeedf upspeedgraph uptime uptime_short user_names user_number user_terms user_times user_time utime voffset voltage_mv voltage_v weather wireless_ap wireless_bitrate wireless_essid wireless_link_bar wireless_link_qual wireless_link_qual_max wireless_link_qual_perc wireless_mode words xmms2_album xmms2_artist xmms2_bar xmms2_bitrate xmms2_comment xmms2_date xmms2_duration xmms2_elapsed xmms2_genre xmms2_id xmms2_percent xmms2_playlist xmms2_size xmms2_smart xmms2_status xmms2_timesplayed xmms2_title xmms2_tracknr xmms2_url hi def link ConkyrcComment Comment hi def link ConkyrcSetting Keyword diff --git a/src/conky.c b/src/conky.c index 57955bcd..e9dcb05e 100644 --- a/src/conky.c +++ b/src/conky.c @@ -1751,6 +1751,76 @@ void generate_text_internal(char *p, int p_max_size, obj->data.s = buf; print_pid_fsgid(obj, p, p_max_size); } + OBJ(pid_vmpeak) { + char buf[max_user_text]; + + generate_text_internal(buf, max_user_text, *obj->sub, cur); + obj->data.s = buf; + print_pid_vmpeak(obj, p, p_max_size); + } + OBJ(pid_vmsize) { + char buf[max_user_text]; + + generate_text_internal(buf, max_user_text, *obj->sub, cur); + obj->data.s = buf; + print_pid_vmsize(obj, p, p_max_size); + } + OBJ(pid_vmlck) { + char buf[max_user_text]; + + generate_text_internal(buf, max_user_text, *obj->sub, cur); + obj->data.s = buf; + print_pid_vmlck(obj, p, p_max_size); + } + OBJ(pid_vmhwm) { + char buf[max_user_text]; + + generate_text_internal(buf, max_user_text, *obj->sub, cur); + obj->data.s = buf; + print_pid_vmhwm(obj, p, p_max_size); + } + OBJ(pid_vmrss) { + char buf[max_user_text]; + + generate_text_internal(buf, max_user_text, *obj->sub, cur); + obj->data.s = buf; + print_pid_vmrss(obj, p, p_max_size); + } + OBJ(pid_vmdata) { + char buf[max_user_text]; + + generate_text_internal(buf, max_user_text, *obj->sub, cur); + obj->data.s = buf; + print_pid_vmdata(obj, p, p_max_size); + } + OBJ(pid_vmstk) { + char buf[max_user_text]; + + generate_text_internal(buf, max_user_text, *obj->sub, cur); + obj->data.s = buf; + print_pid_vmstk(obj, p, p_max_size); + } + OBJ(pid_vmexe) { + char buf[max_user_text]; + + generate_text_internal(buf, max_user_text, *obj->sub, cur); + obj->data.s = buf; + print_pid_vmexe(obj, p, p_max_size); + } + OBJ(pid_vmlib) { + char buf[max_user_text]; + + generate_text_internal(buf, max_user_text, *obj->sub, cur); + obj->data.s = buf; + print_pid_vmlib(obj, p, p_max_size); + } + OBJ(pid_vmpte) { + char buf[max_user_text]; + + generate_text_internal(buf, max_user_text, *obj->sub, cur); + obj->data.s = buf; + print_pid_vmpte(obj, p, p_max_size); + } OBJ(processes) { spaced_print(p, p_max_size, "%hu", 4, cur->procs); } diff --git a/src/core.c b/src/core.c index 46620ca3..e8853e0c 100644 --- a/src/core.c +++ b/src/core.c @@ -710,6 +710,36 @@ struct text_object *construct_text_object(const char *s, const char *arg, long END OBJ_ARG(uid_name, 0, "uid_name needs a uid as argument") obj->sub = malloc(sizeof(struct text_object)); extract_variable_text_internal(obj->sub, arg); + END OBJ_ARG(pid_vmpeak, 0, "pid_vmpeak needs a pid as argument") + obj->sub = malloc(sizeof(struct text_object)); + extract_variable_text_internal(obj->sub, arg); + END OBJ_ARG(pid_vmsize, 0, "pid_vmsize needs a pid as argument") + obj->sub = malloc(sizeof(struct text_object)); + extract_variable_text_internal(obj->sub, arg); + END OBJ_ARG(pid_vmlck, 0, "pid_vmlck needs a pid as argument") + obj->sub = malloc(sizeof(struct text_object)); + extract_variable_text_internal(obj->sub, arg); + END OBJ_ARG(pid_vmhwm, 0, "pid_vmhwm needs a pid as argument") + obj->sub = malloc(sizeof(struct text_object)); + extract_variable_text_internal(obj->sub, arg); + END OBJ_ARG(pid_vmrss, 0, "pid_vmrss needs a pid as argument") + obj->sub = malloc(sizeof(struct text_object)); + extract_variable_text_internal(obj->sub, arg); + END OBJ_ARG(pid_vmdata, 0, "pid_vmdata needs a pid as argument") + obj->sub = malloc(sizeof(struct text_object)); + extract_variable_text_internal(obj->sub, arg); + END OBJ_ARG(pid_vmstk, 0, "pid_vmstk needs a pid as argument") + obj->sub = malloc(sizeof(struct text_object)); + extract_variable_text_internal(obj->sub, arg); + END OBJ_ARG(pid_vmexe, 0, "pid_vmexe needs a pid as argument") + obj->sub = malloc(sizeof(struct text_object)); + extract_variable_text_internal(obj->sub, arg); + END OBJ_ARG(pid_vmlib, 0, "pid_vmlib needs a pid as argument") + obj->sub = malloc(sizeof(struct text_object)); + extract_variable_text_internal(obj->sub, arg); + END OBJ_ARG(pid_vmpte, 0, "pid_vmpte needs a pid as argument") + obj->sub = malloc(sizeof(struct text_object)); + extract_variable_text_internal(obj->sub, arg); END OBJ(processes, &update_total_processes) #ifdef __linux__ END OBJ(running_processes, &update_top) @@ -1329,6 +1359,16 @@ void free_text_objects(struct text_object *root, int internal) case OBJ_pid_egid: case OBJ_pid_sgid: case OBJ_pid_fsgid: + case OBJ_pid_vmpeak: + case OBJ_pid_vmsize: + case OBJ_pid_vmlck: + case OBJ_pid_vmhwm: + case OBJ_pid_vmrss: + case OBJ_pid_vmdata: + case OBJ_pid_vmstk: + case OBJ_pid_vmexe: + case OBJ_pid_vmlib: + case OBJ_pid_vmpte: case OBJ_gid_name: if(obj->sub) { free_text_objects(obj->sub, 1); diff --git a/src/proc.c b/src/proc.c index 683bc23a..dc59e4dc 100644 --- a/src/proc.c +++ b/src/proc.c @@ -598,3 +598,70 @@ void print_pid_fsgid(struct text_object *obj, char *p, int p_max_size) { free(buf); } } + +void internal_print_pid_vm(char* pid, char *p, int p_max_size, const char* entry, const char* errorstring) { + char *begin, *end, *buf = NULL; + int bytes_read; + + asprintf(&buf, PROCDIR "/%s/status", pid); + strcpy(pid, buf); + free(buf); + buf = readfile(pid, &bytes_read, 1); + if(buf != NULL) { + begin = strstr(buf, entry); + if(begin != NULL) { + begin += strlen(entry); + while(*begin == '\t' || *begin == ' ') { + begin++; + } + end = strchr(begin, '\n'); + if(end != NULL) { + *(end) = 0; + } + snprintf(p, p_max_size, "%s", begin); + } else { + NORM_ERR(errorstring, pid); + } + free(buf); + } +} + +void print_pid_vmpeak(struct text_object *obj, char *p, int p_max_size) { + internal_print_pid_vm(obj->data.s, p, p_max_size, "VmPeak:\t", "Can't find the process peak virtual memory size in '%s'"); +} + +void print_pid_vmsize(struct text_object *obj, char *p, int p_max_size) { + internal_print_pid_vm(obj->data.s, p, p_max_size, "VmSize:\t", "Can't find the process virtual memory size in '%s'"); +} + +void print_pid_vmlck(struct text_object *obj, char *p, int p_max_size) { + internal_print_pid_vm(obj->data.s, p, p_max_size, "VmLck:\t", "Can't find the process locked memory size in '%s'"); +} + +void print_pid_vmhwm(struct text_object *obj, char *p, int p_max_size) { + internal_print_pid_vm(obj->data.s, p, p_max_size, "VmHWM:\t", "Can't find the process peak resident set size in '%s'"); +} + +void print_pid_vmrss(struct text_object *obj, char *p, int p_max_size) { + internal_print_pid_vm(obj->data.s, p, p_max_size, "VmHWM:\t", "Can't find the process resident set size in '%s'"); +} + +void print_pid_vmdata(struct text_object *obj, char *p, int p_max_size) { + internal_print_pid_vm(obj->data.s, p, p_max_size, "VmData:\t", "Can't find the process data segment size in '%s'"); +} + +void print_pid_vmstk(struct text_object *obj, char *p, int p_max_size) { + internal_print_pid_vm(obj->data.s, p, p_max_size, "VmData:\t", "Can't find the process stack segment size in '%s'"); +} + +void print_pid_vmexe(struct text_object *obj, char *p, int p_max_size) { + internal_print_pid_vm(obj->data.s, p, p_max_size, "VmData:\t", "Can't find the process text segment size in '%s'"); +} + +void print_pid_vmlib(struct text_object *obj, char *p, int p_max_size) { + internal_print_pid_vm(obj->data.s, p, p_max_size, "VmLib:\t", "Can't find the process shared library code size in '%s'"); +} + +void print_pid_vmpte(struct text_object *obj, char *p, int p_max_size) { + internal_print_pid_vm(obj->data.s, p, p_max_size, "VmPTE:\t", "Can't find the process page table entries size in '%s'"); +} diff --git a/src/proc.h b/src/proc.h index d00abf4f..acdc255c 100644 --- a/src/proc.h +++ b/src/proc.h @@ -53,6 +53,16 @@ void print_pid_gid(struct text_object *obj, char *p, int p_max_size); void print_pid_egid(struct text_object *obj, char *p, int p_max_size); void print_pid_sgid(struct text_object *obj, char *p, int p_max_size); void print_pid_fsgid(struct text_object *obj, char *p, int p_max_size); +void print_pid_vmpeak(struct text_object *obj, char *p, int p_max_size); +void print_pid_vmsize(struct text_object *obj, char *p, int p_max_size); +void print_pid_vmlck(struct text_object *obj, char *p, int p_max_size); +void print_pid_vmhwm(struct text_object *obj, char *p, int p_max_size); +void print_pid_vmrss(struct text_object *obj, char *p, int p_max_size); +void print_pid_vmdata(struct text_object *obj, char *p, int p_max_size); +void print_pid_vmstk(struct text_object *obj, char *p, int p_max_size); +void print_pid_vmexe(struct text_object *obj, char *p, int p_max_size); +void print_pid_vmlib(struct text_object *obj, char *p, int p_max_size); +void print_pid_vmpte(struct text_object *obj, char *p, int p_max_size); void scan_cmdline_to_pid_arg(struct text_object *obj, const char *arg, void* free_at_crash); void print_cmdline_to_pid(struct text_object *obj, char *p, int p_max_size); diff --git a/src/text_object.h b/src/text_object.h index 618f56c6..bb544a94 100644 --- a/src/text_object.h +++ b/src/text_object.h @@ -255,6 +255,16 @@ enum text_object_type { OBJ_pid_egid, OBJ_pid_sgid, OBJ_pid_fsgid, + OBJ_pid_vmpeak, + OBJ_pid_vmsize, + OBJ_pid_vmlck, + OBJ_pid_vmhwm, + OBJ_pid_vmrss, + OBJ_pid_vmdata, + OBJ_pid_vmstk, + OBJ_pid_vmexe, + OBJ_pid_vmlib, + OBJ_pid_vmpte, OBJ_gid_name, OBJ_uid_name, OBJ_processes,